Embodied AI Glossary中文

ROS 2 Executor & Callback Groups

ROS 2 执行器与回调组Advanced

The ROS 2 machinery that decides which threads run callbacks, and whether they can run concurrently.

In a ROS 2 node, events from subscriptions, timers, and services all trigger callback functions, and the Executor is responsible for scheduling them: a single-threaded executor runs only one at a time, while a multi-threaded executor can run several in parallel. Callback groups further control which callbacks are allowed to run concurrently: callbacks in a mutually exclusive group never run at the same time, while those in a reentrant group can. This addresses real-time and deadlock concerns — for example, if a callback synchronously calls a service and waits for the result, and the service's response callback is blocked behind it on the same thread, the node can deadlock. Putting them in different callback groups and running a multi-threaded executor avoids this.

ExamplePut a control node's 100 Hz timer callback and its slower camera-image-processing callback in different callback groups and run them with a MultiThreadedExecutor, so the control loop isn't dragged down by image processing.

Also called
Executor, Callback Group, MultiThreadedExecutor
Related
Robot Operating System 2 · Node (ROS) · ROS Client Library (rclcpp / rclpy) · Composable Nodes (Components) & Intra-process Communication · Real-Time Control · Service (ROS)
Sources
ROS 2 Documentation: Executors
ROS 2 Documentation: Using Callback Groups

See it in the full glossary →