ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question
0

how to identify topic and data type mapping in ros

asked 2017-08-28 11:43:51 -0500

can-43811 gravatar image

Hi All, I want to know the exact data type of topic published. So in some scenario data type integer related information published under some topics or it might be image or string data. in some scenario published information under topic might be collection of some of the data types (int, bool, string, float, double) . so how to identify through command line or API what data type is published under particular topic.

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
4

answered 2017-08-28 12:28:17 -0500

jayess gravatar image

updated 2017-08-28 12:43:38 -0500

For command line usage you can run rostopic info <topic-name> and that will show the message type along with other information. Here's an example with just roscore running.

$ rostopic info /rosout
Type: rosgraph_msgs/Log

Publishers: None

Subscribers: 
 * /rosout (http://127.0.0.1:41588/)

Notice the section that says

Type: rosgraph_msgs/Log

this shows that this topic carries messages of the type rosgraph_msgs/Log. You can read more about this on the wiki.


Edit:

As @gvdhoorn pointed out in the comments, a great shortcut is

rostopic type /my_topic | rosmsg show

which will then show (from my above example)

$ rostopic type /rosout | rosmsg show

byte DEBUG=1
byte INFO=2
byte WARN=4
byte ERROR=8
byte FATAL=16
std_msgs/Header header
  uint32 seq
  time stamp
  string frame_id
byte level
string name
string msg
string file
string function
uint32 line
string[] topics

which gives the definition of the message.

edit flag offensive delete link more

Comments

2

Shortcut: rostopic type /my_topic | rosmsg show.

gvdhoorn gravatar image gvdhoorn  ( 2017-08-28 12:32:30 -0500 )edit

@gvdhoorn, thanks I didn't know about that one. I'll update my answer with it.

jayess gravatar image jayess  ( 2017-08-28 12:37:44 -0500 )edit

@can-43811 if this answered your question, please click on the checkmark to mark the answer as correct.

jayess gravatar image jayess  ( 2018-01-17 03:35:21 -0500 )edit

Question Tools

1 follower

Stats

Asked: 2017-08-28 11:43:51 -0500

Seen: 7,399 times

Last updated: Aug 28 '17