Hi there, I am bit confused about how to find out the message which is used by the particular topic. For instance, we have an exercise where we are told to get the info of the message that is used by the /odom topic. Here we can create the .py script to initialize /odom topic but how can we know beforehand that which type of message it will use, thanks
Hi there,
So there are a couple of commands that will be useful when investigating topics/messages
First is
~$ rostopic list
This will show all of the active ros topics. The output will look something like this
/camera/depth/camera_info /camera/depth/image_raw /camera/depth/points /camera/parameter_descriptions /camera/parameter_updates /camera/rgb/camera_info /camera/rgb/image_raw /clock /cmd_vel /gazebo/link_states /gazebo/model_states /gazebo/parameter_descriptions /gazebo/parameter_updates /gazebo/performance_metrics /gazebo/set_link_state /gazebo/set_model_state /imu /joint_states /odom /rosout /rosout_agg /scan /tf
Now Instead of listing the topics we can get additional information about a single topic by running the following command
~$ rostopic info /odom
The output will look something like
Type: nav_msgs/Odometry Publishers: * /gazebo (http://ubuntu:33969/) Subscribers: None
Here you can see that the message type is nav_msgs/Odometry
You can even go one step further to see how the message is structure with
~$ rosmsg show nav_msgs/Odometry
which produces the following output
std_msgs/Header header uint32 seq time stamp string frame_id string child_frame_id geometry_msgs/PoseWithCovariance pose geometry_msgs/Pose pose geometry_msgs/Point position float64 x float64 y float64 z geometry_msgs/Quaternion orientation float64 x float64 y float64 z float64 w float64[36] covariance geometry_msgs/TwistWithCovariance twist geometry_msgs/Twist twist geometry_msgs/Vector3 linear float64 x float64 y float64 z geometry_msgs/Vector3 angular float64 x float64 y float64 z float64[36] covariance
1 Like
I already found the solution myself before the answer(I used rostopic info) and still many thanks.
1 Like