diff --git a/_docs/tutorials/advanced/nuttx/6lowpan/index.md b/_docs/tutorials/advanced/nuttx/6lowpan/index.md index 4242ca14..5abf6a93 100644 --- a/_docs/tutorials/advanced/nuttx/6lowpan/index.md +++ b/_docs/tutorials/advanced/nuttx/6lowpan/index.md @@ -54,7 +54,7 @@ The last step is to connect a mini-USB cable to the OTG2 USB port (this USB port To create and flash the firmware, we are going to use the micro-ROS build system. You can find the instructions at the micro-ros-build's [README](https://github.com/micro-ROS/micro-ros-build/blob/dashing/micro_ros_setup/README.md). -For this particular guide, it is necessary yo use the branch `dashing` and the configuration profile `uros_6lowpan`. +For this particular guide, it is necessary to use the branch `dashing` and the configuration profile `uros_6lowpan`. Once you follow all the instructions in the build system and flash the board, everything is ready. diff --git a/_docs/tutorials/advanced/zephyr_emulator/index.md b/_docs/tutorials/advanced/zephyr_emulator/index.md index c73bcf05..17e85373 100644 --- a/_docs/tutorials/advanced/zephyr_emulator/index.md +++ b/_docs/tutorials/advanced/zephyr_emulator/index.md @@ -3,54 +3,51 @@ title: Zephyr Emulator permalink: /docs/tutorials/advanced/zephyr_emulator/ --- -This tutorial aims at creating a new micro-ROS application on with **[Zephyr RTOS](https://www.zephyrproject.org/)** emulator (also known as [Native POSIX](https://docs.zephyrproject.org/latest/boards/posix/native_posix/doc/index.html)). +## Target platform -To follow this tutorial, it is assumed that the user is already familiar with the **[First micro-ROS Application on an RTOS](https://micro-ros.github.io/docs/tutorials/core/first_application_rtos/)** tutorial. The target app in this tutorial is the same ping pong app. -Another requirement is that the user has a basic knowledge of micro-ROS and ROS 2. +In this tutorial, you'll learn the use of micro-ROS with a **[Zephyr RTOS](https://www.zephyrproject.org/)** +emulator (also known as [Native POSIX](https://docs.zephyrproject.org/latest/boards/posix/native_posix/doc/index.html)) +by testing a Ping Pong application.
-## Required hardware - -This tutorial requires no hardware beyond a Linux host computer. - -## Building a Zephyr emulator application - -Once the micro-ROS build system is ready, let's create a new Zephyr firmware for the host platform: +{% include first_application_common/build_system.md %} ```bash -# Create firmware step +# Create step ros2 run micro_ros_setup create_firmware_ws.sh zephyr host ``` -micro-ROS apps for Zephyr emulator are located at `firmware/zephyr_apps/apps`. In order to create a new application, create a new folder containing two files: the app code (inside a `src` folder) and the RMW configuration. You will also need some other Zephyr related files: a `CMakeLists.txt` to define the building process and a `prj.conf` where Zephyr is configured. There is a sample proyect [here](https://github.com/micro-ROS/zephyr_apps/tree/dashing/apps/host_ping_pong), for now, it is ok to copy them. +{% include first_application_common/zephyr_common.md %} -```bash -# Creating a new app -pushd firmware/zephyr_apps/apps -mkdir host_ping_pong -cd host_ping_pong -mkdir src - -touch src/app.c -touch app-colcon.meta -touch CMakeLists.txt -touch prj.conf - -popd -``` - -The contents of the files can be found here: [app.c](https://github.com/micro-ROS/zephyr_apps/blob/dashing/apps/host_ping_pong/src/main.c), [app-colcon.meta](https://github.com/micro-ROS/zephyr_apps/blob/dashing/apps/host_ping_pong/app-colcon.meta), [CMakeLists.txt](https://github.com/micro-ROS/zephyr_apps/blob/dashing/apps/host_ping_pong/CMakeLists.txt) and [prj.conf](https://github.com/micro-ROS/zephyr_apps/blob/dashing/apps/host_ping_pong/prj.conf). +{% include first_application_common/config.md %} -Once the app folder is created, let's configure our new app with a UDP transport that looks for the agent on the port UDP/8888 at localhost: +In this tutorial, we will use a UDP transport that looks for the agent on the port UDP/8888 at localhost, and focus on +the out-of-the-box `ping_pong` application located at `firmware/zephyr_apps/apps/ping_pong`. +To execute this application with the chosen transport, run the configuration command above by specifying the `[APP]` +and `[OPTIONS]` parameters as below: ```bash # Configure step ros2 run micro_ros_setup configure_firmware.sh host_ping_pong --transport udp --ip 127.0.0.1 --port 8888 ``` +You can check the complete content of the `ping_pong` app +[here](https://github.com/micro-ROS/zephyr_apps/tree/foxy/apps/ping_pong). + +{% include first_application_common/pingpong_logic.md %} + +The contents of the Zephyr app specific files can be found here: +[main.c](https://github.com/micro-ROS/zephyr_apps/blob/foxy/apps/ping_pong/src/main.c), +[app-colcon.meta](https://github.com/micro-ROS/zephyr_apps/blob/foxy/apps/ping_pong/app-colcon.meta), +[CMakeLists.txt](https://github.com/micro-ROS/zephyr_apps/blob/foxy/apps/ping_pong/CMakeLists.txt) +and [host-udp.conf](https://github.com/micro-ROS/zephyr_apps/blob/foxy/apps/ping_pong/host-udp.conf). +A thorough review of these files is illustrative of how to create a micro-ROS app in this RTOS. + +## Building the firmware + When the configuring step ends, just build the firmware: ```bash @@ -59,117 +56,41 @@ ros2 run micro_ros_setup build_firmware.sh ``` Now you have a Zephyr + micro-ROS app ready to run on your own computer. +Notice that in this case, the steps of flashing the firmware and running the micro-ROS app go together. -## Running the micro-ROS app - -The micro-ROS app is ready to connect to a micro-ROS-Agent and start talking with the rest of the ROS 2 world. - -First of all, create and build a micro-ROS agent: +{% include first_application_common/agent_creation.md %} -```bash -# Download micro-ROS-Agent packages -ros2 run micro_ros_setup create_agent_ws.sh +## Running the micro-ROS app -# Build micro-ROS-Agent packages, this may take a while. -colcon build -source install/local_setup.bash -``` +At this point, you have both the client and the agent correctly installed in your host machine. -Then run the agent: +To give micro-ROS access to the ROS 2 dataspace, run the agent: ```bash # Run a micro-ROS agent ros2 run micro_ros_agent micro_ros_agent udp4 --port 8888 ``` -And run the Zephyr app in another command line (remember sourcing ROS 2 and micro-ROS installation): +## Flashing the firmware + +Finally, in order to run the micro-ROS node inside of the Zephyr RTOS emulator, +open a new command shell and execute the flash step by means of the flashing command: ```bash -source /opt/ros/$ROS_DISTRO/setup.bash -source microros_ws/install/local_setup.bash +source /opt/ros/foxy/setup.bash +source install/local_setup.bash # Flash/run step ros2 run micro_ros_setup flash_firmware.sh ``` -And finally, let's check that everything is working in another command line. We are going to listen to ping topic to check whether the Ping Pong node is publishing its own pings: - -```bash -source /opt/ros/$ROS_DISTRO/setup.bash - -# Subscribe to micro-ROS ping topic -ros2 topic echo /microROS/ping -``` - -You should see the topic messages published by the Ping Pong node every 5 seconds: - -``` -user@user:~$ ros2 topic echo /microROS/ping -stamp: - sec: 20 - nanosec: 867000000 -frame_id: '1344887256_1085377743' ---- -stamp: - sec: 25 - nanosec: 942000000 -frame_id: '730417256_1085377743' ---- -``` - -On another command line, let's subscribe to the pong topic - -```bash -source /opt/ros/$ROS_DISTRO/setup.bash - -# Subscribe to micro-ROS pong topic -ros2 topic echo /microROS/pong -``` - -At this point, we know that our app is publishing pings. Let's check if it also answers to someone else pings in a new command line: - -```bash -source /opt/ros/$ROS_DISTRO/setup.bash - -# Send a fake ping -ros2 topic pub --once /microROS/ping std_msgs/msg/Header '{frame_id: "fake_ping"}' -``` - -Now, we should see on the ping subscriber our fake ping along with the board pings: - -``` -user@user:~$ ros2 topic echo /microROS/ping -stamp: - sec: 0 - nanosec: 0 -frame_id: fake_ping ---- -stamp: - sec: 305 - nanosec: 973000000 -frame_id: '451230256_1085377743' ---- -stamp: - sec: 310 - nanosec: 957000000 -frame_id: '2084670932_1085377743' ---- -``` - -And in the pong subscriber, we should see the board's answer to our fake ping: - -``` -pgarrido@pgarrido:~$ ros2 topic echo /microROS/pong -stamp: - sec: 0 - nanosec: 0 -frame_id: fake_ping ---- -``` +{% include first_application_common/test_app_host.md %} ## Multiple Ping Pong nodes -One of the advantages of having an emulator is that you don't need to buy a bunch of hardware in order to test some multi-node micro-ROS apps. So, with the same micro-ROS agent of the last section, let's open four different command lines and run the following on each: +One of the advantages of having an emulator is that you don't need to buy a bunch of hardware in order to test some +multi-node micro-ROS apps. So, with the same micro-ROS agent of the last section, let's open four different command +lines and run the following on each: ```bash cd microros_ws @@ -181,13 +102,12 @@ cd microros_ws As soon as all micro-ROS node are up and connected to the micro-ROS agent you will see them interacting: ``` -pgarrido@pgarrido$ ./firmware/build/zephyr/zephyr.exe +user@user:~$ ./firmware/build/zephyr/zephyr.exe *** Booting Zephyr OS build zephyr-v2.2.0-492-gc73cb85b4ae9 *** -UDP mode => ip: 127.0.0.1 - port: 8888 Ping send seq 1711620172_1742614911 <---- This micro-ROS node sends a ping with ping ID "1711620172" and node ID "1742614911" -Pong for seq 1711620172_1742614911 (1) <---- The first mate pongs my ping -Pong for seq 1711620172_1742614911 (2) <---- The second mate pongs my ping -Pong for seq 1711620172_1742614911 (3) <---- The third mate pongs my ping +Pong for seq 1711620172_1742614911 (1) <---- The first mate pongs my ping +Pong for seq 1711620172_1742614911 (2) <---- The second mate pongs my ping +Pong for seq 1711620172_1742614911 (3) <---- The third mate pongs my ping Ping received with seq 1845948271_546591567. Answering. <---- A ping is received from a mate identified as "546591567", let's pong it. Ping received with seq 232977719_1681483056. Answering. <---- A ping is received from a mate identified as "1681483056", let's pong it. Ping received with seq 1134264528_1107823050. Answering. <---- A ping is received from a mate identified as "1107823050", let's pong it. diff --git a/_docs/tutorials/core/first_application_linux/index.md b/_docs/tutorials/core/first_application_linux/index.md index de489670..7a527e16 100644 --- a/_docs/tutorials/core/first_application_linux/index.md +++ b/_docs/tutorials/core/first_application_linux/index.md @@ -3,254 +3,113 @@ title: First micro-ROS Application on Linux permalink: /docs/tutorials/core/first_application_linux/ --- -This tutorial teaches you how to create a first micro-ROS application on Linux for testing purposes. In the follow-up tutorial [*First micro-ROS application on an RTOS*](/docs/tutorials/core/first_application_rtos/), you'll learn how to build and bring this application on a microcontroller running the RTOS NuttX, FreeRTOS, or Zephyr. +## Target platform -## Installing ROS 2 and the micro-ROS build system +In this tutorial, you’ll learn the use of micro-ROS with Linux by testing a Ping Pong application. +In the follow-up tutorial [*First micro-ROS application on an RTOS*](/docs/tutorials/core/first_application_rtos/), +you'll learn how to build and bring this application on a microcontroller running the RTOS NuttX, FreeRTOS, or Zephyr. +Finally, in the tutorial [*Zephyr Emulator*](/docs/tutorials/advanced/zephyr_emulator/) you'll learn how to test +a micro-ROS application on a Zephyr emulator. -First of all, let's take a Ubuntu 18.04 LTS computer and install **ROS 2 Dashing Diademata**: - -``` -sudo locale-gen en_US en_US.UTF-8 -sudo update-locale LC_ALL=en_US.UTF-8 LANG=en_US.UTF-8 -export LANG=en_US.UTF-8 - -sudo apt update && sudo apt install curl gnupg2 lsb-release -curl -s https://raw.githubusercontent.com/ros/rosdistro/master/ros.asc | sudo apt-key add - - -sudo sh -c 'echo "deb http://packages.ros.org/ros2/ubuntu `lsb_release -cs` main" > /etc/apt/sources.list.d/ros2-latest.list' -sudo apt update -sudo apt install ros-dashing-desktop -``` - -Once you have a **ROS 2** installation in the computer, follow these steps to install the micro-ROS build system: +{% include first_application_common/build_system.md %} ```bash -# Source the ROS 2 installation -source /opt/ros/$ROS_DISTRO/setup.bash - -# Create a workspace and download the micro-ROS tools -mkdir microros_ws -cd microros_ws -git clone -b $ROS_DISTRO https://github.com/micro-ROS/micro-ros-build.git src/micro-ros-build - -# Update dependencies using rosdep -sudo apt update && rosdep update -rosdep install --from-path src --ignore-src -y - -# Build micro-ROS tools and source them -colcon build -source install/local_setup.bash -``` - -***TIP:** if you are familiar with Docker containers, this image may be useful: [micro-ros:base](https://github.com/micro-ROS/docker/blob/dashing/base/Dockerfile)* - -These instructions will setup a workspace with a ready-to-use micro-ROS build system. This build system is in charge of downloading the required cross-compilation tools and building the apps for the required platforms. - -The build system's workflow is a four-step procedure: - -* **Create step:** This step is in charge of downloading all the required code repositories and cross-compilation toolchains for the specific hardware platform. Among these repositories, it will also download a collection of ready to use micro-ROS apps. -* **Configure step:** In this step, the user can select which app is going to be cross-compiled by the toolchain. Some other options, such as transport, agent address or port will be also selected in this step. -* **Build step:** Here is where the cross-compilation takes place and the platform-specific binaries are generated. -* **Flash step:** The binaries generated in the previous step are flashed onto the hardware platform memory, in order to allow the execution of the micro-ROS app. -Further information about micro-ROS build system can be found [here](https://github.com/micro-ROS/micro-ros-build/tree/dashing/micro_ros_setup). - -## Creating a new micro-ROS app - -Once the build system is installed, let's create a firmware workspace that targets all the required code and tools: - -```bash -# Create step +# Create firmware step ros2 run micro_ros_setup create_firmware_ws.sh host ``` -micro-ROS apps for Linux are located at `src/uros/micro-ROS-demos/rcl/`. In order to create a new application, create a new folder containing two files: the app code and the CMake file. You can check the complete content of these file [here](https://github.com/micro-ROS/micro-ROS-demos/tree/dashing/rcl/ping_pong). - -```bash -# Creating a new app -pushd src/uros/micro-ROS-demos/rcl/ -mkdir ping_pong -cd ping_pong -touch app.c CMakeLists.txt -popd -``` - -Don't forget to register your app in `src/uros/micro-ROS-demos/rcl/CMakeLists.txt` by adding the following line: - -``` -export_executable(ping_pong) -``` +Once the command is executed, a folder named `firmware` must be present in your workspace. -For this example we are going to create a ping pong app where a node sends a ping package with a unique identifier using a publisher and the same package is received by a pong subscriber. The node will also answer to pings received from other nodes with a pong message: +This step is in charge, among other things, of downloading a set of micro-ROS apps for Linux, that are located at +`src/uros/micro-ROS-demos/rcl`. +Each app is represented by a folder containing the following files: -![pingpong](http://www.plantuml.com/plantuml/png/ZOwnIWGn48RxFCNFzSkoUG2vqce5jHEHi1dtWZkPa6GByNntavZY10yknMJu-ORlFwPiOjvvK-d3-M2YOR1uMKvHc93ZJafvoMML07d7h1NAE-DPWblg_na8vnwEx9OeZmzFOt1-BK7AzetJciPxCfRYVw1S0SbRLBEg1IpXPIvpUWLCmZpXIm6BS3addt7uQpu0ZQlxT1MK2r0g-7sfqbsbRrVfMrMwgbev3CDTlsqJGtJhATUmSMrMg5TKwaZUxfcttuMt7m00) +* `main.c`: This file contains the logic of the application. +* `CMakeLists.txt`: This is the CMake file containing the script to compile the application. -The app logic of this demo is contained in [`app.c`](https://github.com/micro-ROS/micro-ROS-demos/blob/dashing/rcl/ping_pong/main.c). A thorough review of this file can show how to create a micro-ROS publisher or subscriber, as shown below. +For the user to create its custom application, a folder `` will need to be registered in this location, +containing the two files just described. +Also, any such new application folder needs to be registered in +`src/uros/micro-ROS-demos/rcl/CMakeLists.txt` by adding the following line: -**For more in depth learning about RCL and RCLC programming [check this section](https://micro-ros.github.io/docs/tutorials/core/programming_rcl_rclc/).** -```c -... - // Create a reliable ping publisher - rcl_publisher_options_t ping_publisher_ops = rcl_publisher_get_default_options(); - rcl_publisher_t ping_publisher = rcl_get_zero_initialized_publisher(); - rcl_publisher_init(&ping_publisher, &node, ROSIDL_GET_MSG_TYPE_SUPPORT(std_msgs, msg, Header), "/microROS/ping", &ping_publisher_ops); -... - -... - // Create a best effort pong subscriber - rcl_subscription_options_t pong_subscription_ops = rcl_subscription_get_default_options(); - pong_subscription_ops.qos.reliability = RMW_QOS_POLICY_RELIABILITY_BEST_EFFORT; - rcl_subscription_t pong_subscription = rcl_get_zero_initialized_subscription(); - rcl_subscription_init(&pong_subscription, &node, ROSIDL_GET_MSG_TYPE_SUPPORT(std_msgs, msg, Header), "/microROS/pong", &pong_subscription_ops); -... -... - // Check if some pong message is received - if (wait_set.subscriptions[index_pong_subscription]) { - rc = rcl_take(wait_set.subscriptions[index_pong_subscription], &rcv_msg, NULL, NULL); - if(rc == RCL_RET_OK) { - // Subscription app logic - } - } - -... - // Reset the pong count and publish the ping message - rcl_publish(&ping_publisher, (const void*)&msg, NULL); -... +``` +export_executable() ``` -## Running the micro-ROS app +In this tutorial, we will focus on the out-of-the-box `ping_pong` application located at +`src/uros/micro-ROS-demos/rcl/ping_pong`. +You can check the complete content of this app +[here](https://github.com/micro-ROS/micro-ROS-demos/tree/foxy/rclc/ping_pong). -The micro-ROS app is ready to be built and connected to a micro-ROS-Agent to start talking with the rest of the ROS 2 world. +{% include first_application_common/pingpong_logic.md %} -First of all, create a micro-ROS agent: +The contents of the host app specific files can be found here: +[main.c](https://github.com/micro-ROS/micro-ROS-demos/blob/foxy/rclc/ping_pong/main.c) and +[CMakeLists.txt](https://github.com/micro-ROS/micro-ROS-demos/blob/foxy/rclc/ping_pong/CMakeLists.txt). +A thorough review of these files is illustrative of how to create a micro-ROS app in this RTOS. -```bash -# Download micro-ROS-Agent packages -ros2 run micro_ros_setup create_agent_ws.sh -``` +## Building the firmware -When the all client and agent packages are ready, just build them all: +Once the app has been created, the build step is in order. +Notice that, with respect to the four-steps workflow delined above, we would expect a configuration step to happen +before building the app. However, given that we are compiling micro-ROS in the host machine rather than in a board, +the cross-compilation implemented by the configuration step is not required in this case. +We can therefore proceed to build the firmware and source the local installation: ```bash # Build step ros2 run micro_ros_setup build_firmware.sh source install/local_setup.bash ``` +{% include first_application_common/agent_creation.md %} -Then run the agent: +## Running the micro-ROS app -```bash -# Run a micro-ROS agent -ros2 run micro_ros_agent micro_ros_agent udp4 --port 8888 -``` +At this point, you have both the client and the agent correctly installed in your host machine. -Then run the app in another command line (remember sourcing ROS 2 and micro-ROS installation): +To give micro-ROS access to the ROS 2 dataspace, run the agent: ```bash -source /opt/ros/$ROS_DISTRO/setup.bash -source install/local_setup.bash - # Run a micro-ROS agent -ros2 run micro_ros_demos_rcl ping_pong -``` - -And finally, let's check that everything is working in another command line. We are going to listen to ping topic to check whether the Ping Pong node is publishing its own pings: - -```bash -source /opt/ros/$ROS_DISTRO/setup.bash - -# Subscribe to micro-ROS ping topic -ros2 topic echo /microROS/ping -``` - -You should see the topic messages published by the Ping Pong node every 5 seconds: - -``` -user@user:~$ ros2 topic echo /microROS/ping -stamp: - sec: 20 - nanosec: 867000000 -frame_id: '1344887256_1085377743' ---- -stamp: - sec: 25 - nanosec: 942000000 -frame_id: '730417256_1085377743' ---- -``` - -On another command line, let's subscribe to the pong topic - -```bash -source /opt/ros/$ROS_DISTRO/setup.bash - -# Subscribe to micro-ROS pong topic -ros2 topic echo /microROS/pong +ros2 run micro_ros_agent micro_ros_agent udp4 --port 8888 ``` -At this point, we know that our app is publishing pings. Let's check if it also answers to someone else pings in a new command line: +And then, in another command line, run the micro-ROS node (remember sourcing the ROS 2 and micro-ROS installations): ```bash -source /opt/ros/$ROS_DISTRO/setup.bash - -# Send a fake ping -ros2 topic pub --once /microROS/ping std_msgs/msg/Header '{frame_id: "fake_ping"}' -``` - -Now, we should see on the ping subscriber our fake ping along with the board pings: - -``` -user@user:~$ ros2 topic echo /microROS/ping -stamp: - sec: 0 - nanosec: 0 -frame_id: fake_ping ---- -stamp: - sec: 305 - nanosec: 973000000 -frame_id: '451230256_1085377743' ---- -stamp: - sec: 310 - nanosec: 957000000 -frame_id: '2084670932_1085377743' ---- -``` - -And in the pong subscriber, we should see the board's answer to our fake ping: +source /opt/ros/foxy/setup.bash +source install/local_setup.bash -``` -user@user:~$ ros2 topic echo /microROS/pong -stamp: - sec: 0 - nanosec: 0 -frame_id: fake_ping ---- +# Run a micro-ROS node +ros2 run micro_ros_demos_rclc ping_pong ``` +{% include first_application_common/test_app_host.md %} ## Multiple Ping Pong nodes -One of the advantages of having an Linux micro-ROS app is that you don't need to buy a bunch of hardware in order to test some multi-node micro-ROS apps. So, with the same micro-ROS agent of the last section, let's open four different command lines and run the following on each: +One of the advantages of having a Linux micro-ROS app is that you don't need to buy a bunch of hardware in order to +test some multi-node micro-ROS apps. +So, with the same micro-ROS agent of the last section, let's open four different command lines and run the following on +each: ```bash cd microros_ws -source /opt/ros/$ROS_DISTRO/setup.bash +source /opt/ros/foxy/setup.bash source install/local_setup.bash -ros2 run micro_ros_demos_rcl my_brand_new_app +ros2 run micro_ros_demos_rclc ping_pong ``` As soon as all micro-ROS nodes are up and connected to the micro-ROS agent you will see them interacting: ``` -user@user$ ros2 run micro_ros_demos_rcl my_brand_new_app -UDP mode => ip: 127.0.0.1 - port: 8888 +user@user:~$ ros2 run micro_ros_demos_rclc ping_pong Ping send seq 1711620172_1742614911 <---- This micro-ROS node sends a ping with ping ID "1711620172" and node ID "1742614911" -Pong for seq 1711620172_1742614911 (1) <---- The first mate pongs my ping -Pong for seq 1711620172_1742614911 (2) <---- The second mate pongs my ping -Pong for seq 1711620172_1742614911 (3) <---- The third mate pongs my ping +Pong for seq 1711620172_1742614911 (1) <---- The first mate pongs my ping +Pong for seq 1711620172_1742614911 (2) <---- The second mate pongs my ping +Pong for seq 1711620172_1742614911 (3) <---- The third mate pongs my ping Ping received with seq 1845948271_546591567. Answering. <---- A ping is received from a mate identified as "546591567", let's pong it. Ping received with seq 232977719_1681483056. Answering. <---- A ping is received from a mate identified as "1681483056", let's pong it. Ping received with seq 1134264528_1107823050. Answering. <---- A ping is received from a mate identified as "1107823050", let's pong it. diff --git a/_docs/tutorials/core/first_application_rtos/freertos.md b/_docs/tutorials/core/first_application_rtos/freertos.md index c95d5d94..9c3e5ad6 100644 --- a/_docs/tutorials/core/first_application_rtos/freertos.md +++ b/_docs/tutorials/core/first_application_rtos/freertos.md @@ -5,53 +5,71 @@ redirect_from: - /docs/tutorials/advanced/freertos/freertos_getting_started/ --- -{% include first_application_rtos_common/section_01_intro.md %} +## Target platform -In this tutorial, you'll learn the use of micro-ROS with FreeRTOS. +In this tutorial, you'll learn the use of micro-ROS with FreeRTOS by testing a Ping Pong application. +{% include first_application_common/target_hardware.md %} +* [USB-to-Serial Cable Female](https://www.olimex.com/Products/Components/Cables/USB-Serial-Cable/USB-SERIAL-F/) -{% include first_application_rtos_common/section_02_target_hardware_and_workspace.md %} +{% include first_application_common/build_system.md %} ```bash # Create step ros2 run micro_ros_setup create_firmware_ws.sh freertos olimex-stm32-e407 ``` -{% include first_application_rtos_common/section_03_configuring_firmware.md %} +Once the command is executed, a folder named `firmware` must be present in your workspace. -| RTOS | `[APP]` | `[OPTIONS]` | Configured app | -| :------: | --------------- | ---------------------------- | :------------------------------------------------------------------------------: | -| NuttX | `uros_pingpong` | | [Source](https://github.com/micro-ROS/apps/tree/dashing/examples/uros_pingpong) | -| **FreeRTOS** | **`ping_pong`** | **`--transport serial --dev 3`** | [**Source**](https://github.com/micro-ROS/freertos_apps/tree/dashing/apps/ping_pong) | -| Zephyr | `ping_pong` | `--transport serial-usb` | [Source](https://github.com/micro-ROS/zephyr_apps/tree/dashing/apps/ping_pong) | +This step is in charge, among other things, of downloading a set of micro-ROS apps for the specific platform you are +addressing. +In the case of FreeRTOS, these are located at `firmware/freertos_apps/apps`. +Each app is represented by a folder containing the following files: -{% include first_application_rtos_common/section_04_demo_description.md %} +* `app.c`: This file contains the logic of the application. +* `app-colcon.meta`: This file contains the micro-ROS app specific colcon configuration. Detailed info on how to + configure the RMW via this file can be found + [here](https://micro-ros.github.io/docs/tutorials/core/microxrcedds_rmw_configuration/). -Create a new app: +For the user to create its custom application, a folder `` will need to be registered in this location, +containing the two files just described. -```bash -# Create your app folder and required files. Contents of these file can be found in column Sample app in table above -pushd firmware/freertos_apps/apps -mkdir ping_pong -cd ping_pong -touch app.c app-colcon.meta -popd -``` +{% include first_application_common/config.md %} -Now you are ready to call: +In this tutorial, we will use a Serial transport (labeled as `serial`) and focus on the out-of-the-box `ping_pong` +application located at `firmware/freertos_apps/apps/ping_pong`. To execute this application with the chosen transport, +run the configuration command above by specifying the `[APP]` and `[OPTIONS]` parameters as below: ```bash -# Configure step -ros2 run micro_ros_setup configure_firmware.sh ping_pong [OPTIONS] +# Configure step with ping_pong app and serial-usb transport +ros2 run micro_ros_setup configure_firmware.sh ping_pong --transport serial --dev 3 ``` -{% include first_application_rtos_common/section_05_building_flashing_and_running.md %} +You can check the complete content of the `ping_pong` app +[here](https://github.com/micro-ROS/freertos_apps/tree/foxy/apps/ping_pong). + +{% include first_application_common/pingpong_logic.md %} + +The contents of the FreeRTOS app specific files can be found here: +[app.c](https://github.com/micro-ROS/freertos_apps/blob/foxy/apps/ping_pong/app.c) and +[app-colcon.meta](https://github.com/micro-ROS/freertos_apps/blob/foxy/apps/ping_pong/app-colcon.meta). +A thorough review of these files is illustrative of how to create a micro-ROS app in this RTOS. + +{% include first_application_common/build_and_flash.md %} + +{% include first_application_common/agent_creation.md %} + +Then, depending on the selected transport and RTOS, the board connection to the agent may differ. +In this tutorial, we're using the Olimex STM32-E407 Serial connection, for which the Olimex development board is +connected to the computer using the usb to serial cable. + + + +***TIP:** Color codes are applicable to +[this cable](https://www.olimex.com/Products/Components/Cables/USB-Serial-Cable/USB-SERIAL-F/). +Make sure to match Olimex Rx with Cable Tx and vice-versa. Remember GND!* -| RTOS | micro-ROS Client to Agent | -| :------: | ------------------------- | -| NuttX | Serial | -| **FreeRTOS** | **Serial** | -| Zephyr | USB | +{% include first_application_common/run_app.md %} -{% include first_application_rtos_common/section_06_agent.md %} +{% include first_application_common/test_app_rtos.md %} This completes the First micro-ROS Application on FreeRTOS tutorial. Do you want to [go back](../) and try a different RTOS, i.e. NuttX or Zephyr? diff --git a/_docs/tutorials/core/first_application_rtos/imgs/6.jpg b/_docs/tutorials/core/first_application_rtos/imgs/6.jpg new file mode 100644 index 00000000..ca4b6789 Binary files /dev/null and b/_docs/tutorials/core/first_application_rtos/imgs/6.jpg differ diff --git a/_docs/tutorials/core/first_application_rtos/imgs/7.jpg b/_docs/tutorials/core/first_application_rtos/imgs/7.jpg new file mode 100644 index 00000000..f8b787b0 Binary files /dev/null and b/_docs/tutorials/core/first_application_rtos/imgs/7.jpg differ diff --git a/_docs/tutorials/core/first_application_rtos/nuttx.md b/_docs/tutorials/core/first_application_rtos/nuttx.md index 52d27093..07d3cdaf 100644 --- a/_docs/tutorials/core/first_application_rtos/nuttx.md +++ b/_docs/tutorials/core/first_application_rtos/nuttx.md @@ -5,103 +5,149 @@ redirect_from: - /docs/tutorials/advanced/nuttx/nuttx_getting_started/ --- -{% include first_application_rtos_common/section_01_intro.md %} +## Target platform -In this tutorial, you'll learn the use of micro-ROS with NuttX. +In this tutorial, you'll learn the use of micro-ROS with NuttX by testing a Ping Pong application. +{% include first_application_common/target_hardware.md %} +* [USB-to-Serial Cable Female](https://www.olimex.com/Products/Components/Cables/USB-Serial-Cable/USB-SERIAL-F/) +* [USB-to-mini-USB cable](https://www.olimex.com/Products/Components/Cables/CABLE-USB-A-MINI-1.8M/) -{% include first_application_rtos_common/section_02_target_hardware_and_workspace.md %} +{% include first_application_common/build_system.md %} ```bash # Create step ros2 run micro_ros_setup create_firmware_ws.sh nuttx olimex-stm32-e407 ``` -{% include first_application_rtos_common/section_03_configuring_firmware.md %} +Once the command is executed, a folder named `firmware` must be present in your workspace. -| RTOS | `[APP]` | `[OPTIONS]` | Configured app | -| :------: | --------------- | ---------------------------- | :------------------------------------------------------------------------------: | -| **NuttX** | **`uros_pingpong`** | | [**Source**](https://github.com/micro-ROS/apps/tree/feature/pingpong_app/examples/uros_pingpong) | -| FreeRTOS | `ping_pong` | `--transport serial --dev 3` | [Source](https://github.com/micro-ROS/freertos_apps/tree/dashing/apps/ping_pong) | -| Zephyr | `ping_pong` | `--transport serial-usb` | [Source](https://github.com/micro-ROS/zephyr_apps/tree/dashing/apps/ping_pong) | +This step is in charge, among other things, of downloading a set of micro-ROS apps for the specific platform you are +addressing. +In the case of NuttX, these are located [here](https://github.com/micro-ROS/apps/tree/foxy/examples). +Each app is represented by a folder containing the following files: -{% include first_application_rtos_common/section_04_demo_description.md %} +* `app.c`: This file contains the logic of the application. +* `Kconfig`: This file contains the NuttX Kconfig configuration. +* `Make.defs`: This file contains the NuttX build system definitions. +* `Makefile`: This file contains the NuttX specific app build script. -Create a new app: +{% include first_application_common/config.md %} + +In this tutorial, we will use a Serial transport (labeled as `serial`) and focus on the out-of-the-box `uros_pingpong` +application located [here](https://github.com/micro-ROS/apps/tree/foxy/examples/uros_pingpong). +To execute this application with the chosen transport, run the configuration command above by specifying the `[APP]` parameter as below: ```bash -# Go to app folder inside firmware -cd firmware/apps/examples - -# Create your app folder and required files. Contents of these file can be found in column Sample app in table above -mkdir uros_pingpong -cd uros_pingpong -touch Kconfig -touch Makefile -touch app.c -touch Make.defs +# Configure step with ping_pong app and serial-usb transport +ros2 run micro_ros_setup configure_firmware.sh drive_base ``` -Create a specific configuration. We're going to start from an already existing one and modify it for our new application. +and with no `[OPTIONS]` parameter. +To proceed with the configuration, clone the following NuttX tools repo: -Execute the following command: ```bash -cd microros_ws -ros2 run micro_ros_setup configure_firmware.sh uros +# Download the tools necessary to work with NuttX +git clone https://bitbucket.org/nuttx/tools.git firmware/tools ``` -Install required `kconfig-frontends`: +and then install the required `kconfig-frontends`: ```bash -git clone https://bitbucket.org/nuttx/tools.git firmware/tools - pushd firmware/tools/kconfig-frontends -./configure --enable-mconf --disable-nconf --disable-gconf --disable-qconf -LD_RUN_PATH=/usr/local/lib && make && sudo make install && sudo ldconfig +./configure +make + +# if the make command fails, type: autoreconf -f -i , and then rerun the make command. + +sudo make install +sudo ldconfig popd ``` -This sets the Ethernet and micro-ROS required configuration. However, in order to add our application, we're going to modify it: +We'll now open an interactive NuttX menu config, which allows to modify the configuration of the RTOS, including adding a new application. ```bash cd firmware/NuttX make menuconfig ``` -This will open the NuttX menu config, which allows you to modify the configuration of the RTOS, including adding a new application. +To add the `uros_pingpong` application, follow the steps listed below: + +* On the menu, follow the path: `Application Configuration ---> Examples` +* A list of the available applications will appear. You need to find: `micro-ROS Ping-Pong` and press the space bar to add it. +* Navigate to the bottom menu with the left and right arrows, and click on the `Exit` button. +* When you're back to the `Application Configuration` menu, go to `micro-ROS ---> Transport (UDP transport)`. +* A list of the available transports will appear. You need to go to `Serial transport` and press the space bar to set the Serial port as micro-ROS transport. After that, you'll be automatically redirected to the previous menu. +* Navigate to the bottom menu with the left and right arrows, and click on the `Save` button. +* You will be asked if you want to save your new `.config` configuration, and you need to click `Ok`, and then `Exit`. +* Finally, push three times the `Esc` key to close the menu. + +When the configuration process is over, go back to the `microros_ws`: + +```bash +cd ../.. +``` + +You can check the complete content of the `uros_pingpong` app +[here](https://github.com/micro-ROS/apps/tree/foxy/examples/uros_pingpong). -- On the menu, follow the path: -``Application Configuration -> Examples `` -![](../imgs/nuttx_menuconfig.png) +{% include first_application_common/pingpong_logic.md %} -- A list of the available applications will appear. You need to find: ``micro-ROS Ping-Pong`` and click ``y`` to add it. -![](../imgs/nuttx_examples.png) +The contents of the FreeRTOS app specific files can be found here: +[app.c](https://github.com/micro-ROS/apps/blob/foxy/examples/uros_pingpong/app.c), +[Kconfig](https://github.com/micro-ROS/apps/blob/foxy/examples/uros_pingpong/Kconfig), +[Make.defs](https://github.com/micro-ROS/apps/blob/foxy/examples/uros_pingpong/Make.defs) and +[Makefile](https://github.com/micro-ROS/apps/blob/foxy/examples/uros_pingpong/Makefile). +A thorough review of these files is illustrative of how to create a micro-ROS app in this RTOS. -- Now push three times the key ``ESC`` to close the menu. You will be asked if you want to save your new configuration, and you need to click ``Yes``. +{% include first_application_common/build_and_flash.md %} -To save your configuration execute the following commands: +{% include first_application_common/agent_creation.md %} + +Then, depending on the selected transport and RTOS, the board connection to the agent may differ. +In this tutorial, we're using the Olimex STM32-E407 Serial connection, for which the Olimex development board is +connected to the computer using the usb to serial cable. + + + +Additionally, you'll need to connect a USB-to-mini-USB cable to the USB OTG 1 connector (the miniUSB connector +that is closer to the Ethernet port). + + + +***TIP:** Color codes are applicable to +[this cable](https://www.olimex.com/Products/Components/Cables/USB-Serial-Cable/USB-SERIAL-F/). +Make sure to match Olimex Rx with Cable Tx and vice-versa. Remember GND!* + +## Running the micro-ROS app + +At this point, you have both the client and the agent correctly installed. + +To give micro-ROS access to the ROS 2 dataspace, run the agent: ```bash -cd uros_ws/firmware/NuttX -make savedefconfig +# Run a micro-ROS agent +ros2 run micro_ros_agent micro_ros_agent serial --dev [device] ``` -This will generate a file called ``defconfig`` inside of ``uros_ws/firmware/NuttX``. This file is a config profile with all the configuration required to run your specific application. +***TIP:** you can use this command to find your serial device name: `ls /dev/serial/by-id/*`* -Finally create a folder called ``uros_pingpong`` into ``uros_ws/firmware/NuttX/configs/olimex-stm32-e407`` and move the defconfig file to uros_pingpong folder so you can execute: +Then, in order to launch the micro-ROS application, you need to install and open Minicom, +a text-based serial port communications program. Open a new shell, and type: ```bash -# Configure step -ros2 run micro_ros_setup configure_firmware.sh uros_pingpong +sudo minicom -D [device] -b 115200 ``` -{% include first_application_rtos_common/section_05_building_flashing_and_running.md %} +***TIP:** you can use this command to find your serial device name: `ls /dev/serial/by-id/*`. Select the one that starts with `usb-NuttX`.* + +From inside the Minicom application, press three times the `Enter` key until Nuttx Shell (NSH) appears. +Once you enter the NSH command line, type: -| RTOS | micro-ROS Client to Agent | -| :------: | ------------------------- | -| **NuttX** | **Serial** | -| FreeRTOS | Serial | -| Zephyr | USB | +```bash +uros_pingpong +``` -{% include first_application_rtos_common/section_06_agent.md %} +{% include first_application_common/test_app_rtos.md %} This completes the First micro-ROS Application on NuttX tutorial. Do you want to [go back](../) and try a different RTOS, i.e. FreeRTOS or Zephyr? diff --git a/_docs/tutorials/core/first_application_rtos/zephyr.md b/_docs/tutorials/core/first_application_rtos/zephyr.md index ebeae6c5..892e0853 100644 --- a/_docs/tutorials/core/first_application_rtos/zephyr.md +++ b/_docs/tutorials/core/first_application_rtos/zephyr.md @@ -5,70 +5,55 @@ redirect_from: - /docs/tutorials/advanced/zephyr/zephyr_getting_started/ --- -{% include first_application_rtos_common/section_01_intro.md %} +## Target platform -In this tutorial, you'll learn the use of micro-ROS with Zephyr. +In this tutorial, you'll learn the use of micro-ROS with Zephyr by testing a Ping Pong application. +{% include first_application_common/target_hardware.md %} +* [USB-to-mini-USB cable](https://www.olimex.com/Products/Components/Cables/CABLE-USB-A-MINI-1.8M/) -{% include first_application_rtos_common/section_02_target_hardware_and_workspace.md %} +{% include first_application_common/build_system.md %} ```bash # Create step ros2 run micro_ros_setup create_firmware_ws.sh zephyr olimex-stm32-e407 ``` -**NOTE for Zephyr: Make sure you have the latest version of CMake!** +{% include first_application_common/zephyr_common.md %} -```bash -sudo apt install wget -wget -O - https://apt.kitware.com/keys/kitware-archive-latest.asc 2>/dev/null | sudo apt-key add - -sudo apt install software-properties-common -sudo apt-add-repository 'deb https://apt.kitware.com/ubuntu/ bionic main' -sudo apt update -sudo apt install cmake -``` - -{% include first_application_rtos_common/section_03_configuring_firmware.md %} - -| RTOS | `[APP]` | `[OPTIONS]` | Configured app | -| :--------: | --------------- | ---------------------------- | :--------------------------------------------------------------------------------: | -| NuttX | `uros_pingpong` | | [Source](https://github.com/micro-ROS/apps/tree/dashing/examples/uros_pingpong) | -| FreeRTOS | `ping_pong` | `--transport serial --dev 3` | [Source](https://github.com/micro-ROS/freertos_apps/tree/dashing/apps/ping_pong) | -| **Zephyr** | **`ping_pong`** | **`--transport serial-usb`** | [**Source**](https://github.com/micro-ROS/zephyr_apps/tree/dashing/apps/ping_pong) | - -{% include first_application_rtos_common/section_04_demo_description.md %} - -micro-ROS apps for Zephyr are located at `firmware/zephyr_apps/apps`. In order to create a new application, create a new folder containing two files: the app code (inside a `src` folder) and the RMW configuration. You will also need some other Zephyr related files: a `CMakeLists.txt` to define the building process and a `prj.conf` where Zephyr is configured. There is a sample proyect [here](https://github.com/micro-ROS/zephyr_apps/tree/dashing/apps/ping_pong), for now, it is ok to copy them. +{% include first_application_common/config.md %} -Create a new app: +In this tutorial, we will use a USB transport (labeled as `serial-usb`) and focus on the out-of-the-box `ping_pong` +application located at `firmware/zephyr_apps/apps/ping_pong`. To execute this application with the chosen transport, +run the configuration command above by specifying the `[APP]` and `[OPTIONS]` parameters as below: ```bash -# Create your app folder and required files. Contents of these file can be found in column Sample app in table above -pushd firmware/zephyr_apps/apps -mkdir ping_pong -cd ping_pong -mkdir src -touch src/app.c app-colcon.meta -touch CMakeLists.txt prj.conf -popd +# Configure step with ping_pong app and serial-usb transport +ros2 run micro_ros_setup configure_firmware.sh ping_pong --transport serial-usb ``` +You can check the complete content of the `ping_pong` app +[here](https://github.com/micro-ROS/zephyr_apps/tree/foxy/apps/ping_pong). -The contents of the files can be found here: [app.c](https://github.com/micro-ROS/zephyr_apps/blob/dashing/apps/ping_pong/src/main.c), [app-colcon.meta](https://github.com/micro-ROS/zephyr_apps/blob/dashing/apps/ping_pong/app-colcon.meta), [CMakeLists.txt](https://github.com/micro-ROS/zephyr_apps/blob/dashing/apps/ping_pong/CMakeLists.txt) and [prj.conf](https://github.com/micro-ROS/zephyr_apps/blob/dashing/apps/ping_pong/prj.conf). +{% include first_application_common/pingpong_logic.md %} -Once the app folder is created, let's configure our new app with a UDP transport that looks for the agent on the port UDP/8888 at localhost: +The contents of the Zephyr app specific files can be found here: +[main.c](https://github.com/micro-ROS/zephyr_apps/blob/foxy/apps/ping_pong/src/main.c), +[app-colcon.meta](https://github.com/micro-ROS/zephyr_apps/blob/foxy/apps/ping_pong/app-colcon.meta), +[CMakeLists.txt](https://github.com/micro-ROS/zephyr_apps/blob/foxy/apps/ping_pong/CMakeLists.txt) +and [serial-usb.conf](https://github.com/micro-ROS/zephyr_apps/blob/foxy/apps/ping_pong/serial-usb.conf). +A thorough review of these files is illustrative of how to create a micro-ROS app in this RTOS. -```bash -# Configure step -ros2 run micro_ros_setup configure_firmware.sh ping_pong --transport serial-usb -``` +{% include first_application_common/build_and_flash.md %} + +{% include first_application_common/agent_creation.md %} + +Then, depending on the selected transport and RTOS, the board connection to the agent may differ. +In this tutorial, we're using the Olimex STM32-E407 USB connection, for which the Olimex development board is connected +to the computer using the USB OTG 2 connector (the miniUSB connector that is furthest from the Ethernet port). -{% include first_application_rtos_common/section_05_building_flashing_and_running.md %} + -| RTOS | micro-ROS Client to Agent | -| :--------: | ------------------------- | -| NuttX | Serial | -| FreeRTOS | Serial | -| **Zephyr** | **USB** | +{% include first_application_common/run_app.md %} -{% include first_application_rtos_common/section_06_agent.md %} +{% include first_application_common/test_app_rtos.md %} This completes the First micro-ROS Application on Zephyr tutorial. Do you want to [go back](../) and try a different RTOS, i.e. NuttX or FreeRTOS? diff --git a/_docs/tutorials/core/microxrcedds_rmw_configuration/index.md b/_docs/tutorials/core/microxrcedds_rmw_configuration/index.md index 6c18e97b..82e87e7f 100644 --- a/_docs/tutorials/core/microxrcedds_rmw_configuration/index.md +++ b/_docs/tutorials/core/microxrcedds_rmw_configuration/index.md @@ -59,7 +59,7 @@ The rmw-microxrcedds uses a static-memory message queue where to to keep the sub The size of this message queue could be set by the `RMW_UXRCE_MAX_HISTORY`. It is worth noting that all the aforementioned CMake flags shall be set in a `.meta` for each platform supported in [micro-ros-build](https://github.com/micro-ROS/micro-ros-build). -For example, in the [ping-pong application](https://micro-ros.github.io//docs/tutorials/core/first_application_linux/) the host [configuration file](https://github.com/micro-ROS/micro-ros-build/blob/dashing/micro_ros_setup/config/host/generic/client-host-colcon.meta) can be optimized with the following modifications: +For example, in the [ping-pong application](https://micro-ros.github.io//docs/tutorials/core/first_application_linux/) the host [configuration file](https://github.com/micro-ROS/micro-ros-build/blob/foxy/micro_ros_setup/config/host/generic/client-host-colcon.meta) can be optimized with the following modifications: ``` { @@ -84,9 +84,9 @@ For example, in the [ping-pong application](https://micro-ros.github.io//docs/tu ## Run-time configuration There are some build time parameters related to Client-to-Agent connection (such as **CONFIG_RMW_DEFAULT_UDP_PORT**, **CONFIG_RMW_DEFAULT_UDP_IP** and **CONFIG_RMW_DEFAULT_SERIAL_DEVICE**) that can be configured either at build time or at run-time. -This means that you can set them in the [configuration file](https://github.com/micro-ROS/micro-ros-build/blob/dashing/micro_ros_setup/config/host/generic/client-host-colcon.meta) mentioned above and that micro-ROS provides a user configuration API for setting some RMW and middleware parameters at run-time. +This means that you can set them in the [configuration file](https://github.com/micro-ROS/micro-ros-build/blob/foxy/micro_ros_setup/config/host/generic/client-host-colcon.meta) mentioned above and that micro-ROS provides a user configuration API for setting some RMW and middleware parameters at run-time. -The following example code shows the [API](https://github.com/micro-ROS/rmw-microxrcedds/blob/dashing/rmw_microxrcedds_c/include/rmw_uros/options.h) calls needed to set the agent's IP address, port or serial device: +The following example code shows the [API](https://github.com/micro-ROS/rmw-microxrcedds/blob/foxy/rmw_microxrcedds_c/include/rmw_uros/options.h) calls needed to set the agent's IP address, port or serial device: ```c #include diff --git a/_docs/tutorials/core/programming_rcl_rclc/index.md b/_docs/tutorials/core/programming_rcl_rclc/index.md index 6730c4dc..357a6cf4 100644 --- a/_docs/tutorials/core/programming_rcl_rclc/index.md +++ b/_docs/tutorials/core/programming_rcl_rclc/index.md @@ -79,9 +79,9 @@ if (rc != RCL_RET_OK) { 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/) -Ready to use code related to this tutorial can be found in [`micro-ROS-demos/rcl/addtwoints_server`](https://github.com/micro-ROS/micro-ROS-demos/blob/dashing/rcl/addtwoints_server/main.c) and [`micro-ROS-demos/rcl/addtwoints_client`](https://github.com/micro-ROS/micro-ROS-demos/blob/dashing/rcl/addtwoints_client/main.c) folders. +Ready to use code related to this tutorial 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. -Note: Services are not supported in rclc package yet. Therefore the configuration is described using RCL layer. +Note: Services are not supported in rclc package yet. Therefore, for the moment, the configuration is described using the RCL layer. However, we are working to port them to the RCLC soon. Starting from a code where RCL is initialized and a micro-ROS node is created, these steps are required in order to generate a service server: diff --git a/_includes/first_application_common/agent_creation.md b/_includes/first_application_common/agent_creation.md new file mode 100644 index 00000000..ed0b3f05 --- /dev/null +++ b/_includes/first_application_common/agent_creation.md @@ -0,0 +1,18 @@ +## Creating the micro-ROS agent + +The micro-ROS app is now ready to be connected to a micro-ROS agent to start talking with the rest of the ROS 2 +world. +To do that, let's first of all create a micro-ROS agent: + +```bash +# Download micro-ROS-Agent packages +ros2 run micro_ros_setup create_agent_ws.sh +``` + +Now, let's build the agent packages and, when this is done, source the installation: + +```bash +# Build step +ros2 run micro_ros_setup build_agent.sh +source install/local_setup.bash +``` \ No newline at end of file diff --git a/_includes/first_application_common/build_and_flash.md b/_includes/first_application_common/build_and_flash.md new file mode 100644 index 00000000..b9e6b19b --- /dev/null +++ b/_includes/first_application_common/build_and_flash.md @@ -0,0 +1,31 @@ +## Building the firmware + +When the configuring step ends, just build the firmware: + +```bash +# Build step +ros2 run micro_ros_setup build_firmware.sh +``` + +## Flashing the firmware + +Flashing the firmware into the platform varies across hardware platforms. +Regarding this tutorial's target platform +(**[Olimex STM32-E407](https://www.olimex.com/Products/ARM/ST/STM32-E407/open-source-hardware)**), +the JTAG interface is going to be used to flash the firmware. + +Connect the [Olimex ARM-USB-TINY-H](https://www.olimex.com/Products/ARM/JTAG/ARM-USB-TINY-H/) to the board: + + + +Make sure that the board power supply jumper (PWR_SEL) is in the 3-4 position in order to power the board from the +JTAG connector: + + + +Once you have your computer connected to the Olimex board through the JTAG adapter, run the flash step: + +```bash +# Flash step +ros2 run micro_ros_setup flash_firmware.sh +``` \ No newline at end of file diff --git a/_includes/first_application_common/build_system.md b/_includes/first_application_common/build_system.md new file mode 100644 index 00000000..cd68f91b --- /dev/null +++ b/_includes/first_application_common/build_system.md @@ -0,0 +1,53 @@ +## Installing ROS 2 and the micro-ROS build system + +First of all, install **ROS 2 Foxy FitzRoy** on your Ubuntu 20.04 LTS computer. +To do so from binaries, via Debian packages, follow the instructions detailed +[here](https://index.ros.org/doc/ros2/Installation/Foxy/Linux-Install-Debians/). + +***TIP:** Alternatively, you can use a docker container with a fresh ROS 2 Foxy installation. The one that serves +the purpose is the container run by the command:* + +```bash +docker run -it --net=host ros:foxy +``` + +Once you have a ROS 2 installation in the computer, follow these steps to install the micro-ROS build system: + +```bash +# Source the ROS 2 installation +source /opt/ros/foxy/setup.bash + +# Create a workspace and download the micro-ROS tools +mkdir microros_ws +cd microros_ws +git clone -b $ROS_DISTRO https://github.com/micro-ROS/micro-ros-build.git src/micro-ros-build + +# Update dependencies using rosdep +sudo apt update && rosdep update +rosdep install --from-path src --ignore-src -y + +# Build micro-ROS tools and source them +colcon build +source install/local_setup.bash +``` + +These instructions will setup a workspace with a ready-to-use micro-ROS build system. +This build system is in charge of downloading the required cross-compilation tools and building the apps for the +required platforms. + +The build system's workflow is a four-step procedure: + +* **Create step:** This step is in charge of downloading all the required code repositories and cross-compilation + toolchains for the specific hardware platform. Among these repositories, it will also download a collection of ready + to use micro-ROS apps. +* **Configure step:** In this step, the user can select which app is going to be cross-compiled by the toolchain. + Some other options, such as transport, agent's IP address/port (for UDP transport) or device ID (for serial connections) will be also selected in this step. +* **Build step:** Here is where the cross-compilation takes place and the platform-specific binaries are generated. +* **Flash step:** The binaries generated in the previous step are flashed onto the hardware platform memory, + in order to allow the execution of the micro-ROS app. +Further information about micro-ROS build system can be found +[here](https://github.com/micro-ROS/micro-ros-build/tree/dashing/micro_ros_setup). + +## Creating a new firmware workspace + +Once the build system is installed, let's create a firmware workspace that targets all the required code and tools: diff --git a/_includes/first_application_common/config.md b/_includes/first_application_common/config.md new file mode 100644 index 00000000..73b0e207 --- /dev/null +++ b/_includes/first_application_common/config.md @@ -0,0 +1,15 @@ +## Configuring the firmware + +The configuration step will set up the main micro-ROS options and select the desired application. +It can be executed with the following command: + +```bash +# Configure step +ros2 run micro_ros_setup configure_firmware.sh [APP] [OPTIONS] +``` + +The options available for this configuration step are: + - `--transport` or `-t`: `udp`, `serial` or any hardware-specific transport label + - `--dev` or `-d`: agent string descriptor in a serial-like transport + - `--ip` or `-i`: agent IP in a network-like transport + - `--port` or `-p`: agent port in a network-like transport \ No newline at end of file diff --git a/_includes/first_application_common/pingpong_logic.md b/_includes/first_application_common/pingpong_logic.md new file mode 100644 index 00000000..f82731a1 --- /dev/null +++ b/_includes/first_application_common/pingpong_logic.md @@ -0,0 +1,14 @@ +This example showcases a micro-ROS node with two publisher-subscriber pairs associated with a `ping` and a `pong` +topics, respectively. +The node sends a `ping` package with a unique identifier, using a `ping` publisher. +If the `ping` subscriber receives a `ping` from an external node, the `pong` publisher responds to the incoming `ping` +with a `pong`. To test that this logic is correctly functioning, we implement communication with a ROS 2 node that: + +* Listens to the topics published by the `ping` subscriber. +* Publishes a `fake_ping` package, that is received by the micro-ROS `ping` subscriber. + As a consequence, the `pong` publisher on the micro-ROS application will publish a `pong`, to signal that it received + the `fake_ping` correctly. + +The diagram below clarifies the communication flow between these entities: + +![pingpong](http://www.plantuml.com/plantuml/png/ZOwnIWGn48RxFCNFzSkoUG2vqce5jHEHi1dtWZkPa6GByNntavZY10yknMJu-ORlFwPiOjvvK-d3-M2YOR1uMKvHc93ZJafvoMML07d7h1NAE-DPWblg_na8vnwEx9OeZmzFOt1-BK7AzetJciPxCfRYVw1S0SbRLBEg1IpXPIvpUWLCmZpXIm6BS3addt7uQpu0ZQlxT1MK2r0g-7sfqbsbRrVfMrMwgbev3CDTlsqJGtJhATUmSMrMg5TKwaZUxfcttuMt7m00) \ No newline at end of file diff --git a/_includes/first_application_common/run_app.md b/_includes/first_application_common/run_app.md new file mode 100644 index 00000000..f9bb8463 --- /dev/null +++ b/_includes/first_application_common/run_app.md @@ -0,0 +1,12 @@ +## Running the micro-ROS app + +At this point, you have both the client and the agent correctly installed. + +To give micro-ROS access to the ROS 2 dataspace, you just need to run the agent: + +```bash +# Run a micro-ROS agent +ros2 run micro_ros_agent micro_ros_agent serial --dev [device] +``` + +***TIP:** you can use this command to find your serial device name: `ls /dev/serial/by-id/*`* \ No newline at end of file diff --git a/_includes/first_application_common/target_hardware.md b/_includes/first_application_common/target_hardware.md new file mode 100644 index 00000000..c6aef0a9 --- /dev/null +++ b/_includes/first_application_common/target_hardware.md @@ -0,0 +1,7 @@ +The target hardware for this tutorial is the +**[Olimex STM32-E407](https://www.olimex.com/Products/ARM/ST/STM32-E407/open-source-hardware)** evaluation board. + +The following hardware will be used: + +* [Olimex STM32-E407](https://www.olimex.com/Products/ARM/ST/STM32-E407/open-source-hardware) +* [Olimex ARM-USB-TINY-H](https://www.olimex.com/Products/ARM/JTAG/ARM-USB-TINY-H/) \ No newline at end of file diff --git a/_includes/first_application_common/test_app_host.md b/_includes/first_application_common/test_app_host.md new file mode 100644 index 00000000..bdedb098 --- /dev/null +++ b/_includes/first_application_common/test_app_host.md @@ -0,0 +1,100 @@ +## Testing the micro-ROS app + +Now, we want to check that everything is working. + +Open a new command line. We are going to listen to the `ping` topic +with ROS 2 to check whether the micro-ROS Ping Pong node is correctly publishing the expected pings: + +```bash +source /opt/ros/foxy/setup.bash + +# Subscribe to micro-ROS ping topic +ros2 topic echo /microROS/ping +``` + +You should see the topic messages published by the Ping Pong node every 5 seconds: + +``` +user@user:~$ ros2 topic echo /microROS/ping +stamp: + sec: 20 + nanosec: 867000000 +frame_id: '1344887256_1085377743' +--- +stamp: + sec: 25 + nanosec: 942000000 +frame_id: '730417256_1085377743' +--- +``` + +At this point, we know that our app is publishing pings. +Let's check if it also answers to someone else's pings. If this works, it'll publish a pong. + +So, first of all, let's subscribe with ROS 2 to the `pong` topic from a new shell +(notice that initially we don't expect to receive any pong, since none has been sent yet): + +```bash +source /opt/ros/foxy/setup.bash + +# Subscribe to micro-ROS pong topic +ros2 topic echo /microROS/pong +``` + +And now, let's publish a `fake_ping` with ROS 2 from yet another command line: + +```bash +source /opt/ros/foxy/setup.bash + +# Send a fake ping +ros2 topic pub --once /microROS/ping std_msgs/msg/Header '{frame_id: "fake_ping"}' +``` + +Now, we should see this `fake_ping` in the `ping` subscriber console, +along with the micro-ROS pings: + +``` +user@user:~$ ros2 topic echo /microROS/ping +stamp: + sec: 0 + nanosec: 0 +frame_id: fake_ping +--- +stamp: + sec: 305 + nanosec: 973000000 +frame_id: '451230256_1085377743' +--- +stamp: + sec: 310 + nanosec: 957000000 +frame_id: '2084670932_1085377743' +--- +``` + +Also, we expect that, because of having received the `fake_ping`, the micro-ROS node will answer with a `pong`: + +``` +user@user:~$ ros2 run micro_ros_demos_rcl ping_pong +Ping send seq 1706097268_1085377743 +Ping send seq 181171802_1085377743 +Ping send seq 1385567526_1085377743 +Ping send seq 926583793_1085377743 +Ping send seq 1831510138_1085377743 +Ping received with seq fake_ping. Answering. +Ping send seq 1508705084_1085377743 +Ping send seq 1702133625_1085377743 +Ping send seq 176104820_1085377743 +``` + +As a consequence, in the `pong` subscriber console, +we should see the micro-ROS app answer to our `fake_ping`: + +``` +user@user:~$ ros2 topic echo /microROS/pong +stamp: + sec: 0 + nanosec: 0 +frame_id: fake_ping +--- +``` \ No newline at end of file diff --git a/_includes/first_application_common/test_app_rtos.md b/_includes/first_application_common/test_app_rtos.md new file mode 100644 index 00000000..30b49982 --- /dev/null +++ b/_includes/first_application_common/test_app_rtos.md @@ -0,0 +1,111 @@ +## Testing the micro-ROS app + +At this point, the micro-ROS app is built and flashed and the board is connected to a micro-ROS agent. +We now want to check that everything is working. + +Open a new command line. We are going to listen to the `ping` topic +with ROS 2 to check whether the micro-ROS Ping Pong node is correctly publishing the expected pings: + +```bash +source /opt/ros/foxy/setup.bash + +# Subscribe to micro-ROS ping topic +ros2 topic echo /microROS/ping +``` + +You should see the topic messages published by the Ping Pong node every 5 seconds: + +``` +user@user:~$ ros2 topic echo /microROS/ping +stamp: + sec: 20 + nanosec: 867000000 +frame_id: '1344887256_1085377743' +--- +stamp: + sec: 25 + nanosec: 942000000 +frame_id: '730417256_1085377743' +--- +``` + +At this point, we know that our micro-ROS app is publishing pings. +Let's check if it also answers to someone else's pings. If this works, it'll publish a pong. + +So, first of all, let's subscribe with ROS 2 to the `pong` topic from a new shell +(notice that initially we don't expect to receive any pong, since none has been sent yet): + +```bash +source /opt/ros/foxy/setup.bash + +# Subscribe to micro-ROS pong topic +ros2 topic echo /microROS/pong +``` + +And now, let's publish a `fake_ping` with ROS 2 from yet another command line: + +```bash +source /opt/ros/foxy/setup.bash + +# Send a fake ping +ros2 topic pub --once /microROS/ping std_msgs/msg/Header '{frame_id: "fake_ping"}' +``` + +Now, we should see this `fake_ping` in the `ping` subscriber console, +along with the board's pings: + +``` +user@user:~$ ros2 topic echo /microROS/ping +stamp: + sec: 0 + nanosec: 0 +frame_id: fake_ping +--- +stamp: + sec: 305 + nanosec: 973000000 +frame_id: '451230256_1085377743' +--- +stamp: + sec: 310 + nanosec: 957000000 +frame_id: '2084670932_1085377743' +--- +``` + +Also, we expect that, because of having received the `fake_ping`, the micro-ROS `pong` publisher will answer with a +`pong`. As a consequence, in the `pong` subscriber console, +we should see the board's answer to our `fake_ping`: + +``` +user@user:~$ ros2 topic echo /microROS/pong +stamp: + sec: 0 + nanosec: 0 +frame_id: fake_ping +--- +``` + + +### Multiple Ping Pong nodes + +If you have multiple boards, by connecting them to the same ROS 2 space it is possible to see them interacting. +In the case you only have one board, it is possible to see your micro-ROS ping pong app running on hardware interacting +with the [ping pong app from the Linux tutorial](../../first_application_linux). When multiple ping pong nodes coexists, +it is possible to see their output like this micro-ROS for Linux app: + +``` +Ping send seq 1711620172_1742614911 <---- This micro-ROS node sends a ping with ping ID "1711620172" and node ID "1742614911" +Pong for seq 1711620172_1742614911 (1) <---- The first mate pongs my ping +Pong for seq 1711620172_1742614911 (2) <---- The second mate pongs my ping +Pong for seq 1711620172_1742614911 (3) <---- The third mate pongs my ping +Ping received with seq 1845948271_546591567. Answering. <---- A ping is received from a mate identified as "546591567", let's pong it. +Ping received with seq 232977719_1681483056. Answering. <---- A ping is received from a mate identified as "1681483056", let's pong it. +Ping received with seq 1134264528_1107823050. Answering. <---- A ping is received from a mate identified as "1107823050", let's pong it. +Ping send seq 324239260_1742614911 +Pong for seq 324239260_1742614911 (1) +Pong for seq 324239260_1742614911 (2) +Pong for seq 324239260_1742614911 (3) +Ping received with seq 1435780593_546591567. Answering. +Ping received with seq 2034268578_1681483056. Answering. +``` \ No newline at end of file diff --git a/_includes/first_application_common/zephyr_common.md b/_includes/first_application_common/zephyr_common.md new file mode 100644 index 00000000..646d4386 --- /dev/null +++ b/_includes/first_application_common/zephyr_common.md @@ -0,0 +1,17 @@ +Once the command is executed, a folder named `firmware` must be present in your workspace. + +This step is in charge, among other things, of downloading a set of micro-ROS apps for the specific platform you are +addressing. +In the case of Zephyr, these are located at `firmware/zephyr_apps/apps`. +Each app is represented by a folder containing the following files: + +* `src/main.c`: This file contains the logic of the application. +* `app-colcon.meta`: This file contains the micro-ROS app specific colcon configuration. Detailed info on how to + configure the RMW via this file can be found + [here](https://micro-ros.github.io/docs/tutorials/core/microxrcedds_rmw_configuration/). +* `CMakeLists.txt`: This is the CMake file containing the script to compile the application. +* `.conf`: This is a Zephyr specific and transport-dependent app configuration file. +`` can be `serial`, `serial-usb` and `host-udp`. + +For the user to create its custom application, a folder `` will need to be registered in this location, +containing the four files just described. \ No newline at end of file diff --git a/_includes/first_application_rtos_common/section_01_intro.md b/_includes/first_application_rtos_common/section_01_intro.md deleted file mode 100644 index 7962bcf6..00000000 --- a/_includes/first_application_rtos_common/section_01_intro.md +++ /dev/null @@ -1,5 +0,0 @@ -After you have completed the [First micro-ROS application on Linux tutorial](../../first_application_linux), you are now ready to flash a microcontroller with this application based on a Real-Time Operating System (RTOS). Micro-ROS currently supports three different RTOS, namely NuttX, FreeRTOS, and Zephyr. - -To follow this tutorial, it is assumed that the user is already familiar with the **[First micro-ROS Application on an RTOS](https://micro-ros.github.io/docs/tutorials/core/first_application_rtos/)** tutorial. The target app in this tutorial is the same ping pong app. Another requirement is that the user has a basic knowledge of micro-ROS and ROS 2. - -The target app in this tutorial is the same ping pong app. Another requirement is that the user has a basic knowledge of micro-ROS and ROS 2. \ No newline at end of file diff --git a/_includes/first_application_rtos_common/section_02_target_hardware_and_workspace.md b/_includes/first_application_rtos_common/section_02_target_hardware_and_workspace.md deleted file mode 100644 index 7eca3215..00000000 --- a/_includes/first_application_rtos_common/section_02_target_hardware_and_workspace.md +++ /dev/null @@ -1,24 +0,0 @@ -The target hardware for this tutorial is the **[Olimex STM32-E407](https://www.olimex.com/Products/ARM/ST/STM32-E407/open-source-hardware)** evaluation board. - -First of all, make sure that you have a **ROS 2** environment and the **micro-ROS build system** installed in the computer. If not, please check the [**First micro-ROS application on Linux**](../../first_application_linux/) tutorial in order to learn how to start with micro-ROS. - -The build system's workflow in the case of embedded systems is a four-step procedure: - -* **Create step:** This step is in charge of downloading all the required code repositories and cross-compilation toolchains for the specific hardware platform. Among these repositories, it will also download a collection of ready to use micro-ROS apps. -* **Configure step:** In this step, the user can select which app is going to be cross-compiled by the toolchain. Some other options, such as transport, agent address or port will be also selected in this step. -* **Build step:** Here is where the cross-compilation takes place and the platform-specific binaries are generated. -* **Flash step:** The binaries generated in the previous step are flashed onto the hardware platform memory, in order to allow the execution of the micro-ROS app. - -Further information about micro-ROS build system can be found [here](https://github.com/micro-ROS/micro-ros-build/tree/dashing/micro_ros_setup). - -## Required hardware - -The following hardware will be used: - -* [Olimex STM32-E407](https://www.olimex.com/Products/ARM/ST/STM32-E407/open-source-hardware) -* [Olimex ARM-USB-TINY-H](https://www.olimex.com/Products/ARM/JTAG/ARM-USB-TINY-H/) -* [USB-Serial Cable Female](https://www.olimex.com/Products/Components/Cables/USB-Serial-Cable/USB-Serial-Cable-F/) - -## Step 1: Creating a new firmware workspace - -In order to accomplish the first step, a new firmware workspace can be created using the command: diff --git a/_includes/first_application_rtos_common/section_03_configuring_firmware.md b/_includes/first_application_rtos_common/section_03_configuring_firmware.md deleted file mode 100644 index b2bd15f1..00000000 --- a/_includes/first_application_rtos_common/section_03_configuring_firmware.md +++ /dev/null @@ -1,19 +0,0 @@ -Once the command is executed, a folder named `firmware` must be present in your workspace. - -## Step 2: Configuring the firmware - -The configuration step will set up the main micro-ROS options and will select the required application. It can be executed with the following command: - -```bash -# Configure step -ros2 run micro_ros_setup configure_firmware.sh [APP] [OPTIONS] -``` - -The options available for this configuration step are: - - `--transport` or `-t`: `udp`, `tcp`, `serial` or any hardware-specific transport label - - `--dev` or `-d`: agent string descriptor in a serial-like transport - - `--ip` or `-i`: agent IP in a network-like transport - - `--port` or `-p`: agent port in a network-like transport - -At this point, in order to build your first micro-ROS application you can use the following example as a reference: - diff --git a/_includes/first_application_rtos_common/section_04_demo_description.md b/_includes/first_application_rtos_common/section_04_demo_description.md deleted file mode 100644 index f88493fe..00000000 --- a/_includes/first_application_rtos_common/section_04_demo_description.md +++ /dev/null @@ -1,65 +0,0 @@ -These reference examples consist in the ping-pong app, from the [First micro-ROS application on Linux](../../first_application_linux/) tutorial. In this app, a micro-ROS node sends a ping message with a unique identifier using a publisher. The message is received by pong subscribers (in another ROS 2 or micro-ROS node). The ping-pong node will also answer to pings received from other nodes with a pong message, as elucidated by the diagram below: - -![pingpong](http://www.plantuml.com/plantuml/png/ZOwnIWGn48RxFCNFzSkoUG2vqce5jHEHi1dtWZkPa6GByNntavZY10yknMJu-ORlFwPiOjvvK-d3-M2YOR1uMKvHc93ZJafvoMML07d7h1NAE-DPWblg_na8vnwEx9OeZmzFOt1-BK7AzetJciPxCfRYVw1S0SbRLBEg1IpXPIvpUWLCmZpXIm6BS3addt7uQpu0ZQlxT1MK2r0g-7sfqbsbRrVfMrMwgbev3CDTlsqJGtJhATUmSMrMg5TKwaZUxfcttuMt7m00) - -The files that a micro-ROS app needs are RTOS-dependent, but they differ only in the includes and signature of the main function. The remaining lines are RTOS-independent micro-ROS code. The table below clarifies which files are required for creating a new app in the three RTOSes supported: - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
FileDescription
Nuttxapp.cmicro-ROS app code.Sample app
KconfigNuttx Kconfig configuration
Make.defsNuttx build system definitions
MakefileNuttx specific app build script
FreeRTOSapp.cmicro-ROS app code.Sample app
app-colcon.metamicro-ROS app specific colcon configuration. Detailed info here.
Zephyrsrc/app.cmicro-ROS app code.Sample app
app-colcon.metamicro-ROS app specific colcon configuration. Detailed info here.
CMakeLists.txtCMake file for Zephyr app building
prj.confZephyr specific app configuration
- -The following steps are RTOS-specific commands for creating a new app once the firmware folder is created inside `microros_ws`. Please refer to the table above in order to get an idea of the content that the RTOS-specific files described below needed to create your own app should contain. diff --git a/_includes/first_application_rtos_common/section_05_building_flashing_and_running.md b/_includes/first_application_rtos_common/section_05_building_flashing_and_running.md deleted file mode 100644 index fd5c39ec..00000000 --- a/_includes/first_application_rtos_common/section_05_building_flashing_and_running.md +++ /dev/null @@ -1,44 +0,0 @@ -## Step 3: Building the firmware - -When the configuring step ends, just build the firmware: - -```bash -# Build step -ros2 run micro_ros_setup build_firmware.sh -``` - -## Step 4: Flashing the firmware - -Flashing the firmware into the platform may vary across hardware platforms. Regarding this tutorial's target platform (**[Olimex STM32-E407](https://www.olimex.com/Products/ARM/ST/STM32-E407/open-source-hardware)**), JTAG interface is going to be used to flash the firmware. - -Connect [Olimex ARM-USB-TINY-H](https://www.olimex.com/Products/ARM/JTAG/ARM-USB-TINY-H/) to the board: - - - -Make sure that the board power supply jumper (PWR_SEL) is in the 3-4 position in order to power the board from the JTAG connector: - - - -Once you have your computer connected to the Olimex board through the JTAG adapter, run the flash step: - -```bash -# Flash step -ros2 run micro_ros_setup flash_firmware.sh -``` - -## Running the micro-ROS app - -The micro-ROS app is ready to connect to a micro-ROS-Agent and start talking with the rest of the ROS 2 world. - -First of all, create and build a micro-ROS agent: - -```bash -# Download micro-ROS-Agent packages -ros2 run micro_ros_setup create_agent_ws.sh - -# Build micro-ROS-Agent packages, this may take a while. -colcon build -source install/local_setup.bash -``` - -Then, depending on the selected transport and RTOS, the board connection to the agent may differ: diff --git a/_includes/first_application_rtos_common/section_06_agent.md b/_includes/first_application_rtos_common/section_06_agent.md deleted file mode 100644 index ef9ada0f..00000000 --- a/_includes/first_application_rtos_common/section_06_agent.md +++ /dev/null @@ -1,125 +0,0 @@ ---- - -### Olimex STM32-E407 Serial connection - -Olimex development board is connected to the computer using the usb to serial cable: - - - -***TIP:** Color codes are applicable to [this cable](https://www.olimex.com/Products/Components/Cables/USB-Serial-Cable/USB-Serial-Cable-F/). Make sure to match Olimex Rx with Cable Tx and vice-versa. Remember GND!* - ---- - -### Olimex STM32-E407 USB connection - -Olimex development board is connected to the computer using the USB OTG 2 connector (the miniUSB connector that is furthest from the Ethernet port). - ---- - -Then run the agent: - -```bash -# Run a micro-ROS agent -ros2 run micro_ros_agent micro_ros_agent serial --dev [device] -``` - -***TIP:** you can use this command to find your serial device name: `ls /dev/serial/by-id/*`* - -## Test the sample micro-ROS app behaviour - -Once the micro-ROS app is built and flashed, and the board is connected to a micro-ROS agent, let's check that everything is working in a new command line. -We are going to listen to ping topic to check whether the Ping Pong node is publishing its own ping messages: - -```bash -source /opt/ros/$ROS_DISTRO/setup.bash - -# Subscribe to micro-ROS ping topic -ros2 topic echo /microROS/ping -``` - -You should see the topic messages published by the Ping Pong node every 5 seconds: - -``` -user@user:~$ ros2 topic echo /microROS/ping -stamp: - sec: 20 - nanosec: 867000000 -frame_id: '1344887256_1085377743' ---- -stamp: - sec: 25 - nanosec: 942000000 -frame_id: '730417256_1085377743' ---- -``` - -On another command line, let's subscribe to the pong topic - -```bash -source /opt/ros/$ROS_DISTRO/setup.bash - -# Subscribe to micro-ROS pong topic -ros2 topic echo /microROS/pong -``` - -At this point, we know that our app is publishing pings. Let's check if it also answers to someone else pings in a new command line: - -```bash -source /opt/ros/$ROS_DISTRO/setup.bash - -# Send a fake ping -ros2 topic pub --once /microROS/ping std_msgs/msg/Header '{frame_id: "fake_ping"}' -``` - -Now, we should see on the ping subscriber our fake ping along with the board pings: - -``` -user@user:~$ ros2 topic echo /microROS/ping -stamp: - sec: 0 - nanosec: 0 -frame_id: fake_ping ---- -stamp: - sec: 305 - nanosec: 973000000 -frame_id: '451230256_1085377743' ---- -stamp: - sec: 310 - nanosec: 957000000 -frame_id: '2084670932_1085377743' ---- -``` - -And in the pong subscriber, we should see the board's answer to our fake ping: - -``` -user@user:~$ ros2 topic echo /microROS/pong -stamp: - sec: 0 - nanosec: 0 -frame_id: fake_ping ---- -``` - -### Multiple Ping Pong nodes - -If you have multiple boards, by connecting them to the same ROS 2 space it is possible to see them interacting. In the case you only have one board, it is possible to see your micro-ROS ping pong app running on hardware interacting with the [ping pong app from the Linux tutorial](../../first_application_linux). When multiple ping pong nodes coexists, it is possible to see their output like this micro-ROS for Linux app: - -``` -UDP mode => ip: 127.0.0.1 - port: 8888 -Ping send seq 1711620172_1742614911 <---- This micro-ROS node sends a ping with ping ID "1711620172" and node ID "1742614911" -Pong for seq 1711620172_1742614911 (1) <---- The first mate pongs my ping -Pong for seq 1711620172_1742614911 (2) <---- The second mate pongs my ping -Pong for seq 1711620172_1742614911 (3) <---- The third mate pongs my ping -Ping received with seq 1845948271_546591567. Answering. <---- A ping is received from a mate identified as "546591567", let's pong it. -Ping received with seq 232977719_1681483056. Answering. <---- A ping is received from a mate identified as "1681483056", let's pong it. -Ping received with seq 1134264528_1107823050. Answering. <---- A ping is received from a mate identified as "1107823050", let's pong it. -Ping send seq 324239260_1742614911 -Pong for seq 324239260_1742614911 (1) -Pong for seq 324239260_1742614911 (2) -Pong for seq 324239260_1742614911 (3) -Ping received with seq 1435780593_546591567. Answering. -Ping received with seq 2034268578_1681483056. Answering. -``` \ No newline at end of file diff --git a/_posts/2020-07-17-EWG.md b/_posts/2020-07-17-EWG.md new file mode 100644 index 00000000..55a168de --- /dev/null +++ b/_posts/2020-07-17-EWG.md @@ -0,0 +1,23 @@ +--- +title: The ROS 2 Embedded Working Group is back +author: francesca-finocchiaro +--- + +The OFERA consortium is glad to announce that the ROS 2 Embedded Working Group meetings are back! + +Starting the next 22nd of July, at 5 pm CEST (8 am PDT) they'll be retaken with a 4-weekly periodicity and with a +special focus on micro-ROS and its middleware, Micro XRCE-DDS. + +The community is kindly invited to participate and to bring any micro-ROS related issues, doubts and projects to this +platform. + +The proper way to be regularly updated and informed regarding the WG activities is to register to the dedicated Slack +chat. To do so, go to the [micro-ROS main page](https://micro-ros.github.io/) and get an invitation by subscribing +with your email address on the right bottom of the main page. + +Please find [here](http://meet.google.com/saf-gjix-swf) the link to the Google meet and +[here](https://docs.google.com/document/d/1hGxwpuHDPCyEYHBCd5IIgvoFGJgkC5WKI12ghEfqwXg/edit?usp=sharing) the agenda for +the first meeting. +Everyone is welcome to add items that they consider relevant in the form of comments. + +micro-ROS display