Robotics StackExchange | Archived questions

Use AsyncSpinner to process callbacks

I'm trying to understand the behavior of AsyncSpinner class from this post. Given two callbacks cb1 registered to one subscriber sub1 and cb2 registered to another different subscriber sub2 , the frequency of subscribing to message in sub1 is much higher than that in sub2 . We may have a global callback queue like [cb1, cb1, cb1, cb1, cb2, cb1, cb1, cb1, cb1] . Also, the processing time of cb1 is very long. Does the process still get stuck even if we use AsyncSpinner because ROS prevents a callback registered in one subscriber from being called simultaneously by multiple threads by default. For example, we have 4 threads but 3 threads are idle and waiting for 1 thread to finish execution of cb1 since ROS only allows one thread to process callbacks registered to one subscriber. Thus, the process is still stuck and behaves like single threaded spinning because other threads have to wait while one thread is processing cb1. Is my understanding correct?

Asked by hck007 on 2022-08-23 13:03:08 UTC

Comments

Answers