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

Revision history [back]

You could use templates if all your messages have a common member variable which you need. Let's say it is an int called int_value. Then you could write

void processInt (int a)
{
  // Your real work goes here again
}

template<typename MsgPtr>
void genericCallback (MsgPtr m)
{
  processInt (m->int_value);
}

I'm still not sure what you want to achieve, though. If you have lots of messages with basically the same layout, why not use just one message and add an extra variable that encodes the intended type?