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

Revision history [back]

One solution to this in ROS is to include the type variable as well as a variable for each of the CustomMessages, so that only one of those custom messages is used each time. This shouldn't be too bad if you don't have that many different custom message types to choose from.

A more dynamic but even less elegant solution would be to serialise the custom message type and store it in a byte array next to the type variable. This means that there is no limit to the number of message types it can hold, but the code to deal with them becomes much more complicated.

Hope this helps.