CodeTheRobot

ROS 2 Lyrical Luth · Lesson 70 of 86

Full navigation launch system

A complete bringup: robot, sensors, localization, Nav2 and RViz in one launch.

Estimated time · 90–120 min

Learning goals

What you will understand

  • Explain full navigation launch system 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

A finished robot needs one command that starts everything in the right order: robot_state_publisher and the drivers (or simulator), the map server and AMCL (or SLAM), Nav2's servers with the lifecycle manager, and RViz2. Split this into small launch files and one top-level file that includes them and passes shared arguments (use_sim_time, map, params_file).

Test the whole system from a clean terminal, on a fresh boot, and with one component deliberately missing. Check lifecycle states with ros2 lifecycle get, watch the TF tree with view_frames, and record the exact command that works so the deployment can repeat it.

Guided lesson

Work through these steps

  1. 1.

    Source the ROS 2 Lyrical environment in a fresh terminal.

  2. 2.

    Read the full navigation launch system 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

from launch import LaunchDescription
# Launch container.
from launch.actions import DeclareLaunchArgument, IncludeLaunchDescription
# Arguments and includes.
from launch.substitutions import LaunchConfiguration
# Read arguments.
from launch.launch_description_sources import PythonLaunchDescriptionSource
# Include Python launch files.
def generate_launch_description():
# Entry point.
    nav2 = IncludeLaunchDescription(PythonLaunchDescriptionSource('/opt/ros/lyrical/share/nav2_bringup/launch/bringup_launch.py'), launch_arguments={'map': LaunchConfiguration('map'), 'use_sim_time': 'true', 'params_file': LaunchConfiguration('params')}.items())
# Include Nav2's bringup with our map and parameter file.
    return LaunchDescription([DeclareLaunchArgument('map'), DeclareLaunchArgument('params'), nav2])
# Expose map and params as arguments and start Nav2.

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 · Mobile robot

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.

goalMOBILE ROBOT

Demo for Full navigation launch system. Expected result: The robot navigates to the goal after one launch command

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.

# launch/bringup.launch.py
from launch import LaunchDescription
from launch.actions import DeclareLaunchArgument
from launch.substitutions import LaunchConfiguration


def generate_launch_description():
    # TODO: declare launch arguments named map and params, and read them with LaunchConfiguration
    return LaunchDescription([map_arg, params_arg])

Expected output

The robot navigates to the goal after one launch command
Stuck? Show the full solution (try it yourself first)
# launch/bringup.launch.py
from launch import LaunchDescription
from launch.actions import DeclareLaunchArgument
from launch.substitutions import LaunchConfiguration


def generate_launch_description():
    map_arg = DeclareLaunchArgument('map')
    params_arg = DeclareLaunchArgument('params')
    map_file = LaunchConfiguration('map')
    params = LaunchConfiguration('params')
    return LaunchDescription([map_arg, params_arg])

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

Build bringup.launch.py that starts the simulator, robot_state_publisher, Nav2 and RViz2 with map and params arguments. Start it from a clean terminal and send one navigation goal with a single command.

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.