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

Revision history [back]

click to hide/show revision 1
initial version

answered 2011-11-05 16:20:04 -0500

joq gravatar image

A boost shared pointer to the message does appear in the call. That is how you access the message. You can't pass other parameters, because this callback is invoked by ROS whenever a message arrives.

The best way to pass information back to main() is defining a C++ class in your program with the callback as a member function. It can then update class data as messages arrive.

Alternatively, you could update some global data structure. That is not generally a good practice unless your node is small and simple.