You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This tutorial aims to create a new micro-ROS application on **[Olimex STM32-E407](https://www.olimex.com/Products/ARM/ST/STM32-E407/open-source-hardware)** evaluation board with **[FreeRTOS RTOS](https://www.freertos.org/)**
First of all make sure that you have a **ROS 2** installation.
28
+
29
+
***TIP:** if you are familiar with Docker containers, this image may be useful: [ros:dashing](https://hub.docker.com/layers/ros/library/ros/dashing/images/sha256-b796c14ea663537129897769aa6c715a851ca08dffd4875ef2ecaa31a4dbd431?context=explore)*
30
+
31
+
On the **ROS 2** installation open a command line and follow these steps:
32
+
33
+
```bash
34
+
# Source the ROS 2 installation
35
+
source /opt/ros/$ROS_DISTRO/setup.bash
36
+
37
+
# Create a workspace and download the micro-ROS tools
Now, let's create a firmware workspace that targets all the required code and tools for Olimex development board and FreeRTOS:
53
+
54
+
```bash
55
+
# Create step
56
+
ros2 run micro_ros_setup create_firmware_ws.sh freertos olimex-stm32-e407
57
+
```
58
+
59
+
Now you have all the required tools to crosscompile micro-ROS and FreeRTOS for Olimex STM32-E407 development board. At this point, you must know that the micro-ROS build system is a four-step workflow:
60
+
61
+
<!-- TODO (pablogs9): Remove and link to build-system tutorial when done -->
62
+
1.**Create**: retrieves all the required packages for a specific RTOS and hardware platform.
63
+
2.**Configure**: configures the downloaded packages with options such as the micro-ROS application, the selected transport layer or the micro-ROS agent IP address (in network transports).
64
+
3.**Build**: generates a binary file ready for being loaded in the hardware.
65
+
4.**Flash**: load the micro-ROS software in the hardware.
66
+
67
+
micro-ROS apps for Olimex + FreeRTOS are located at `firmware/freertos_apps/apps`. In order to create a new application, create a new folder containing two files: the app code and the RMW configuration.
68
+
69
+
```bash
70
+
# Creating a new app
71
+
cd firmware/freertos_apps/apps
72
+
mkdir my_brand_new_app
73
+
cd my_brand_new_app
74
+
touch app.c app-colcon.meta
75
+
```
76
+
77
+
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:
To start creating this app, lets configure the RMW with the required static memory. You can read more about RMW and Micro XRCE-DDS Configuration [here](/docs/tutorials/basic/microxrcedds_rmw_configuration/) The `app-colcon.meta` should look like:
82
+
83
+
```
84
+
{
85
+
"names": {
86
+
"rmw_microxrcedds": {
87
+
"cmake-args": [
88
+
"-DRMW_UXRCE_MAX_NODES=1",
89
+
"-DRMW_UXRCE_MAX_PUBLISHERS=2",
90
+
"-DRMW_UXRCE_MAX_SUBSCRIPTIONS=2",
91
+
"-DRMW_UXRCE_MAX_SERVICES=0",
92
+
"-DRMW_UXRCE_MAX_CLIENTS=0",
93
+
"-DRMW_UXRCE_MAX_HISTORY=4",
94
+
]
95
+
}
96
+
}
97
+
}
98
+
```
99
+
100
+
Meanwhile `app.c` should look like the following code:
101
+
102
+
```c
103
+
#include<allocators.h>
104
+
105
+
#include<rcl/rcl.h>
106
+
#include<rcl_action/rcl_action.h>
107
+
#include<rcl/error_handling.h>
108
+
#include"rosidl_generator_c/string_functions.h"
109
+
#include<std_msgs/msg/header.h>
110
+
111
+
#include<rmw_uros/options.h>
112
+
113
+
#include<stdio.h>
114
+
#include<unistd.h>
115
+
#include<pthread.h>
116
+
117
+
#defineSTRING_BUFFER_LEN 100
118
+
119
+
// FreeRTOS thread for triggering a publication guard condition
Once the new folder is created, let's configure our new app with a serial transport on UART 3:
261
+
262
+
```bash
263
+
# Configure step
264
+
ros2 run micro_ros_setup configure_firmware.sh my_brand_new_app --transport serial --dev 3
265
+
```
266
+
267
+
When the configuring step ends, just build the firmware:
268
+
269
+
```bash
270
+
# Build step
271
+
ros2 run micro_ros_setup build_firmware.sh
272
+
```
273
+
274
+
Once the build has successfully ended, let's power and connect the board. First, connect Olimex ARM-USB-TINY-H JTAG programmer to the board's JTAG port:
***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!*
307
+
308
+
Then run the agent:
309
+
310
+
```bash
311
+
# Run a micro-ROS agent
312
+
ros2 run micro_ros_agent micro_ros_agent serial --dev [device]
313
+
```
314
+
315
+
***TIP:** you can use this command to find your serial device name: `ls /dev/serial/by-id/*`*
316
+
317
+
And finally, let's check that everything is working. We are going to listen to ping topic to check whether the Ping Pong node is publishing its own pings
318
+
319
+
```bash
320
+
# Subscribe to micro-ROS ping topic
321
+
ros2 topic echo /microROS/ping
322
+
```
323
+
324
+
You should see the topic messages published by the Ping Pong node every 5 seconds:
0 commit comments