Navigation¶
examples/navigation.ipynb runs the pipeline every robot vacuum and self-driving car
runs: drive around to build a map with the LiDAR (SLAM), then click a
destination on that map and the car localizes itself, plans a path, and drives there on
its own (Nav2). Pure classical robotics — no training, no GPU. The runnable cells are
shell cells (%%bash) that launch the standard ROS 2 stack — slam_toolbox, AMCL, Nav2 —
preconfigured for PhysiCar's Ackermann steering in examples/assets/navigation/config/.
Inside the notebook¶
| Cell | What happens |
|---|---|
| 1. Build a map | starts slam_toolbox + RViz — you drive, the map grows |
| 2. Let it drive | saves the map, swaps SLAM for AMCL localization, brings up Nav2 (~30 s), reopens RViz for goal clicking |
| 2.2 Check the map | shows the saved my_map.png and its metadata |
| 3. Stop & tune | shuts everything down; pointers into the two config files |
Run it¶
- Open
examples/navigation.ipynband pick the Python 3 (PhysiCar AI) kernel. - Run cell 1, then open
app.physicarand switch to the VNC tab — RViz is there. Drive the car around (the CONTROL tab works) and watch the map grow with every scan. Passing the same spot twice (loop closure) sharpens it. - Covered the whole area? Run cell 2 — it saves the map to
examples/assets/navigation/map/, shuts SLAM down, and brings up AMCL plus the Nav2 stack — about 30 seconds. - In RViz: 2D Pose Estimate if the robot isn't where RViz thinks it is, then 2D Goal Pose — click a destination. Off it goes: watch the planned path, the local costmap, and the AMCL particle cloud tighten as it drives.
The map origin is wherever mapping starts. In the simulator, cell 1 first resets the
car to the start line, so the origin is always the start line; on a real kit, place the
car at your chosen origin before running. The same notebook runs on both — SIM is
auto-detected.
Make it yours¶
All in examples/assets/navigation/config/ — edit, then rerun cells 1–2:
resolution: 0.05(slam_params.yaml) — 5 cm per map cell. Finer maps, slower matching.max_laser_range: 16.0— how far a scan reaches into the map.nav2_params.yaml— the whole autonomous-driving character: costmap inflation (how shy of walls), MPPI controller weights (how aggressive), planner and AMCL settings.
Watch out
- Order matters — without a saved map, cell 2 exits with a notice. Run cell 1 first.
- Cell 2 stops SLAM, so the map saved at that moment is final — check it in cell 2.2 before trusting it.
- Nav2 takes about 30 s to come up — the cell waits for the stack to report active before opening RViz.
- Want a fresh map? Just run cell 1 again — it cleans up the previous stack.
🛠 Mission: map the whole track, then send the car to the far side and watch the particle cloud tighten as it drives — then move an obstacle into its path in the simulator viewer and see the local costmap react.
Learn more
Nodes and topics → ROS2 basics. TF, odometry, SLAM → Robot anatomy & sensors. Full topics/services → ROS2 interface reference.