How Robots Navigate Homes: Inside the Nav2 Autonomous Navigation Framework
Robotic vacuum cleaners use SLAM to map unknown homes, then rely on the ROS 2 Nav2 framework—comprising global and local planners, controllers, smoothers, and AMCL localization—to plan optimal paths, avoid dynamic obstacles, and generate velocity commands, with algorithms like Dijkstra, A*, DWA, and TEB explained.
Robot Autonomous Navigation Principles
When a mobile robot first enters an unknown indoor environment it must explore the space, build a map with SLAM, and then repeatedly cover the entire area while avoiding static obstacles (walls, furniture) and dynamic obstacles (people, pets, moved objects).
Nav2 Autonomous Navigation Framework (ROS 2)
Nav2 (Navigation2) is a collection of ROS 2 packages that provide localization, global and local path planning, obstacle avoidance, and motion control for mobile robots.
1. System Architecture
Nav2 operates on a behavior‑tree server that coordinates three core servers and consumes the following data:
Waypoints – goal positions supplied by a user or higher‑level planner.
tf transforms – coordinate frames linking the robot base, odometry, and map.
Odometry – incremental pose estimate from wheel encoders or visual‑inertial sensors.
Map – a 2‑D occupancy grid generated by SLAM.
The three servers are:
Planner Server : computes a global path on the global_costmap using a plug‑in planner (e.g., A* or Dijkstra).
Controller Server : follows the global path, refines it with the local_costmap, and publishes velocity commands on cmd_vel.
Smoother Server : post‑processes the planned trajectory to reduce abrupt turns and acceleration spikes.
The behavior tree defines the execution order and conditional logic for these modules.
2. Global Navigation
The Planner Server generates the optimal route from start to goal on the global_costmap, which merges the static SLAM map with dynamic sensor updates. Cost values encode traversal difficulty (low cost for free space, high cost near obstacles).
Nav2 supports multiple plug‑in planners. Typical choices are:
Dijkstra : exhaustive breadth‑first search guaranteeing the globally optimal path but slower and memory‑intensive.
A* : uses a heuristic to guide the search, offering faster computation at the possible expense of optimality.
3. Local Navigation
The Controller Server refines the global path in real time using a local_costmap built from laser, depth, or point‑cloud sensors. It selects a local planner to generate safe velocity commands.
DWA (Dynamic Window Approach) samples feasible linear and angular velocities, simulates short trajectories, scores each trajectory based on collision risk, distance to the global path, and goal proximity, then selects the highest‑scoring command.
TEB (Time Elastic Band) treats the path as an elastic band of pose points between start and goal. It inserts intermediate poses and solves an optimization problem that minimizes travel time and distance while respecting velocity, acceleration, and obstacle‑clearance constraints.
4. Localization
Nav2 typically uses the AMCL (Adaptive Monte Carlo Localization) package for 2‑D pose estimation on a known map. AMCL maintains a set of particles, each representing a hypothesized robot pose. At each update cycle:
Particles are propagated according to the robot’s motion model.
Sensor measurements (e.g., laser scans) are compared against the map to compute a weight for each particle.
Particles are resampled proportionally to their weights, discarding unlikely hypotheses.
Over time the particle cloud converges to the most probable pose, providing accurate localization for both global and local planners.
In summary, Nav2 integrates SLAM‑derived mapping, global planning (A* / Dijkstra), local planning (DWA / TEB), and Monte‑Carlo localization to enable robust autonomous navigation in dynamic indoor environments.
Liangxu Linux
Liangxu, a self‑taught IT professional now working as a Linux development engineer at a Fortune 500 multinational, shares extensive Linux knowledge—fundamentals, applications, tools, plus Git, databases, Raspberry Pi, etc. (Reply “Linux” to receive essential resources.)
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
