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

Understanding messages MDSum

asked 2018-11-15 07:54:36 -0500

Vicente Penades gravatar image

updated 2018-11-15 08:43:11 -0500

I am trying to understand how the MD5Sum of the messages is being calculated following this link

So far, I undestand that a plain message like std_msgs/Header translates to:

uint32 seq
time stamp
string frame_id

And if I paste that block of text into this online MD5Sum calculator it correctly gives me the Header hash: 2176decaecbce78abc3b96ef049fabed

Now, for complex messages, the documentation states that: "In order to catch changes that occur in embedded message types, the MD5 text is concatenated with the MD5 text of each of the embedded types, in the order that they appear."

So, how that would translate to a message like geometry_msgs/Vector3Stamped ?

I tried combinations like this:

Header header
Vector3 vector
uint32 seq
time stamp
string frame_id
float64 x
float64 y
float64 z

or like this:

Header header
Vector3 vector
2176decaecbce78abc3b96ef049fabed
4a842b65f413084dc2b10fb484ea7f17

Also with capital letters

but none gives me the correct Vector3Stamped MD5Sum of 7b324c7325e683bf02a9b14b01090ec7

edit retag flag offensive close merge delete

2 Answers

Sort by ยป oldest newest most voted
0

answered 2018-11-15 12:47:57 -0500

Vicente Penades gravatar image

After trying a bunch or permutations, this is what it worked for Vector3Stamp

2176decaecbce78abc3b96ef049fabed header
4a842b65f413084dc2b10fb484ea7f17 vector

So they're not concatenated as the documentation says. What happens is the MD5 hash of the underlaying message replaces the type itself. so std_msgs/Header becomes 2176decaecbce78abc3b96ef049fabed and geometry_msgs/Vector3 becomes 4a842b65f413084dc2b10fb484ea7f17

I would recomend updating the docs to reflect this behavior.

edit flag offensive delete link more

Comments

1

The documentation you refer to is a wiki, so if you feel it should be corrected then it would make sense for you to do that.

Btw: this line in the code I linked does what you describe.

gvdhoorn gravatar image gvdhoorn  ( 2018-11-15 13:13:29 -0500 )edit
0

answered 2018-11-15 08:55:16 -0500

gvdhoorn gravatar image

According to the documentation that you linked, the md5 text is defined as:

[..] the .msg text with:

  • comments removed
  • whitespace removed
  • package names of dependencies removed
  • constants reordered ahead of other declarations

And for composite messages: "the MD5 text is concatenated with the MD5 text of each of the embedded types, in the order that they appear."

So only the text is concatenated. The MD5 sum itself is not part of what is defined as the md5 text.

edit flag offensive delete link more

Comments

Yes, I've read that line, it would be like this:

Header header   // Vector3Stamped
Vector3 vector
uint32 seq         // Header
time stamp
string frame_id
float64 x            // Vector3
float64 y
float64 z

But it's not working, so what am I doing wrong

Vicente Penades gravatar image Vicente Penades  ( 2018-11-15 09:02:19 -0500 )edit

Comments are stripped. Did you include those?

gvdhoorn gravatar image gvdhoorn  ( 2018-11-15 09:07:41 -0500 )edit

Also: Vector3 is not a primitive type. If I understand the explanation correctly, Vector3 vector and Header header should be replaced by the contents of those respective messages.

gvdhoorn gravatar image gvdhoorn  ( 2018-11-15 09:08:45 -0500 )edit

Trying the aggregation of the contents of Header and Vector3:

uint32 seq
time stamp
string frame_id
float64 x
float64 y
float64 z

At the MD5 calculator gives an incorrect hash too.

Vicente Penades gravatar image Vicente Penades  ( 2018-11-15 10:12:01 -0500 )edit

I'm trying all permutations I can imagine.... the "the MD5 text is concatenated with the MD5 text of each of the embedded types, in the order that they appear." can really be interpreted in many ways, at the very least, the documentation should provide some examples on how exactly is concatenated

Vicente Penades gravatar image Vicente Penades  ( 2018-11-15 10:13:49 -0500 )edit

I don't think it can be interpreted in many ways:

  1. the md5 text is defined earlier in the text
  2. it is + with the md5 text of the other msgs (ie: fields)
  3. in the other that they appear: if you have md5_text of field a and of field b, you'd do md5_text(a) + md5_text(b)
gvdhoorn gravatar image gvdhoorn  ( 2018-11-15 10:51:50 -0500 )edit

this is the code that computes the "md5 text" for a given msg spec.

gvdhoorn gravatar image gvdhoorn  ( 2018-11-15 10:53:48 -0500 )edit

What md5_text(a) function does? it returns the hash as in "4a842b65f413084dc2b10fb484ea7f17" or it returns the list of compacted fields as in "float64 x float64 y ..." ? and, how the concatenated result of Vector3Stamped (or any other composited message) would look like?

Vicente Penades gravatar image Vicente Penades  ( 2018-11-15 10:57:27 -0500 )edit

Question Tools

1 follower

Stats

Asked: 2018-11-15 07:54:36 -0500

Seen: 1,602 times

Last updated: Nov 15 '18