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
***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)*
46
39
47
-
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.
40
+
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.
48
41
49
42
The build system's workflow is a four-step procedure:
50
43
@@ -63,87 +56,87 @@ Once the build system is installed, let's create a firmware workspace that targe
63
56
ros2 run micro_ros_setup create_firmware_ws.sh host
64
57
```
65
58
66
-
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).
59
+
This step is in charge, among other things, of creating a set of micro-ROS apps for Linux, that are located at
60
+
`src/uros/micro-ROS-demos/rcl`. Each app is represented by a folder containing two files: a `.c` file with the app code
61
+
and the CMake file. The former contains the logic of the application, whereas the latter contains the script to
62
+
compile it.
67
63
68
-
```bash
69
-
# Creating a new app
70
-
pushd src/uros/micro-ROS-demos/rcl/
71
-
mkdir ping_pong
72
-
cd ping_pong
73
-
touch app.c CMakeLists.txt
74
-
popd
75
-
```
76
-
77
-
Don't forget to register your app in `src/uros/micro-ROS-demos/rcl/CMakeLists.txt` by adding the following line:
64
+
For the user to create its custom application, a folder `<my_app>` will need to be registered in this location,
65
+
containing the two files just described. Also, any such new application folder needs to be registered in
66
+
`src/uros/micro-ROS-demos/rcl/CMakeLists.txt` by adding the following line:
78
67
79
68
```
80
-
export_executable(ping_pong)
69
+
export_executable(<my_app>)
81
70
```
82
71
83
-
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:
72
+
In this tutorial, we will focus on the out-of-the-box `ping_pong` application located at
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.
88
-
89
-
**For more in depth learning about RCL and RCLC programming [check this section](https://micro-ros.github.io/docs/tutorials/core/programming_rcl_rclc/).**
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:
149
+
## Testing the micro-ROS app
150
+
151
+
Now, we want to check that everything is working.
152
+
153
+
Open another command line. We are going to listen to the `ping` topic
154
+
with ROS 2 to check whether the micro-ROS Ping Pong node is correctly publishing the expected pings:
And in the pong subscriber, we should see the board's answer to our fake ping:
223
+
Also, we expect that, because of having received the `fake_ping`, the micro-ROS `pong` publisher will answer with a
224
+
`pong`. As a consequence, in the `pong` subscriber console (the third that we opened),
225
+
we should see the micro-ROS app answer to our `fake_ping`:
221
226
222
227
```
223
228
user@user:~$ ros2 topic echo /microROS/pong
@@ -228,18 +233,20 @@ frame_id: fake_ping
228
233
---
229
234
```
230
235
231
-
232
236
## Multiple Ping Pong nodes
233
237
234
-
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:
238
+
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
239
+
test some multi-node micro-ROS apps.
240
+
So, with the same micro-ROS agent of the last section, let's open four different command lines and run the following on
241
+
each:
235
242
236
243
```bash
237
244
cd microros_ws
238
245
239
246
source /opt/ros/$ROS_DISTRO/setup.bash
240
247
source install/local_setup.bash
241
248
242
-
ros2 run micro_ros_demos_rcl my_brand_new_app
249
+
ros2 run micro_ros_demos_rcl ping_pong
243
250
```
244
251
245
252
As soon as all micro-ROS nodes are up and connected to the micro-ROS agent you will see them interacting:
@@ -248,9 +255,9 @@ As soon as all micro-ROS nodes are up and connected to the micro-ROS agent you w
248
255
user@user$ ros2 run micro_ros_demos_rcl my_brand_new_app
249
256
UDP mode => ip: 127.0.0.1 - port: 8888
250
257
Ping send seq 1711620172_1742614911 <---- This micro-ROS node sends a ping with ping ID "1711620172" and node ID "1742614911"
251
-
Pong for seq 1711620172_1742614911 (1) <---- The first mate pongs my ping
252
-
Pong for seq 1711620172_1742614911 (2) <---- The second mate pongs my ping
253
-
Pong for seq 1711620172_1742614911 (3) <---- The third mate pongs my ping
258
+
Pong for seq 1711620172_1742614911 (1) <---- The first mate pongs my ping
259
+
Pong for seq 1711620172_1742614911 (2) <---- The second mate pongs my ping
260
+
Pong for seq 1711620172_1742614911 (3) <---- The third mate pongs my ping
254
261
Ping received with seq 1845948271_546591567. Answering. <---- A ping is received from a mate identified as "546591567", let's pong it.
255
262
Ping received with seq 232977719_1681483056. Answering. <---- A ping is received from a mate identified as "1681483056", let's pong it.
256
263
Ping received with seq 1134264528_1107823050. Answering. <---- A ping is received from a mate identified as "1107823050", let's pong it.
0 commit comments