# attu0/spartan architecture

> Architecture diagram of the GitHub repository attu0/spartan, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-02). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/attu0/spartan
- Repository: https://github.com/attu0/spartan

## Overview

This repository implements an operator-teleoperated tracked rover with a 4-DOF arm, stereo camera, and local Streamlit dashboard. The operator selects arm, camera, or rover controls; the dashboard dispatches arm commands through the UNO Q bridge, sends rover commands over serial to the Mega, and displays camera and locally computed depth imagery. The README documents hardware-level relationships; the Mega firmware directory is present but its source was not sampled, and GPS is currently stubbed rather than an active capability.

Main entry points: [`python/ui.py`](https://github.com/attu0/spartan/blob/main/python/ui.py) (Control Dashboard), [`python/vision.py`](https://github.com/attu0/spartan/blob/main/python/vision.py) (Camera Capture), [`python/main.py`](https://github.com/attu0/spartan/blob/main/python/main.py) (App Entry), [`python/arm_control.py`](https://github.com/attu0/spartan/blob/main/python/arm_control.py) (Arm Interface)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_dashboard["Operator Dashboard"]
  node_app_entry["App Entry<br/>[main.py]"]
  node_dashboard_ui["Control Dashboard<br/>[ui.py]"]
end

subgraph group_arm["Arm Control"]
  node_arm_interface["Arm Interface<br/>[arm_control.py]"]
  node_uno_firmware["UNO Q Firmware<br/>[sketch.ino]"]
  node_arm_hardware{{"Arm Motors"}}
end

subgraph group_rover["Rover Locomotion"]
  node_rover_interface["Rover Interface<br/>[rover_control.py]"]
  node_mega_firmware["Mega Firmware"]
  node_track_drive{{"Track Motors"}}
  node_gps_status["GPS Status Stub<br/>[rover_control.py]"]
end

subgraph group_vision["Stereo Vision"]
  node_stereo_camera{{"Stereo Camera"}}
  node_camera_capture["Camera Capture<br/>[vision.py]"]
  node_depth_processing["Depth Processing<br/>[vision.py]"]
end

node_operator(("Operator"))

node_operator -->|"opens dashboard"| node_app_entry
node_app_entry -->|"loads pages"| node_dashboard_ui
node_dashboard_ui -->|"dispatches arm"| node_arm_interface
node_arm_interface -->|"calls bridge"| node_uno_firmware
node_uno_firmware -->|"drives directly"| node_arm_hardware
node_dashboard_ui -->|"dispatches drive"| node_rover_interface
node_rover_interface -->|"sends serial commands"| node_mega_firmware
node_mega_firmware -->|"controls locomotion"| node_track_drive
node_stereo_camera -->|"streams frames"| node_camera_capture
node_camera_capture -->|"provides stereo frames"| node_depth_processing
node_dashboard_ui -->|"starts and reads capture"| node_camera_capture
node_dashboard_ui -->|"starts and reads depth"| node_depth_processing
node_dashboard_ui -->|"reads status"| node_gps_status

click node_app_entry "https://github.com/attu0/spartan/blob/main/python/main.py"
click node_dashboard_ui "https://github.com/attu0/spartan/blob/main/python/ui.py"
click node_arm_interface "https://github.com/attu0/spartan/blob/main/python/arm_control.py"
click node_uno_firmware "https://github.com/attu0/spartan/blob/main/sketch/sketch.ino"
click node_rover_interface "https://github.com/attu0/spartan/blob/main/python/rover_control.py"
click node_mega_firmware "https://github.com/attu0/spartan/tree/main/mega_code/ros_arduino_bridge"
click node_camera_capture "https://github.com/attu0/spartan/blob/main/python/vision.py"
click node_depth_processing "https://github.com/attu0/spartan/blob/main/python/vision.py"
click node_gps_status "https://github.com/attu0/spartan/blob/main/python/rover_control.py"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_app_entry,node_dashboard_ui toneBlue
class node_arm_interface,node_uno_firmware,node_arm_hardware toneAmber
class node_rover_interface,node_mega_firmware,node_track_drive,node_gps_status toneMint
class node_stereo_camera,node_camera_capture,node_depth_processing toneRose
class node_operator toneIndigo
```

## Components

### Operator Dashboard

- [App Entry](https://github.com/attu0/spartan/blob/main/python/main.py): `python/main.py`
- [Control Dashboard](https://github.com/attu0/spartan/blob/main/python/ui.py): `python/ui.py`

### Arm Control

- [Arm Interface](https://github.com/attu0/spartan/blob/main/python/arm_control.py): `python/arm_control.py`
- [UNO Q Firmware](https://github.com/attu0/spartan/blob/main/sketch/sketch.ino): `sketch/sketch.ino`
- **Arm Motors**

### Rover Locomotion

- [Rover Interface](https://github.com/attu0/spartan/blob/main/python/rover_control.py): `python/rover_control.py`
- [Mega Firmware](https://github.com/attu0/spartan/tree/main/mega_code/ros_arduino_bridge): `mega_code/ros_arduino_bridge`
- **Track Motors**
- [GPS Status Stub](https://github.com/attu0/spartan/blob/main/python/rover_control.py): `python/rover_control.py`

### Stereo Vision

- **Stereo Camera**
- [Camera Capture](https://github.com/attu0/spartan/blob/main/python/vision.py): `python/vision.py`
- [Depth Processing](https://github.com/attu0/spartan/blob/main/python/vision.py): `python/vision.py`

### Other components

- **Operator**

## Connections

- Operator → App Entry: opens dashboard (evidence: `README.md`)
- App Entry → Control Dashboard: loads pages (evidence: `python/main.py`)
- Control Dashboard → Arm Interface: dispatches arm (evidence: `python/ui.py`)
- Arm Interface → UNO Q Firmware: calls bridge (evidence: `README.md`)
- UNO Q Firmware → Arm Motors: drives directly (evidence: `README.md`)
- Control Dashboard → Rover Interface: dispatches drive (evidence: `python/ui.py`)
- Rover Interface → Mega Firmware: sends serial commands (evidence: `python/rover_control.py`)
- Mega Firmware → Track Motors: controls locomotion (evidence: `README.md`)
- Stereo Camera → Camera Capture: streams frames (evidence: `README.md`)
- Camera Capture → Depth Processing: provides stereo frames (evidence: `python/vision.py`)
- Control Dashboard → Camera Capture: starts and reads capture (evidence: `python/ui.py`)
- Control Dashboard → Depth Processing: starts and reads depth (evidence: `python/ui.py`)
- Control Dashboard → GPS Status Stub: reads status (evidence: `python/ui.py`)
