# tranhoaiduong136/capstoneproject architecture

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

- Interactive diagram: https://gitdiagram.com/tranhoaiduong136/capstoneproject
- Repository: https://github.com/tranhoaiduong136/capstoneproject

## Overview

##### Project Type & Purpose
- This is a multi-agent path planner for robots constrained to move along grid edges. It integrates both motion planning and visualization using ROS.
- The important components include a motion planner node (that calculates the shortest, collision-free path) and an agent node (that handles the robot’s actual movement visualization and user-triggered goal updates).

##### File Structure
- Top-level files like CMakeLists.txt and package.xml indicate that this is a ROS package.
- The “src” directory contains C++ source files divided into two groups:
- motion_planner_node and its corresponding object files (source/object files for the planner’s functionality)
- agent_node and its object files (for agent representation and goal updates).
- The “srv” and “msg” directories show custom service definitions and messages (get_plan, update_goal, and agent_info), which facilitate inter-node communication via ROS services and topics.
- The “launch” directory contains launch files (agents.launch) to start and wire up the various nodes.
- The “rviz” directory holds configurations for the RViz display.
- The “media” directory, although not affecting architecture directly, contains videos that validate the system’s functioning.
- The “test” directories indicate that unit-testing is a part of the system, testing both the service calls (update_goal) and planning algorithm.

##### Key Components & Their Interactions
- Motion Planner Node:
- Responsible for computing the optimal path using A*.
- Publishes marker topics (grid nodes free/occupied) for grid visualization.
- Subscribes to feedback from agent nodes.
- Provides a service endpoint (/get_plan) for other nodes (i.e., agent nodes) to request a path.
- Files: motion_planner_node.cpp, motion_planner_obj.cpp/h.
- Agent Node:
- Responsible for receiving a goal pose via a ROS service call (/agent_x/update_goal).
- Acts as a service client calling /get_plan to receive the planned path.
- Publishes markers for both the base link of the robot and its planned path.
- Files: agent_node.cpp, agent_obj.cpp/h.
- ROS Communication:
- Service calls between agent nodes and the motion planner.
- Topics for publishing visualizations (e.g., grid nodes, agent base link, and path).
- Feedback channel through a common /agent_feedback topic.

##### Architectural Patterns & Design Principles
- Modular node design: Separates motion planning and agent actions into dedicated ROS nodes.
- Service-Oriented Architecture: Using ROS services (get_plan, update_goal) ensures decoupled communication between the motion planner and agents.
- Object-based implementation: Both nodes leverage object-oriented programming to encapsulate their functionality.
- Scalability: The design supports scaling (adding more agents by including additional agent nodes and corresponding markers) with minimal changes.

- Clear labels for each ROS node: Motion Planner Node and Agent Node(s).
- Service calls (/get_plan, /update_goal).
- Published topics: grid markers, path, agent feedback, etc.

## Diagram (Mermaid)

```mermaid
flowchart TD
    A["Launch Setup"]:::serviceSetup
    B["ROS Master"]:::core
    H["ROS Service Definitions"]:::nodeBlue
    C["Motion Planner Node<br/>(/get_plan server)"]:::nodeBlue
    D["Agent Node<br/>(update_goal client/server)"]:::nodeBlue
    G["(/agent_feedback Topic)"]:::topic
    E["Rviz<br/>(Visualization)"]:::vis
    F["Testing Framework"]:::test

    %% Layout Connections
    A -->|"launches"| B
    B -->|"defines services"| H
    H --- C
    H --- D

    D -->|"calls_/get_plan"| C
    C -->|"returns_path"| D

    C -->|"publishes_grid_markers"| E
    D -->|"publishes_robot_markers"| E

    C -- "publishes_feedback" --> G
    D -- "publishes_feedback" --> G

    F --- C
    F --- D

    %% Click Events
    click A "https://github.com/tranhoaiduong136/capstoneproject/blob/master/launch/agents.launch"
    click C "https://github.com/tranhoaiduong136/capstoneproject/blob/master/src/motion_planner_node.cpp"
    click D "https://github.com/tranhoaiduong136/capstoneproject/blob/master/src/agent_node.cpp"
    click H "https://github.com/tranhoaiduong136/capstoneproject/blob/master/srv/get_plan.srv"
    click E "https://github.com/tranhoaiduong136/capstoneproject/blob/master/rviz/rviz_config.rviz"
    click F "https://github.com/tranhoaiduong136/capstoneproject/blob/master/src/test/tests_multi_agent_planner.cpp"

    %% Styles
    classDef nodeBlue fill:#ADD8E6,stroke:#000,stroke-width:2px;
    classDef core fill:#F0E68C,stroke:#000,stroke-width:2px;
    classDef vis fill:#90EE90,stroke:#000,stroke-width:2px;
    classDef serviceSetup fill:#FFD700,stroke:#000,stroke-width:2px;
    classDef test fill:#FFB6C1,stroke:#000,stroke-width:2px;
    classDef topic fill:#FFA500,stroke:#000,stroke-width:2px;
```
