ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | Q&A
Ask Your Question

rostopic echo only a msg of topic

asked 2016-02-04 10:34:48 -0600

Hossein gravatar image

I have a topic containing several messages. How can I use 'rostopic echo' to echo only one message.

For example this is my topic containing the following messages:

Header      hdr
int32       runlevel
int32       sublevel
int32       last_seq
int32[2]    type
int32[6]    pos
float32[18]   ori

and I am just interested to see only message pos on my terminal.

edit retag flag offensive close merge delete


Is there anyway to decrease the rate of publishing? It's too fast and I can't see them.

Also is there anyway to plot them?

Hossein gravatar image Hossein  ( 2016-02-04 13:04:31 -0600 )edit

please update your question, don't post an answer.

MichaelKorn gravatar image MichaelKorn  ( 2016-02-04 13:09:55 -0600 )edit

1 Answer

Sort by ยป oldest newest most voted

answered 2016-02-04 11:02:44 -0600

updated 2016-02-04 13:41:32 -0600

Regarding to the documentation of rostopic, this should work:

rostopic echo /my_topic/field_name

one complex example for typical tf messages:

rostopic echo /tf/transforms[0]/transform/translation/x

You can change the output rate (e.g. 1sec) with:

watch -n1 rostopic echo /my_topic/field_name

You can plot topics with rqt_plot

edit flag offensive delete link more


I can confirm that the first version works. I use it frequently.

ahendrix gravatar image ahendrix  ( 2016-02-04 12:15:12 -0600 )edit

@ahendrix: You are right. I tried it with tf and I failed to take into account that the field "transforms" is an array.

MichaelKorn gravatar image MichaelKorn  ( 2016-02-04 13:44:19 -0600 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools



Asked: 2016-02-04 10:34:48 -0600

Seen: 26,042 times

Last updated: Feb 04 '16