Using the map generated by Simultaneous Localisation and Mapping (SLAM), we can finally navigate around the map autonomously using Nav2. Nav2 is an autonomous navigation framework for ROS 2 designed to move a mobile robot from Point A to Point B safely and efficiently. Instead of being one massive program, Nav2 uses a highly modular, distributed Server-Client Architecture driven by a centralised logic brain.
The Server-Client Framework
In Nav2, major navigation tasks are split into independent programs called Action Servers. This is like having a central manager that tells these servers what to do, and the servers report back their progress or failures.
This modular setup means we can completely swap out how the robot plans its route or avoids obstacles without touching the rest of the navigation system.
Core Architectural Components
The overall framework is built on four core pillars:
Core Pipeline Data Flow
This is how data moves through the overall architecture at runtime:
- Input: We give Nav2 a goal coordinates destination on the map.
- Brain Check: The BT Navigator receives the goal and commands the Planner Server to calculate a path.
- Global Mapping: The Planner Server checks the Global Costmap and sends a geometry path back to the brain.
- Local Driving: The BT Navigator passes that path to the Controller Server, which cross-references the live Local Costmap (LiDAR data) and sends safe driving commands to the
/cmd_veltopic. - Monitoring: If the controller gets blocked by an obstacle, the BT Navigator halts driving and calls the Behaviour Server to run a recovery manoeuvre.