Call a function on new subscription data outside callback function?

asked 2016-02-24 08:08:55 -0600

ros_geller gravatar image

Hi.

I am trying to call a function to perform some calculations whenever one of my subscriptions get new data, but i don't want to call the function inside my callback function since the calculations could take longer than the timestep of the subscription.

Is there a notifier or something similar that i could use that lets me know when new data has arrived from a particular subscription?

I was considering just doing this:

while(ros::ok())
{
     ros::getGlobalCallbackQueue()->callAvailable(ros::WallDuration(0.1));
     callMyFunction();
}

But this would call my function whenever any of my subscriptions get new data.

I have a feeling there is an easy way about doing this, but I'm stuck at the moment.

All and any help is appreciated.

edit retag flag offensive close merge delete