Open jacknlliu opened 6 years ago
There are inner callback queues in moveit
, and it uses the global callback queue. When calling the service server, the callback queue can't response to the coming moveit
inner callback event(current callback queue is busy because current callback is not exit), so it's blocking. If assign more spinner, when main thread callback queue is busy, another spinner thread will process other things.
moveit using the same callback queue with the main thread, this makes blocking when it is in a callback function, because the new callback from the moveit can't enter when the current callback function does not exit.
Solution: using a separated callback queue for service inner callback. We can use multiple threads async spinner with the number of threads larger than 1, or using a specific callback queue for this service and another callback queue for others(can also used for the service inner callback event).
Method 1
Add async spinner with N threads where N > 1 in main function
Method 2
We need corresponding option object to set callback queue for
subscribe()
,advertise()
,advertiseService()
, etc. For example, option objectros::AdvertiseServiceOptions
foradvertiseService
.NOTE: We also should add an another
spinner
for other callback queues, or callback functions in the main process can't work!Using service callback In main function
Using service callback In a Class:
Reference