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

rosmsg md5 byte[] array - how best to confirm md5?

asked 2020-11-10 18:28:39 -0500

wegunterjr gravatar image

updated 2020-11-13 16:52:48 -0500

I am able to confirm checksums for most of the std_msgs, but am having issues with the ByteMultiArray, as it has a MultiArrayLayout and a byte[] - i cannot figure out how to get the md5 to match? Thoughts?

edit retag flag offensive close merge delete

Comments

2

To avoid an xy-problem, could you clarify why you seem to reimplement this functionality? Are you writing a client library?

gvdhoorn gravatar image gvdhoorn  ( 2020-11-11 02:47:16 -0500 )edit

Interesting... I am writing s client library for something not running ROS.

wegunterjr gravatar image wegunterjr  ( 2020-11-11 07:13:03 -0500 )edit
1

Could you say something about the platform you're targetting? There are quite a few existing client libraries (even for 'small' systems, or limited ones, like PLCs) which may have already solved this problem. Avoiding duplication of effort is important here.

gvdhoorn gravatar image gvdhoorn  ( 2020-11-11 07:17:50 -0500 )edit

I am aware of a good portion of the clients available. I don't need one of those I need to understand how to run the checksum in something like I've suggested above. Do you know how to do the most for something like ByteMultiArray. I am just not sure what to do with the square brackets or array part. Any thoughts?

wegunterjr gravatar image wegunterjr  ( 2020-11-11 07:56:50 -0500 )edit

so, the current process for me to recreate what rosmsg md5 does. For example:

$ rosmsg md5 std_msgs/ColorRGBA

Output

$ a29a96539573343b1310c73607334b00

ColorRGBA is made up of 4 float32:

float32 r
float32 g
float32 b
float32 a

The md5 hash for these using a webtool like http://onlinemd5.com/ is exactly the same:

A29A96539573343B1310C73607334B00

When I start to break down something like ByteMultiArray, it contains:

MultiArrayLayout layout
byte[] data

MultiArrayLayout is actually made up of:

MultiArrayDimension[] dim
uint32 data_offset

MultiArrayDimension is made up of:

string label
uint32 size
uint32 stride

So, using rosmsg md5 I can get the has of the actual message type instead of the smaller std_msgs like string, uint32, etc. but my client doesn't have that, so I feel that this should really look like:

string label
uint32 size
uint32 stride
uint32 data_offset
byte[] data
wegunterjr gravatar image wegunterjr  ( 2020-11-11 10:16:55 -0500 )edit

This is the output of the md5 for the breakdown:

9280F1C055E4C32736216B03EC53407A

Not sure what else to do. And what exactly do i do with that byte that has brackets ....

wegunterjr gravatar image wegunterjr  ( 2020-11-11 10:17:34 -0500 )edit

This labview library from Tuftes doesn't seem to work quite right, messages are truncated and cannot add any more messages. Some VI's start up and can't be killed... https://github.com/tuftsBaxter/ROS-fo...

wegunterjr gravatar image wegunterjr  ( 2020-11-13 16:51:41 -0500 )edit

@wegunterjr Hope I helped. Could you please update your question to include what you are doing and what results you got (comments #3 and #4 as of now)

OzzieTheHead gravatar image OzzieTheHead  ( 2021-04-30 10:41:22 -0500 )edit

1 Answer

Sort by ยป oldest newest most voted
0

answered 2021-04-30 10:38:08 -0500

OzzieTheHead gravatar image

updated 2021-04-30 10:38:57 -0500

Quoting ROS Technical Overview

Message types (msgs) in ROS are versioned using a special MD5 sum calculation of the msg text. In general, client libraries do not implement this MD5 sum calculation directly, instead storing this MD5 sum in auto-generated message source code using the output of roslib/scripts/gendeps.

I arrived at this after looking into how messages are serialized, especially if they are nested. Then I remembered, and correct me if I am wrong, the md5sums are calculated during message_generation (so while building messages).

Try hashlib.md5` to help you with this. You can refer to this here.

edit flag offensive delete link more

Question Tools

Stats

Asked: 2020-11-10 18:28:39 -0500

Seen: 281 times

Last updated: Apr 30 '21