Robotics StackExchange | Archived questions

Are action callbacks blocking?

Let's say an action Fibonnaci takes 5 minutes to complete. If Fibonacci is called twice in quick succession, does the second call need to wait 5 minutes for the first call to complete, or do they run concurrently?

Asked by galaxee on 2020-12-09 15:37:36 UTC

Comments

Answers

I think it depends upon how you code the node that provides the ActionServer. On the client side you can start a new action with ActionClient.send_goal_async which will return a future. When that future completes, the result will tell you if the action was accepted. Your server side code can decide to accept a new action or not.

Asked by SmallJoeMan on 2020-12-09 16:30:56 UTC

Comments

I meant how can I make it so that the action server can accept new callbacks even while it is still processing another callback? Is MultiThreadedExecutor and ReentrantCallbackGroup sufficient?

Asked by galaxee on 2020-12-09 17:08:12 UTC

I have used a MultiThreadedExecutor and can successfully handle new action requests whilst an existing callback is running (running a while loop to navigate a robot to a goal pose). Not used a RentrantCallbackGroup, but that is not to say you shouldn't.

Asked by SmallJoeMan on 2020-12-09 18:46:14 UTC

I can try switching to single threaded executor and see what happens...

Asked by SmallJoeMan on 2020-12-09 18:47:18 UTC

Got it, thanks for the info! That helps a lot. Realized my initial question was not framed properly.

That's interesting that it works even though you're not using ReentrantCallbackGroup. I wonder what the difference is.

Asked by galaxee on 2020-12-09 19:49:19 UTC

@SmallJoeMan Actually would you be open to switching to a single threaded executor to see what happens?

Asked by galaxee on 2020-12-09 20:04:33 UTC

Just tried it and it all locked up.

Asked by SmallJoeMan on 2020-12-10 03:02:32 UTC

All rclpy examples use a MultiThreadedExecutor, so I think it is a requirement: examples_rclpy_minimal_action_server

Asked by SmallJoeMan on 2020-12-10 03:05:14 UTC

It's correct that you must use a MultiThreadedExecutor for action servers in rclpy. I think this is because we chose to use the executor to process the user-provided "execute" function. In contrast, rclcpp's implementation of the action server leaves it up to the user to handle separate threads when executing goals, and so a single threaded executor is fine.

It's is probably worth considering a refactor in rclpy such that any executor is compatible.

Asked by jacobperron on 2020-12-18 14:25:31 UTC