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
{{ message }}
Repository navigation
Commit f2c7253
Browse filesBrowse the repository at this point in the historyBrowse files
The rclc-package is a [ROS 2](http://www.ros2.org/) package, which provides convenience functions to create ROS Client Library(RCL) data types and an RCLC-Executor to manage the execution for applications written in the C programming language. A complete documentation of the API and examples can be found [rclc package](https://github.com/ros2/rclc/tree/master/rclc) and [rclc example package](https://github.com/ros2/rclc/tree/master/rclc_examples), respectivly.
219
-
The convenience functions can be used to create RCL objects, like publishers, subscribers, timers and nodes in a simplified API: The convenience functions, aka the rclc-package does not introduce any additional types but uses the data types of RCL only.
220
-
The rclc Executor provides an API to configure the communication objects like subscriptions and timers and a defined semantics to execute corresponding callbacks, like the rclcpp Executor for C++.
221
-
As described in [CB2019](#CB2019), it is difficult to reason about end-to-end latencies because of the complex semantics of the rclcpp Executor.
222
-
Therefore, the RCLC Executor provides a number of features for deterministic and real-time execution.
218
+
The rclc Executor provides an C-API to manage the execution of communication objects, like subscriptions and timers, like the rclcpp Executor for C++.
219
+
Due to the complex semantics of the rclcpp Executor, it is difficult to reason about end-to-end latencies and to give real-time guarantees.
220
+
To resolve these issues, the rclc Executor provides additional features for deterministic execution.
221
+
222
+
### Minimal setup
223
+
This example demonstrates a minimal setup of the rclc Executor.
224
+
225
+
First, you include the header files [rclc/rclc.h](https://github.com/micro-ROS/rclc/blob/master/rclc/include/rclc/rclc.h). and [rclc/executor.h](https://github.com/micro-ROS/rclc/blob/master/rclc/include/rclc/executor.h).. After defining the `executor` you need to call the function `rclc_executor_get_zero_initialized_executor()` which returns a properly zero-initialized executor object.
In the next step, executor is initialized with the RCL `context`, the number of communication objects `num_handles` and an `allocator`. The number of communication objects defines the total number of times and subscriptions, the executor shall manage. In this example, the executor will be setup with one timer and one subscription.
236
+
237
+
The `context` can be created with the convenience function `rclc_support_init()`, which creates a `support` variable of the type `rclc_support_t`, containing also other rcl objects necessary for the executor. To dynamically create memory, the `rclc_support_init()` function also needs an `allocator`, which is defined first.
To add a subscription the function `rclc_c_executor_add_subscription` is used. Assuming you have created a susbscription `my_sub` with its message `sub_msg`and its callback `my_subscriber_callback`, the code looks like this:
258
+
259
+
continue Here
260
+
261
+
and a timer `my_timer`, as described above, the following code snippet shows the configuration for the executor:
A key feature of the rclc-Executor is, that the order of these functions to add handles matters. It defines the processing order when multiple messages have arrived or timers are ready. This provides full control over the execution order to the user.
290
+
291
+
There are are several functions, how to start the executor, one is `rclc_executor_spin_some(...)`, which allows the user to specify a timeout in nanoseconds.
292
+
293
+
Finally the code snippet shows how to destroy the objects for the node, publisher, subscriber and the executor with the respective fini-methods.
The rclc Executor is a ROS 2 Executor implemented based on and for the rcl API, for applications written in the C language.
@@ -366,73 +463,6 @@ The function `rlce_executor_fini` frees the dynamically allocated memory of the
366
463
367
464
We provide the relevant code snippets how to setup the rclc Executor for typical software design patterns in mobile robotics applications and for real-time embedded use-cases.
368
465
369
-
#### Minimal example of rclc Executor
370
-
This example demonstrates a minimal setup of the rclc Executor.
371
-
The Executor is configured and setup with the functions
372
-
`rclc_executor_get_zero_initialized_executor(..)`, `rclc_executor_set_timeout(..)`, `rclc_executor_add_subscription(...)`, `rclc_executor_add_timer(...)`, `rclc_executor_spin_some(...)` and `rclc_executor_fini(...)` in [rclc/executor.h](https://github.com/micro-ROS/rclc/blob/master/rclc/include/rclc/executor.h).
373
-
374
-
Assuming that you have created a subscription and a timer, as described above, the following code snippet shows the configuration of the RCLC-executor.
375
-
376
-
The executor is configured with 2 handles, aka one subscription and one timer. The `support.context` is the ROS 2 context, as shown above with `rclc_support_init(...)`.
377
-
378
-
The timeout is the waiting time for new handles to get ready, for example new messages arrive or timers are ready. The unit of the timeout is milliseconds.
379
-
380
-
A subscription `my_sub`, a place-holder for it's message `sub_msg` and it's corresponding callback `my_subscriber_callback` is added to the executor with the function `rclc_executor_add_subscription(...)`
381
-
382
-
A timers is added to the executor with the function `rclc_executor_add_timer(...)`
383
-
384
-
A key feature of the rclc-Executor is, that the order of these functions to add handles matters. It defines the processing order when multiple messages have arrived or timers are ready. This provides full control over the execution order to the user.
385
-
386
-
There are are several functions, how to start the executor, one is `rclc_executor_spin_some(...)`, which allows the user to specify a timeout in nanoseconds.
387
-
388
-
Finally the code snippet shows how to destroy the objects for the node, publisher, subscriber and the executor with the respective fini-methods.
389
-
390
-
```c
391
-
rclc_executor_t executor;
392
-
393
-
// compute total number of subsribers and timers
394
-
unsignedint num_handles = 1 + 1;
395
-
printf("Debug: number of DDS handles: %u\n", num_handles);
#### Example sense-plan-act pipeline in mobile robotics
437
467
438
468
A common design paradigm in mobile robotics is a control loop, consisting of several phases: A sensing phase to aquire sensor data, a plan phase for localization and path planning and an actuation-phase to steer the mobile robot.
0 commit comments