Robotics StackExchange | Archived questions

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

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?

Asked by wegunterjr on 2020-11-10 19:28:39 UTC

Comments

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

Asked by gvdhoorn on 2020-11-11 03:47:16 UTC

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

Asked by wegunterjr on 2020-11-11 08:13:03 UTC

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.

Asked by gvdhoorn on 2020-11-11 08:17:50 UTC

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?

Asked by wegunterjr on 2020-11-11 08:56:50 UTC

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

Asked by wegunterjr on 2020-11-11 11:16:55 UTC

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

Asked by wegunterjr on 2020-11-11 11:17:34 UTC

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-for-LabVIEW-Software

Asked by wegunterjr on 2020-11-13 17:51:41 UTC

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

Asked by OzzieTheHead on 2021-04-30 10:41:22 UTC

Answers

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.

Asked by OzzieTheHead on 2021-04-30 10:38:08 UTC

Comments