Ask Your Question

ROS msg format specification

asked 2014-06-05 20:45:13 -0600

bjem85 gravatar image

Hi All,

I have created a custom CAN bus message but I would like to change the way that the information is printed out.

My .msg file is:

# Custom message for sending the IMU data to the hydraulic test system
# BJEM 19th May 2014.

Header header
uint32 time_ms
uint16 time_us
uint32 id         # 11/29 bit code
uint8 msgtype     # bits of MSGTYPE_*
uint8 len         # count of data bytes (0..8)
uint8[] data      # data bytes, up to 8

##### END OF FILE #####

I would like the fields id, and data to be printed out as hexadecimal numbers. There doesn't seem to be an obvious way to do that. Here's an example header sequence obtained using rostopic echo:

  seq: 48533
    secs: 1402018614
    nsecs: 775459838
  frame_id: ''
time_ms: 132547
time_us: 476
id: 2565877120
msgtype: 0
len: 7
data: [237, 124, 82, 122, 107, 122, 0]

Hexadecimal for the id and data makes it much easier to comprehend.

Thanks in Advance

edit retag flag offensive close merge delete

2 Answers

Sort by » oldest newest most voted

answered 2014-06-06 01:53:29 -0600

ahendrix gravatar image

rostopic doesn't support custom message formatting.

If you need to print messages to the console in custom format, you should write a custom node.

edit flag offensive delete link more


I ended up doing this, as I am already writing a ROS node that uses the data for further calculations.

bjem85 gravatar image bjem85  ( 2014-06-08 21:32:07 -0600 )edit

answered 2014-06-06 10:06:12 -0600

Jérôme gravatar image

The easyiest way, I think, is to write a python script with a callback for your particular message and made your transform by yourself !

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-06-05 20:45:13 -0600

Seen: 550 times

Last updated: Jun 06 '14