Navigation — map it, then let the robot find its way¶
SLAM builds the map, Nav2 drives the route. Both run from the PhysiCar panel › Tutorials tab › Navigation — two pages, SLAM and Nav2 — and you watch everything in RViz, which opens on the VNC tab of the app by itself.
1. Map the world¶
On the SLAM page press ▶ SLAM. The command it types into the terminal is shown under the button:
ros2 launch slam_toolbox online_async_launch.py slam_params_file:=/home/physicar/physicar_ws/tutorials/navigation/slam_params.yaml use_sim_time:=true
(use_sim_time is true on the simulator, false on the robot — the panel picks it.)
RViz appears in app.physicar → VNC with the map growing. Drive the robot around
(keyboard is fine) until walls close into a complete floor plan. Sweep corners twice;
loop closures snap the map tight.
2. Save the map¶
Still on the SLAM page, press ▶ Save map. The map is saved from the running SLAM as
tutorials/navigation/my_map.yaml + .pgm (saving again overwrites it). Then
■ Stop SLAM — RViz closes with it.
3. Navigate¶
Open the Nav2 page and press ▶ Nav2:
ros2 launch nav2_bringup bringup_launch.py map:=/home/physicar/physicar_ws/tutorials/navigation/my_map.yaml params_file:=/home/physicar/physicar_ws/tutorials/navigation/nav2_params.yaml use_sim_time:=true
That one launch runs localization (AMCL) and navigation together. In RViz, set a navigation goal (2D Goal Pose / Nav2 Goal) — the planned path appears and the robot follows it, dodging obstacles on the way. Drop a box in its path (in the simulator: use the world's objects) and watch the local planner bend around it.
Settings¶
- SLAM — map resolution, laser range, how often a scan is added, loop closing. Written
into
slam_params.yaml; they count from the next ▶ SLAM. - Nav2 — max and reverse speed, goal tolerance, costmap inflation. Written into
nav2_params.yaml; they count from the next ▶ Nav2. - The two parameter files sit in
tutorials/navigation/(read-only in the explorer, like every tutorial file); the column is how you change them. Want other keys? Copy the files into a folder of your own and launch with your copy. - While SLAM or Nav2 runs, the other tutorials wait — one SLAM, one Nav2 per robot.
What to look at¶
- The global path (the long line to the goal) vs the local path (the short one that swerves) — two planners cooperating.
- The costmap glow around obstacles — that's what "too close" looks like to a robot. Shrink the inflation radius and see the path hug the walls.
Make it yours¶
- Map one of your own worlds and navigate it.
- Ask the tutor to send goals from code — "patrol these three points forever".
The theory → Learn: SLAM & navigation