Overview
Path planning computes a collision-free path from robot’s current position to goal. Nav2 uses two levels of planning:Global Planner
Plans complete path from start to goal using static map. Updates when goal changes or path blocked.
Local Planner (Controller)
Follows global path while avoiding dynamic obstacles. Updates continuously (20-50Hz).
Global Planners
NavFn Planner
Dijkstra-based planner (default):- Fast: O(n log n) complexity
- Complete: Finds path if exists
- Smooth: Produces reasonable paths
- No optimization: May not be shortest
Smac Planner
State lattice planner (better for complex robots):- Kinematically feasible: Respects robot constraints
- Smoother paths: Better for Ackermann steering
- Slower: More computation
- Configurable: Many tuning parameters
Comparison
| Feature | NavFn | Smac |
|---|---|---|
| Speed | Fast | Slower |
| Path Quality | Good | Better |
| Kinematic Constraints | No | Yes |
| Reverse Motion | No | Yes (Reeds-Shepp) |
| Best For | Omnidirectional | Car-like, complex |
Local Planners (Controllers)
DWB (Dynamic Window Approach)
Trajectory rollout planner (default):- Sample velocity space (vx, vy, vtheta)
- Simulate trajectory for each sample
- Score trajectories using critics
- Select best trajectory
- Execute first command
- PathAlign: Prefer trajectories aligned with global path
- GoalAlign: Turn toward goal when close
- PathDist: Stay close to path
- GoalDist: Move toward goal
- BaseObstacle: Avoid obstacles
- RotateToGoal: Rotate to final orientation
- Oscillation: Penalize back-and-forth motion
TEB (Timed Elastic Band)
Optimization-based planner:- Smooth paths: Optimizes for smoothness
- Time-optimal: Minimizes travel time
- Complex: Many parameters
- CPU intensive: Requires good processor
MPPI (Model Predictive Path Integral)
Sampling-based MPC controller:- Probabilistic: Explores velocity space stochastically
- Robust: Handles uncertainty well
- Smooth: Natural motion
- Experimental: Newer, less tested
Costmaps
Costmaps represent obstacle information for planning.Global Costmap
For global planning (entire map):Local Costmap
For local planning (around robot):Robot Footprint
For non-circular robots:Tuning Guide
Path Quality Issues
Problem: Paths too close to obstaclesController Tuning
Problem: Robot oscillatesPerformance Optimization
High CPU usage:Visualization
View Costmaps
In RViz:- Add → Map
- Topic:
/global_costmap/costmap - Color Scheme: costmap
- 254 (red): Lethal obstacle
- 253 (pink): Inscribed obstacle (robot footprint touches)
- 128-252 (orange-yellow): Inflation zone
- 0 (blue): Free space
- 255 (gray): Unknown
View Plans
Global plan:- Add → Path
- Topic:
/plan - Color: Green
- Add → Path
- Topic:
/local_plan - Color: Red
Next Steps
Behavior Trees
Customize navigation decision logic
Navigation Testing
Validate and benchmark navigation
Recovery Behaviors
Configure what happens when stuck
Nav2 Tuning Guide
Official Nav2 configuration guide