Skip to content

Commit ecefa55

Browse files
committed
Update QoS and style
1 parent 43df4b9 commit ecefa55

7 files changed

Lines changed: 101 additions & 123 deletions

File tree

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22
title: Executor and timers
3-
permalink: /docs/tutorials/programming_rcl_rclc/micro-ROS/
3+
permalink: /docs/tutorials/programming_rcl_rclc/executor/
44
---
55

6-
// TODO: Use existing tutorial if possible
6+
// TODO: Use existing parts of previous tutorial if possible

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

Lines changed: 7 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -3,44 +3,31 @@ title: micro-ROS utilities
33
permalink: /docs/tutorials/programming_rcl_rclc/micro-ROS/
44
---
55

6-
## <a name="sub"/>micro-ROS features
6+
// TODO
77

8-
9-
- Custom transport
10-
rmw_ret_t rmw_uros_set_custom_transport(
11-
bool framing,
12-
void * args,
13-
open_custom_func open_cb,
14-
close_custom_func close_cb,
15-
write_custom_func write_cb,
16-
read_custom_func read_cb);
17-
18-
19-
- Time sync
8+
## <a name="sub"/>Time sync
209

2110
```C
22-
2311
bool rmw_uros_epoch_synchronized();
2412
int64_t rmw_uros_epoch_millis();
2513
int64_t rmw_uros_epoch_nanos();
2614
rmw_ret_t rmw_uros_sync_session(const int timeout_ms);
27-
2815
```
2916
30-
- Ping agent
17+
## <a name="sub"/>Ping agent
3118
19+
```C
3220
rmw_ret_t rmw_uros_ping_agent(const int timeout_ms, const uint8_t attempts);
33-
21+
```
3422

3523
- Init options ??
3624

3725
- Discovery ??
3826

3927
- Continous serialization ??
28+
-```C
4029
void rmw_uros_set_continous_serialization_callbacks(
4130
rmw_publisher_t * publisher,
4231
rmw_uros_continous_serialization_size size_cb,
4332
rmw_uros_continous_serialization serialization_cb);
44-
45-
46-
// Add publisher / service / client timeout here?
33+
```

_docs/tutorials/programming_rcl_rclc/node/node.md

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@ title: Nodes
33
permalink: /docs/tutorials/programming_rcl_rclc/node/
44
---
55

6-
ROS 2 nodes are the ground element on ROS2 ecosystem. They will contain 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 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)
77

8-
// TODO: explain general micro-ROS initialization (allocator and support)
8+
// TODO: explain general micro-ROS initialization (allocator and support). Where?
99
## <a name="init_node"/>Initialization
1010

1111
- Create a node with default configuration:
@@ -33,12 +33,9 @@ ROS 2 nodes are the ground element on ROS2 ecosystem. They will contain communic
3333
```
3434
3535
- Create a node with custom options:
36+
// TODO: explain possible options
3637
37-
Node configuration will also be applied to its future elements (Publishers, subscribers, services, ...).
38-
39-
// TODO: explain possible options and their meaning
40-
41-
The API used to customize the node options differs between ROS2 distributions:
38+
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:
4239
4340
Foxy: The `rcl_node_options_t` is used to configure the node
4441
@@ -67,7 +64,7 @@ ROS 2 nodes are the ground element on ROS2 ecosystem. They will contain communic
6764
return -1;
6865
}
6966
```
70-
67+
7168
Galactic: In this case, the node options are configured on the `rclc_support_t` object with a custom API
7269

7370
```C
@@ -101,14 +98,15 @@ ROS 2 nodes are the ground element on ROS2 ecosystem. They will contain communic
10198
10299
### <a name="node_end"/>Cleaning Up
103100
104-
To destroy a initialized node all entities owned by the node (Publishers, subscribers, services, ...) needs to be destroyed before the node itself:
101+
To destroy a initialized node all entities owned by the node (Publishers, subscribers, services, ...) have to be destroyed before the node itself:
105102
106103
```C
107-
// Destroy created entities
104+
// Destroy created entities (Example)
105+
rcl_publisher_fini(&publisher, &node);
108106
...
109107
110-
// Destroy a node
108+
// Destroy the node
111109
rcl_node_fini(&node);
112110
```
113111

114-
This will delete any automatically created infrastructure on the agent (if possible) and deallocate used memory on the client side.
112+
This will delete the node from ROS2 graph, including any generated infrastructure on the agent (if possible) and used memory on the client.

_docs/tutorials/programming_rcl_rclc/overview/index.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +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 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.
99

10-
* [**Node**](../node/)
10+
* [**Nodes**](../node/)
1111
* [**Publishers and Subscriptions**](../pub_sub/)
1212
* [**Services**](../service/)
1313
* [**Parameters**](../parameters/)

_docs/tutorials/programming_rcl_rclc/pub_sub/pub_sub.md

Lines changed: 33 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -5,17 +5,17 @@ permalink: /docs/tutorials/programming_rcl_rclc/pub_sub/
55

66
ROS 2 publishers and subscribers are the basic communication mechanism between nodes using topics. Further information about ROS 2 publish–subscribe pattern can be found [here](https://docs.ros.org/en/foxy/Tutorials/Topics/Understanding-ROS2-Topics.html).
77

8-
Ready to use code related to this tutorial can be found in [`micro-ROS-demos/rclc/int32_publisher`](https://github.com/micro-ROS/micro-ROS-demos/blob/foxy/rclc/int32_publisher/main.c) and [`micro-ROS-demos/rclc/int32_subscriber`](https://github.com/micro-ROS/micro-ROS-demos/blob/foxy/rclc/int32_subscriber/main.c) folders. Fragments of code from this examples are used on this tutorial.
8+
Ready to use code related to this concepts can be found in [`micro-ROS-demos/rclc/int32_publisher`](https://github.com/micro-ROS/micro-ROS-demos/blob/foxy/rclc/int32_publisher/main.c) and [`micro-ROS-demos/rclc/int32_subscriber`](https://github.com/micro-ROS/micro-ROS-demos/blob/foxy/rclc/int32_subscriber/main.c) folders. Fragments of code from this examples are used on this tutorial.
9+
10+
// TODO: add index?
911

1012
## <a name="pub"/>Publisher
1113

1214
### <a name="pub_init"/>Initialization
1315

1416
Starting from a code where RCL is initialized and a micro-ROS node is created, there are tree ways to initialize a publisher depending on the desired quality-of-service configuration:
1517

16-
// TODO: explain and link diferences between each approach on QoS section
17-
18-
- Reliable:
18+
- Reliable (default):
1919
```C
2020
// Publisher object
2121
rcl_publisher_t publisher;
@@ -27,28 +27,12 @@ Starting from a code where RCL is initialized and a micro-ROS node is created, t
2727
// Creates a reliable rcl publisher
2828
rcl_ret_t rc = rclc_publisher_init_default(&publisher, &node, &type_support, &topic_name);
2929

30-
if (RCL_RET_OK != rc) {
31-
... // Handle error
32-
return -1;
33-
}
34-
```
35-
36-
// TODO: move to micro-ROS features section?
37-
Reliable publishers will wait for confirmation for each published message, which leads to blocking `rcl_publish` calls, `rmw-microxrcedds` offers an API to configure the acknowledgement timeout for each publisher:
38-
39-
```C
40-
// Set confirmation timeout in milliseconds
41-
int ack_timeout = 1000;
42-
rc = rmw_uros_set_publisher_session_timeout(&publisher, ack_timeout);
43-
4430
if (RCL_RET_OK != rc) {
4531
... // Handle error
4632
return -1;
4733
}
4834
```
4935
50-
The default value for all publishers is configured at compilation time by the cmake variable `RMW_UXRCE_PUBLISH_RELIABLE_TIMEOUT`.
51-
5236
- Best effort:
5337
```C
5438
// Publisher object
@@ -66,7 +50,7 @@ Starting from a code where RCL is initialized and a micro-ROS node is created, t
6650
return -1;
6751
}
6852
```
69-
53+
7054
- Custom QoS:
7155

7256
```C
@@ -88,11 +72,13 @@ Starting from a code where RCL is initialized and a micro-ROS node is created, t
8872
return -1;
8973
}
9074
```
75+
76+
For a detail on the avaliable QoS options and the advantages and disadvantages between reliable and best effort modes, check the [QoS tutorial](../qos/).
9177
9278
## <a name="pub_publish"/>Publish a message
9379
94-
// TODO: explain message memory allocation and link to tutorial
95-
// TODO: explain periodic publication and link to timers
80+
To publish messages to the topic:
81+
9682
```C
9783
// Int32 message object
9884
std_msgs__msg__Int32 msg;
@@ -102,12 +88,15 @@ msg.data = 0;
10288
10389
// Publish message
10490
rcl_ret_t rc = rcl_publish(&publisher, &msg, NULL);
91+
10592
if (rc != RCL_RET_OK) {
10693
... // Handle error
10794
return -1;
10895
}
10996
```
11097

98+
For periodic publications, `rcl_publish` can be placed inside a timer callback. Check the [Executor and timers](../executor/) section for details.
99+
111100
Note: `rcl_publish` is thread safe and can be called from multiple threads.
112101

113102
## <a name="sub"/>Subscription
@@ -153,7 +142,7 @@ The suscriptor initialization is almost identical to the publisher one:
153142
}
154143
```
155144

156-
- Add QoS API
145+
- Custom QoS:
157146

158147
```C
159148
// Subscription object
@@ -175,8 +164,13 @@ The suscriptor initialization is almost identical to the publisher one:
175164
}
176165
```
177166
167+
For a detail on the avaliable QoS options and the advantages and disadvantages between reliable and best effort modes, check the [QoS tutorial](../qos/).
168+
178169
### <a name="sub_callback"/>Callbacks
170+
The executor is responsible to call the configured callback when a message is published.
171+
The function will have the message as its only argument, containing the values sended by the publisher:
179172
173+
// TODO: explain function prototype?
180174
```C
181175
void subscription_callback(const void * msgin)
182176
{
@@ -188,10 +182,11 @@ void subscription_callback(const void * msgin)
188182
}
189183
```
190184

191-
Once the subscriber and the executor are initialized, the subscriber callback must be added to the executor to receive incoming publications once the executor is spinning:
192185

186+
Once the subscriber and the executor are initialized, the subscriber callback must be added to the executor to receive incoming publications once its spinning:
187+
193188
```C
194-
// Message object to save publication data
189+
// Message object to receive publisher data
195190
std_msgs__msg__Int32 msg;
196191

197192
// Add subscription to the executor
@@ -200,19 +195,26 @@ rcl_ret_t rc = rclc_executor_add_subscription(&executor, &subscriber, &msg, &sub
200195
if (RCL_RET_OK != rc) {
201196
... // Handle error
202197
return -1;
203-
}
198+
199+
// Spin executor to receive messages
200+
rclc_executor_spin(&executor);
204201
```
205202
206-
### <a name="pubsub_end"/>Cleaning Up
203+
## <a name="pubsub_msg"/>Message initialization
204+
Before publishing or receiving a message, it may be neccesary to initialize its memory for types with strings or sequences.
205+
Check the [Handling messages memory in micro-ROS](../../advanced/handling_type_memory/) section for details.
207206
207+
## <a name="pubsub_end"/>Cleaning Up
208+
209+
After finishing the publisher/subscriber, the node will no longer be advertising that it is publishing/listening on the topic.
208210
To destroy an initialized publisher or subscriber:
209211
210212
```C
211-
// Destroy publisher and subscriber
213+
// Destroy publisher
212214
rcl_publisher_fini(&publisher, &node);
215+
216+
// Destroy subscriber
213217
rcl_subscription_fini(&subscriber, &node);
214218
```
215219

216-
After finishing the publisher/subscriber, the node will no longer be advertising that it is publishing/listening on the topic.
217-
218220
This will delete any automatically created infrastructure on the agent (if possible) and deallocate used memory on the client side.

_docs/tutorials/programming_rcl_rclc/qos/QoS.md

Lines changed: 35 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,43 @@ title: Quality of service
33
permalink: /docs/tutorials/programming_rcl_rclc/qos/
44
---
55

6-
## <a name="qos"/>QoS
6+
// Add benchmark results for Throughput and RTT to compare both modes?
7+
// Explain custom QoS options
8+
9+
## <a name="qos"/>Reliable QoS
710

8-
```C
11+
Reliable communication implies a confirmation for each message sended. This mode can detect errors in the communication process at the cost of increasing the message latency and the resources usage.
12+
13+
This message confirmation proccess can increase blocking time on `rcl_publish` or executor spin calls as reliable publishers, services and clients will wait for acknowledgement for each sended message. `rmw-microxrcedds` offers an API to individually configure the acknowledgement timeout on them:
14+
15+
```C
16+
// Confirmation timeout in milliseconds
17+
int ack_timeout = 1000;
18+
19+
// Set reliable publisher timeout
20+
rc = rmw_uros_set_publisher_session_timeout(&publisher, ack_timeout);
21+
22+
// Set reliable service server timeout
23+
rc = rmw_uros_set_service_session_timeout(&service, ack_timeout);
24+
25+
// Set reliable service client timeout
26+
rc = rmw_uros_set_client_session_timeout(&client, ack_timeout);
27+
28+
if (RCL_RET_OK != rc) {
29+
... // Handle error
30+
return -1;
31+
}
32+
```
33+
34+
The default value for all publishers is configured at compilation time by the cmake variable `RMW_UXRCE_PUBLISH_RELIABLE_TIMEOUT`.
935
36+
## <a name="qos"/>Best Effort
37+
38+
In best effort mode no acknowledgement is needed, the messages sended are expected to be received. This method improves publication throughput and reduces resources usage but is vulnerable to communication errors.
39+
40+
## <a name="qos"/>Custom QoS configuration
41+
42+
```C
1043
/// ROS MiddleWare quality of service profile.
1144
typedef struct RMW_PUBLIC_TYPE rmw_qos_profile_t
1245
{
@@ -27,19 +60,7 @@ typedef struct RMW_PUBLIC_TYPE rmw_qos_profile_t
2760
struct rmw_time_t liveliness_lease_duration;
2861
2962
/// If true, any ROS specific namespacing conventions will be circumvented.
30-
/**
31-
* In the case of DDS and topics, for example, this means the typical
32-
* ROS specific prefix of `rt` would not be applied as described here:
33-
*
34-
* http://design.ros2.org/articles/topic_and_service_names.html#ros-specific-namespace-prefix
35-
*
36-
* This might be useful when trying to directly connect a native DDS topic
37-
* with a ROS 2 topic.
38-
*/
3963
bool avoid_ros_namespace_conventions;
4064
} rmw_qos_profile_t;
4165
4266
```
43-
44-
45-
// TODO: explain difference between reliable and best effort

0 commit comments

Comments
 (0)