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
{{ message }}
Repository navigation
Commit 133634a
Browse filesBrowse the repository at this point in the historyBrowse files
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.
7
7
8
+
## Installing ROS 2 and the micro-ROS build system
8
9
9
-
## Adding a new micro-ROS app
10
+
First of all, let's take a Ubuntu 18.04 LTS computer and install **ROS 2 Dashing Diademata**:
10
11
11
-
First of all, make sure that you have a **ROS 2** installation.
***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)*
On the **ROS 2** installation open a command line and follow these steps:
25
+
Once you have a **ROS 2** installation in the computer, follow these steps to install the micro-ROS build system:
16
26
17
27
```bash
18
28
# Source the ROS 2 installation
@@ -32,224 +42,84 @@ colcon build
32
42
source install/local_setup.bash
33
43
```
34
44
35
-
Now, let's create a firmware workspace that targets all the required code and tools:
45
+
***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
+
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.
48
+
49
+
The build system's workflow is a four-step procedure:
50
+
51
+
***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.
52
+
***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.
53
+
***Build step:** Here is where the cross-compilation takes place and the platform-specific binaries are generated.
54
+
***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.
55
+
Further information about micro-ROS build system can be found [here](https://github.com/micro-ROS/micro-ros-build/tree/dashing/micro_ros_setup).
56
+
57
+
## Creating a new micro-ROS app
58
+
59
+
Once the build system is installed, let's create a firmware workspace that targets all the required code and tools:
36
60
37
61
```bash
38
62
# Create step
39
63
ros2 run micro_ros_setup create_firmware_ws.sh host
40
64
```
41
65
42
-
Now you have all the required tools to build micro-ROS. At this point, you must know that the micro-ROS build system is a four-step workflow:
43
-
44
-
<!-- TODO (pablogs9): Remove and link to build-system tutorial when done -->
45
-
1.**Create**: retrieves all the required packages for a specific RTOS and hardware platform.
46
-
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).
47
-
3.**Build**: generates a binary file ready for being loaded in the hardware.
48
-
4.**Flash**: load the micro-ROS software in the hardware.
49
-
50
-
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.
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).
51
67
52
68
```bash
53
69
# Creating a new app
54
70
pushd src/uros/micro-ROS-demos/rcl/
55
-
mkdir my_brand_new_app
56
-
cdmy_brand_new_app
71
+
mkdir ping_pong
72
+
cdping_pong
57
73
touch app.c CMakeLists.txt
58
74
popd
59
75
```
60
76
61
-
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:
To start creating this app, the `CMakeLists.txt` file should looks like:
66
-
67
-
```cmake
68
-
cmake_minimum_required(VERSION 3.5)
69
-
70
-
project(my_brand_new_app LANGUAGES C)
71
-
72
-
find_package(ament_cmake REQUIRED)
73
-
find_package(rcl REQUIRED)
74
-
find_package(std_msgs REQUIRED)
75
-
find_package(rmw_microxrcedds REQUIRED)
77
+
Don't forget to register your app in `src/uros/micro-ROS-demos/rcl/CMakeLists.txt` by adding the following line:
76
78
77
-
add_executable(${PROJECT_NAME} app.c)
79
+
```
80
+
export_executable(ping_pong)
81
+
```
78
82
79
-
ament_target_dependencies(${PROJECT_NAME}
80
-
rcl
81
-
std_msgs
82
-
rmw_microxrcedds
83
-
)
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:
Meanwhile `app.c` should look like the following code:
87
+
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.
91
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:
0 commit comments