Core Engineering Takeaways
- •Navigation separates into two loops: a slow Global Planner (1-5 Hz) finding topological paths, and a fast Local Controller (20-100 Hz) steering clear of dynamic obstacles.
- •A* achieves optimal heuristic graph search, whereas RRT* (Rapidly-exploring Random Trees) explores high-degree-of-freedom continuous configuration spaces with asymptotic optimality.
- •The Timed Elastic Band (TEB) planner deforms the global path in real time, optimizing for time-of-flight, clearance distance, and motor acceleration limits simultaneously.
- •Costmaps convert raw sensor point clouds into 2D/3D grids with lethal obstacle zones and exponential inflation decays so robots never clip walls.
- •Modern ROS 2 Nav2 uses Behavior Trees (BT) instead of finite state machines, allowing clean recovery behaviors (backing up, spinning, clearing costmaps) without code lockups.
- Coordinate frames and transform tree (TF2) basics
- Differential drive and unicycle kinematics
- Basic probability and grid representations (occupancy grids)
2. Global Path Planning: Graph Search (A*, Dijkstra) & Sampling (RRT*)
Global planners compute paths through a configuration space (C-space) where the robot is represented as a dimensionless point and obstacles are grown by the robot's inscribed radius.
Graph-Based Planners: Dijkstra vs A*
- Dijkstra's Algorithm: Uniformly expands outward in concentric rings, evaluating cost from the start node. It guarantees the shortest path but evaluates unnecessary nodes away from the goal.
- A* Algorithm: Uses a heuristic (typically Euclidean or Manhattan distance) to prioritize exploration towards the goal node:
where is the accumulated path cost from start to node , and is the estimated remaining distance to the goal.
Sampling-Based Planners: RRT and RRT*
In large outdoor spaces or high-dimensional manipulator arms, grid search suffers from the "curse of dimensionality". RRT (Rapidly-exploring Random Trees) incrementally builds a search tree by picking random points in continuous space. RRT* introduces local edge rewiring: when a new node is added, it rewires neighboring nodes if passing through the new node yields lower accumulated path cost, guaranteeing asymptotic optimality.
A* Heuristic Evaluation Function
| Algorithm | Search Paradigm | Optimality | CPU Cost | Best Suited For |
|---|---|---|---|---|
| Dijkstra | Graph Grid (Exhaustive) | Guaranteed Shortest | High (Explores all directions) | Pre-computed static transit routes |
| A* | Graph Grid (Heuristic) | Guaranteed Shortest (if h admissible) | Moderate | 2D Indoor Warehouses and AGVs |
| RRT | Continuous Sampling | Sub-optimal (Probabilistically Complete) | Low / Fast | Quick feasibility checks in mazes |
| RRT* | Continuous Sampling + Rewiring | Asymptotically Optimal | Moderate-High | High-DOF arms and off-road navigation |
| Theta* | Any-Angle Grid Search | Near-Optimal (Straight diagonals) | Moderate | Robots that do not want jagged 90° zig-zags |
3. Local Trajectory Controllers: DWB, TEB & Model Predictive Control (MPC)
The local controller takes the global path and generates actuator velocity commands every 20–50 ms.
1. DWA / DWB (Dynamic Window Approach)
Discretizes the robot's velocity space into allowable pairs based on current motor accelerations over a brief time window . It forward-simulates circular trajectory arcs, scores them against obstacle clearance, global path alignment, and forward speed, and picks the highest scoring velocity tuple.
2. TEB (Timed Elastic Band)
Represents the path as an elastic rubber band deformed by virtual forces:
- Internal elastic tension pulling nodes together (shortening time).
- Repulsive potential fields pushing nodes away from live LiDAR obstacles.
- Non-holonomic kinematic constraints preventing sideways wheel slippage.
TEB optimizes both spatial waypoints and time intervals simultaneously, producing buttery-smooth trajectories that brake naturally before corners.
3. MPC (Model Predictive Control)
Uses a physics-based dynamic model of the vehicle to solve a quadratic optimization problem over a finite preview horizon (e.g., 20 steps into the future). Highly popular in autonomous highway vehicles and high-speed Ackermann rovers.
import numpy as np
def evaluate_trajectory_velocity(v, w, dt, horizon, obstacles, goal_pose):
"""
Simulates unicycle trajectory: x_{t+1} = x_t + v*cos(theta)*dt
Scores for clearance, speed, and goal distance.
"""
x, y, theta = 0.0, 0.0, 0.0
min_dist_to_obs = float('inf')
for t in np.arange(0, horizon, dt):
x += v * np.cos(theta) * dt
y += v * np.sin(theta) * dt
theta += w * dt
# Calculate distance to nearest obstacle point
for ox, oy in obstacles:
dist = np.hypot(x - ox, y - oy)
if dist < min_dist_to_obs:
min_dist_to_obs = dist
if min_dist_to_obs < 0.25: # Collision threshold (inscribed radius)
return -1.0 # Lethal collision
dist_to_goal = np.hypot(goal_pose[0] - x, goal_pose[1] - y)
score = (0.6 * v) + (0.3 * min_dist_to_obs) - (0.5 * dist_to_goal)
return scoreNote: Core evaluation function of Dynamic Window local planning: forward-simulating motion arcs and scoring against obstacle clearance and goal heading.
4. Costmaps: Static, Obstacle, Voxel & Inflation Decay Math
A costmap translates geometric surroundings into a 2D grid of 8-bit cost values from 0 (Free Space) to 255 (Lethal Obstacle).
Modern Nav2 costmaps use a layered plugin pipeline:
- Static Map Layer: Reads the SLAM 2D occupancy grid (walls, permanent pillars).
- Obstacle Layer: Integrates live 2D planar LiDAR scans via raytracing (marking hits as obstacles and clearing free space along laser rays).
- Voxel Layer: Maintains 3D voxel columns from RGB-D depth cameras to detect low obstacles (pallets, steps) and overhead overhangs (pipes).
- Inflation Layer: Propagates costs outwards from lethal boundaries using an exponential decay function. This guarantees the robot's physical bumper never touches an obstacle.
Costmap Inflation Decay Formula
5. Kinematics & Dynamic Feasibility: Differential vs Ackermann vs Omnidirectional
Path planners must know what motion the chassis can physically execute:
- 1Holonomic (Omnidirectional / Mecanum):
- Degrees of freedom match controllable inputs: can drive sideways while rotating .
- Simplest for path planning; any coordinate can be traversed directly.
- 2Non-Holonomic Differential Drive (2-Wheel / Unicycle):
- Cannot translate sideways (). Must rotate in place before driving forward.
- Requires trajectories with continuous curvature or explicit zero-radius pivot points.
- 3Non-Holonomic Ackermann Steering (Car-like):
- Cannot rotate in place! Has a minimum turning radius .
- Must use specialized planners like Hybrid A* or Reeds-Shepp curves that account for reverse gearing and steering angle limits.
| Drive Architecture | Sideways Translation | In-Place Rotation | Minimum Turning Radius | Standard Local Planner |
|---|---|---|---|---|
| Differential Drive (2WD/Tracks) | No (v_y = 0) | Yes (Zero radius) | 0 meters | DWB, TEB Local Planner |
| Ackermann (Car steering) | No (v_y = 0) | No | L / tan(delta_max) | TEB (Ackermann mode), Hybrid A*, MPC |
| Mecanum / Omnidirectional | Yes (Full holonomic) | Yes (Simultaneous) | 0 meters | Omni DWB, MPPI, Vector Pursuit |
| Tricycle / Steered Wheel | No | No | Varies by pivot angle | Pure Pursuit, TEB |
Common Questions & Troubleshooting
Q:Why does my robot oscillate back and forth when approaching the goal pose?
This classic "hunting" oscillation happens when the goal XY tolerance is set too tight (e.g. 2 cm) while odometry drift or noise is 3-5 cm. Fix this by: (1) Increasing xy_goal_tolerance to 0.08–0.15 m, (2) Enabling yaw_goal_tolerance latching so the robot stops translating before rotating to final heading, and (3) Decreasing deceleration limits near the goal.
Q:What is the difference between Inscribed Radius and Circumscribed Radius?
Inscribed Radius is the radius of the largest circle entirely inside your robot footprint. Any obstacle inside this radius is guaranteed to be a collision. Circumscribed Radius is the radius of the smallest circle containing your entire footprint (including corners). If an obstacle is farther than the circumscribed radius, the robot can rotate freely without hitting anything.
Q:When should I choose TEB over DWB in ROS 2 Nav2?
Use DWB for simple, circular differential drive robots in wide indoor spaces where low CPU usage is critical. Choose TEB when: (1) Your robot is non-circular (rectangular or long pallet mover), (2) You have an Ackermann car chassis with turning radius limits, or (3) You navigate tight corridors with dynamic obstacles where velocity and acceleration constraints must be optimized simultaneously.
