@@ -5,10 +5,10 @@ permalink: /docs/tutorials/core/first_application_linux/
55
66## Target platform
77
8- This tutorial teaches you how to try a first micro-ROS application on Linux, by testing a Ping Pong application.
8+ In this tutorial, you’ll learn the use of micro-ROS with Linux by testing a Ping Pong application.
99In the follow-up tutorial [ * First micro-ROS application on an RTOS* ] ( /docs/tutorials/core/first_application_rtos/ ) ,
1010you'll learn how to build and bring this application on a microcontroller running the RTOS NuttX, FreeRTOS, or Zephyr.
11- Finally in the tutorial [ * Zephyr Emulator* ] ( /docs/tutorials/advanced/zephyr_emulator/ ) you'll learn how to test
11+ Finally, in the tutorial [ * Zephyr Emulator* ] ( /docs/tutorials/advanced/zephyr_emulator/ ) you'll learn how to test
1212a micro-ROS application on a Zephyr emulator.
1313
1414{% include first_application_common/build_system.md %}
@@ -24,7 +24,7 @@ This step is in charge, among other things, of creating a set of micro-ROS apps
2424` src/uros/micro-ROS-demos/rcl ` .
2525Each app is represented by a folder containing the following files:
2626
27- * ` app .c` : The former contains the logic of the application.
27+ * ` main .c` : This file contains the logic of the application.
2828* ` CMakeLists.txt ` : This is the CMake file containing the script to compile the application.
2929
3030For the user to create its custom application, a folder ` <my_app> ` will need to be registered in this location,
@@ -43,9 +43,10 @@ You can check the complete content of this app
4343
4444{% include first_application_common/pingpong_logic.md %}
4545
46- The app logic of this demo is contained in
47- [ ` app.c ` ] ( https://github.com/micro-ROS/micro-ROS-demos/blob/dashing/rcl/ping_pong/main.c ) .
48- A thorough review of this file is illustrative of how to create a micro-ROS publisher or subscriber.
46+ The contents of the host app specific files can be found here:
47+ [ main.c] ( https://github.com/micro-ROS/micro-ROS-demos/blob/dashing/rcl/ping_pong/main.c ) and
48+ [ CMakeLists.txt] ( https://github.com/micro-ROS/micro-ROS-demos/blob/dashing/rcl/ping_pong/CMakeLists.txt ) .
49+ A thorough review of these files is illustrative of how to create a micro-ROS app in this RTOS.
4950
5051## Building the firmware
5152
@@ -83,118 +84,19 @@ source install/local_setup.bash
8384ros2 run micro_ros_demos_rcl ping_pong
8485```
8586
86- ## Testing the micro-ROS app
87-
88- Now, we want to check that everything is working.
89-
90- Open a new command line. We are going to listen to the ` ping ` topic
91- with ROS 2 to check whether the micro-ROS Ping Pong node is correctly publishing the expected pings:
92-
93- ``` bash
94- source /opt/ros/dashing/setup.bash
95-
96- # Subscribe to micro-ROS ping topic
97- ros2 topic echo /microROS/ping
98- ```
99-
100- You should see the topic messages published by the Ping Pong node every 5 seconds:
101-
102- ```
103- user@user:~$ ros2 topic echo /microROS/ping
104- stamp:
105- sec: 20
106- nanosec: 867000000
107- frame_id: '1344887256_1085377743'
108- ---
109- stamp:
110- sec: 25
111- nanosec: 942000000
112- frame_id: '730417256_1085377743'
113- ---
114- ```
115-
116- At this point, we know that our Linux app is publishing pings.
117- Let's check if it also answers to someone else's pings. If this works, it'll publish a pong.
118-
119- So, first of all, let's subscribe with ROS 2 to the ` pong ` topic
120- (notice that initially we don't expect to receive any pong, since none has been sent yet):
121-
122- ``` bash
123- source /opt/ros/dashing/setup.bash
124-
125- # Subscribe to micro-ROS pong topic
126- ros2 topic echo /microROS/pong
127- ```
128-
129- And now, let's publish a ` fake_ping ` with ROS 2 from yet another command line:
130-
131- ``` bash
132- source /opt/ros/dashing/setup.bash
133-
134- # Send a fake ping
135- ros2 topic pub --once /microROS/ping std_msgs/msg/Header ' {frame_id: "fake_ping"}'
136- ```
137-
138- Now, we should see this ` fake_ping ` in the ` ping ` subscriber console (the second that we opened),
139- along with the micro-ROS pings:
140-
141- ```
142- user@user:~$ ros2 topic echo /microROS/ping
143- stamp:
144- sec: 0
145- nanosec: 0
146- frame_id: fake_ping
147- ---
148- stamp:
149- sec: 305
150- nanosec: 973000000
151- frame_id: '451230256_1085377743'
152- ---
153- stamp:
154- sec: 310
155- nanosec: 957000000
156- frame_id: '2084670932_1085377743'
157- ---
158- ```
159-
160- Also, we expect that, because of having received the ` fake_ping ` , the micro-ROS node will answer with a ` pong ` :
161-
162- ```
163- user@user:~$ ros2 run micro_ros_demos_rcl ping_pong
164- Ping send seq 1706097268_1085377743
165- Ping send seq 181171802_1085377743
166- Ping send seq 1385567526_1085377743
167- Ping send seq 926583793_1085377743
168- Ping send seq 1831510138_1085377743
169- Ping received with seq fake_ping. Answering.
170- Ping send seq 1508705084_1085377743
171- Ping send seq 1702133625_1085377743
172- Ping send seq 176104820_1085377743
173- ```
174-
175- As a consequence, in the ` pong ` subscriber console (the third that we opened),
176- we should see the micro-ROS app answer to our ` fake_ping ` :
177-
178- ```
179- user@user:~$ ros2 topic echo /microROS/pong
180- stamp:
181- sec: 0
182- nanosec: 0
183- frame_id: fake_ping
184- ---
185- ```
87+ {% include first_application_common/test_app_host.md %}
18688
18789## Multiple Ping Pong nodes
18890
189- 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
91+ 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
19092test some multi-node micro-ROS apps.
19193So, with the same micro-ROS agent of the last section, let's open four different command lines and run the following on
19294each:
19395
19496``` bash
19597cd microros_ws
19698
197- source /opt/ros/$ROS_DISTRO /setup.bash
99+ source /opt/ros/dashing /setup.bash
198100source install/local_setup.bash
199101
200102ros2 run micro_ros_demos_rcl ping_pong
@@ -203,7 +105,7 @@ ros2 run micro_ros_demos_rcl ping_pong
203105As soon as all micro-ROS nodes are up and connected to the micro-ROS agent you will see them interacting:
204106
205107```
206- user@user$ ros2 run micro_ros_demos_rcl my_brand_new_app
108+ user@user:~ $ ros2 run micro_ros_demos_rcl ping_pong
207109UDP mode => ip: 127.0.0.1 - port: 8888
208110Ping send seq 1711620172_1742614911 <---- This micro-ROS node sends a ping with ping ID "1711620172" and node ID "1742614911"
209111Pong for seq 1711620172_1742614911 (1) <---- The first mate pongs my ping
0 commit comments