# hkust-aerial-robotics/falcon architecture

> Architecture diagram of the GitHub repository hkust-aerial-robotics/falcon, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-04-07). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/hkust-aerial-robotics/falcon
- Repository: https://github.com/hkust-aerial-robotics/falcon

## Overview

##### Main Components and Their Roles
- Exploration Manager Package:
- Contains the core exploration logic including a finite state machine (e.g., exploration_fsm, exploration_data).
- Loads configuration files for both maps and robot models.
- Interacts directly with the planner modules.
- Exploration Preprocessing and Utils:
- Compute the preliminary information such as frontier detection, grid representations, and connectivity graphs.
- Provide helper libraries (e.g., LKH TSP solver integration) used by the planner.
- Fast Planner & Pathfinding Modules:
- Use techniques such as A* search, coverage path guidance and optimization (e.g., using NLopt and bisection methods) to compute flight paths.
- Trajectory generation modules (B-spline, polynomial trajectories) that convert these paths into dynamically feasible trajectories.
- Voxel Mapping and Perception Utilities:
- Handle 3D mapping and environment representation (computing occupancy grids, ESDF/TSDF maps) that support real-time perception.
- Process the simulated sensor data and feed mapping and planning modules.
- UAV Simulator and Associated Sensor Packages:
- Various sub-packages for camera sensing (mesh and pointcloud renderers), map rendering, disturbance injection, and UAV dynamics simulation (SO3 control and quadrotor simulator).
- These packages mimic real sensor outputs and vehicle state feedback.
- Vehicle Control and Disturbance Generators:
- Provide low-level control nodes (e.g., so3_control, so3_disturbance_generator) that interface with trajectory outputs to command the UAV.
- Utility Packages:
- These include multi-map servers, visualization plugins for RViz, message definitions (quadrotor_msgs), pose and odometry utilities, and supporting scripts for deployment.

##### Relationships and Data Flow
- At the highest level, the autonomous exploration cycle begins with environment perception (camera sensors, pointcloud data from the simulated UAV sensor modules), which feed into the voxel mapping system.
- The mapping output is used by the exploration manager and the preprocessing modules to identify regions to explore (frontier detection, occupancy maps).
- Based on these inputs, the fast planner and pathfinding modules compute a coverage path which is then converted to a smooth trajectory by the trajectory generator.
- The trajectory is then fed into the control modules (SO3 control) that simulate vehicle dynamics (or interface with a real UAV on the UniQuad platform) via the UAV simulator.
- Feedback from the simulator (or real sensors on a UAV) is published via ROS topics to complete the control loop.
- In addition, RViz and other visualization utilities allow developers to monitor and debug the system by visualizing maps, planned paths, trajectories, and vehicle poses.

##### Architectural Patterns and Design Principles
- Modularity by ROS Package: Each subsystem (planning, mapping, simulation, control, utilities) is implemented as a ROS package and communicates via ROS topics, services, and messages.
- Separation of Concerns: The separation between perception/mapping, planning, and control ensures each module can be developed, tested, and maintained independently.
- Configuration-Driven: A significant amount of runtime behavior is controlled through YAML configuration files, allowing for flexible testing with different maps and robot models.
- Extensive Use of CMake and ROS Build Systems: The repository is structured with CMakeLists.txt in most modules, indicating that build and integration configurations are explicitly managed.

## Diagram (Mermaid)

```mermaid
graph TD

  %% SENSOR / PERCEPTION LAYER
  subgraph "Sensor/Perception Layer"
    A1["Mesh Renderer"]:::sensor
    A2["Pointcloud Renderer"]:::sensor
    A3["Map Rendering"]:::sensor
  end

  %% MAPPING LAYER
  subgraph "Mapping Layer"
    B1["Voxel Mapping"]:::mapping
  end

  %% EXPLORATION & PREPROCESSING LAYER
  subgraph "Exploration & Preprocessing Layer"
    C1["Exploration Manager"]:::exploration
    C2["Exploration Preprocessing"]:::exploration
    C3["Exploration Utilities"]:::exploration
  end

  %% PLANNING LAYER
  subgraph "Planning Layer"
    D1["Fast Planner"]:::planning
    D2["Pathfinding Modules"]:::planning
    D3["Trajectory Generation"]:::planning
  end

  %% CONTROL LAYER
  subgraph "Control Layer"
    E1["SO3 Control"]:::control
    E2["Disturbance Generator"]:::control
    E3["Quadrotor Simulation"]:::control
  end

  %% UTILITIES & VISUALIZATION LAYER
  subgraph "Utilities & Visualization"
    F1["Multi-map Server"]:::utility
    F2["RViz Plugins"]:::utility
    F3["Pose Utilities"]:::utility
    F4["Quadrotor Msgs"]:::utility
    F5["UAV Utilities"]:::utility
    F6["Waypoint Generator"]:::utility
  end

  %% DATA FLOW / CONNECTIONS
  %% Sensor to Mapping
  A1 -->|"sensor data"| B1
  A2 -->|"sensor data"| B1
  A3 -->|"rendered data"| B1

  %% Mapping to Exploration
  B1 -->|"mapping output"| C1
  B1 -->|"mapping output"| C2
  B1 -->|"mapping output"| C3

  %% Exploration to Planning
  C1 -->|"plan request"| D1
  C1 -->|"plan request"| D2

  %% Planning Pipeline
  D1 -->|"path info"| D3
  D2 -->|"path info"| D3

  %% Planning to Control
  D3 -->|"trajectory"| E1

  %% Control Processing
  E2 -->|"influence"| E3
  E1 -->|"control commands"| E3

  %% Feedback Loop from Control to Mapping (simulated sensor feedback)
  E3 -->|"state feedback"| B1

  %% Utilities integration (for visualization and monitoring)
  E3 -- "feedback topics" --> F2
  C1 -- "status topics" --> F3
  D3 -- "trajectory view" --> F2

  %% CLICK EVENTS
  click C1 "https://github.com/hkust-aerial-robotics/falcon/tree/ros1-noetic/falcon_planner/exploration_manager"
  click C2 "https://github.com/hkust-aerial-robotics/falcon/tree/ros1-noetic/falcon_planner/exploration_preprocessing"
  click C3 "https://github.com/hkust-aerial-robotics/falcon/tree/ros1-noetic/falcon_planner/exploration_utils"
  click D1 "https://github.com/hkust-aerial-robotics/falcon/tree/ros1-noetic/falcon_planner/fast_planner"
  click D2 "https://github.com/hkust-aerial-robotics/falcon/tree/ros1-noetic/falcon_planner/pathfinding"
  click D3 "https://github.com/hkust-aerial-robotics/falcon/tree/ros1-noetic/falcon_planner/trajectory"
  click B1 "https://github.com/hkust-aerial-robotics/falcon/tree/ros1-noetic/falcon_planner/voxel_mapping"
  click A1 "https://github.com/hkust-aerial-robotics/falcon/tree/ros1-noetic/uav_simulator/camera_sensing/mesh_render"
  click A2 "https://github.com/hkust-aerial-robotics/falcon/tree/ros1-noetic/uav_simulator/camera_sensing/pointcloud_render"
  click A3 "https://github.com/hkust-aerial-robotics/falcon/tree/ros1-noetic/uav_simulator/map_render"
  click E1 "https://github.com/hkust-aerial-robotics/falcon/tree/ros1-noetic/uav_simulator/so3_control"
  click E2 "https://github.com/hkust-aerial-robotics/falcon/tree/ros1-noetic/uav_simulator/so3_disturbance_generator"
  click E3 "https://github.com/hkust-aerial-robotics/falcon/tree/ros1-noetic/uav_simulator/so3_quadrotor_simulator"
  click F1 "https://github.com/hkust-aerial-robotics/falcon/tree/ros1-noetic/uav_simulator/utils/multi_map_server"
  click F2 "https://github.com/hkust-aerial-robotics/falcon/tree/ros1-noetic/uav_simulator/utils/rviz_plugins"
  click F3 "https://github.com/hkust-aerial-robotics/falcon/tree/ros1-noetic/uav_simulator/utils/pose_utils"
  click F4 "https://github.com/hkust-aerial-robotics/falcon/tree/ros1-noetic/uav_simulator/utils/quadrotor_msgs"
  click F5 "https://github.com/hkust-aerial-robotics/falcon/tree/ros1-noetic/uav_simulator/utils/uav_utils"
  click F6 "https://github.com/hkust-aerial-robotics/falcon/tree/ros1-noetic/uav_simulator/utils/waypoint_generator"

  %% STYLES
  classDef sensor fill:#f4cccc, stroke:#c27ba0, stroke-width:2px;
  classDef mapping fill:#c9daf8, stroke:#6d9eeb, stroke-width:2px;
  classDef exploration fill:#d9ead3, stroke:#6aa84f, stroke-width:2px;
  classDef planning fill:#fff2cc, stroke:#ffd966, stroke-width:2px;
  classDef control fill:#ead1dc, stroke:#b854a3, stroke-width:2px;
  classDef utility fill:#d9d2e9, stroke:#8e7cc3, stroke-width:2px;
```
