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

Size of topic in command line

asked 2014-08-06 12:00:53 -0500

anamcarvalho gravatar image


is it possible to know the size of a topic in the command line?

The topic I am dealing with should return 1920 values and I want to confirm that, without doing a cout in the code!

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted

answered 2014-08-06 12:21:34 -0500

ahendrix gravatar image

Rostopic doesn't support this directly. You might be able to hack it by doing something like:

rostopic echo -n1 /topic/array | wc -l # echo the array part of one message (-n1) into the word count program (wc) and count lines (-l)

This might be off by one or two depending on how rostopic formats the output; you might want to look at one or two examples before piping it into wc.

Or just add a check for the correct array size in your code, and a warning if the array is not the correct size.

The ROS message definition also allows for fixed-size arrays in messages.

edit flag offensive delete link more

Your Answer

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

Add Answer

Question Tools

1 follower


Asked: 2014-08-06 12:00:53 -0500

Seen: 1,939 times

Last updated: Aug 06 '14