ROS 2 Lyrical Luth · Lesson 56 of 86
Installing Nav2
Nav2 packages, the bringup launch files and running the simulation demo.
Estimated time · 45–60 min
Learning goals
What you will understand
- Explain installing nav2 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
Nav2 is the ROS 2 navigation framework. It is a set of servers (planner, controller, smoother, behavior, BT navigator, waypoint follower) managed as lifecycle nodes, plus map and localization servers. Install navigation2 and nav2_bringup with apt, then test with the TurtleBot 3 simulation before touching your own robot.
Nav2 needs a working base first: /cmd_vel accepted by the drive, /odom and odom → base_link published, a sensor topic (/scan) and a URDF with TF. If those are wrong, no Nav2 setting will help; check them first.
Guided lesson
Work through these steps
- 1.
Source the ROS 2 Lyrical environment in a fresh terminal.
- 2.
Read the installing nav2 example and identify what each line does.
- 3.
Build only the affected package, source the workspace overlay, and run the example.
- 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
sudo apt install ros-lyrical-navigation2 ros-lyrical-nav2-bringup
# Install Nav2 and its bringup launch files.
sudo apt install ros-lyrical-turtlebot3-gazebo
# Install a ready-made simulated robot and world.
export TURTLEBOT3_MODEL=waffle
# Choose the simulated robot model.
ros2 launch nav2_bringup tb3_simulation_launch.py headless:=False
# Start Gazebo, Nav2 and RViz2 together.
ros2 lifecycle get /planner_server
# Nav2 servers are lifecycle nodes; check that this one is active.What the example is doing
- 1.The ros2 commands query the running graph; they do not prove that a node's internal behavior is correct.
- 2.Build from the workspace root, then source install/setup.bash so the shell can discover the new package.
- 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.
Demo for Installing Nav2. Expected result: primary state: active
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.
source /opt/ros/lyrical/setup.bash
# TODO: check the lifecycle state of /planner_serverExpected output
primary state: activeStuck? Show the full solution (try it yourself first)
source /opt/ros/lyrical/setup.bash
ros2 lifecycle get /planner_serverExpected 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
Install Nav2, launch the TurtleBot 3 simulation, set the initial pose in RViz2 with '2D Pose Estimate', send a goal with 'Nav2 Goal', and record the lifecycle state of each server.
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
Source /opt/ros/lyrical/setup.bash, build from the workspace root, then source install/setup.bash in that terminal.
Confirm both terminals use Lyrical, the same ROS_DOMAIN_ID, and compatible network/discovery settings.