0
$\begingroup$

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 
%time,field.layout.data_offset,field.data0,field.data1,field.data2,field.data3
1499982217479538917,0,20805,1,21,22
1499982219479435920,0,20805,1,21,22
1499982223479465007,0,20805,1,21,22
1499982225479479074,0,20805,1,21,22

Looks something like this:

%time,field.layout.data_offset,field.data0,field.data1,field.data2,field.data3
1499982217479538917,0x0,0x5145,0x1,0x15,0x16
1499982219479435920,0x0,0x5145,0x1,0x15,0x16
1499982223479465007,0x0,0x5145,0x1,0x15,0x16
1499982225479479074,0x0,0x5145,0x1,0x15,0x16

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

$\endgroup$

1 Answer 1

0
$\begingroup$

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.

$\endgroup$

Your Answer

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