ROS Resources: Documentation | Support | Discussion Forum | Service Status | Q&A

Anonymous messages in ROS2

i was wondering (just out of interest) if it is possible generate the message definitions at runtime. As far as I understand the message type system it should be possible to generate the rosidl_message_type_support_t information at runtime and create a message with content according to the defined rosidl_message_type_support_t.


When you use an RMW implementation which relies on statically generated types (rmw_connext_cpp, rmw_opensplice_cpp) this is not possible since it relies on code being generated and compiled for each type.

When you use an RMW implementation which supports dynamic types the mapping happens by looking at the introspection information of the message type and using an API which handles each field individually (rmw_fastrtps_cpp, rmw_connext_dynamic_cpp [this one is currently not maintained and will likely not work with the current state of ROS 2 but would need to be updated]). In that case it should be possible to pass arbitrary types to the API as long as a corresponding introspection description of the message is provided with it (which is basically an object representation of the message). We haven’t tried this though so it might be “bumpy” if you go ahead with this.