Ask Your Question

Custom message is NOT available at python in ROS2

asked 2021-01-20 04:59:16 -0500

updated 2021-01-20 05:18:58 -0500

Good evening, everyone.

I faced a problem that a original custom message is not available.

I tried to create a custom message referred to "this tutorial #1", and comfirmed a correct output of a ros2 interface show custom_message command.

But, then, my subscriber written that referred to "this tutorial #2" in python, could't use the created custom message.

The error message when execute ros2 run my_sub listener is following:

Traceback (most recent call last):
 File "/home/ubuntu/msg_ws/install/sub_area_dec/lib/sub_area_dec/listener", line 11, in <module>
   load_entry_point('sub-area-dec==0.0.0', 'console_scripts', 'listener')()
 File "/home/ubuntu/msg_ws/install/sub_area_dec/lib/python3.8/site-packages/sub_area_dec/", line 28, in main
   minimal_subscriber = MinimalSubscriber()
 File "/home/ubuntu/msg_ws/install/sub_area_dec/lib/python3.8/site-packages/sub_area_dec/", line 14, in __init__
AttributeError: module 'area_detection_msgs' has no attribute 'msg'

I checked & package.xml of the subscriber, but I seemed it's not wrong.

What's happened?

Please, help me..

edit retag flag offensive close merge delete


ksato-dev gravatar image ksato-dev  ( 2021-01-20 06:01:16 -0500 )edit

1 Answer

Sort by ยป oldest newest most voted

answered 2021-01-20 07:39:18 -0500

updated 2021-01-20 07:40:04 -0500

Could it be that not setup correctly custom message?

I tried to publish a topic of a original custom message, but could not publish topic.

I got the output below by ros2 topic pub command:

$ ros2 topic pub /hogehoge area_detection_msgs/msg/Data "{area_name: "hoge"}"

ros2 topic pub /hogehoge area_detection_msgs/msg/Data "{area_name: "hoge"}"
Traceback (most recent call last):
  File "/opt/ros/foxy/lib/python3.8/site-packages/rosidl_generator_py/", line 46, in import_type_support
    return importlib.import_module(module_name, package=pkg_name)
  File "/usr/lib/python3.8/importlib/", 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 1101, in create_module
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
ImportError: /home/ubuntu/msg_ws/install/area_detection_msgs/lib/ undefined symbol: std_msgs__msg__UInt16MultiArray__fini

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/opt/ros/foxy/bin/ros2", line 11, in <module>
    load_entry_point('ros2cli==0.9.7', 'console_scripts', 'ros2')()
  File "/opt/ros/foxy/lib/python3.8/site-packages/ros2cli/", line 67, in main
    rc = extension.main(parser=parser, args=args)
  File "/opt/ros/foxy/lib/python3.8/site-packages/ros2topic/command/", line 41, in main
    return extension.main(args=args)
  File "/opt/ros/foxy/lib/python3.8/site-packages/ros2topic/verb/", line 93, in main
    return main(args)
  File "/opt/ros/foxy/lib/python3.8/site-packages/ros2topic/verb/", line 103, in main
    return publisher(
  File "/opt/ros/foxy/lib/python3.8/site-packages/ros2topic/verb/", line 130, in publisher
    pub = node.create_publisher(msg_module, topic_name, qos_profile)
  File "/opt/ros/foxy/lib/python3.8/site-packages/rclpy/", line 1140, in create_publisher
  File "/opt/ros/foxy/lib/python3.8/site-packages/rclpy/", line 29, in check_for_type_support
  File "/home/ubuntu/msg_ws/install/area_detection_msgs/lib/python3.8/site-packages/area_detection_msgs/msg/", line 27, in __import_type_support__
    module = import_type_support('area_detection_msgs')
  File "/opt/ros/foxy/lib/python3.8/site-packages/rosidl_generator_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 'area_detection_msgs'
edit flag offensive delete link more


Maybe, I did modify well.

Apparently, it seems like a setting for dependencies of custom msgs was not correctly.

ksato-dev gravatar image ksato-dev  ( 2021-01-20 08:33:55 -0500 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower


Asked: 2021-01-20 04:59:16 -0500

Seen: 394 times

Last updated: Jan 20 '21