# ros-planning/navigation architecture

> Architecture diagram of the GitHub repository ros-planning/navigation, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2024-12-28). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/ros-planning/navigation
- Repository: https://github.com/ros-planning/navigation

## Overview

##### Main Components Identification
The system should be divided into these major components:

a. Core Navigation Components:
- move_base (central node)
- costmap_2d (environmental representation)
- nav_core (interfaces)

b. Planners:
- global_planner
- navfn (Dijkstra/A* implementation)
- dwa_local_planner
- base_local_planner
- carrot_planner

c. Localization:
- amcl (Adaptive Monte Carlo Localization)
- fake_localization (testing purposes)

d. Recovery Behaviors:
- clear_costmap_recovery
- rotate_recovery
- move_slow_and_clear

e. Support Components:
- map_server
- voxel_grid

**Top Level (User Interface)**

- ▼
**Navigation Core (move_base)**

- ┬─────────────────────┐
- ▼                     ▼                     ▼
**Global Planning    Local Planning        Recovery Behaviors**

- ▼                     ▼                     ▼
**Perception Layer    Control Layer         Safety Layer**

##### Component Relationships

Key interactions:
- Plugin relationships (especially with nav_core)
- Sensor input processing
- Command output flow

##### Specific Implementation Details

a. Input/Output:
- Sensor inputs (odometry, laser scans)
- Goal pose input
- Velocity command outputs

b. Key Interfaces:
- BaseGlobalPlanner
- BaseLocalPlanner
- RecoveryBehavior

c. Costmap Layers:
- Static Layer
- Obstacle Layer
- Inflation Layer
- Voxel Layer

##### Additional Elements

Critical aspects:
- Configuration parameters flow
- Transform (TF) dependencies
- ROS topic/service connections
- Plugin architecture representation

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Style definitions
    classDef core fill:#3498db,stroke:#2980b9,color:white
    classDef planner fill:#2ecc71,stroke:#27ae60,color:white
    classDef recovery fill:#f1c40f,stroke:#f39c12,color:black
    classDef support fill:#95a5a6,stroke:#7f8c8d,color:white
    classDef localization fill:#e74c3c,stroke:#c0392b,color:white
    classDef interface fill:#9b59b6,stroke:#8e44ad,color:white
    classDef costmap fill:#1abc9c,stroke:#16a085,color:white

    %% Core Navigation
    MoveBase["Move Base"]:::core
    CostMap2D["Costmap 2D"]:::costmap
    NavCore["Nav Core Interfaces"]:::interface

    %% Planners
    GlobalPlanner["Global Planner"]:::planner
    Navfn["Navfn"]:::planner
    DWAPlanner["DWA Local Planner"]:::planner
    BaseLocalPlanner["Base Local Planner"]:::planner
    CarrotPlanner["Carrot Planner"]:::planner

    %% Localization
    AMCL["AMCL"]:::localization
    FakeLocalization["Fake Localization"]:::localization

    %% Recovery Behaviors
    subgraph Recovery
        ClearCostmap["Clear Costmap Recovery"]:::recovery
        RotateRecovery["Rotate Recovery"]:::recovery
        MoveSlowClear["Move Slow and Clear"]:::recovery
    end

    %% Support Components
    MapServer["Map Server"]:::support
    VoxelGrid["Voxel Grid"]:::support

    %% Relationships
    MoveBase --> NavCore
    NavCore --> GlobalPlanner
    NavCore --> BaseLocalPlanner
    NavCore --> CostMap2D
    
    GlobalPlanner --> Navfn
    GlobalPlanner --> CarrotPlanner
    BaseLocalPlanner --> DWAPlanner
    
    CostMap2D --> VoxelGrid
    MapServer --> CostMap2D
    
    AMCL --> MoveBase
    FakeLocalization --> MoveBase
    
    MoveBase --> ClearCostmap
    MoveBase --> RotateRecovery
    MoveBase --> MoveSlowClear

    %% Click events for component mapping
    click MoveBase "https://github.com/ros-planning/navigation/blob/noetic-devel/move_base/include/move_base/move_base.h"
    click CostMap2D "https://github.com/ros-planning/navigation/blob/noetic-devel/costmap_2d/include/costmap_2d/costmap_2d.h"
    click NavCore "https://github.com/ros-planning/navigation/tree/noetic-devel/nav_core/include/nav_core/"
    click GlobalPlanner "https://github.com/ros-planning/navigation/blob/noetic-devel/global_planner/include/global_planner/planner_core.h"
    click Navfn "https://github.com/ros-planning/navigation/blob/noetic-devel/navfn/include/navfn/navfn_ros.h"
    click DWAPlanner "https://github.com/ros-planning/navigation/blob/noetic-devel/dwa_local_planner/include/dwa_local_planner/dwa_planner.h"
    click BaseLocalPlanner "https://github.com/ros-planning/navigation/blob/noetic-devel/base_local_planner/include/base_local_planner/trajectory_planner.h"
    click CarrotPlanner "https://github.com/ros-planning/navigation/blob/noetic-devel/carrot_planner/include/carrot_planner/carrot_planner.h"
    click AMCL "https://github.com/ros-planning/navigation/blob/noetic-devel/amcl/include/amcl/amcl_node.cpp"
    click FakeLocalization "https://github.com/ros-planning/navigation/blob/noetic-devel/fake_localization/fake_localization.cpp"
    click ClearCostmap "https://github.com/ros-planning/navigation/blob/noetic-devel/clear_costmap_recovery/include/clear_costmap_recovery/clear_costmap_recovery.h"
    click RotateRecovery "https://github.com/ros-planning/navigation/blob/noetic-devel/rotate_recovery/include/rotate_recovery/rotate_recovery.h"
    click MoveSlowClear "https://github.com/ros-planning/navigation/blob/noetic-devel/move_slow_and_clear/include/move_slow_and_clear/move_slow_and_clear.h"
    click MapServer "https://github.com/ros-planning/navigation/blob/noetic-devel/map_server/include/map_server/image_loader.h"
    click VoxelGrid "https://github.com/ros-planning/navigation/blob/noetic-devel/voxel_grid/include/voxel_grid/voxel_grid.h"

    %% Legend
    subgraph Legend
        L1["Core Component"]:::core
        L2["Planner"]:::planner
        L3["Recovery Behavior"]:::recovery
        L4["Support Service"]:::support
        L5["Localization"]:::localization
        L6["Interface"]:::interface
        L7["Costmap"]:::costmap
    end
```
