Knowing Topics and Messages in depth

From Lofaro Lab Wiki
Jump to: navigation, search

From now on we have understood that nodes are communicating with each other through messages. So it’s time to understand the messages and the type of the messages. Let’s take a closer look at topic and messages.

To get a list of active topics, use this command

 rostopic list 

From our example it should show 5 topics

 
/rosout
/rosout_agg
/turtle1/cmd_vel
/turtle1/color_sensor
/turtle1/pose 
  

You can see the actual messages that are being published on a single topic using the command

 rostopic echo topic-name

For example, if you want to see the messages of /turtle1/cmd_vel, command should be

 rostopic echo /turtle1/cmd_vel

If you want to know more about the topic use this command,

 rostopic info

to know more about the message type

rosmsg show message-type-name

lets try with on the message type for turtle1/color_senor

rosmsg show turtlesim/Color 

the output should look like

 
uint8 r
uint8 g
uint8 b