# btvvardhan/ras598_project architecture

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

- Interactive diagram: https://gitdiagram.com/btvvardhan/ras598_project
- Repository: https://github.com/btvvardhan/ras598_project

## Overview

##### Project Type and Purpose
- This is a robotics simulation pipeline combining PX4 (flight control), Gazebo Sim (custom terrain), and ROS 2 (middleware).

##### File Structure
- Top-level:
- README.md, space robotics final report.pdf
- ros2_project/ (ROS 2 package tree)
- Under ros2_project/:
- launch/ (arena.launch.py, drone.launch.py) – orchestration of Gazebo, PX4 and nodes
- resource/ (custom_world.sdf, rviz config) – simulation world and visualization
- ros2_project/ (Python nodes & model weights) – sensor publishers, object detection, coordinate estimation, TF broadcaster, controllers
- package.xml, setup.py/cfg – build and dependency config

##### README Insights
- Stack: ROS 2 Humble/Jazzy, Gazebo Sim, PX4, Python 3.10+, YOLOv8
- Workflow steps: launch drone, publish camera info, run YOLO, estimate coordinates
- Key topics and transforms: `/rgb_camera`, `/depth_camera`, `/synced/*`, TF tree (camera→world)

##### Main Components
a. Simulation Environment
- Gazebo Sim
- PX4 Autopilot plugin
- Custom world (custom_world.sdf)
b. ROS 2 Middleware
- Launch system (drone.launch.py)
- Topics and TF
c. Perception Nodes
- `camera_info_publisher` (sync RGB & depth)
- `yolo` (YOLOv8 detection)
- `coordinates` (3D coordinate computation + TF)
d. Control Nodes
- `velocity_control` / `control` (keyboard or algorithmic commands)
- `odometry_tf_broadcaster` (publish drone pose)
e. Visualization
f. External Dependencies
- NVIDIA GPU (for YOLO)
- colcon build system

##### Relationships and Data Flow
- Gazebo → camera topics (`/rgb_camera`, `/depth_camera`)
- camera_info_publisher subscribes and republishes on `/synced/*`
- yolo node subscribes to `/synced/rgb_camera`, outputs annotated images
- control nodes send velocity or keyboard commands to PX4 through ROS topics
- odometry_tf_broadcaster publishes drone pose transforms for coordinate conversion
- RViz2 subscribes to final image and TF

##### Architectural Patterns and Principles
- Modular ROS 2 node architecture (single responsibility per node)
- Pub-sub messaging pattern for decoupling perception, control, and visualization
- TF2 transform tree for spatial frame management
- Launch files as composition root for bringing up simulation

##### Essential Elements
- Component labels (node names, systems)
- TF transforms (camera_frame → world_frame)

## Diagram (Mermaid)

```mermaid
flowchart TD
    subgraph "Launch: drone.launch.py"
        Gazebo["Gazebo Sim"]:::sim
        PX4["PX4 Autopilot Plugin"]:::sim
        CustomWorld["custom_world.sdf"]:::sim
        CameraInfo["camera_info_publisher\n(Python)"]:::perception
        YOLO["yolo\n(Ultralitycs YOLOv8)"]:::perception
        Coordinates["coordinates\n(3D Estimation)"]:::perception
        OdometryTF["odometry_tf_broadcaster"]:::control
        VelocityCtrl["velocity_control"]:::control
        ControlNode["control\n(Keyboard/Algo)"]:::control
        VisualizerNode["visualizer\n(Markers & Image)"]:::visualization
        ImageViewer["image_viewer"]:::visualization
    end

    MLWeights["YOLOv8 Weights\n(best.pt)"]:::data
    GPU["NVIDIA GPU"]:::external
    RViz2["RViz2"]:::visualization

    CustomWorld -->|loads| Gazebo
    Gazebo -->|"/rgb_camera"| CameraInfo
    Gazebo -->|"/depth_camera"| CameraInfo
    CameraInfo -->|"/synced/rgb_camera"| YOLO
    CameraInfo -->|"/synced/depth_camera"| Coordinates
    YOLO -->|"/annotated/rgb_camera/image"| VisualizerNode
    YOLO -->|"bounding_boxes"| Coordinates
    Coordinates -->|"3D_coords"| VisualizerNode
    OdometryTF -->|"TF tree"| Coordinates
    PX4 -->|"odometry"| OdometryTF
    VelocityCtrl -->|"cmd_vel"| PX4
    ControlNode -->|"cmd_vel"| PX4
    VisualizerNode -->|"/final_image"| ImageViewer
    ImageViewer -->|feeds image| RViz2
    OdometryTF -->|TF frames| RViz2

    MLWeights --> YOLO
    GPU --> YOLO

    classDef sim fill:#AED6F1,stroke:#21618C,color:#1B2631;
    classDef perception fill:#A9DFBF,stroke:#196F3D,color:#1B2631;
    classDef control fill:#F5CBA7,stroke:#BA4A00,color:#1B2631;
    classDef visualization fill:#D2B4DE,stroke:#6C3483,color:#1B2631;
    classDef external fill:#FADBD8,stroke:#922B21,color:#1B2631;
    classDef data fill:#F9E79F,stroke:#B7950B,color:#1B2631;

    click CustomWorld "https://github.com/btvvardhan/ras598_project/blob/main/ros2_project/custom_world.sdf"
    click Gazebo "https://github.com/btvvardhan/ras598_project/blob/main/ros2_project/launch/arena.launch.py"
    click PX4 "https://github.com/btvvardhan/ras598_project/blob/main/ros2_project/launch/drone.launch.py"
    click CameraInfo "https://github.com/btvvardhan/ras598_project/blob/main/ros2_project/ros2_project/camera_info_publisher.py"
    click YOLO "https://github.com/btvvardhan/ras598_project/blob/main/ros2_project/ros2_project/yolo.py"
    click Coordinates "https://github.com/btvvardhan/ras598_project/blob/main/ros2_project/ros2_project/coordinates.py"
    click OdometryTF "https://github.com/btvvardhan/ras598_project/blob/main/ros2_project/ros2_project/odometry_tf_broadcaster.py"
    click VelocityCtrl "https://github.com/btvvardhan/ras598_project/blob/main/ros2_project/ros2_project/velocity_control.py"
    click ControlNode "https://github.com/btvvardhan/ras598_project/blob/main/ros2_project/ros2_project/control.py"
    click VisualizerNode "https://github.com/btvvardhan/ras598_project/blob/main/ros2_project/ros2_project/visualizer.py"
    click ImageViewer "https://github.com/btvvardhan/ras598_project/blob/main/ros2_project/ros2_project/image_viewer.py"
    click MLWeights "https://github.com/btvvardhan/ras598_project/blob/main/ros2_project/ros2_project/best.pt"
    click RViz2 "https://github.com/btvvardhan/ras598_project/blob/main/ros2_project/resource/visualize.rviz"
```
