Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

I decided to go with the solution of having multiple callback queues by adapting the answer found here.

callback1 is thus kept in the global ROS queue, while callback2 is run asynchronously.

To make the callback2 preemptable, I added a variable which stores the time stamp of the most recent callback, and a check for a more recent time stamp in the while loop of the callback which is used for preemption. Some care had to be taken to avoid race condition, but it was rather simple with atomic variables or mutex locks.