Skip to content

Commit 2d0700d

Browse files
JanStaschulatralph-lange
authored andcommitted
Changes as discussed regarding concept of ROS 2 Executor
Signed-off-by: Staschulat Jan (CR/AEX3) <jan.staschulat@de.bosch.com>
1 parent 87076ea commit 2d0700d

1 file changed

Lines changed: 12 additions & 11 deletions

File tree

  • _docs/concepts/client_library/real-time_executor

‎_docs/concepts/client_library/real-time_executor/index.md‎

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,7 @@ permalink: /docs/concepts/client_library/real-time_executor/
99

1010
* [Introduction](#introduction)
1111

12-
* [ROS 2 Executor](#ros-2-executor)
13-
* [Concept](#concept)
12+
* [Analysis of rclcpp standard Executor](#analysis-of-rclcpp-standard-executor)
1413
* [Architecture](#architecture)
1514
* [Scheduling Semantics](#scheduling-semantics)
1615

@@ -42,8 +41,11 @@ Therefore the goal of the Real-Time Executor is to support roboticists with prac
4241
- Integration of real-time and non real-time functionalities on one platform
4342
- Specific support for RTOS and microcontrollers
4443

45-
The challenges to achieve these goals are:
46-
- to develop an adequate and well-defined scheduling mechanisms for the ROS framework and the operating system (RTOS)
44+
45+
In ROS 1 a network thread is responsible for receiving all messages and putting them into a FIFO queue (in roscpp). That is, all callbacks were called in a FIFO manner, without any execution management. With the introduction of DDS (data distribution service) in ROS 2, the messages are buffered in DDS. In ROS 2, an Executor concept was introduced to support execution management, like priorization. At the rcl-layer, a _wait-set_ is configured with the messages to be received and in a second step, the messages are taken from the DDS-queue. The standard implementation of the ROS 2 Executor for the C++ API (rclcpp) has, however, certain unusual features, like precedence of timers over all other DDS messages, non-preemptive round-robin scheduling for subscriptions, clients and services and considering only one instance of message type (even if multiple are available). These features have the consequence, that in certain situations the standard rclcpp Executor is not deterministic and it makes proving real-time guarantees hard. We have not looked at the Executor implementation for Python (rclpy) because we have micro-controllers as the platform in mind, on which typically C or C++ appliations will run.
46+
47+
The challenges to achieve the afore-mentioned goals for ROS 2 are:
48+
- to develop an adequate and well-defined scheduling mechanisms for the ROS 2 framework and the real-time operating system (RTOS)
4749
- to define an easy-to-use interface for ROS-developers
4850
- to model requirements (like latencies, determinism in subsystems)
4951
- mapping of ROS framework and OS scheduler (semi-automated and optimized mapping is desired as well as generic, well-understood framework mechanisms)
@@ -52,9 +54,8 @@ Our approach is to provide a real-time Executor on two layers as described in se
5254

5355
As the first step, we propose the LET-Executor, which implements static order scheduling policy with logic execution time semantics. In this scheduling policy, all callbacks are executed in a pre-defined order. Logical execution time refers to the concept, that first input data is read before tasks are executed. Secondly, we developed a Callback-group-level Executor, which allows to prioritize a group of callbacks. These approaches are based on the concept of Executors, which have been introduced in ROS 2.
5456

55-
## ROS 2 Executor
5657

57-
### Concept
58+
## Analysis of rclcpp standard Executor
5859

5960
ROS 2 allows to bundle multiple nodes in one operating system process. To coordinate the execution of the callbacks of the nodes of a process, the Executor concept was introduced in rclcpp (and also in rclpy).
6061

@@ -80,9 +81,9 @@ The Executor concept, however, does not provide means for prioritization or cate
8081

8182
In a recent paper [CB2019](#CB2019), the rclcpp Executor has been analyzed in detail and a response time analysis of cause-effect chains has been proposed under reservation-based scheduling. The Executor distinguishes four categories of callbacks: _timers_, which are triggered by system-level timers, _subscribers_, which are triggered by new messages on a subscribed topic, _services_, which are triggered by service requests, and _clients_, which are triggered by responses to service requests. The Executor is responsible for taking messages from the input queues of the DDS layer and executing the corresponding callback. Since it executes callbacks to completion, it is a non-preemptive scheduler, However it does not consider all ready tasks for execution, but only a snapshot, called readySet. This readySet is updated when the Executor is idle and in this step it interacts with the DDS layer updating the set of ready tasks. Then for every type of task, there are dedicated queues (timers, subscriptions, services, clients) which are processed sequentially. The following undesired properties were pointed out:
8283

83-
* The Executor processes _timers_ always first. This can lead to the intrinsic effect, that in overload situations messages from the DDS queue are not processed.
84-
* Messages arriving during the processing of the readySet are not considered until the next update, which depends on the execution time of all remaining callbacks. This leads to priority inversion, as lower-priority callbacks may implicitly block higher-priority callbacks by prolonging the current processing of the readySet.
85-
* The readySet contains only one task instance, For example, even if multiple messages of the same topic are available, only one instance is processed until the Executor is idle again and the readySet is updated from the DDS layer. This aggravates priority inversion, as a backlogged callback might have to wait for multiple processing of readySets until it is considered for scheduling. This means that non-timer callback instances might be blocked by multiple instances of the same lower-priority callback.
84+
* Timers have the highest priority. The Executor processes _timers_ always first. This can lead to the intrinsic effect, that in overload situations messages from the DDS queue are not processed.
85+
* Non-preemptive round-robin scheduling of non-timer handles. Messages arriving during the processing of the readySet are not considered until the next update, which depends on the execution time of all remaining callbacks. This leads to priority inversion, as lower-priority callbacks may implicitly block higher-priority callbacks by prolonging the current processing of the readySet.
86+
* Only one message per handle is considered. The readySet contains only one task instance, For example, even if multiple messages of the same topic are available, only one instance is processed until the Executor is idle again and the readySet is updated from the DDS layer. This aggravates priority inversion, as a backlogged callback might have to wait for multiple processing of readySets until it is considered for scheduling. This means that non-timer callback instances might be blocked by multiple instances of the same lower-priority callback.
8687

8788
Due to these findings, the authors present an alternative approach to provide determinism and to apply well-known schedulability analyses to a ROS 2 systems. A response time analysis is described under reservation-based scheduling.
8889

@@ -96,9 +97,9 @@ The LET-Executor consists of tho phases, configuration and running phase. First,
9697

9798
### Example
9899

99-
We provide an example for using the LET-Executor. First, the callbacks for a subscription and a timer need to be defined. Then the ROS context and the ROS node are defined as well as the subscription and timer.
100+
We provide an example for using the LET-Executor. First, the callbacks _my\_sub\_cb_ and my_timer\_cb_ are defined for a subscription and a timer, respectivly. Then, the ROS _context_ and the ROS _node_ are defined as well as the subscription object _sub_ and the timer object _timer_.
100101

101-
The Executor is initialized with two handles. Then, the _add_ functions define the static execution order of the handles. In this example, the subscription shall be processed before the timer. Finally, the Executor is started with the _spin\_period_ function, which is continuously called every 20 ms.
102+
The Executor is initialized with two handles. Then, the _add_ functions define the static execution order of the handles. In this example, the subscription _sub_ shall be processed before the timer _timer_. Finally, the Executor is activated with the _spin\_period_ function, which is continuously called every 20 ms.
102103
```C
103104
#include "rcl_executor/let_executor.h"
104105

0 commit comments

Comments
 (0)