Skip to content

Commit 27e7a54

Browse files
committed
Content post review update
1 parent 03a0241 commit 27e7a54

File tree

1 file changed

+35
-31
lines changed
  • content/hardware/04.pro/boards/portenta-x8/tutorials/16.getting-started-with-ros2

1 file changed

+35
-31
lines changed

content/hardware/04.pro/boards/portenta-x8/tutorials/16.getting-started-with-ros2/content.md

Lines changed: 35 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
---
2-
title: '16. Getting Started with ROS2 and Turtlesim on Portenta X8'
2+
title: '16. Getting Started with ROS 2 and Turtlesim on Portenta X8'
33
difficulty: intermediate
4-
description: "Learn how to set up and run ROS2 with turtlesim visualization on Portenta X8 using an external display via USB-C® to HDMI."
4+
description: "Learn how to set up and run ROS 2 with turtlesim visualization on Portenta X8 using an external display via USB-C® to HDMI."
55
tags:
6-
- ROS2
6+
- ROS 2
77
- Docker
88
- Linux
99
- Wayland
@@ -15,18 +15,18 @@ hardware:
1515

1616
## Overview
1717

18-
In this tutorial, you will learn to set up and run **ROS2 (Robot Operating System 2)** with the **`turtlesim`** visualization tool on the Portenta X8. You will learn to display the graphical output on an external monitor connected via a USB-C® dongle with HDMI output.
18+
In this tutorial, you will learn to set up and run **ROS 2 (Robot Operating System 2)** with the **`turtlesim`** visualization tool on the Portenta X8. You will learn to display the graphical output on an external monitor connected via a USB-C® dongle with HDMI output.
1919

20-
![Portenta X8 and ROS2 Turtlesim](assets/x8-ros2-turtlesim-banner.gif)
20+
![Portenta X8 and ROS 2 Turtlesim](assets/x8-ros2-turtlesim-banner.gif)
2121

22-
We will explore two approaches: running ROS2 directly through commands and deploying it in a containerized environment using Docker. The **`turtlesim`** application is an excellent introduction to ROS2, providing a simple way to understand ROS2 concepts like nodes, topics and services through an interactive turtle graphics simulation.
22+
We will explore two approaches: running ROS 2 directly through commands and deploying it in a containerized environment using Docker. The **`turtlesim`** application is an excellent introduction to ROS 2, providing a simple way to understand ROS 2 concepts like nodes, topics and services through an interactive turtle graphics simulation.
2323

2424
## Goals
2525

2626
- Learn how to connect and configure an external display with the Portenta X8
2727
- Understand the Wayland display server configuration on the Portenta X8
28-
- Run ROS2 and turtlesim using direct commands
29-
- Deploy ROS2 and turtlesim in a Docker container
28+
- Run ROS 2 and turtlesim using direct commands
29+
- Deploy ROS 2 and turtlesim in a Docker container
3030

3131
## Hardware and Software Requirements
3232

@@ -58,7 +58,7 @@ To check your Portenta X8 Linux version and update if necessary, refer to the [P
5858

5959
### Video Output Setup
6060

61-
To display ROS2 `turtlesim` on an external monitor, you will need a USB-C® hub with video output capabilities. The Portenta X8 serves as the host device, is connected to the hub, and provides the necessary ports for display connectivity and optional peripherals.
61+
To display ROS 2 `turtlesim` on an external monitor, you will need a USB-C® hub with video output capabilities. The Portenta X8 serves as the host device, is connected to the hub, and provides the necessary ports for display connectivity and optional peripherals.
6262

6363
Connect the Portenta X8 to the USB-C® hub's host port, then connect your HDMI cable to your external display. The hub's power supply can be connected to your computer or a dedicated power adapter. You can connect a USB mouse and keyboard to the hub's additional ports for interactive system control. This is optional for the `turtlesim` example.
6464

@@ -72,7 +72,7 @@ When you first connect the Portenta X8 to your display, you will see the default
7272

7373
![X8 home screen on external display](assets/portentaX8-home-screen.png)
7474

75-
The Portenta X8 uses **Weston** as its **Wayland** compositor, which automatically detects and configures external displays. You can interact with the interface directly if you have connected a mouse or keyboard to your USB hub. However, we will mostly work through terminal commands and use Docker configuration files for the present ROS2 `turtlesim` tutorial.
75+
The Portenta X8 uses **Weston** as its **Wayland** compositor, which automatically detects and configures external displays. You can interact with the interface directly if you have connected a mouse or keyboard to your USB hub. However, we will mostly work through terminal commands and use Docker configuration files for the present ROS 2 `turtlesim` tutorial.
7676

7777
### Adjusting Display Resolution (Optional)
7878

@@ -82,11 +82,11 @@ For example, to configure a display for `1600 x 758` resolution at `60 Hz`, you
8282

8383
***For detailed instructions on connecting to your Portenta X8 via ADB, refer to the [Working with Linux section](https://docs.arduino.cc/tutorials/portenta-x8/user-manual#working-with-linux) of the user manual. Additional information about display configuration and WebGL capabilities can be found in the [Display Output tutorial](https://docs.arduino.cc/tutorials/portenta-x8/display-output-webgl/).***
8484

85-
Once your display is properly connected and configured, you are ready to proceed with running ROS2 and visualizing the `turtlesim` application on your external monitor.
85+
Once your display is properly connected and configured, you are ready to proceed with running ROS 2 and visualizing the `turtlesim` application on your external monitor.
8686

8787
## What Is ROS
8888

89-
**ROS (Robot Operating System)** is an open-source middleware framework that enables robotic and embedded systems to exchange data through standardized **nodes**, **topics**, **services** and **actions**. It provides reusable libraries and tools, such as visualization, package management and message passing, so developers can focus on application logic instead of low-level infrastructure.
89+
**ROS (Robot Operating System)** is an open-source middleware framework that enables robotic and embedded systems to exchange data through standardized **nodes**, **topics**, **services** and **actions**. ROS is a trademark of Open Source Robotics Foundation. It provides reusable libraries and tools, such as visualization, package management and message passing, so developers can focus on application logic instead of low-level infrastructure.
9090

9191
### What Is ROS 2
9292

@@ -100,7 +100,7 @@ Once your display is properly connected and configured, you are ready to proceed
100100

101101
Throughout this tutorial, we use [**ROS 2 Jazzy**](https://docs.ros.org/en/jazzy/index.html) on the Portenta X8, allowing you to leverage these newer capabilities while still relying on familiar ROS concepts.
102102

103-
![ROS2 Jazzy on Portenta X8](assets/x8-with-ros2-jazzy.png)
103+
![ROS 2 Jazzy on Portenta X8](assets/x8-with-ros2-jazzy.png)
104104

105105
## Wayland Display Configuration
106106

@@ -141,11 +141,11 @@ This command would return something as follows:
141141

142142
![Wayland Display Socket](assets/x8-wayland-display-socket.png)
143143

144-
## Running ROS2 Directly
144+
## Running ROS 2 Directly
145145

146146
### Setting Up the Environment
147147

148-
To run ROS2 and `turtlesim` directly on the Portenta X8, we will use Docker containers to ensure a consistent environment. This approach lets us quickly test ROS2 functionality without creating a permanent installation.
148+
To run ROS 2 and `turtlesim` directly on the Portenta X8, we will use Docker containers to ensure a consistent environment. This approach lets us quickly test ROS 2 functionality without creating a permanent installation.
149149

150150
First, we need to configure the environment variables that will allow our Docker container to communicate with the Wayland display server. The `Wayland` protocol requires specific environment variables to establish the connection between the containerized application and the display server running on the host system:
151151

@@ -163,7 +163,7 @@ export QT_QPA_PLATFORM=wayland
163163

164164
These variables tell applications where to find the `Wayland` socket (`wayland-1`), specify the runtime directory where `Wayland` stores its communication files (`/run/user/63`) and tell Qt-based applications like `turtlesim` to use `Wayland` as their display platform.
165165

166-
With the environment configured, we can now launch a ROS2 Docker container. The following command creates an interactive container with all the necessary permissions and volume mounts to access the display:
166+
With the environment configured, we can now launch a ROS 2 Docker container. The following command creates an interactive container with all the necessary permissions and volume mounts to access the display:
167167

168168
```bash
169169
docker run -it --rm \
@@ -184,17 +184,17 @@ This command uses flags like `--privileged` that grant the container elevated pe
184184

185185
### Installing and Running Turtlesim
186186

187-
You will see a bash prompt once you are inside the Docker container. The container has ROS2 pre-installed, but we need to set up the ROS2 environment and install the turtlesim package.
187+
You will see a bash prompt once you are inside the Docker container. The container has ROS 2 pre-installed, but we need to set up the ROS 2 environment and install the turtlesim package.
188188

189-
Start by sourcing the ROS2 setup script, which configures all the necessary ROS2 environment variables and paths:
189+
Start by sourcing the ROS 2 setup script, which configures all the necessary ROS 2 environment variables and paths:
190190

191191
```bash
192192
source /opt/ros/jazzy/setup.bash
193193
```
194194

195-
This command initializes the ROS2 workspace, making all ROS2 commands and tools available in your current shell session. Without this step, ROS2 commands won't be recognized.
195+
This command initializes the ROS 2 workspace, making all ROS 2 commands and tools available in your current shell session. Without this step, ROS 2 commands won't be recognized.
196196

197-
Next, install the `turtlesim` package, which is not included in the base ROS2 image. Update the package list and install `turtlesim`:
197+
Next, install the `turtlesim` package, which is not included in the base ROS 2 image. Update the package list and install `turtlesim`:
198198

199199
```bash
200200
apt-get update && apt-get install -y ros-jazzy-turtlesim
@@ -249,15 +249,15 @@ Open a new terminal on your Portenta X8 and access the running Docker container
249249
docker exec -it ros2_wayland_test bash
250250
```
251251

252-
This command opens a new bash session inside the running container named `ros2_wayland_test`. You will need to source the ROS2 environment again in this new session:
252+
This command opens a new bash session inside the running container named `ros2_wayland_test`. You will need to source the ROS 2 environment again in this new session:
253253

254254
```bash
255255
source /opt/ros/jazzy/setup.bash
256256
```
257257

258258
![Turtlesim Control with Second Terminal](assets/x8-ros2-cmd-turtlesim-control-env.gif)
259259

260-
Now, you can control the turtle using ROS2 topics. The `turtlesim` node subscribes to velocity commands on the `/turtle1/cmd_vel` topic. You have different options for controlling the turtle's movement.
260+
Now, you can control the turtle using ROS 2 topics. The `turtlesim` node subscribes to velocity commands on the `/turtle1/cmd_vel` topic. You have different options for controlling the turtle's movement.
261261

262262
For continuous circular movement, publish velocity commands that combine linear and angular velocities:
263263

@@ -288,15 +288,15 @@ The `draw_square` node will reset the turtle to its starting position and then c
288288

289289
### Overview of the Dockerized Approach
290290

291-
While running ROS2 directly through Docker commands is useful for testing and development, a dockerized deployment using Docker Compose can provide integration for persistent applications. This method automates the entire setup process, ensures consistent behavior across restarts, and makes managing the ROS2 `turtlesim` application as a service easy.
291+
While running ROS 2 directly through Docker commands is useful for testing and development, a dockerized deployment using Docker Compose can provide integration for persistent applications. This method automates the entire setup process, ensures consistent behavior across restarts, and makes managing the ROS 2 `turtlesim` application as a service easy.
292292

293293
The dockerized approach includes all dependencies, configurations and startup procedures in a self-contained environment. This is particularly useful when you want the `turtlesim` example to start automatically on boot or recover from unexpected shutdowns.
294294

295295
### Creating the Docker Environment
296296

297297
[Here](assets/ros2_turtleNative.zip), you can download the files for dockerized deployment.
298298

299-
Within this directory, you will have three essential files that define your dockerized ROS2 application:
299+
Within this directory, you will have three essential files that define your dockerized ROS 2 application:
300300

301301
- Docker Compose configuration
302302
- Dockerfile
@@ -329,7 +329,7 @@ services:
329329
330330
This configuration tells Docker Compose to build a custom image using the Dockerfile in the current directory. It sets up the same privileged access and environment variables we used in the direct method but adds a restart policy (`unless-stopped`) that ensures the container automatically restarts if the system reboots or if the container exits unexpectedly.
331331

332-
Next, create the `Dockerfile` that defines how to build your custom ROS2 image with `turtlesim` pre-installed:
332+
Next, create the `Dockerfile` that defines how to build your custom ROS 2 image with `turtlesim` pre-installed:
333333

334334
```
335335
FROM arm64v8/ros:jazzy-ros-base
@@ -361,15 +361,15 @@ ENV XDG_RUNTIME_DIR=/run/user/63
361361
ENTRYPOINT ["/usr/local/bin/start_turtlesim.sh"]
362362
```
363363

364-
This Dockerfile starts from the official ROS2 Jazzy base image for ARM64 architecture, installs the turtlesim package and Python tools, and configures the environment. The key point here is that it copies and sets up a custom startup script as the container's entry point, which handles all initialization and coordination of multiple ROS2 processes.
364+
This Dockerfile starts from the official ROS 2 Jazzy base image for ARM64 architecture, installs the turtlesim package and Python tools, and configures the environment. The key point here is that it copies and sets up a custom startup script as the container's entry point, which handles all initialization and coordination of multiple ROS 2 processes.
365365

366366
The `start_turtlesim.sh` is the main script. This file handles the startup of `turtlesim` with defined movement patterns:
367367

368368
```bash
369369
#!/bin/bash
370370
set -e
371371
372-
# Source ROS2 environment
372+
# Source ROS 2 environment
373373
source /opt/ros/jazzy/setup.bash
374374
375375
# Set Wayland environment variables
@@ -448,7 +448,7 @@ Here are the Docker configuration and setup files for the turtlesim example, rea
448448

449449
### Running the Dockerized Setup
450450

451-
With all files in place, you are now ready to build and launch your dockerized ROS2 turtlesim application. The Docker Compose command handles the build and deployment process:
451+
With all files in place, you are now ready to build and launch your dockerized ROS 2 turtlesim application. The Docker Compose command handles the build and deployment process:
452452

453453
```bash
454454
docker compose up --build
@@ -531,7 +531,7 @@ The turtle will now trace a tighter spiral–square pattern and stay comfortably
531531

532532
### Managing the Dockerized Application
533533

534-
Docker Compose provides useful commands for managing your deployed application. Understanding these commands helps you maintain and troubleshoot your ROS2 deployment effectively.
534+
Docker Compose provides useful commands for managing your deployed application. Understanding these commands helps you maintain and troubleshoot your ROS 2 deployment effectively.
535535

536536
To monitor the application's output in real time, use the logs command with the following flag:
537537

@@ -605,16 +605,20 @@ If the container cannot connect to the Wayland display:
605605

606606
## Conclusion
607607

608-
In this tutorial, you have learned how to set up and run ROS2 with turtlesim visualization on the Portenta X8 using an external display. You have implemented direct command execution and containerized deployment methods, providing flexibility for different use cases.
608+
In this tutorial, you have learned how to set up and run ROS 2 with turtlesim visualization on the Portenta X8 using an external display. You have implemented direct command execution and containerized deployment methods, providing flexibility for different use cases.
609609

610610
The direct method offers quick testing and development capabilities, while the Dockerized approach provides an automated method ideal for controlled deployments.
611611

612612
### Next Steps
613613

614-
Now that you have ROS2 running on your Portenta X8, you can try different ROS2 packages, create custom nodes, integrate sensor data from the Portenta X8's built-in capabilities with carriers, develop robotics applications using the ROS2 framework, or create custom Docker images with your ROS2 applications.
614+
Now that you have ROS 2 running on your Portenta X8, you can try different ROS 2 packages, create custom nodes, integrate sensor data from the Portenta X8's built-in capabilities with carriers, develop robotics applications using the ROS 2 framework, or create custom Docker images with your ROS 2 applications.
615615

616616
For more information about Portenta X8 capabilities, check out the [Portenta X8 User Manual](https://docs.arduino.cc/tutorials/portenta-x8/user-manual).
617617

618+
## Acknowledgments
619+
620+
ROS is a trademark of Open Source Robotics Foundation. This tutorial is provided for educational purposes to help users learn ROS 2 on Arduino hardware. This content does not imply endorsement, partnership or affiliation between Arduino and Open Source Robotics Foundation.
621+
618622
## Support
619623

620624
If you encounter any issues or have questions while working with the Portenta X8, we provide various support resources to help you find answers and solutions.

0 commit comments

Comments
 (0)