Edit 2:
Warning: long piece of text ahead about semantics of messages and why what we have is actually not that bad.
Thank you for the time and in-depth answer! Not the answer I was hoping for, but what I feared... I was hoping that hardcoded /msg in genpy wouldn't be there.
Thanks for the alternative solution, I was aware of the rosbag migration, just dealing with dozens of bags with 10s of thousands of messages makes adding any new enumeration extremely cumbersome.
With the risk of "gold plating" this, I feel there is actually a big advantage to the way things are implemented now.
ROS messages (and services and actions) are supposed to be stand-alone. That is: their contents should be interpretable without requiring any external sources of information (that's of course difficult to achieve in reality, but that's the idea).
This is important both for archival reasons (ie: when stored in .bag
s from say 10 years ago) as well as to help ensure that consumers will be able to figure out what is being communicated right now. Both at the syntax level (ie: form of the data) as well as semantics (ie: meaning).
The MD5 hash of message structures ensures that the form of .msg
s expected by consumers is exactly the same as those produced by publishers. This not only guarantees that consumers will be able to deserialise the data (ie: they know in what form the data is), but it will also go a long way to make sure that how they interpret the meaning of that data is as the producer expected them to (ie: their responses and behaviour match with what the intentions of the producer were).
What you propose in your example (using a plain uint16
to contain the value of an enum value and then storing the possible (legal?) values of that uint16
in a separate message type) goes against this (if it doesn't completely make it impossible).
With the proposed approach, it would be possible to change the members of the "enum" (in quotes, as the msg
spec does not really support enum
s) without any producer or consumer being able to detect this, as there is no direct coupling between the enum and the uint16
. None of the hashes would change, as the "enum message" is not stored anywhere.
The proper way to do this would be to either keep the enumeration values in the same .msg
, or use the type of the enumeration .msg
as the type of the field containing the value (ie: instead of uint16
).
I realise this doesn't help make things any easier, but I believe the current system does help avoid all sorts of problems.
I was aware of the rosbag migration, just dealing with dozens of bags with 10s of thousands of messages makes adding any new enumeration extremely cumbersome.
This is easy for me to say (as I don't have to do it), but automation should ... (more)