ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question
0

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/test_sub.py", line 28, in main
   minimal_subscriber = MinimalSubscriber()
 File "/home/ubuntu/msg_ws/install/sub_area_dec/lib/python3.8/site-packages/sub_area_dec/test_sub.py", line 14, in __init__
   area_detection_msgs.msg.Data,
AttributeError: module 'area_detection_msgs' has no attribute 'msg'

I checked setup.py & 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

Comments

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

1 Answer

Sort by ยป oldest newest most voted
0

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/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 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/libarea_detection_msgs__rosidl_generator_c.so: 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/cli.py", line 67, in main
    rc = extension.main(parser=parser, args=args)
  File "/opt/ros/foxy/lib/python3.8/site-packages/ros2topic/command/topic.py", line 41, in main
    return extension.main(args=args)
  File "/opt/ros/foxy/lib/python3.8/site-packages/ros2topic/verb/pub.py", line 93, in main
    return main(args)
  File "/opt/ros/foxy/lib/python3.8/site-packages/ros2topic/verb/pub.py", line 103, in main
    return publisher(
  File "/opt/ros/foxy/lib/python3.8/site-packages/ros2topic/verb/pub.py", line 130, in publisher
    pub = node.create_publisher(msg_module, topic_name, qos_profile)
  File "/opt/ros/foxy/lib/python3.8/site-packages/rclpy/node.py", line 1140, in create_publisher
    check_for_type_support(msg_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/ubuntu/msg_ws/install/area_detection_msgs/lib/python3.8/site-packages/area_detection_msgs/msg/_data.py", 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/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 'area_detection_msgs'
edit flag offensive delete link more

Comments

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

Question Tools

1 follower

Stats

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

Seen: 1,055 times

Last updated: Jan 20 '21