记录一次ROS2消息BUG ImportError rosidl_generator_c.so: undefined symbol

我是小鱼,欢迎关注公众号鱼香ROS,一起学习机器人。

BUG表现如下

自定义消息,编译不报错,运行就出错

Traceback (most recent call last):
  File "/opt/ros/foxy/lib/python3.8/site-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.8/importlib/__init__.py", line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1014, in _gcd_import
  File "<frozen importlib._bootstrap>", line 991, in _find_and_load
  File "<frozen importlib._bootstrap>", line 975, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 657, in _load_unlocked
  File "<frozen importlib._bootstrap>", line 556, in module_from_spec
  File "<frozen importlib._bootstrap_external>", line 1166, in create_module
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
ImportError: /home/ros2/code/town_ws/install/village_interfaces/lib/libvillage_interfaces__rosidl_generator_c.so: undefined symbol: sensor_msgs__msg__Image__init

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/ros2/code/town_ws/install/village_li/lib/village_li/li4_node", line 11, in <module>
    load_entry_point('village-li==0.0.0', 'console_scripts', 'li4_node')()
  File "/home/ros2/code/town_ws/install/village_li/lib/python3.8/site-packages/village_li/li4.py", line 46, in main
    node = Li4Node()  # 新建一个节点
  File "/home/ros2/code/town_ws/install/village_li/lib/python3.8/site-packages/village_li/li4.py", line 23, in __init__
    self.borrow_server = self.create_service(BorrowMoney,"borrow_money",self.borrow_money_callback)
  File "/opt/ros/foxy/lib/python3.8/site-packages/rclpy/node.py", line 1295, in create_service
    check_for_type_support(srv_type)
  File "/opt/ros/foxy/lib/python3.8/site-packages/rclpy/type_support.py", line 29, in check_for_type_support
    msg_type.__class__.__import_type_support__()
  File "/home/ros2/code/town_ws/install/village_interfaces/lib/python3.8/site-packages/village_interfaces/srv/_borrow_money.py", line 316, in __import_type_support__
    module = import_type_support('village_interfaces')
  File "/opt/ros/foxy/lib/python3.8/site-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 'village_interfaces'

原因:

自定义消息未添加对其他消息的依赖

解决办法,添加依赖在CMakeists.txt中

find_package(rosidl_default_generators REQUIRED)
rosidl_generate_interfaces(${PROJECT_NAME}
  #---msg---
  "msg/Novel.msg"
  #---srv---
  "srv/BorrowMoney.srv"
  "srv/SellNovel.srv"
   DEPENDENCIES std_msgs sensor_msgs
 )
  • 2
    点赞
  • 7
    收藏
    觉得还不错? 一键收藏
  • 13
    评论
评论 13
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值