diff --git a/_docs/tutorials/advanced/zephyr_emulator/index.md b/_docs/tutorials/advanced/zephyr_emulator/index.md index 47158d46..c73bcf05 100644 --- a/_docs/tutorials/advanced/zephyr_emulator/index.md +++ b/_docs/tutorials/advanced/zephyr_emulator/index.md @@ -3,7 +3,10 @@ title: Zephyr Emulator permalink: /docs/tutorials/advanced/zephyr_emulator/ --- -This tutorial aims to create 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)). +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)). + +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.
@@ -13,244 +16,39 @@ This tutorial aims to create a new micro-ROS application on with **[Zephyr RTOS]
This tutorial requires no hardware beyond a Linux host computer.
-## Adding a new micro-ROS app
-
-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:
-
-```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 && sudo apt install python3-colcon-metadata
-rosdep update
-rosdep install --from-path src --ignore-src -y
-
-# Build micro-ROS tools and source them
-colcon build
-source install/local_setup.bash
-```
+## Building a Zephyr emulator application
-Let's install the last version of CMake:
-
-```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
-```
-
-Now, let's create a firmware workspace that targets all the required code and tools for Zephyr emulator:
+Once the micro-ROS build system is ready, let's create a new Zephyr firmware for the host platform:
```bash
# Create firmware step
ros2 run micro_ros_setup create_firmware_ws.sh zephyr host
```
-Now you have all the required tools to compile micro-ROS and Zephyr. At this point, you must know that the micro-ROS build system is a four-step workflow:
-
-
-1. **Create**: retrieves all the required packages for a specific RTOS and hardware platform.
-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).
-3. **Build**: generates a binary file ready for being loaded in the hardware.
-4. **Flash**: load the micro-ROS software in the hardware.
-
-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. You have these two files [here](https://github.com/micro-ROS/zephyr_apps/tree/dashing/apps/host_ping_pong), for now, it is ok to copy them.
+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.
```bash
# Creating a new app
pushd firmware/zephyr_apps/apps
-mkdir my_brand_new_app
-cd my_brand_new_app
+mkdir host_ping_pong
+cd host_ping_pong
mkdir src
-touch src/app.c app-colcon.meta
-# Copying CMakeLists.txt and prj.conf
-wget https://raw.githubusercontent.com/micro-ROS/zephyr_apps/dashing/apps/host_ping_pong/CMakeLists.txt
-wget https://raw.githubusercontent.com/micro-ROS/zephyr_apps/dashing/apps/host_ping_pong/prj.conf
+touch src/app.c
+touch app-colcon.meta
+touch CMakeLists.txt
+touch prj.conf
popd
```
-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, lets configure the RMW with the required static memory. You can read more about RMW and Micro XRCE-DDS Configuration [here](/docs/tutorials/core/microxrcedds_rmw_configuration/). The `app-colcon.meta` should look like:
-
-```
-{
- "names": {
- "rmw_microxrcedds": {
- "cmake-args": [
- "-DRMW_UXRCE_MAX_NODES=1",
- "-DRMW_UXRCE_MAX_PUBLISHERS=2",
- "-DRMW_UXRCE_MAX_SUBSCRIPTIONS=2",
- "-DRMW_UXRCE_MAX_SERVICES=0",
- "-DRMW_UXRCE_MAX_CLIENTS=0",
- "-DRMW_UXRCE_MAX_HISTORY=4",
- ]
- }
- }
-}
-```
-
-Meanwhile `src/app.c` should look like the following code:
-
-```c
-#include