Skip to content

Commit 530e5b6

Browse files
committed
Tutorial content update
1 parent 42b94f4 commit 530e5b6

File tree

2 files changed

+68
-1
lines changed

2 files changed

+68
-1
lines changed
Loading

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

Lines changed: 68 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -454,14 +454,81 @@ With all files in place, you are now ready to build and launch your dockerized R
454454
docker compose up --build
455455
```
456456

457-
This command builds the custom Docker image according to your Dockerfile specifications. Then, it starts the container with all the configurations defined in docker-compose.yml. The `--build` flag ensures the image is rebuilt, including any changes you have made to the files.
457+
This command builds the custom Docker image according to your Dockerfile specifications. Then, it starts the container with all the configurations defined in `docker-compose.yml`. The `--build` flag ensures the image is rebuilt, including any changes you have made to the files.
458+
459+
The following sequence of the commands also works:
460+
461+
```bash
462+
docker build . -t turtlesim_auto
463+
```
464+
465+
```bash
466+
docker run -it --rm \
467+
--privileged \
468+
-e WAYLAND_DISPLAY=wayland-1 \
469+
-e XDG_RUNTIME_DIR=/run/user/63 \
470+
-e QT_QPA_PLATFORM=wayland \
471+
-v /run/user/63:/run/user/63 \
472+
-v /tmp/.X11-unix:/tmp/.X11-unix:rw \
473+
--name turtlesim_container \
474+
turtlesim_auto
475+
```
458476

459477
As the container starts, you will see a detailed output showing the initialization process in your terminal. The turtlesim window should appear on your external display within a few seconds, with the turtle already performing pre-defined movements.
460478

461479
![Turtlesim in Dockerized Format](assets/x8-ros2-docker-turtlesim-run.gif)
462480

463481
The turtle will simultaneously run square-drawing patterns while maintaining a circular trajectory, creating a hybrid spiral-square pattern.
464482

483+
![Turtlesim in Dockerized Format](assets/x8-ros2-turtlesim-docker.gif)
484+
485+
When the turtle _crashes_ into a wall, while the example is running, you will eventually see log lines like:
486+
487+
```bash
488+
[WARN] [turtlesim]: Oh no! I hit the wall!
489+
```
490+
491+
Nothing is wrong, `turtlesim` clamps the pose to keep the turtle inside the blue window and keeps drawing. You can clear or reset the screen at any time:
492+
493+
```bash
494+
# clear the drawing
495+
ros2 service call /clear std_srvs/srv/Empty {}
496+
497+
# reset turtle position (also clears)
498+
ros2 service call /reset std_srvs/srv/Empty {}
499+
```
500+
501+
The motion parameters can be adjusted and avoid wall collisions in `start_turtlesim.sh`. Edit that sketch to use smaller values that keep the turtle away from the edges:
502+
503+
```bash
504+
nano start_turtlesim.sh
505+
```
506+
507+
```bash
508+
# Draw-square demo (optional)
509+
ros2 run turtlesim draw_square &
510+
511+
# Continuous circular motion
512+
ros2 topic pub --rate 1 /turtle1/cmd_vel geometry_msgs/msg/Twist \
513+
"{linear: {x: 2.0, y: 0.0, z: 0.0}, angular: {x: 0.0, y: 0.0, z: 1.8}}" &
514+
```
515+
516+
The starting point can be updated to be:
517+
518+
| **Parameter** | **Original Value** | **Suggested Example Value** | **Effect of Change** |
519+
|------------------------------------------|--------------------|-----------------------------|--------------------------------------------------------------------------|
520+
| `linear.x` (forward) | `1.5` | `0.8 – 1.0` | Slower advance → tighter overall pattern |
521+
| `angular.z` (turn rate) | `0.8` | `0.4 – 0.6` | Gentler turn → smaller spiral radius |
522+
| `sleep 5` (delay before circular motion) | `5 s` | `2 – 3 s` (optional) | Starts circle soonera and reduces distance covered during square routine |
523+
524+
After saving the changes, rebuild and relaunch:
525+
526+
```bash
527+
docker compose up --build
528+
```
529+
530+
The turtle will now trace a tighter spiral–square pattern and stay comfortably inside the boundaries. These warnings are a helpful indicator that the simulation’s collision logic is working and fine tuning the script gives you full control over the turtle’s behavior.
531+
465532
### Managing the Dockerized Application
466533

467534
Docker Compose provides useful commands for managing your deployed application. Understanding these commands helps you maintain and troubleshoot your ROS2 deployment effectively.

0 commit comments

Comments
 (0)