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 -0600
Seen: 119 times
Last updated: Jan 23 '23
Is there a release date of ros 2 or more informations about it?
Is the planned ROS1 to ROS2/DDS bridge available yet?
ROS2: content-based topic subscriptions?
Building Ros 2.0 without OpenCV?
ros2 rttest example build error
ROS 2 Alpha 2 ros1_bridge using DDS between two computers