From bae8329268d88694df87f51517ce0981758eb31c Mon Sep 17 00:00:00 2001 From: Ralph Lange Date: Fri, 10 Sep 2021 11:40:01 +0200 Subject: [PATCH 1/5] Moved Programming with rcl and rclc tutorial section before Advanced tutorials. Signed-off-by: Ralph Lange --- _data/docs.yml | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/_data/docs.yml b/_data/docs.yml index 91133c78..d0798f88 100644 --- a/_data/docs.yml +++ b/_data/docs.yml @@ -53,6 +53,17 @@ - tutorials/core/zephyr_emulator - tutorials/core/teensy_with_arduino +- title: Programming with rcl and rclc + docs: + - tutorials/programming_rcl_rclc/overview + - tutorials/programming_rcl_rclc/node + - tutorials/programming_rcl_rclc/pub_sub + - tutorials/programming_rcl_rclc/service + - tutorials/programming_rcl_rclc/parameters + - tutorials/programming_rcl_rclc/executor + - tutorials/programming_rcl_rclc/qos + - tutorials/programming_rcl_rclc/micro-ROS + - title: Advanced Tutorials docs: - tutorials/advanced/overview @@ -65,17 +76,6 @@ - tutorials/advanced/benchmarking - tutorials/advanced/tracing -- title: Programming with rcl and rclc - docs: - - tutorials/programming_rcl_rclc/overview - - tutorials/programming_rcl_rclc/node - - tutorials/programming_rcl_rclc/pub_sub - - tutorials/programming_rcl_rclc/service - - tutorials/programming_rcl_rclc/parameters - - tutorials/programming_rcl_rclc/executor - - tutorials/programming_rcl_rclc/qos - - tutorials/programming_rcl_rclc/micro-ROS - - title: Unmaintained Tutorials docs: - tutorials/old/microros_nuttx_bsp From c306f5fd7b0ab1ddd56391670693a810b843cb5f Mon Sep 17 00:00:00 2001 From: Ralph Lange Date: Fri, 10 Sep 2021 11:41:29 +0200 Subject: [PATCH 2/5] Added badges for distro status to individual programming with rcl and rclc tutorials. Signed-off-by: Ralph Lange --- _docs/tutorials/programming_rcl_rclc/executor/executor.md | 2 ++ _docs/tutorials/programming_rcl_rclc/micro-ROS/micro-ROS.md | 4 +++- _docs/tutorials/programming_rcl_rclc/node/node.md | 2 ++ _docs/tutorials/programming_rcl_rclc/overview/index.md | 6 ++---- .../tutorials/programming_rcl_rclc/parameters/parameters.md | 2 ++ _docs/tutorials/programming_rcl_rclc/pub_sub/pub_sub.md | 4 +++- _docs/tutorials/programming_rcl_rclc/qos/QoS.md | 2 ++ _docs/tutorials/programming_rcl_rclc/service/services.md | 2 ++ 8 files changed, 18 insertions(+), 6 deletions(-) diff --git a/_docs/tutorials/programming_rcl_rclc/executor/executor.md b/_docs/tutorials/programming_rcl_rclc/executor/executor.md index 6978e8fd..dbc6f343 100644 --- a/_docs/tutorials/programming_rcl_rclc/executor/executor.md +++ b/_docs/tutorials/programming_rcl_rclc/executor/executor.md @@ -3,6 +3,8 @@ title: Executor and timers permalink: /docs/tutorials/programming_rcl_rclc/executor/ --- + + - [Timers](#timers) - [Initialization](#initialization) - [Callback](#callback) diff --git a/_docs/tutorials/programming_rcl_rclc/micro-ROS/micro-ROS.md b/_docs/tutorials/programming_rcl_rclc/micro-ROS/micro-ROS.md index baa8b148..8005eb2b 100644 --- a/_docs/tutorials/programming_rcl_rclc/micro-ROS/micro-ROS.md +++ b/_docs/tutorials/programming_rcl_rclc/micro-ROS/micro-ROS.md @@ -3,8 +3,10 @@ title: micro-ROS utilities permalink: /docs/tutorials/programming_rcl_rclc/micro-ROS/ --- -// TODO: Change section name + + + - [Allocators](#allocators) - [Custom allocator](#custom-allocator) - [Time sync](#time-sync) diff --git a/_docs/tutorials/programming_rcl_rclc/node/node.md b/_docs/tutorials/programming_rcl_rclc/node/node.md index 00a4fe40..86549473 100644 --- a/_docs/tutorials/programming_rcl_rclc/node/node.md +++ b/_docs/tutorials/programming_rcl_rclc/node/node.md @@ -3,6 +3,8 @@ title: Nodes permalink: /docs/tutorials/programming_rcl_rclc/node/ --- + + 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) diff --git a/_docs/tutorials/programming_rcl_rclc/overview/index.md b/_docs/tutorials/programming_rcl_rclc/overview/index.md index 14e2f987..838d69ec 100644 --- a/_docs/tutorials/programming_rcl_rclc/overview/index.md +++ b/_docs/tutorials/programming_rcl_rclc/overview/index.md @@ -5,8 +5,6 @@ redirect_from: - /docs/tutorials/programming_rcl_rclc/ --- - - In this section, you'll learn the basics of the micro-ROS C API: **rclc**. 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. @@ -16,5 +14,5 @@ The major concepts (publishers, subscriptions, services, timers, ...) are identi * [**Services**](../service/) * [**Parameters**](../parameters/) * [**Executor and timers**](../executor/) -* [**QoS**](../qos/) -* [**micro-ROS Utils**](../micro-ROS/) +* [**Quality of service**](../qos/) +* [**micro-ROS utilities**](../micro-ROS/) diff --git a/_docs/tutorials/programming_rcl_rclc/parameters/parameters.md b/_docs/tutorials/programming_rcl_rclc/parameters/parameters.md index 18438a2e..48a2a49b 100644 --- a/_docs/tutorials/programming_rcl_rclc/parameters/parameters.md +++ b/_docs/tutorials/programming_rcl_rclc/parameters/parameters.md @@ -3,6 +3,8 @@ title: Parameter server permalink: /docs/tutorials/programming_rcl_rclc/parameters/ --- + + ROS 2 parameters allow the user to create variables on a node and manipulate/read them with different ROS2 commands. Further information about ROS 2 parameters can be found [here](https://docs.ros.org/en/galactic/Tutorials/Parameters/Understanding-ROS2-Parameters.html) Ready to use code related to this tutorial can be found in [`rclc/rclc_examples/src/example_parameter_server.c`](https://github.com/ros2/rclc/blob/master/rclc_examples/src/example_parameter_server.c). Fragments of code from this example is used on this tutorial. diff --git a/_docs/tutorials/programming_rcl_rclc/pub_sub/pub_sub.md b/_docs/tutorials/programming_rcl_rclc/pub_sub/pub_sub.md index e7348ef4..a2691d5f 100644 --- a/_docs/tutorials/programming_rcl_rclc/pub_sub/pub_sub.md +++ b/_docs/tutorials/programming_rcl_rclc/pub_sub/pub_sub.md @@ -1,8 +1,10 @@ --- -title: Publishers and Subscribers +title: Publishers and subscribers permalink: /docs/tutorials/programming_rcl_rclc/pub_sub/ --- + + 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). 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. diff --git a/_docs/tutorials/programming_rcl_rclc/qos/QoS.md b/_docs/tutorials/programming_rcl_rclc/qos/QoS.md index e2bf648b..55c57b91 100644 --- a/_docs/tutorials/programming_rcl_rclc/qos/QoS.md +++ b/_docs/tutorials/programming_rcl_rclc/qos/QoS.md @@ -3,6 +3,8 @@ title: Quality of service permalink: /docs/tutorials/programming_rcl_rclc/qos/ --- + + - [Reliable QoS](#reliable-qos) - [Best Effort](#best-effort) - [Custom QoS configuration](#custom-qos-configuration) diff --git a/_docs/tutorials/programming_rcl_rclc/service/services.md b/_docs/tutorials/programming_rcl_rclc/service/services.md index c140c05b..897362b9 100644 --- a/_docs/tutorials/programming_rcl_rclc/service/services.md +++ b/_docs/tutorials/programming_rcl_rclc/service/services.md @@ -3,6 +3,8 @@ title: Services permalink: /docs/tutorials/programming_rcl_rclc/service/ --- + + ROS 2 services are 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/) Ready to use code related to this concepts can be found in [`micro-ROS-demos/rclc/addtwoints_server`](https://github.com/micro-ROS/micro-ROS-demos/blob/foxy/rclc/addtwoints_server/main.c) and [`micro-ROS-demos/rclc/addtwoints_client`](https://github.com/micro-ROS/micro-ROS-demos/blob/foxy/rclc/addtwoints_client/main.c) folders. Fragments of code from this examples are used on this tutorial. From 560f03e0a1fb2dfc03111e661d1d5825f38563f9 Mon Sep 17 00:00:00 2001 From: Ralph Lange Date: Fri, 10 Sep 2021 12:01:02 +0200 Subject: [PATCH 3/5] Fixed links to programming with rcl and rclc tutorial section. --- _docs/concepts/client_library/features/index.md | 2 +- _docs/tutorials/core/overview/index.md | 12 ++++++------ .../programming_rcl_rclc/service/services.md | 2 +- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/_docs/concepts/client_library/features/index.md b/_docs/concepts/client_library/features/index.md index 892d0713..7da9dd64 100644 --- a/_docs/concepts/client_library/features/index.md +++ b/_docs/concepts/client_library/features/index.md @@ -13,4 +13,4 @@ The micro-ROS Client Library, formed by standard [ROS 2 Client Support Library ( * Lifecycle * Parameters -Most features are already available in the Foxy release. Please see our [Feature Overview page](/docs/overview/features/) for details on the status. To learn developing your own application nodes with rcl + rclc, please head to the corresponding [programming tutorial](/docs/tutorials/core/programming_rcl_rclc/). +Most features are already available in the Foxy release. Please see our [Feature Overview page](/docs/overview/features/) for details on the status. To learn developing your own application nodes with rcl + rclc, please head to the corresponding [programming tutorial](/docs/tutorials/programming_rcl_rclc/). diff --git a/_docs/tutorials/core/overview/index.md b/_docs/tutorials/core/overview/index.md index bc9ea861..04db3550 100644 --- a/_docs/tutorials/core/overview/index.md +++ b/_docs/tutorials/core/overview/index.md @@ -6,9 +6,7 @@ redirect_from: - /docs/tutorials/ --- -This chapter provides the user with a number of tutorials to learn micro-ROS and relevant tools for the different RTOSes supported by micro-ROS. In the [**Advanced Tutorials**](../../advanced/overview/) section, you'll find more advanced tutorials to strenghten your micro-ROS knowledge. - -If you are new to micro-ROS, we strongly suggest that you take the tutorials in the following order: +This chapter provides a number of tutorials to learn micro-ROS and relevant tools for the different RTOSes supported by micro-ROS. If you are new to micro-ROS, we strongly suggest that you take the tutorials in the following order: * [**First micro-ROS application on Linux**](../first_application_linux/) @@ -18,9 +16,9 @@ If you are new to micro-ROS, we strongly suggest that you take the tutorials in In this tutorial, you will learn how to build the application from the previous tutorial for an Real-Time Operating System (RTOS). You will see how to flash a microcontroller board with the application and how to communicate with it from a microprocessor running ROS 2 on Linux. (The tutorial covers all three RTOS supported by micro-ROS, namely NuttX, FreeRTOS, and Zephyr. The choice is up to you!) -* [**Programming with rcl and rclc**](../programming_rcl_rclc/) +Then, at this point, you may head over to the next section [**Programming with rcl and rclc**](../../programming_rcl_rclc/), where you 'll learn the concepts of the micro-ROS C API in this tutorial in depth. If you are already familiar with the ROS 2 C++ API or even the underlying ROS Client Support Library (rcl), you'll learn this very quickly. - You'll learn the concepts of the micro-ROS C API in this tutorial in depth. If you are already familiar with the ROS 2 C++ API or even the underlying ROS Client Support Library (rcl), you'll learn this very quickly. +In case you are using the corresponding RTOS or hardware, the following basic tutorials may be interesting before switching to the [**Programming with rcl and rclc**](../../programming_rcl_rclc/) section: * [**Zephyr Emulator**](../zephyr_emulator/) @@ -28,4 +26,6 @@ If you are new to micro-ROS, we strongly suggest that you take the tutorials in * [**Teensy with Arduino**](../teensy_with_arduino/) - In this tutorial you will learn how to connect Teensy with micro-ROS and ROS2. You will also learn how to install micro-ROS agent in linux systems to communicate with Teensy based arduino board using Arduino IDE. This tutorial will also cover a simple publisher topic published from teensy and subscribed using ROS2 interface. + In this tutorial you will learn how to connect Teensy with micro-ROS and ROS 2. You will also learn how to install micro-ROS agent in linux systems to communicate with Teensy based arduino board using Arduino IDE. This tutorial will also cover a simple publisher topic published from teensy and subscribed using ROS2 interface. + + In the [**Advanced Tutorials**](../../advanced/overview/) section, you'll find more advanced tutorials to strenghten your micro-ROS knowledge. \ No newline at end of file diff --git a/_docs/tutorials/programming_rcl_rclc/service/services.md b/_docs/tutorials/programming_rcl_rclc/service/services.md index 897362b9..c3ddd7d2 100644 --- a/_docs/tutorials/programming_rcl_rclc/service/services.md +++ b/_docs/tutorials/programming_rcl_rclc/service/services.md @@ -4,7 +4,7 @@ permalink: /docs/tutorials/programming_rcl_rclc/service/ --- - + ROS 2 services are 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/) Ready to use code related to this concepts can be found in [`micro-ROS-demos/rclc/addtwoints_server`](https://github.com/micro-ROS/micro-ROS-demos/blob/foxy/rclc/addtwoints_server/main.c) and [`micro-ROS-demos/rclc/addtwoints_client`](https://github.com/micro-ROS/micro-ROS-demos/blob/foxy/rclc/addtwoints_client/main.c) folders. Fragments of code from this examples are used on this tutorial. From 8dbf82475aa10ed4dec6bbe2459d3e43789d7fb7 Mon Sep 17 00:00:00 2001 From: Ralph Lange Date: Fri, 10 Sep 2021 12:19:12 +0200 Subject: [PATCH 4/5] Updated distro status badges for rclc parameter server. Signed-off-by: Ralph Lange --- .../tutorials/programming_rcl_rclc/parameters/parameters.md | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/_docs/tutorials/programming_rcl_rclc/parameters/parameters.md b/_docs/tutorials/programming_rcl_rclc/parameters/parameters.md index 48a2a49b..63075032 100644 --- a/_docs/tutorials/programming_rcl_rclc/parameters/parameters.md +++ b/_docs/tutorials/programming_rcl_rclc/parameters/parameters.md @@ -3,13 +3,13 @@ title: Parameter server permalink: /docs/tutorials/programming_rcl_rclc/parameters/ --- - + ROS 2 parameters allow the user to create variables on a node and manipulate/read them with different ROS2 commands. Further information about ROS 2 parameters can be found [here](https://docs.ros.org/en/galactic/Tutorials/Parameters/Understanding-ROS2-Parameters.html) Ready to use code related to this tutorial can be found in [`rclc/rclc_examples/src/example_parameter_server.c`](https://github.com/ros2/rclc/blob/master/rclc_examples/src/example_parameter_server.c). Fragments of code from this example is used on this tutorial. -Note: micro-ROS parameter server is only supported on ROS2 galactic distribution +Note: micro-ROS parameter server is only supported on ROS 2 Galactic distribution - [Initialization](#initialization) - [Memory requirements](#memory-requirements) @@ -56,6 +56,7 @@ Note: micro-ROS parameter server is only supported on ROS2 galactic distribution ``` ## Memory requirements + The parameter server uses 4 services and an optional publisher, this needs to be taken into account on the `rmw-microxredds` package memory configuration: ```json From 77340ca941717bce5883a61ee105c9914de3ded0 Mon Sep 17 00:00:00 2001 From: Antonio cuadros Date: Mon, 13 Sep 2021 08:00:22 +0200 Subject: [PATCH 5/5] Fix code identation --- .../parameters/parameters.md | 70 +++++++++---------- 1 file changed, 35 insertions(+), 35 deletions(-) diff --git a/_docs/tutorials/programming_rcl_rclc/parameters/parameters.md b/_docs/tutorials/programming_rcl_rclc/parameters/parameters.md index 63075032..afce0633 100644 --- a/_docs/tutorials/programming_rcl_rclc/parameters/parameters.md +++ b/_docs/tutorials/programming_rcl_rclc/parameters/parameters.md @@ -135,55 +135,55 @@ rc = rclc_executor_add_parameter_server(&executor, ¶m_server, NULL); micro-ROS parameter server supports the following parameter types: - Boolean: -```c -const char * parameter_name = "parameter_bool"; -bool param_value = true; + ```c + const char * parameter_name = "parameter_bool"; + bool param_value = true; -// Add parameter to the server -rcl_ret_t rc = rclc_add_parameter(¶m_server, parameter_name, RCLC_PARAMETER_BOOL); + // Add parameter to the server + rcl_ret_t rc = rclc_add_parameter(¶m_server, parameter_name, RCLC_PARAMETER_BOOL); -// Set parameter value (Triggers parameter change callback) -rc = rclc_parameter_set_bool(¶m_server, parameter_name, param_value); + // Set parameter value (Triggers parameter change callback) + rc = rclc_parameter_set_bool(¶m_server, parameter_name, param_value); -// Get parameter value on param_value -rc = rclc_parameter_get_bool(¶m_server, "param1", ¶m_value); + // Get parameter value on param_value + rc = rclc_parameter_get_bool(¶m_server, "param1", ¶m_value); -if (RCL_RET_OK != rc) { - ... // Handle error - return -1; -} -``` + if (RCL_RET_OK != rc) { + ... // Handle error + return -1; + } + ``` - Integer: -```c -const char * parameter_name = "parameter_int"; -int param_value = 100; + ```c + const char * parameter_name = "parameter_int"; + int param_value = 100; -// Add parameter to the server -rcl_ret_t rc = rclc_add_parameter(¶m_server, parameter_name, RCLC_PARAMETER_INT); + // Add parameter to the server + rcl_ret_t rc = rclc_add_parameter(¶m_server, parameter_name, RCLC_PARAMETER_INT); -// Set parameter value -rc = rclc_parameter_set_int(¶m_server, parameter_name, param_value); + // Set parameter value + rc = rclc_parameter_set_int(¶m_server, parameter_name, param_value); -// Get parameter value on param_value -rc = rclc_parameter_get_int(¶m_server, parameter_name, ¶m_value); -``` + // Get parameter value on param_value + rc = rclc_parameter_get_int(¶m_server, parameter_name, ¶m_value); + ``` - Double: -```c -const char * parameter_name = "parameter_double"; -double param_value = 0.15; - -// Add parameter to the server -rcl_ret_t rc = rclc_add_parameter(¶m_server, parameter_name, RCLC_PARAMETER_DOUBLE); + ```c + const char * parameter_name = "parameter_double"; + double param_value = 0.15; -// Set parameter value -rc = rclc_parameter_set_double(¶m_server, parameter_name, param_value); + // Add parameter to the server + rcl_ret_t rc = rclc_add_parameter(¶m_server, parameter_name, RCLC_PARAMETER_DOUBLE); -// Get parameter value on param_value -rc = rclc_parameter_get_double(¶m_server, parameter_name, ¶m_value); -``` + // Set parameter value + rc = rclc_parameter_set_double(¶m_server, parameter_name, param_value); + // Get parameter value on param_value + rc = rclc_parameter_get_double(¶m_server, parameter_name, ¶m_value); + ``` + ## Cleaning up To destroy an initialized parameter server: