ROS 2: Zero to Robot  ยท  Illustrated Learning Book

Chapter 18: From Simulation to Real ARCHO

The stage where everything suddenly becomes real
Prerequisite: Chapters 7 through 17
Running project: Physical ARCHO
Focus: Bringup, calibration, safety
Study time: 130 to 150 minutes
What we'll cover in this chapter 18.1What changes, what doesn't 18.2Bringup order on real hardware 18.3Preflight Checklist 18.4Wheel testing and open-loop motion 18.5Calibrating wheel radius and wheel separation 18.6Stop testing: one safety layer is not enough 18.7Automatic startup with systemd 18.8Logging and Observability 18.9The Simulation-to-Reality gap 18.10Summary, glossary, and exercises

18.1What changes, what doesn't

This chapter ties together everything from the previous chapters: the good news is that when you move from Gazebo to real ARCHO hardware, most of the architecture you built stays untouched.

flowchart LR subgraph SIM["Simulation"] A1["ros2_control"] --> A2["gz_ros2_control"] --> A3["Virtual Joints"] end subgraph REAL["Real Robot"] B1["ros2_control"] --> B2["Custom Hardware Interface"] --> B3["CAN / Serial / EtherCAT"] --> B4["Motor Drivers"] end style A1 fill:#eef0ff,stroke:#3d4bf5 style B1 fill:#eef0ff,stroke:#3d4bf5
LayerDoes it change?
Nav2, SLAM, ControllersNo
TF naming, URDFNo
High-level topicsNo
Hardware Interface (the lowest layer of ros2_control)Yes โ€” this is the only part that actually changes
๐Ÿง  Why this architecture is so valuable

This is exactly why we emphasized separating the Hardware Interface from the rest of the architecture so strongly in Chapter 8. If that separation was done correctly, moving from simulation to reality is just a swap of the bottom layer, not a rewrite of the entire system.

18.2Bringup order on real hardware

  1. Power and Safety
  2. Microcontroller (MCU)
  3. Motor drivers
  4. Sensors
  5. Hardware Interface
  6. robot_state_publisher
  7. robot_localization
  8. SLAM or AMCL
  9. Nav2
  10. Mission Manager
โš ๏ธ Why order matters

Exactly the same reason you learned about Lifecycle Nodes in Chapter 12: if Nav2 activates before Localization is ready, it can make dangerous decisions. This Bringup order applies the same principle to the entire physical system.

18.3Preflight Checklist

Before ARCHO's very first movement on real ground:

  • Emergency Stop is functional and accessible.
  • Wheels are lifted off the ground (for the first test).
  • Encoder direction is correct.
  • Motor direction is correct.
  • Current limit is configured.
  • Watchdog is active.
  • cmd_vel is zero (before the test starts).
  • TF tree is complete โ€” no frame is missing.
  • LiDAR is publishing valid data.
  • Battery is healthy.
  • The physical test area is clear of people and obstacles.

18.4Wheel testing and open-loop motion

Step one: test each wheel individually

Command positive
      โ†“
Wheel rotates forward?

If the answer is no, check these four things in order: motor direction, encoder direction, command sign, and driver mapping.

Step two: open-loop test with increasing speeds

Never start at high speed. The safe sequence:

0.05 m/s
0.10 m/s
0.20 m/s
0.30 m/s

At each step, before increasing the speed, make sure ARCHO moves exactly as you expect.

18.5Calibrating wheel radius and wheel separation

Wheel radius calibration

You command ARCHO to drive 5 meters straight, but the actual distance traveled is 4.8 meters:

correction factor = 5 / 4.8 = 1.0417
new_radius = old_radius ร— 1.0417

Wheel separation calibration

You command ARCHO to make one full rotation, but instead of 360 degrees it actually rotates only 330 degrees:

๐Ÿ”ง Why this calibration is critical

These are exactly the same parameters we set in controllers.yaml for diff_drive_controller in Chapter 8 (wheel_radius, wheel_separation). If these values don't precisely match ARCHO's real geometry, Odometry (Chapter 9) develops a systematic error from the very start โ€” and that error propagates directly into SLAM and Nav2 as well.

18.6Stop testing: one safety layer is not enough

You must test that ARCHO actually stops under all of these conditions:

flowchart TB A["High-Level Command"] --> B["ROS Watchdog"] B --> C["MCU Watchdog"] C --> D["Motor Driver Enable"] D --> E["Mechanical / Electrical Brake"] style B fill:#fdeeec,stroke:#d64a3c style C fill:#fdeeec,stroke:#d64a3c
โš ๏ธ One safety layer is not enough

Remember how we emphasized an independent Watchdog on the ESP32 in Chapter 16? Here's exactly why: if you rely only on the ROS-level Watchdog and the very computer that ROS runs on crashes, no layer remains to stop ARCHO. Real safety comes from redundancy of layers, not from a single point of failure.

18.7Automatic startup with systemd

So that ARCHO comes back up on its own after any power outage or restart, without human intervention:

# /etc/systemd/system/archo-bringup.service
[Unit]
Description=ARCHO ROS 2 Bringup
After=network-online.target

[Service]
Type=simple
User=robot
ExecStart=/usr/local/bin/start_archo.sh
Restart=on-failure
RestartSec=3

[Install]
WantedBy=multi-user.target
#!/bin/bash
# /usr/local/bin/start_archo.sh
source /opt/ros/jazzy/setup.bash
source /home/robot/archo_ws/install/setup.bash
exec ros2 launch archo_bringup real_robot.launch.py

18.8Logging and Observability

When ARCHO is operating in a real warehouse without direct supervision, you need to be able to answer these questions:

ToolUse
rosbag2Full data recording for later replay and analysis
diagnostic_msgsStandardized health reporting for each subsystem
/diagnosticsCentral topic for aggregating health status
Prometheus or similarMonitoring metrics over time
Log RotationPreventing the disk from filling up
Health HeartbeatQuickly detecting when a subsystem has failed
ros2 bag record \
  /scan \
  /imu/data \
  /odometry/filtered \
  /tf \
  /tf_static \
  /diagnostics

18.9The Simulation-to-Reality gap

Even with the best Gazebo simulation (Chapter 7), the real world always has surprises in store:

SimulationReality
Perfectly flat groundSlip and unevenness
Ideal wheelsWear, slight differences between wheels
Controlled noiseReal, unpredictable noise
Low, constant latencyVariable network and hardware latency
Clean sensorsDust, direct light, surface reflections
๐Ÿ”ง How to reduce this gap
  • Add realistic noise to simulated sensors.
  • Simulate realistic network and processing latency.
  • Enter the real mass and inertia of parts into the URDF (not approximate values).
  • Calibrate the real friction coefficient of the warehouse floor.
  • Apply the real velocity and acceleration limits of the motors.
  • Domain Randomization โ€” randomize parameters slightly on each simulation run so the system becomes robust to a range of possible conditions instead of a single fixed world.

18.10Chapter 18 summary

ARCHO has now gone from a Gazebo simulation to a real physical robot โ€” with a controlled Bringup order, a complete Preflight Checklist, calibrated wheels, several independent safety layers, automatic startup with systemd, and a logging system that always tells you why something happened.

โœ… Learning checkpoint
  • I can explain why only the Hardware Interface changes, not the whole architecture.
  • I know why the Bringup order matters.
  • I can describe the Wheel Radius and Wheel Separation calibration process.
  • I know why one safety layer is not enough and why safety must be multi-layered.
  • I can name at least three important differences between simulation and reality.
๐ŸŒ Connection to the running project

ARCHO Project now has a fully calibrated physical version that starts up automatically via systemd, records rosbag2 data for troubleshooting, and benefits from a multi-layered safety chain.

What the next chapter adds

In Chapter 19 we move on to industrial-grade production standards: QoS, DDS, Diagnostics, and safety architecture โ€” the things that take a project from "it works" to "reliable in production."

Chapter 18 glossary

Preflight Checklist
The list of safety and technical checks that must be performed before a robot's first movement.
Open Loop Test
A motion test with gradually increasing speed, without relying on full system feedback.
Wheel Radius Calibration
Correcting the effective wheel radius based on the actual distance traveled versus the expected distance.
Redundancy (multi-layer safety)
Designing several independent safety layers so that the failure of one layer doesn't cause total system failure.
systemd
The Linux service manager used for automatic, stable startup of robot Bringup.
Domain Randomization
The technique of randomizing simulation parameters to reduce the Sim-to-Real gap.

Common mistakes in Chapter 18 โ€” summary