ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question

Are action callbacks blocking?

asked 2020-12-09 14:37:36 -0500

galaxee gravatar image

updated 2020-12-09 14:37:48 -0500

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?

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted

answered 2020-12-09 15:30:56 -0500

SmallJoeMan gravatar image

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.

edit flag offensive delete link more


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?

galaxee gravatar image galaxee  ( 2020-12-09 16:08:12 -0500 )edit

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.

SmallJoeMan gravatar image SmallJoeMan  ( 2020-12-09 17:46:14 -0500 )edit

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

SmallJoeMan gravatar image SmallJoeMan  ( 2020-12-09 17:47:18 -0500 )edit

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.

galaxee gravatar image galaxee  ( 2020-12-09 18:49:19 -0500 )edit

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

galaxee gravatar image galaxee  ( 2020-12-09 19:04:33 -0500 )edit

Just tried it and it all locked up.

SmallJoeMan gravatar image SmallJoeMan  ( 2020-12-10 02:02:32 -0500 )edit

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

SmallJoeMan gravatar image SmallJoeMan  ( 2020-12-10 02:05:14 -0500 )edit

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.

jacobperron gravatar image jacobperron  ( 2020-12-18 13:25:31 -0500 )edit

Question Tools

1 follower


Asked: 2020-12-09 14:37:36 -0500

Seen: 772 times

Last updated: Dec 09 '20