You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: _docs/concepts/client_library/execution_management/index.md
+55-8Lines changed: 55 additions & 8 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -90,13 +90,17 @@ The dispatching mechanism resembles the ROS 1 spin thread behavior: the Executor
90
90
91
91
The following diagram depicts the relevant classes of the standard ROS 2 Executor implementation:
92
92
93
-

93
+
<center>
94
+
<imgsrc="png/executor_class_diagram.png"alt="ROS 2 Executor class diagram"width="100%" />
95
+
</center>
94
96
95
97
Note that an Executor instance maintains weak pointers to the NodeBaseInterfaces of the nodes only. Therefore, nodes can be destroyed safely, without notifying the Executor.
96
98
97
99
Also, the Executor does not maintain an explicit callback queue, but relies on the queue mechanism of the underlying DDS implementation as illustrated in the following sequence diagram:
98
100
99
-

101
+
<center>
102
+
<imgsrc="png/executor_to_dds_sequence_diagram.png"alt="Call sequence from executor to DDS"width="100%" />
103
+
</center>
100
104
101
105
The Executor concept, however, does not provide means for prioritization or categorization of the incoming callback calls. Moreover, it does not leverage the real-time characteristics of the underlying operating-system scheduler to have finer control on the order of executions. The overall implication of this behavior is that time-critical callbacks could suffer possible deadline misses and a degraded performance since they are serviced later than non-critical callbacks. Additionally, due to the FIFO mechanism, it is difficult to determine usable bounds on the worst-case latency that each callback execution may incur.
102
106
@@ -118,13 +122,17 @@ In embedded systems, real-time behavior is approached by using the time-triggere
118
122
119
123
<center>
120
124
<imgsrc="png/scheduling_01.png"alt="Schedule with fixed periods"width="30%"/>
125
+
</center>
126
+
<center>
121
127
Figure 1: Fixed periodic preemptive scheduling.
122
128
</center>
123
129
124
130
To each process one or multiple tasks can be assigned, as shown in Figure 2. These tasks are executed sequentially, which is often called cooperative scheduling.
125
131
126
132
<center>
127
133
<imgsrc="png/scheduling_02.png"alt="Schedule with fixed periods"width="30%"/>
134
+
</center>
135
+
<center>
128
136
Figure 2: Processes with sequentially executed tasks.
129
137
</center>
130
138
@@ -137,6 +145,8 @@ However, data consistency is often an issue when preemptive scheduling is used a
137
145
138
146
<center>
139
147
<imgsrc="png/scheduling_LET.png"alt="Schedule with fixed periods"width="80%"/>
148
+
</center>
149
+
<center>
140
150
Figure 3: Data communication without and with Logical Execution Time paradigm.
141
151
</center>
142
152
@@ -166,6 +176,8 @@ A common design paradigm in mobile robotics is a control loop, consisting of sev
166
176
167
177
<center>
168
178
<imgsrc="png/sensePlanActScheme.png"alt="Sense Plan Act Pipeline"width="60%"/>
179
+
</center>
180
+
<center>
169
181
Figure 4: Multiple sensors driving a Sense-Plan-Act pipeline.
170
182
</center>
171
183
@@ -186,6 +198,8 @@ Often multiple sensors are being used to sense the environment for mobile roboti
186
198
187
199
<center>
188
200
<imgsrc="png/sensorFusion_01.png"alt="Sychronization of multiple rates"width="30%" />
201
+
</center>
202
+
<center>
189
203
Figure 5: How to deterministically process multi-frequent sensor data.
190
204
</center>
191
205
@@ -197,6 +211,8 @@ An Alternative would be to evalute the IMU sample and the laser scan by synchron
197
211
198
212
<center>
199
213
<imgsrc="png/sensorFusion_02.png"alt="Sychnronization with a trigger"width="40%" />
214
+
</center>
215
+
<center>
200
216
Figure 6: Synchronization of multiple input data with a trigger.
201
217
</center>
202
218
@@ -207,6 +223,8 @@ Another idea would be to activly request for IMU data only when a laser scan is
207
223
208
224
<center>
209
225
<imgsrc="png/sensorFusion_03.png"alt="Sychronization with sequence"width="30%" />
226
+
</center>
227
+
<center>
210
228
Figure 7: Synchronization with sequential processing.
211
229
</center>
212
230
@@ -221,6 +239,8 @@ Often a robot has to fullfill several activities at the same time. For example f
Figure 8: Managing high priority path with sequential order.
225
245
</center>
226
246
@@ -276,13 +296,22 @@ The rclc Executor supports all event types as the default ROS 2 Executor, which
276
296
277
297
Figure 9 shows three callbacks, A, B and C. Assume, they shall be executed in the order *B,A,C*. Then the user adds the callbacks to the rclc Executor in this order. Whenever new messages have arrived then the callbacks for which a new message is availabe will be always executed in the user-defined processing order.
- Given a set of handles, a trigger condition, which is based on the availability of input data of these handles, decides when the processing of all callbacks starts.
307
+
- Given a set of handles, a trigger condition, which is based on the availability of input data of these handles, decides when the processing of all callbacks starts. This is shown in Figure 10.
Figure 10 shows an example of the ALL semantics. Only if all messages *msg_A, msg_B, msg_C* were received, then trigger condition is fullfilled and the callbacks are processed in a user-defined order.
Figure 11 shows an example of the ANY semantics. Thas is, if any messages *msg_A, msg_B, msg_C* was received, then trigger condition is fullfilled and the callbacks are processed in a user-defined order. This is equivalent to OR semantics.
Figure 12 shows an example of the ONE semantics. Thas is, only if message *msg_B* was received, the trigger condition is fullfilled and (potentially all) callbacks are processed in a user-defined order.
Figure 13 describes the custom semantics. A custom trigger condition with could be a more complex logic of multiple messages, can be passed to the executor. This might also include hardware triggers, like interrupts.
@@ -561,7 +598,9 @@ Thus, an Executor instance can be dedicated to specific callback group(s) and th
561
598
562
599
The following figure illustrates this approach with two nodes served by three Callback-group-level Executors in one process:
563
600
564
-

601
+
<center>
602
+
<img src="png/cbg-executor_sample_system.png" alt="Sample system with two nodes and three Callback-group-level Executors in one process" width="60%" />
603
+
</center>
565
604
566
605
The different callbacks of the Drive-Base node are distributed to different Executors (visualized by the color red, yellow and green). For example the onCmdVel and publishWheelTicks callback are scheduled by the same Executor (yellow). Callbacks from different nodes can be serviced by the same Executor.
567
606
@@ -592,10 +631,16 @@ The callback-group-level executor has been merged into ROS 2 rclcpp in [pull req
592
631
593
632
As a proof of concept, we implemented a small test bench in the present package cbg-executor_ping-pong_cpp. The test bench comprises a Ping node and a Pong node which exchange real-time and best-effort messages simultaneously with each other. Each class of messages is handled with a dedicated Executor, as illustrated in the following figure.
594
633
595
-

634
+
<center>
635
+
<img src="png/ping_pong_diagram.png" alt="Architecture for the Callback-group-level Executor test bench" width="100%" />
636
+
</center>
637
+
596
638
With the test bench, we validated the functioning of the approach.
597
639
598
-

640
+
<center>
641
+
<img src="png/cbg_executor_demo_plot.png" alt="Results from Callback-group-level Executor test bench" width="80%" />
642
+
</center>
643
+
599
644
In this example, the callback for the high priority task (red line) consumes 10ms and the low priority task (blue line) 40ms in the Pong Node. With a ping rate of 20 Hz, the CPU saturates (10ms\*20+40ms\*20=1000ms). With higher frequencies the high priorty task can continue to send its pong message, while the low priority pong task degrades. With a frequency of 100Hz the high priority task requires 100% CPU utilization. With higher ping rates it keeps sending pong messages with 100Hz, while the low priority task does not get any CPU ressources any more and cannot send any messages.
600
645
601
646
The test bench is provided in the [cbg_executor_demo](https://github.com/boschresearch/ros2_demos/tree/cbg_executor_demo/cbg_executor_demo).
@@ -647,7 +692,9 @@ A module (thread) can be configured independent of these sense-plan-act synchron
647
692
648
693
The high level overview of the Fawkes framework is shown in the next figure. At compile-time the configuration of the sense-plan act wakeup hook is done (upper part), while at run-time the scheduler iterates through this list of wakeup-hooks (lower part):
649
694
650
-

695
+
<center>
696
+
<img src="png/fawkes_executor_diagram.png" alt="Sequence diagram for Fawkes Executor" width="50%" />
697
+
</center>
651
698
652
699
Hence, at run-time, the hooks are executed as a fixed static schedule without preemption. Multiple threads registered in the same hook are executed in parallel.
0 commit comments