Skip to content

Commit 0550bb0

Browse files
committed
Minor updates
1 parent 6bde2f5 commit 0550bb0

7 files changed

Lines changed: 232 additions & 148 deletions

File tree

_docs/tutorials/programming_rcl_rclc/micro-ROS/micro-ROS.md

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,18 +5,21 @@ permalink: /docs/tutorials/programming_rcl_rclc/micro-ROS/
55

66
// TODO
77

8-
## <a name="sub"/>Time sync
8+
- [Time sync](#time-sync)
9+
- [Ping agent](#ping-agent)
910

10-
```C
11+
## Time sync
12+
13+
```c
1114
bool rmw_uros_epoch_synchronized();
1215
int64_t rmw_uros_epoch_millis();
1316
int64_t rmw_uros_epoch_nanos();
1417
rmw_ret_t rmw_uros_sync_session(const int timeout_ms);
1518
```
1619
17-
## <a name="sub"/>Ping agent
20+
## Ping agent
1821
19-
```C
22+
```c
2023
rmw_ret_t rmw_uros_ping_agent(const int timeout_ms, const uint8_t attempts);
2124
```
2225

@@ -25,7 +28,7 @@ rmw_ret_t rmw_uros_ping_agent(const int timeout_ms, const uint8_t attempts);
2528
- Discovery ??
2629

2730
- Continous serialization ??
28-
-```C
31+
-```c
2932
void rmw_uros_set_continous_serialization_callbacks(
3033
rmw_publisher_t * publisher,
3134
rmw_uros_continous_serialization_size size_cb,

_docs/tutorials/programming_rcl_rclc/node/node.md

Lines changed: 21 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,17 @@ title: Nodes
33
permalink: /docs/tutorials/programming_rcl_rclc/node/
44
---
55

6-
ROS 2 nodes are the main participants on ROS2 ecosystem. They will communicate between each other using publishers, subscriptions, services, ... Further information about ROS 2 nodes can be found [here](https://docs.ros.org/en/galactic/Tutorials/Understanding-ROS2-Nodes.html)
6+
ROS 2 nodes are the main participants on ROS 2 ecosystem. They will communicate between each other using publishers, subscriptions, services, etc. Further information about ROS 2 nodes can be found [here](https://docs.ros.org/en/galactic/Tutorials/Understanding-ROS2-Nodes.html)
77

88
// TODO: explain general micro-ROS initialization (allocator and support). Where?
9-
## <a name="init_node"/>Initialization
9+
10+
- [Initialization](#initialization)
11+
- [Cleaning Up](#cleaning-up)
12+
13+
## Initialization
1014

1115
- Create a node with default configuration:
12-
```C
16+
```c
1317
// Initialize micro-ROS allocator
1418
rcl_allocator_t allocator = rcl_get_default_allocator();
1519

@@ -33,13 +37,14 @@ ROS 2 nodes are the main participants on ROS2 ecosystem. They will communicate b
3337
```
3438
3539
- Create a node with custom options:
40+
3641
// TODO: explain possible options
3742
3843
The configuration of the node will also be applied to its future elements (Publishers, subscribers, services, ...).The API used to customize the node options differs between ROS2 distributions:
3944
4045
Foxy: The `rcl_node_options_t` is used to configure the node
4146
42-
```C
47+
```c
4348
// Initialize allocator and support objects
4449
...
4550
@@ -51,37 +56,37 @@ ROS 2 nodes are the main participants on ROS2 ecosystem. They will communicate b
5156
const char * namespace = "test_namespace";
5257
5358
// Get default node options and modify them
54-
rcl_node_options_t node_ops = rcl_node_get_default_options();
59+
rcl_node_options_t node_ops = rcl_node_get_default_options();
5560
5661
// Set node ROS domain ID to 10
57-
node_ops.domain_id = (size_t)(10);
62+
node_ops.domain_id = (size_t)(10);
5863
5964
// Init node with custom options
60-
rc = rclc_node_init_with_options(&node, node_name, namespace, &support, &node_ops);
65+
rc = rclc_node_init_with_options(&node, node_name, namespace, &support, &node_ops);
6166
6267
if (rc != RCL_RET_OK) {
6368
... // Handle error
6469
return -1;
6570
}
6671
```
67-
72+
6873
Galactic: In this case, the node options are configured on the `rclc_support_t` object with a custom API
6974

70-
```C
75+
```c
7176
// Initialize micro-ROS allocator
7277
rcl_allocator_t allocator = rcl_get_default_allocator();
7378

7479
// Initialize and modify options (Set DOMAIN ID to 10)
75-
rcl_init_options_t init_options = rcl_get_zero_initialized_init_options();
76-
rcl_init_options_init(&init_options, allocator);
77-
rcl_init_options_set_domain_id(&init_options, 10);
80+
rcl_init_options_t init_options = rcl_get_zero_initialized_init_options();
81+
rcl_init_options_init(&init_options, allocator);
82+
rcl_init_options_set_domain_id(&init_options, 10);
7883

7984
// Initialize rclc support object with custom options
8085
rclc_support_t support;
81-
rclc_support_init_with_options(&support, 0, NULL, &init_options, &allocator);
86+
rclc_support_init_with_options(&support, 0, NULL, &init_options, &allocator);
8287

8388
// Create node object
84-
rcl_node_t node;
89+
rcl_node_t node;
8590
const char * node_name = "test_node";
8691

8792
// Node namespace (Can remain empty "")
@@ -96,11 +101,11 @@ ROS 2 nodes are the main participants on ROS2 ecosystem. They will communicate b
96101
}
97102
```
98103
99-
### <a name="node_end"/>Cleaning Up
104+
### Cleaning Up
100105
101106
To destroy a initialized node all entities owned by the node (Publishers, subscribers, services, ...) have to be destroyed before the node itself:
102107
103-
```C
108+
```c
104109
// Destroy created entities (Example)
105110
rcl_publisher_fini(&publisher, &node);
106111
...

_docs/tutorials/programming_rcl_rclc/overview/index.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,9 @@ redirect_from:
55
- /docs/tutorials/programming_rcl_rclc/
66
---
77

8-
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/ros2/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.
8+
In this section, you'll learn the basics of the micro-ROS C API: **rclc**.
9+
10+
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/ros2/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.
911

1012
* [**Nodes**](../node/)
1113
* [**Publishers and Subscriptions**](../pub_sub/)

_docs/tutorials/programming_rcl_rclc/parameters/parameters.md

Lines changed: 29 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,16 @@ Ready to use code related to this tutorial can be found in [`rclc/rclc_examples/
99

1010
Note: micro-ROS parameter server is only supported on ROS2 galactic distribution
1111

12-
## <a name="parameters_init"/>Initialization
12+
- [Initialization](#initialization)
13+
- [Memory requirements](#memory-requirements)
14+
- [Callback](#callback)
15+
- [Add a parameter](#add-a-parameter)
16+
- [Cleaning up](#cleaning-up)
17+
18+
## Initialization
1319

1420
- Default initialization:
15-
```C
21+
```c
1622
// Parameter server object
1723
rclc_parameter_server_t param_server;
1824

@@ -27,12 +33,14 @@ Note: micro-ROS parameter server is only supported on ROS2 galactic distribution
2733

2834
// TODO: explain options
2935
- Custom options:
30-
```C
36+
```c
3137
// Parameter server object
3238
rclc_parameter_server_t param_server;
3339

3440
// Define parameter server options
35-
const rclc_parameter_options_t options = { .notify_changed_over_dds = true, .max_params = 4 };
41+
const rclc_parameter_options_t options = {
42+
.notify_changed_over_dds = true,
43+
.max_params = 4 };
3644

3745
// Initialize parameter server with configured options
3846
rcl_ret_t rc = rclc_parameter_server_init_with_option(&param_server, &node, &options);
@@ -43,10 +51,10 @@ Note: micro-ROS parameter server is only supported on ROS2 galactic distribution
4351
}
4452
```
4553

46-
## <a name="parameters_init"/>Memory requirements
54+
## Memory requirements
4755
The parameter server uses 4 services and an optional publisher, this needs to be taken into account on the `rmw-microxredds` package memory configuration:
4856

49-
```C
57+
```json
5058
# colcon.meta example with memory requirements to use a parameter server
5159
{
5260
"names": {
@@ -65,19 +73,21 @@ The parameter server uses 4 services and an optional publisher, this needs to be
6573

6674
On runtime, the variable `RCLC_PARAMETER_EXECUTOR_HANDLES_NUMBER` defines the RCLC executor handles required for a parameter server:
6775

68-
```C
76+
```c
6977
// Executor init example with the minimum RCLC executor handles required
7078
rclc_executor_t executor = rclc_executor_get_zero_initialized_executor();
71-
rc = rclc_executor_init(&executor, &support.context, RCLC_PARAMETER_EXECUTOR_HANDLES_NUMBER, &allocator);
79+
rc = rclc_executor_init(
80+
&executor, &support.context,
81+
RCLC_PARAMETER_EXECUTOR_HANDLES_NUMBER, &allocator);
7282
```
73-
74-
## <a name="parameters_callback"/>Callback
83+
84+
## Callback
7585

7686
When adding the parameter server to the executor, a callback can be configured.
7787
This callback will be executed after a parameter value is modified.
7888

7989
A pointer to the changed parameter is passed as first and only argument. Example:
80-
```C
90+
```c
8191
void on_parameter_changed(Parameter * param)
8292
{
8393
// Get parameter name
@@ -104,24 +114,24 @@ void on_parameter_changed(Parameter * param)
104114
}
105115
```
106116
Once the parameter server and the executor are initialized, the parameter server must be added to the executor in order to accept parameters commands from ROS2:
107-
```C
117+
```c
108118
// Add parameter server to executor including defined callback
109119
rc = rclc_executor_add_parameter_server(&executor, &param_server, on_parameter_changed);
110120
```
111121

112122
Note that this callback is optional as its just an event information for the user. To use the parameter server without a callback:
113-
```C
123+
```c
114124
// Add parameter server to executor without callback
115125
rc = rclc_executor_add_parameter_server(&executor, &param_server, NULL);
116126
```
117127

118128

119-
## <a name="parameters_add"/>Add a parameter
129+
## Add a parameter
120130

121131
// TODO: improve explanation of types
122132

123133
- Bool parameter
124-
```C
134+
```c
125135
const char * parameter_name = "parameter_bool";
126136
bool param_value = true;
127137

@@ -141,7 +151,7 @@ if (RCL_RET_OK != rc) {
141151
```
142152

143153
- Integer parameter
144-
```C
154+
```c
145155
const char * parameter_name = "parameter_int";
146156
int param_value = 100;
147157

@@ -156,7 +166,7 @@ rc = rclc_parameter_get_int(&param_server, parameter_name, &param_value);
156166
```
157167

158168
- Double parameter
159-
```C
169+
```c
160170
const char * parameter_name = "parameter_double";
161171
double param_value = 0.15;
162172

@@ -170,11 +180,11 @@ rc = rclc_parameter_set_double(&param_server, parameter_name, param_value);
170180
rc = rclc_parameter_get_double(&param_server, parameter_name, &param_value);
171181
```
172182

173-
## <a name="parameters_end"/>Cleaning up
183+
## Cleaning up
174184

175185
To destroy an initialized parameter server:
176186

177-
```C
187+
```c
178188
// Delete parameter server
179189
rclc_parameter_server_fini(&param_server, &node);
180190
```

0 commit comments

Comments
 (0)