Nav2 architecture overview

From wimblerobotics/ros2-copilot-skills · View interactive version

Nav2 architecture overview is an AI agent skill from the GitHub repository wimblerobotics/ros2-copilot-skills. Understand Nav2 architecture and component interactions. Use when learning how planner, controller, BT navigator, and costmaps fit together.

How to use this skill

Skill file

<!--

SPDX-FileCopyrightText: 2026 Michael Wimble

SPDX-License-Identifier: Apache-2.0

-->


name: nav2-architecture-overview

description: 'Understand Nav2 architecture and component interactions. Use when learning how planner, controller, BT navigator, and costmaps fit together.'


Nav2 Architecture Overview

System Architecture

Nav2 is a collection of lifecycle-managed servers orchestrated by a Behavior Tree (BT) Navigator. Every server runs as a lifecycle node managed by nav2_lifecycle_manager.

Core Servers

| Server | Role | Default Action |

|--------|------|----------------|

| BT Navigator | Orchestrates navigation via behavior trees | navigate_to_pose, navigate_through_poses |

| Planner Server | Computes global paths (e.g., NavFn) | compute_path_to_pose |

| Controller Server | Follows paths locally (e.g., MPPI) | follow_path |

| Behavior Server | Executes recoveries (spin, backup, wait) | spin, backup, drive_on_heading, wait |

| Smoother Server | Refines global paths post-planning | smooth_path |

| Velocity Smoother | Limits acceleration/jerk on cmd_vel | Subscribes/publishes cmd_vel |

| Collision Monitor | Final safety layer before motors | Subscribes/publishes cmd_vel |

| Waypoint Follower | Manages multi-goal sequences | follow_waypoints |

Costmap Servers

The Planner Server hosts the global costmap and the Controller Server hosts the local costmap. Each costmap is a Costmap2D instance with its own plugin layers (static, inflation, obstacle, voxel). The global costmap covers the full map; the local costmap is a rolling window around the robot.

Data Flow Pipeline

Goal (PoseStamped)
  → BT Navigator (selects planner + controller)
    → Planner Server → global path (nav_msgs/Path)
      → Smoother Server (optional) → smoothed path
        → Controller Server → raw cmd_vel
          → Velocity Smoother → rate-limited cmd_vel
            → Collision Monitor → safe cmd_vel
              → Motor driver

The BT Navigator is the central coordinator. It does NOT compute paths or velocities itself—it delegates to the planner and controller servers via action calls and handles recovery logic through behavior tree nodes.

Lifecycle Management

All Nav2 servers implement the ROS 2 managed (lifecycle) node interface. The nav2_lifecycle_manager transitions them through: unconfigured → inactive → active. Two lifecycle managers are typical:

Startup order matters—nodes are activated in the order listed in node_names.

Launch Structure (nav2_bringup)

The standard nav2_bringup package provides:

bringup_launch.py          # Top-level: localization + navigation + rviz
  ├── localization_launch.py   # map_server + amcl + lifecycle_manager_localization
  ├── navigation_launch.py     # All nav servers + lifecycle_manager_navigation
  └── rviz_launch.py           # RViz2 with nav2 panel

navigation_launch.py uses RewrittenYaml to inject use_sim_time into every node's parameters:

configured_params = RewrittenYaml(
    source_file=params_file,
    root_key='',
    param_rewrites={'use_sim_time': use_sim_time},
    convert_types=True
)

BT Navigator Details

The BT Navigator loads an XML behavior tree file. Default trees are in nav2_bt_navigator/behavior_trees/. Key trees:

The BT uses action nodes (ComputePathToPose, FollowPath), condition nodes (GoalReached, IsPathValid), decorator nodes (RateController for replanning rate), and control nodes (PipelineSequence, RecoveryNode).

Key Topics

| Topic | Type | Purpose |

|-------|------|---------|

| /cmd_vel | geometry_msgs/Twist | Final velocity command to motors |

| /cmd_vel_nav | geometry_msgs/Twist | Controller output before smoothing |

| /plan | nav_msgs/Path | Current global plan for visualization |

| /local_plan | nav_msgs/Path | Controller's local trajectory |

| /map | nav_msgs/OccupancyGrid | Static map |

| /global_costmap/costmap | nav2_msgs/Costmap | Global costmap |

| /local_costmap/costmap | nav2_msgs/Costmap | Local costmap |

Key Design Decisions

Common Debugging Entry Points

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.