Nav2

On this page 7

Nav2 is the open-source navigation framework for ROS 2 that takes a mobile robot from its current pose to a goal pose safely, combining localization, costmap-based perception, global path planning, local trajectory control and recovery behaviors. In robotics navigation, it is the successor to the original ROS Navigation Stack and its central node, move_base.

Nav2 is not a single algorithm but a modular system of servers and plugins orchestrated by behavior trees. Integrators choose the planner, controller and costmap layers that fit their platform, which allows the same framework to drive differential-drive service robots, Ackermann vehicles and legged platforms.

How Nav2 is organized

Nav2 divides navigation into independent servers that communicate through ROS 2 actions, topics and services. A central BT Navigator loads a behavior tree that decides when to plan, when to follow a path and when to recover, and it calls each server as a tree node.

Every server is a managed lifecycle node, which means a lifecycle manager configures, activates and shuts down components in a deterministic order. This design gives predictable startup and clean failure handling, both of which matter in commercial deployments.

ServerResponsibilityTypical plugins or inputs
BT NavigatorExecutes the navigation behavior treeNavigateToPose, NavigateThroughPoses
Planner serverComputes a global path to the goalNavFn, Smac Planner, Theta Star
Controller serverGenerates velocity commands to follow the pathRegulated Pure Pursuit, MPPI, DWB
Smoother serverRefines a path for feasibility and comfortSimple and constrained smoothers
Behavior serverRuns recovery actionsSpin, back up, wait, drive on heading
Map server and AMCLProvide the map and global localizationOccupancy grid, laser scans
Core Nav2 servers and their roles

Additional components such as the waypoint follower, velocity smoother and collision monitor sit around this core. The collision monitor acts as an independent safety layer that can slow or stop the robot when polygons around the base detect obstacles, regardless of what the controller commands.

Costmaps and environment representation

Nav2 represents the world through layered 2D costmaps, grids in which each cell holds a cost from free to lethal. The planner uses a global costmap covering the whole map, while the controller uses a smaller rolling local costmap centered on the robot and updated at higher frequency.

LayerSourcePurpose
Static layerPrebuilt occupancy gridEncodes permanent walls and structures
Obstacle layerLaser scans or point cloudsMarks and clears dynamic obstacles in 2D
Voxel layer3D sensor dataTracks obstacles at different heights
Inflation layerOther layersAdds a cost gradient around obstacles
Keepout and speed filtersFilter masksEnforces no-go zones and speed limits
Standard costmap layers

The inflation radius and cost scaling factor strongly shape behavior. A large radius keeps the robot centered in corridors but can close narrow doorways, whereas a small radius allows tight passages at the price of driving closer to obstacles.

Planners and controllers in Nav2

Nav2 separates global planning from local control, and both are selected as plugins. The global planner finds a collision-free route through the global costmap, while the controller converts that route into velocity commands several times per second, reacting to obstacles the map did not contain.

Choosing the right pair depends on the robot’s kinematics and on the environment. Holonomic and differential-drive robots can use simple grid planners, whereas car-like platforms need kinematically feasible planners that respect a minimum turning radius.

Robot or situationRecommended plannerRecommended controller
Differential drive in an officeNavFn or Smac 2DRegulated Pure Pursuit
Ackermann vehicleSmac Hybrid-A*MPPI
Large or irregular footprintSmac State LatticeMPPI
Dynamic crowded spacesSmac 2DMPPI or DWB with tuned critics
Precise docking or alignmentShort straight pathsRotation shim with pure pursuit
Selecting planner and controller plugins

The MPPI controller samples thousands of candidate trajectories and weights them by cost, which handles complex constraints well but requires more CPU. Regulated Pure Pursuit is lightweight and predictable, slowing automatically near obstacles and on sharp curves.

Behavior trees and recovery logic

Behavior trees give Nav2 explicit, editable task logic. A tree expressed in XML defines how planning, control and recovery nodes connect, so engineers can change behavior without recompiling code. Nav2 builds on the BehaviorTree.CPP library.

The default tree replans periodically, follows the path and, when progress stalls, triggers a recovery sequence such as clearing costmaps, spinning in place, waiting or backing up. Teams often add custom nodes for elevators, doors or charging docks, turning navigation into a broader mission executor.

  • NavigateToPose drives to a single goal.
  • NavigateThroughPoses passes through intermediate poses without stopping.
  • FollowWaypoints stops at each waypoint and can run a task there.

Common integration mistakes

Most Nav2 problems come from configuration rather than algorithms. The framework assumes correct transforms, timing and odometry, and it fails in confusing ways when those assumptions break.

SymptomLikely causeFix
Robot oscillates near the goalTolerances tighter than control precisionRelax goal tolerances or tune the controller
Planner reports no valid pathInflation blocks narrow passagesReduce inflation radius or footprint padding
Obstacles never clearSensor ranges or clearing settings wrongAdjust raytrace and obstacle ranges
Transform timeout errorsMissing or delayed TF framesCheck map, odom and base_link chain
Robot drifts off the pathPoor odometry qualityFuse IMU and wheel data before Nav2
Frequent problems and fixes

Nav2 also has inherent limits. Its standard costmaps are two-dimensional, so rough terrain, stairs or overhangs need extra perception, and it does not certify functional safety on its own. Safety-rated scanners and independent emergency stops remain necessary in industrial settings.

Understanding it simply

Nav2 is the software that lets a robot find its own way. It keeps a map of walls and obstacles. It plans a route, much like a phone navigation app. Then it steers the wheels to follow that route.

Sometimes a person blocks a hallway. Nav2 then follows simple rules. It waits, looks around and tries another way. Its key strength is that every part can be swapped. The same system can run a small cleaning robot or a large warehouse vehicle.

Applied in practice

A hospital deploys a differential-drive delivery robot that carries medication between the pharmacy and four wards. The team builds a map with SLAM, then runs Nav2 with AMCL localization, the Smac 2D planner and Regulated Pure Pursuit at 0.6 m/s, adding a keepout filter around operating theaters and a speed filter of 0.3 m/s in patient corridors.

A custom behavior tree node calls the elevator system and waits for the doors before continuing. When visitors block a corridor, the robot waits ten seconds, replans and takes a parallel hallway. Over the first month, the robot completes most deliveries without staff intervention, and the remaining failures trace mainly to closed fire doors, which the team then adds to the tree logic.