Rosanswers logo

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.

Originally posted by roboticom314 on ROS Answers with karma: 107 on 2017-07-13

Post score: 0


1 Answer 1


Rosanswers logo

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);

Originally posted by AndyZe with karma: 2331 on 2017-07-13

This answer was ACCEPTED on the original site

Post score: 1

Original comments

Comment by Ed Venator on 2017-07-13:
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.

Comment by roboticom314 on 2017-07-17:
In that case, why not just update /opt/ros/indigo/lib/python2.7/dist-packages/rostopic/__init__.py? Looks like the CallbackEcho class handles the printing specifically in the callback function where there are sys.stdout.write.

Comment by Ed Venator on 2017-07-18:
Yeah, you could do that too, but it'll be wiped out if rostopic ever gets a package update.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.