ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question
0

rostopic echo Int32MultiArray as hex

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

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 
%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.

edit retag flag offensive close merge delete

2 Answers

Sort by ยป oldest newest most voted
1

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

AndyZe gravatar image

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

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

Comments

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 -0600 )edit

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.

roboticom314 gravatar image roboticom314  ( 2017-07-17 09:01:23 -0600 )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 -0600 )edit
0

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

tzx gravatar image

this python code may help: https://gist.github.com/district10/72...

edit flag offensive delete link more

Question Tools

1 follower

Stats

Asked: 2017-07-13 16:53:48 -0600

Seen: 1,375 times

Last updated: Jul 13 '17