Error when change the sensor message from custom one to standard
Hi
I changed some ROS2 nodes so can use standard IMU sensor messages defined in ROS as standard sensor IMU message instead of custom one . I defined correctly the IMU sensor message in the message file. Also in the python3 code I have imported correctly with from sensor_msgs.msg import Imu.. So, somewhere in my python code I would like to use this standard sensor message . When I execute the launch file with
ros2 launch system_launch test_system_launch.py
I got the following ERROR
[ERROR] [1666862786.571709059] [rosbag2_transport]: Topic '/robot/imu' has several types associated. Only topics with one type are supported
I think have to check the publishers of the /robot/imu
topic Which nodes publishes and which message types.. But not sure is the right way to find out the error and how to do it. Any help ?
Asked by Astronaut on 2022-10-27 04:46:18 UTC
Answers
It seems that you try to publish on one topic with two different publishers using two different message types. Because you said:
I defined correctly the IMU sensor message in the message file.
I am assuming that you created a custom message with the same field types as the sensor_msgs/Imu message? The message type is distinguished through the name of the message. Therefore the types of your custom imu message and the default message are different, which is causing the error.
You can execute: ros2 topic info /robot/imu
to see which returns the message type of the topic.
Asked by nils_iseke on 2022-10-27 07:31:53 UTC
Comments
yes exactly , I created a message myself that is structured in the same way as the sensor_msgs/Imu Message. how to check the message types of the publishers that publish to the topic /robot/imu
? you mean check the nodes that publish that topic /robot/imu
?
Asked by Astronaut on 2022-10-27 09:33:45 UTC
So i don't get why you are not using the sensor_msgs/Imu everywhere? I would assume if you do so, it would resolve the issue. Yes check the message type of each publisher that publishes to /robot/imu in your code and change them all to the official sensor_msgs/Imu message.
Asked by nils_iseke on 2022-10-27 11:34:01 UTC
to point is if possible to keep both, means custom sensor_msg/CustomImu and standard sensor_msg/Imu. Is that possible?
Asked by Astronaut on 2022-10-27 21:23:16 UTC
updated my awnser, hope that helps :)
Asked by nils_iseke on 2022-10-28 04:08:22 UTC
when run ros2 topic info /robot/imu
I got this: Type: sensor_msgs/msg/Imu
Publisher count: 1
Subscription count: 0
So means only one publisher? how to find him?
Asked by Astronaut on 2022-10-30 21:26:16 UTC
I would assume that the second publisher (the one with the custom message), is not running because of the error. So therefore just one publisher is found. To find a publisher go through the executables which are called by your launchfile test_system_launch.py
and then search for the publisher that publish to "/robot/imu", change the message type of all those publishers to the same message type.
Asked by nils_iseke on 2022-11-01 14:26:27 UTC
Comments