Skip to content

Commit 8c55dcc

Browse files
authored
Prepared new structure of programming rcl and rclc tutorial. (#148)
* Prepared structure of 'Programming with rcl and rclc' tutorial for new content. Signed-off-by: Ralph Lange <ralph.lange@de.bosch.com> * Added intro to 'Programming with rcl and rclc' tutorial. * Added section on creating a node in 'Programming with rcl and rclc' tutorial. Signed-off-by: Ralph Lange <ralph.lange@de.bosch.com> * Improved intro of 'Programming with rcl and rclc' tutorial and added link to rclc repo. Signed-off-by: Ralph Lange <ralph.lange@de.bosch.com>
1 parent 6becd66 commit 8c55dcc

1 file changed

Lines changed: 46 additions & 1 deletion

File tree

  • _docs/tutorials/core/programming_rcl_rclc

‎_docs/tutorials/core/programming_rcl_rclc/index.md‎

Lines changed: 46 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,44 @@ title: Programming with rcl and rclc
33
permalink: /docs/tutorials/core/programming_rcl_rclc/
44
---
55

6-
## Programming client/service with rcl
6+
In this tutorial, you'll learn the basics of the micro-ROS C API. The major concepts (publishers, subscriptions, services,timers, ...) are identical with ROS 2. They even rely on the *same* implementation, as the micro-ROS C API is based on the ROS 2 client support library (rcl), enriched with a set of convenience functions by the package [rclc](https://github.com/micro-ROS/rclc/). That is, rclc does not add a new layer of types on top of rcl (like rclcpp and rclpy do) but only provides functions that ease the programming with the rcl types. New types are introduced only for concepts that are missing in rcl, such as the concept of an executor.
7+
8+
* [Creating a node](#node)
9+
* [Publishers and subscriptions](#pub_sub)
10+
* [Services](#services)
11+
* [Timers](#timers)
12+
* [Rclc Executor](#rclc_executor)
13+
14+
15+
## <a name="node"/>Creating a Node
16+
17+
To simplify the creation of a node with rcl, rclc provides two functions `rclc_support_init(..)` and `rclc_node_init_default(..)` in [rclc/init.h](https://github.com/micro-ROS/rclc/blob/master/rclc/include/rclc/init.h) and [rclc/node.h](https://github.com/micro-ROS/rclc/blob/master/rclc/include/rclc/node.h), respectively. The first lines of the main function of a micro-ROS programm are:
18+
19+
```c
20+
rcl_allocator_t allocator = rcl_get_default_allocator();
21+
rclc_support_t support;
22+
rcl_ret_t rc;
23+
24+
rc = rclc_support_init(&support, argc, argv, &allocator);
25+
if (rc != RCL_RET_OK) {
26+
... // Some error reporting.
27+
return -1;
28+
}
29+
30+
rcl_node_t my_node = rcl_get_zero_initialized_node();
31+
rc = rclc_node_init_default(&my_node, "my_node_name", "my_namespace", &support);
32+
if (rc != RCL_RET_OK) {
33+
... // Some error reporting.
34+
return -1;
35+
}
36+
```
37+
38+
39+
## <a name="pub_sub"/>Publishers and Subscriptions
40+
41+
42+
43+
## <a name="services"/>Services
744

845
ROS 2 services is another communication mechanism between nodes. Services implement a client-server paradigm based on ROS 2 messages and types. Further information about ROS 2 services can be found [here](https://index.ros.org/doc/ros2/Tutorials/Services/Understanding-ROS2-Services/)
946

@@ -120,3 +157,11 @@ while(1){
120157
}
121158
}
122159
```
160+
161+
162+
163+
## <a name="timers"/>Timers
164+
165+
166+
## <a name="rclc_executor"/>Rclc Executor
167+

0 commit comments

Comments
 (0)