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

Revision history [back]

I'm not sure if that's a good approach at all, but in your service callback you could use ros::topic::waitForMessage to get just one image. If you do that, make sure that you are actually running more than one spinner because otherwise waitForMessage in your service callback will block. You can use ros::AsyncSpinner for instance.

As I said, above solution is probably not the best one. I would instead have the subscriber callbacks running all the time and just store the newest image in a member variable of the class. Then, you can always use the latest image in your service callback.

Btw. please retag your question to help people to find your question easily.