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

rostopic echo Int32MultiArray as hex

asked 2017-07-13 16:53:48 -0500

roboticom314 gravatar image

I'm looking for a way to use rostopic echo to print a Int32MultiArray message data as hex values instead of decimal. I've tried piping to xxd but it's printing the hex for the ASCII text representing the numbers.

Here's an example Int32MultiArray. I'm using the plotting format flag -p only to reduce the clutter. I'd like to see this:

rostopic echo -p /test_topic 

Looks something like this:


I've even tried using wireshark to look at the raw message but that's a challenge to trace down.

edit retag flag offensive close merge delete

2 Answers

Sort by ยป oldest newest most voted

answered 2017-07-13 17:06:54 -0500

AndyZe gravatar image

updated 2017-07-13 18:14:16 -0500

Do you need to use rostopic? Why not write your own ROS subscriber node, then use ROS_INFO or printf to specify hex format. Something like...

printf("%#010x, %#010x\n", field.data0, field.data1);
edit flag offensive delete link more


This is a good answer. rostopic echo doesn't support hex output, and I've found that it's faster to whip up python nodes than it is to come up with creative solutions using the CLI tools.

Ed Venator gravatar image Ed Venator  ( 2017-07-13 21:30:40 -0500 )edit

In that case, why not just update /opt/ros/indigo/lib/python2.7/dist-packages/rostopic/ Looks like the CallbackEcho class handles the printing specifically in the callback function where there are sys.stdout.write.

roboticom314 gravatar image roboticom314  ( 2017-07-17 09:01:23 -0500 )edit

Yeah, you could do that too, but it'll be wiped out if rostopic ever gets a package update.

Ed Venator gravatar image Ed Venator  ( 2017-07-18 19:47:44 -0500 )edit

answered 2021-03-31 22:54:46 -0500

tzx gravatar image

this python code may help:

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: 2017-07-13 16:53:48 -0500

Seen: 751 times

Last updated: Jul 13 '17