Why ROS messages do not inherit from a base class??
Hello there!
I am a software engineer and I try to design a general message-type-agnostic multiple socket node interface that wraps a NodeHandle and also i have the demand to make it able to change these dynamically on the runtime using an interface that we have developed. This inteface, named StateClient, is implemented by someone who wants to hear about state changes in the system. A StateServer is announcing to all subscribers the state change and to which state we are entering, in order for nodes that are StateClients to change behaviour on the runtime. An example of what i want to do:
Suppose that our system works properly being in state 2. Our example node is the system NodeExample and is subscribed to some concrete topics of concrete message types, publishes other concrete message types to concrete topics and also uses a concrete method of processing the input data to transform them into output data in a functional way, such as when processing raw data in order to detect something or to transform them. Then let's say that state changes to state 3. In this state i want to change the postprocessing of the data in order to form a different output message type that will be delivered to a different topic. In state 4, i may want to change my subscriber options instead and subscribe plus to another topic of some type and change naturally the preprocessing of the input data.
I find this task extremely difficult because of the way ROS messages are implemented. If ROS messages inherited from a base class things would be easier because all subscribers would then refer to that base message type and i could easily with a bridge pattern define the concrete message type on runtime. ROS messages are not implemented like this unfortunately, so i try to find a solution using template metaprogramming (using boost.variant??) or function-binding to some dynamic language, such as python (with boost.python).
Long story short: How come ROS messages do not inherit from a standard common base container? How could one implement something like that (dynamically change the types being used in our node's interface with the system)? Note that i want to build something that is agnostic both to type and the number of input or output messages.