# mevans4/41068rs12025-group18 architecture

> Architecture diagram of the GitHub repository mevans4/41068rs12025-group18, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-11-11). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/mevans4/41068rs12025-group18
- Repository: https://github.com/mevans4/41068rs12025-group18

## Overview

##### Project Type and Purpose
- This is a full-stack robotics simulation application:
– Uses Ignition Gazebo for world and robot/drone simulation.
– Runs ROS2 nodes for perception (LiDAR), mapping (SLAM), localization, navigation (Nav2), control (drone_controller), and a Qt-based UI.
– Objective: autonomously navigate plantation rows, detect/count/measure tree trunks, build a rich map, and produce a report.

##### File Structure
Top-level packages (ROS2 workspace):
- 41068_ignition_bringup
– Launch files (launch/…launch.py) to spin up Gazebo, SLAM, Nav2, localization, and robot/drone drivers.
– Models (models/…), URDFs (urdf/, urdf_drone/) define robot and drone.
– config/*.yaml for Gazebo–ROS bridge, Nav2 params, SLAM params, robot_localization params.
- drone_controller
– C++ nodes: altitude_controller, drone_controller (velocity commands), mission_node (goal publisher).
- drone_ui
- lidar_tree_detector
– C++ node subscribing to /scan, publishing TreeDetectionArray.msg.

Other artifacts:
- Saved maps (TreePlantation*.pgm/.yaml), `.posegraph` & `.data` for offline SLAM.
- Drone_UI.ui (Qt Designer file).

##### Key Insights from README
- Autonomous navigation through pine plantation.
- LiDAR-based tree trunk detection, counting, diameter estimation.
- Final outputs: enriched map + report for plantation manager.

1. Simulation Environment
– Ignition Gazebo + world files (worlds/) + models + gazebo_ros_bridges.
2. ROS2 Middleware (DDS) – the communication bus.
3. Perception
– lidar_tree_detector_node
– (SLAM) slam_toolbox node
– map_server node
4. Localization
– robot_localization (EKF)
5. Planning & Mission
– Nav2 stack (planner, controller, bt_navigator)
– mission_node (from drone_controller)
6. Control
– drone_controller (velocity & altitude)
– Gazebo plugins/drivers receive /cmd_vel
7. User Interface
– drone_ui_node (Qt GUI)
8. Data Storage / Reporting
– Map files (.pgm/.yaml)
– Report generator (could be offline script or incorporated in UI)

- Gazebo → (via gazebo_bridge) → /scan, /odom, /tf, sensor topics → ROS2
- /scan → slam_toolbox → /map → map_server → Nav2 & UI
- /odom, /imu → robot_localization → filtered /odom → Nav2 & slam_toolbox
- UI → mission_node → /goal_pose → Nav2
- Nav2 → /cmd_vel → drone_controller → /drone_velocity → Gazebo plugin
- /scan → lidar_tree_detector_node → /tree_detections → UI & logger
- Data outputs (map + detection logs) → report generator

c. Architectural Patterns & Principles
- Modular ROS2 nodes communicate over topics/services.
- Layered pipeline:
– Simulation → Perception → Localization → Planning → Control → Actuation
- Separation of concerns: perception vs. planning vs. control vs. UI
- Reusability: standard Nav2, robot_localization, slam_toolbox

d. Key Technologies & Frameworks
- ROS2 (Foxy/Galactic)
- Ignition Gazebo + gazebo_ros_bridge
- SLAM Toolbox
- robot_localization (EKF)
- Nav2 (nav2_bringup)
- C++ (colcon, ament_cmake)
- Python Qt (PyQt5 or PySide)
- Qt Designer (.ui)
- YAML for configs & map definitions

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Simulation Layer
    subgraph "Simulation Environment" 
        style SimulationEnv fill:#cccccc,stroke:#333,stroke-width:1px
        SimulationEnv["Ignition Gazebo & World"] 
        GazeboLaunch["Gazebo Launch\n41068_ignition.launch.py"] 
        Worlds["World Files\n(worlds/*.sdf)"] 
        URDFs["URDF Models\n(urdf/, urdf_drone/)"] 
        Models["Gazebo Models\n(models/)"] 
    end

    %% ROS2 Middleware
    ROS2Bus["ROS2 DDS Bus"]:::bus

    %% Perception Layer
    subgraph "Perception" 
        style Perception fill:#a8e6cf,stroke:#333,stroke-width:1px
        LiDARNode["lidar_tree_detector_node\n(lidar_tree_detector)"] 
        TreeMsgs["TreeDetectionArray.msg\nTreeDetection.msg"] 
        SLAMParams["SLAM Params\n(slam_params.yaml)"] 
        MapServer["map_server\n(TreePlantation*.pgm/.yaml)"] 
    end

    %% Localization & Mapping
    subgraph "Localization & Mapping"
        style LocMap fill:#dcedc1,stroke:#333,stroke-width:1px
        RobotLoc["robot_localization EKF\n(ekf_node)"] 
        RobotLocParams["robot_localization Params\n(robot_localization.yaml)"] 
        SLAMToolbox["slam_toolbox\n(slamboolbox Node)"] 
    end

    %% Planning & Mission
    subgraph "Planning & Mission"
        style Planning fill:#ffd3b6,stroke:#333,stroke-width:1px
        Nav2["Nav2 Stack\n(planner, controller, bt_navigator)"] 
        Nav2Launch["Nav2 Launch\n(41068_navigation.launch.py)"] 
        Nav2Params["Nav2 Params\n(nav2_params.yaml)"] 
        MissionNode["mission_node\n(drone_controller)"] 
    end

    %% Control Layer
    subgraph "Control"
        style Control fill:#ffaaa5,stroke:#333,stroke-width:1px
        AltController["altitude_controller.cpp"] 
        VelController["drone_controller.cpp"] 
        DroneControllerPkg["drone_controller Package"] 
    end

    %% UI & Reporting
    subgraph "UI & Reporting"
        style UI fill:#d7bde2,stroke:#333,stroke-width:1px
        DroneUI["drone_ui_node\n(PyQt GUI)"] 
        UICode["drone_ui_code.py\nDrone_UI.ui"] 
        ReportFiles["Map & Posegraph Files\n(TreePlantation*.pgm/.yaml/.posegraph/.data)"] 
    end

    %% Connections
    SimulationEnv -->|gazebo_ros_bridge| ROS2Bus
    GazeboLaunch -->|launches| SimulationEnv
    Worlds --> SimulationEnv
    URDFs --> SimulationEnv
    Models --> SimulationEnv

    ROS2Bus -->|"/scan"| LiDARNode
    ROS2Bus -->|"/scan"| SLAMToolbox
    ROS2Bus -->|"/odom, /imu"| RobotLoc
    LiDARNode -->|"/tree_detections"| DroneUI
    LiDARNode -->|"/tree_detections"| ReportFiles

    SLAMToolbox -->|"/map"| MapServer
    MapServer -->|"/map"| Nav2
    RobotLoc -->|"/odom_filtered"| Nav2
    RobotLoc -->|"/odom_filtered"| SLAMToolbox

    DroneUI -->|UI commands| MissionNode
    MissionNode -->|"/goal_pose"| Nav2

    Nav2 -->|"/cmd_vel"| VelController
    Nav2 -->|"/cmd_vel"| AltController
    VelController -->|"/drone_velocity"| ROS2Bus
    AltController -->|"/drone_velocity"| ROS2Bus

    ReportFiles -->|files| DroneUI

    %% Click Events
    click SimulationEnv "https://github.com/mevans4/41068rs12025-group18/tree/main/41068_ignition_bringup/"
    click GazeboLaunch "https://github.com/mevans4/41068rs12025-group18/blob/main/41068_ignition_bringup/launch/41068_ignition.launch.py"
    click Worlds "https://github.com/mevans4/41068rs12025-group18/tree/main/41068_ignition_bringup/worlds/"
    click URDFs "https://github.com/mevans4/41068rs12025-group18/tree/main/41068_ignition_bringup/urdf/"
    click Models "https://github.com/mevans4/41068rs12025-group18/tree/main/41068_ignition_bringup/models/"
    click LiDARNode "https://github.com/mevans4/41068rs12025-group18/blob/main/lidar_tree_detector/src/lidar_tree_detector_node.cpp"
    click TreeMsgs "https://github.com/mevans4/41068rs12025-group18/blob/main/lidar_tree_detector/msg/TreeDetection.msg"
    click TreeMsgs "https://github.com/mevans4/41068rs12025-group18/blob/main/lidar_tree_detector/msg/TreeDetectionArray.msg"
    click SLAMParams "https://github.com/mevans4/41068rs12025-group18/blob/main/41068_ignition_bringup/config/slam_params.yaml"
    click MapServer "https://github.com/mevans4/41068rs12025-group18/blob/main/TreePlantation*.pgm"
    click RobotLocParams "https://github.com/mevans4/41068rs12025-group18/blob/main/41068_ignition_bringup/config/robot_localization.yaml"
    click Nav2Launch "https://github.com/mevans4/41068rs12025-group18/blob/main/41068_ignition_bringup/launch/41068_navigation.launch.py"
    click Nav2Params "https://github.com/mevans4/41068rs12025-group18/blob/main/41068_ignition_bringup/config/nav2_params.yaml"
    click MissionNode "https://github.com/mevans4/41068rs12025-group18/blob/main/drone_controller/src/mission_node.cpp"
    click AltController "https://github.com/mevans4/41068rs12025-group18/blob/main/drone_controller/src/altitude_controller.cpp"
    click VelController "https://github.com/mevans4/41068rs12025-group18/blob/main/drone_controller/src/drone_controller.cpp"
    click DroneControllerPkg "https://github.com/mevans4/41068rs12025-group18/tree/main/drone_controller/"
    click DroneUI "https://github.com/mevans4/41068rs12025-group18/blob/main/drone_ui/drone_ui/drone_ui_node.py"
    click UICode "https://github.com/mevans4/41068rs12025-group18/blob/main/drone_ui/drone_ui/drone_ui_code.py"
    click UICode "https://github.com/mevans4/41068rs12025-group18/blob/main/drone_ui/Drone_UI.ui"

    %% Styles
    classDef bus fill:#e0e0e0,stroke:#666,stroke-width:1px
    classDef external fill:#f9f,stroke:#333,stroke-width:1px
    classDef default fill:#fff,stroke:#333,stroke-width:1px
```
