Hi, I built a node with a class in it, the class has two callbacks one is bind to dynamic reconfigure server, the other is bind to a service. Both callbacks are class member. So it is something like this:
class A
{
bool param;
bool callback1 (node::service::Request &req, node::service::Response &res)
{
//some long computations
if (param)
//do something
else
//do something else
}
void callback2 (node::nodeConfig &config, uint32_t level)
{
//updating parameters...
param = config.param;
}
}
The service callback has some internal loop that requires user input to continue, my idea was to let user (re)configure parameters while the service executes. However this is not working because callback2 does not interrupt callback1 and param is only set AFTER callback1 terminates.
What would be the correct way to achieve this ? How can i rewrite the class so that callback2 can interrupt callback1 ?
I thought that maybe this happens because both callbacks are class members, what if callback2 is a global function ?
Originally posted by Tabjones on ROS Answers with karma: 43 on 2015-03-23
Post score: 0
Original comments
Comment by dornhege on 2015-03-23:
This has nothing to do with callbacks being members or not. You need to do multi-threaded spinning if you want multiple callbacks to trigger. I'm not sure if just adding an AsyncSpinner is already sufficient.
Comment by dornhege on 2015-03-23:
If you are doing very lengthy computations, it might be a good idea to switch to actionlib.