# hkwns6otyn/burger_war architecture

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

- Interactive diagram: https://gitdiagram.com/hkwns6otyn/burger_war
- Repository: https://github.com/hkwns6otyn/burger_war

## Overview

##### Project Overview & Context
- This project is a robotics game where robots (turtlebot3 based “burger” robots) compete by “reading” AR markers rather than firing actual weapons. It supports both real-world deployments (実機) and Gazebo simulation.
- There are separate ROS packages for robot navigation and battle (burger_navigation and burger_war) as well as a dedicated server for managing scores and game state (the judge folder).

##### Key Components
a. Core ROS Packages:
- burger_war: Contains launch files, simulation scripts, models (URDF/xacro and Gazebo SDF), world definitions, and ROS nodes (Python scripts and some C++ code) that control the robots.
- burger_navigation: Provides navigation stack functionality including different planning parameters, costmap configuration, and rviz configurations.
b. Simulator & Environment:
- Gazebo world files in burger_war/world and associated model definitions (inside burger_war/models) that configure the virtual battlefield (burger_field).
- Launch files to start the simulation (setup_sim.launch) and robot run (sim_robot_run.launch).
c. Judge Server:
- Located under the judge directory, it is responsible for handling game rules, state logging, and providing a visual interface to monitor the game.
- It includes the main judgeServer.py, test scripts, marker set configurations, and client-side web templates/static files to show results.
d. Supporting Launch & Script Components:
- Top-level launch files (e.g., your_burger.launch, setup.launch) that initialize ROS nodes, configure namespaces, and control simulation/real robot startup.
- Python scripts under burger_war/scripts serving different roles (e.g., teleoperation, sensor handling, AR marker reading, state publishing).

##### Relationships and Data Flow
- The robot system (either simulation or actual) communicates with:
- Navigation nodes (for local/global planning) provided by burger_navigation
- Robot control nodes (e.g., teleop, enemy, and dedicated battle scripts)
- Hardware drivers (camera sensors, potentially LIDAR, etc.)
- The Judge Server subsystem (in the judge folder):
- Connects to the robots via ROS topics (publishing state messages such as war_state.msg and CvRect.msg).
- May use HTTP (Flask) to serve a visual interface and handle game management.
- Data flows include:
- Sensor data (from cameras for AR marker detection) flowing from the robot to processing nodes.
- Navigation commands and telemetry between robot control nodes in their dedicated namespaces.
- Higher-level game state updates between the robots and the judge server.

1. ROS Master: Central to the entire system.
2. Robot Subsystem (burger_war):
- Node Group for robot initialization (launch files for real and simulated robots).
- Navigation module (burger_navigation) that includes costmap configurations and planning parameters.
- Simulation Environment: Gazebo world environment along with defined models.
3. Judge Server:
- JudgeServer node (Python script) managing the game rules and state.
- Supporting components for logging, marker configuration, and visualization (e.g., visualizing window and web templates).
4. External Integration and Startup Scripts:
- Startup and one-click execution scripts (in scripts/ and judge/test_scripts) that tie together launching of robots, simulation, and the judge server.
- Interactions:
- Data flows (topics, parameters, service calls) between robot nodes and the judge server should be shown.
- How namespace separation for the two competing robots (red_bot and blue_bot) affects topic/message routing.

##### Architectural Patterns and Technologies
- That the project leverages ROS’s node and topic architecture to create a loosely coupled system where simulation nodes, navigation, sensor processing, and game adjudication are all independent yet interconnected.
- Usage of:
- ROS launch files to parameterize the robot’s behavior (via arguments such as side and robot_name).
- Standard ROS message types (war_state.msg, CvRect.msg) for inter-node communication.
- Gazebo simulation for the virtual environment.
- The separation between simulation (burger_navigation, gazebo launch files) and game logic (burger_war scripts and judge server).

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% ROS Infrastructure
    ROSMaster["ROS Master"]:::ros

    %% Robot Subsystem
    subgraph "Robot Subsystem"
        BW["burger_war Package"]:::pkg
        BWLaunch["Launch Files (burger_war)"]:::launch
        BWScripts["Sensor & AR Marker Scripts"]:::script
        BWModels["Simulation Models"]:::sim
        BWWorld["Gazebo World"]:::sim
        BN["burger_navigation Package"]:::pkg
        BNConfig["Navigation & Planning"]:::nav
    end

    %% Judge Server Subsystem
    subgraph "Judge Server Subsystem"
        JudgeNode["Judge Server (Flask, Logging, Visual)"]:::judge
    end

    %% External Startup & Integration
    subgraph "External Startup & Integration"
        Startup["Start-up & One-Click Scripts"]:::script
    end

    %% Relationships and Data Flow
    ROSMaster -->|"Coordinates"| BW
    ROSMaster -->|"Coordinates"| BN
    ROSMaster -->|"Publishes/Subscribes"| JudgeNode

    BW -->|"ContainsLaunchFiles"| BWLaunch
    BW -->|"ContainsScripts"| BWScripts
    BW -->|"DefinesModels"| BWModels
    BW -->|"IncludesWorld"| BWWorld

    BN -->|"ProvidesNavigation"| BNConfig

    BWScripts -->|"SendsSensorData"| JudgeNode
    BWLaunch -->|"TriggersNodes"| Startup
    BNConfig -->|"SendsNavCommands"| BW

    Startup -->|"InitiatesLaunch"| BW
    Startup -->|"InitiatesNav"| BN

    %% Click Events
    click BW "https://github.com/hkwns6otyn/burger_war/tree/master/burger_war/"
    click BWLaunch "https://github.com/hkwns6otyn/burger_war/tree/master/burger_war/launch"
    click BWModels "https://github.com/hkwns6otyn/burger_war/tree/master/burger_war/models"
    click BWWorld "https://github.com/hkwns6otyn/burger_war/tree/master/burger_war/world"
    click BN "https://github.com/hkwns6otyn/burger_war/tree/master/burger_navigation/"
    click JudgeNode "https://github.com/hkwns6otyn/burger_war/tree/master/judge/"
    click BWScripts "https://github.com/hkwns6otyn/burger_war/tree/master/burger_war/scripts"

    %% Styles
    classDef ros fill:#f9f,stroke:#333,stroke-width:2px;
    classDef pkg fill:#ccf,stroke:#333,stroke-width:2px;
    classDef launch fill:#9f9,stroke:#333,stroke-width:2px;
    classDef sim fill:#ff9,stroke:#333,stroke-width:2px;
    classDef nav fill:#cff,stroke:#333,stroke-width:2px;
    classDef judge fill:#fc9,stroke:#333,stroke-width:2px;
    classDef script fill:#cfc,stroke:#333,stroke-width:2px;
```
