CodeTheRobot

ROS 2 Lyrical Luth · Lesson 80 of 86

Deployment on real hardware: Jetson, NUC and Raspberry Pi

Choosing computers, installing, systemd services, containers and remote updates.

Estimated time · 60–90 min

Learning goals

What you will understand

  • Explain deployment on real hardware: jetson, nuc and raspberry pi in your own words
  • Use it in a small robotics example
  • Verify the result instead of assuming it worked

Understand the idea first

The mental model

Pick the computer from the workload: a Raspberry Pi suits light control and drivers, an Intel NUC gives general x86 power, and an NVIDIA Jetson adds a GPU for perception and detection. Check that the ROS 2 distribution supports your OS and architecture (arm64 vs amd64), and budget power, cooling and boot time.

Run the robot software as a service so it starts on boot: a systemd unit that sources ROS, runs the launch file, restarts on failure and logs to the journal. Containers (Docker) make the environment reproducible. Keep a tested rollback path, use a read-only or protected filesystem where possible, and never test new code first on an untethered robot.

Guided lesson

Work through these steps

  1. 1.

    Source the ROS 2 Lyrical environment in a fresh terminal.

  2. 2.

    Read the deployment on real hardware: jetson, nuc and raspberry pi example and identify what each line does.

  3. 3.

    Build only the affected package, source the workspace overlay, and run the example.

  4. 4.

    Inspect the result from a second terminal with the ros2 CLI or RViz2 and compare it with the expected result.

Worked example

Read it before you run it

[Unit]
# Start of the service description.
Description=Robot bringup
# A human-readable name.
After=network-online.target
# Start after the network is up.
[Service]
# How to run it.
User=robot
# Run as an unprivileged user.
ExecStart=/bin/bash -lc 'source /opt/ros/lyrical/setup.bash && source /home/robot/robot_ws/install/setup.bash && ros2 launch robot_bringup bringup.launch.py'
# Source ROS, then start the launch file.
Restart=on-failure
# Restart if it crashes.
[Install]
# When to enable it.
WantedBy=multi-user.target
# Start at normal boot.

What the example is doing

  1. 1.The ros2 commands query the running graph; they do not prove that a node's internal behavior is correct.
  2. 2.Build from the workspace root, then source install/setup.bash so the shell can discover the new package.
  3. 3.Use a second sourced terminal to inspect nodes and interfaces while the example runs.

Watch it run · The robot's computer

See what this code does

The terminal types this lesson's practice solution and runs it. The scene shows the kind of robot behaviour that code drives. It plays by itself and loops.

robot computercpumemdiskdriverstoppedplannerstoppedloggerstoppedsafetystoppedTHE ROBOT'S COMPUTER

Demo for Deployment on real hardware: Jetson, NUC and Raspberry Pi. Expected result: Active: active (running)

Practice code

Now type it yourself

Copy the starter into your ROS 2 package, replace every TODO, then build with colcon build and run it from a sourced terminal.

# /etc/systemd/system/robot-bringup.service is installed. Enable and start it:
# TODO: reload systemd, enable the service at boot and start it now
systemctl status robot-bringup.service

Expected output

Active: active (running)
Stuck? Show the full solution (try it yourself first)
# /etc/systemd/system/robot-bringup.service is installed. Enable and start it:
sudo systemctl daemon-reload
sudo systemctl enable --now robot-bringup.service
systemctl status robot-bringup.service

Expected result

How you know it worked

  • ROS_DISTRO is lyrical in every terminal used for the exercise.
  • The complete package from the exercise builds and the expected graph entity appears in a second terminal.

Practical exercise

Apply the lesson

Write a systemd unit for your bringup launch file, enable it, reboot, and confirm the robot starts on its own. Read its log with journalctl -u robot-bringup and kill a node to test the restart.

Before you continue

  • ROS_DISTRO reports lyrical in every terminal you used
  • The example builds and runs without errors
  • You checked the result with a ros2 command, RViz2 or a test, not just by reading the code

If something goes wrong

ros2 cannot find a package or executable.

Source /opt/ros/lyrical/setup.bash, build from the workspace root, then source install/setup.bash in that terminal.

Nodes run but cannot discover each other.

Confirm both terminals use Lyrical, the same ROS_DOMAIN_ID, and compatible network/discovery settings.