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

Error when execute 'ros2 topic echo /hello_ros2 ros1_msgs/MyMsg'

asked 2019-10-28 07:45:16 -0600

lobby gravatar image

updated 2023-04-26 10:08:27 -0600

130s gravatar image

The ros1_msgs/MyMsg is my custom message type, The package directory path is ~/ros1_install/src/ros1_msgs. So I open a terminal, then source the relevant package path to environment by this order:

ubuntu@cscsh:~$ ros2 topic echo /hello_ros2 ros1_msgs/MyMsg

ros2: command not found

ubuntu@cscsh:~$ source /opt/ros/melodic/setup.bash 

ubuntu@cscsh:~$ source ~/ros1_install/devel/local_setup.bash(the install path of my custom message type package)

ubuntu@cscsh:~$ source /opt/ros/dashing/setup.bash 

ubuntu@cscsh:~$ source ~/ros2_ws/install/local_setup.bash(the source code path of my ros2) 

ROS_DISTRO was set to 'melodic' before. Please make sure that the environment does not mix paths from different     distributions.

Then i execute the command:

dbt@cscsh-dubingtao:~$ ros2 topic echo /hello_ros2 ros1_msgs/MyMsg

Traceback (most recent call last):
  File "/home/dbt/ros2_ws/install/ros2cli/bin/ros2", line 11, in <module>
    load_entry_point('ros2cli==0.7.0', 'console_scripts', 'ros2')()
  File "/home/dbt/ros2_ws/install/ros2cli/lib/python3.6/site-packages/ros2cli/cli.py", line 69, in main
    rc = extension.main(parser=parser, args=args)
  File "/home/dbt/ros2_ws/install/ros2topic/lib/python3.6/site-packages/ros2topic/command/topic.py", line 43, in main
    return extension.main(args=args)
  File "/home/dbt/ros2_ws/install/ros2topic/lib/python3.6/site-packages/ros2topic/verb/echo.py", line 69, in main
    return main(args)
  File "/home/dbt/ros2_ws/install/ros2topic/lib/python3.6/site-packages/ros2topic/verb/echo.py", line 79, in main
    node.node, args.topic_name, args.message_type, callback)
  File "/home/dbt/ros2_ws/install/ros2topic/lib/python3.6/site-packages/ros2topic/verb/echo.py", line 109, in subscriber
    msg_module, topic_name, callback, qos_profile_sensor_data)
  File "/home/dbt/ros2_ws/install/rclpy/lib/python3.6/site-packages/rclpy/node.py", line 1126, in create_subscription
    check_for_type_support(msg_type)
  File "/home/dbt/ros2_ws/install/rclpy/lib/python3.6/site-packages/rclpy/type_support.py", line 20, in check_for_type_support
    ts = msg_type.__class__._TYPE_SUPPORT
AttributeError: type object 'type' has no attribute '_TYPE_SUPPORT' This might be a ROS 1 message type but it should be a ROS 2 message type. Make sure to source your ROS 2 workspace after your ROS 1 workspace.

If i use the builtin message type, as i execute this command:

ros2 topic echo /hello_ros2 std_msgs/String

It work normally. so i check the PATH environment:

ubuntu@cscsh:~$ env | grep PYTHONPATH

/home/dbt/ros2_ws/install/ament_cppcheck/lib/python3.6/site-packages:/home/dbt/ros2_ws/install/ament_clang_tidy/lib/python3.6/site-packages:/home/dbt/ros2_ws/install/ament_clang_format/lib/python3.6/site-packages:/opt/ros/dashing/lib/python3.6/site-packages:/home/dbt/ros1_install/devel/lib/python2.7/dist-packages:/opt/ros/melodic/lib/python2.7/dist-packages

The output is not just like the above, I only showed a part, you can see that ros2 uses python3.6, ros1 uses 2.7+, I think the problem maybe related to the Python version inconsistency?

Does anyone know the reason of the error message? Appreciate.

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
0

answered 2019-10-28 11:43:09 -0600

I'm not sure why you're doing anything with ROS1, just source your dashing workspace and use it that way.

If you're trying to publish a ROS1 topic to ROS2, that's not going to work, nor is it going to work to try to publish a ROS1 compiled message from ROS2, you need to compile the messages in ROS2 to create the IDL files for DDS.

If you want to mix messages between ROS1 and 2 you need to use the ros1_bridge

edit flag offensive delete link more

Question Tools

1 follower

Stats

Asked: 2019-10-28 07:45:16 -0600

Seen: 2,929 times

Last updated: Apr 26 '23