ROS2 get the class of a given topic
Hi, how can a I get the class of a given topic in ROS2? Thanks
ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange |
Hi, how can a I get the class of a given topic in ROS2? Thanks
Your question is not entirely clear. topics are of type message - not class.
As described in ROS2 Manual: If you want to know the type of message, you can use:
ros2 topic list -t
which will result in a similar output:
/parameter_events [rcl_interfaces/msg/ParameterEvent] ...
so that /parameter events is the topic/message name and rcl_interfaces/msg/ParameterEvent is the type.
Hope this helps.
It does not make sense. In a node you import (using Python) already at the beginning of the file the message type (or class if you prefer), that you want to subscribe/publish. If I understood, you want a node, which automatically detect a topic and then it tries to identify the message sent. It does not make sense such design, since you could expect anything from a string to a pose messagge.
Hi lfb, As I mentioned before, you can run ros2 topic list through an terminal and get the type. I found an example on how to use the API you just mentioned in the following link
Let me know if this helps.
Asked: 2023-01-18 14:27:36 -0500
Seen: 46 times
Last updated: Jan 23 '23
'ament_python' has no 'setup.py' file
[ROS2] ros2 command stucks without exit
Use FastRTPS in Docker with ROS2 Galactic
How do you "colcon build" with a specific C++ version?
Cannot build ROS2 humble (rclcpp) with Android NDK
Is there a way to throttle publisher rate in ROS2?