最近学习古月居的ROS2中遇到一个问题:
在运行ros2 run learning_service service_adder_server
时遇到的,
ModuleNotFoundError: No module named 'learning_interface.learning_interface_s__rosidl_typesupport_c'
具体的报错信息是:
Traceback (most recent call last):
File "/opt/ros/humble/local/lib/python3.10/dist-packages/rosidl_generator_py/import_type_support_impl.py", line 46, in import_type_support
return importlib.import_module(module_name, package=pkg_name)
File "/usr/lib/python3.10/importlib/__init__.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 1050, in _gcd_import
File "<frozen importlib._bootstrap>", line 1027, in _find_and_load
File "<frozen importlib._bootstrap>", line 1004, in _find_and_load_unlocked
ModuleNotFoundError: No module named 'learning_interface.learning_interface_s__rosidl_typesupport_c'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/home/sunx/ros_humble/install/learning_service/lib/learning_service/service_adder_server", line 33, in <module>
sys.exit(load_entry_point('learning-service==0.0.0', 'console_scripts', 'service_adder_server')())
File "/home/sunx/ros_humble/install/learning_service/lib/python3.10/site-packages/learning_service/service_adder_server.py", line 25, in main
node = adderServer("service_adder_server") # 创建ROS2节点对象并进行初始化
File "/home/sunx/ros_humble/install/learning_service/lib/python3.10/site-packages/learning_service/service_adder_server.py", line 16, in __init__
self.srv = self.create_service(AddTwoInts, 'add_two_ints', self.adder_callback) # 创建服务器对象(接口类型、服务名、服务器回调函数)
File "/opt/ros/humble/local/lib/python3.10/dist-packages/rclpy/node.py", line 1458, in create_service
check_is_valid_srv_type(srv_type)
File "/opt/ros/humble/local/lib/python3.10/dist-packages/rclpy/type_support.py", line 51, in check_is_valid_srv_type
check_for_type_support(srv_type)
File "/opt/ros/humble/local/lib/python3.10/dist-packages/rclpy/type_support.py", line 29, in check_for_type_support
msg_or_srv_type.__class__.__import_type_support__()
File "/home/sunx/ros_humble/install/learning_interface/lib/python3.11/site-packages/learning_interface/srv/_add_two_ints.py", line 284, in __import_type_support__
module = import_type_support('learning_interface')
File "/opt/ros/humble/local/lib/python3.10/dist-packages/rosidl_generator_py/import_type_support_impl.py", line 48, in import_type_support
raise UnsupportedTypeSupport(pkg_name)
rosidl_generator_py.import_type_support_impl.UnsupportedTypeSupport: Could not import 'rosidl_typesupport_c' for package 'learning_interface'
[ros2run]: Process exited with failure 1
不知道怎么解决这个问题。