# makkima16/line_follower_vatr architecture

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

- Interactive diagram: https://gitdiagram.com/makkima16/line_follower_vatr
- Repository: https://github.com/makkima16/line_follower_vatr

## Overview

This is a classical-vision line-following robot with a phone-camera/PC/robot feedback loop, plus a closed-loop track simulator and a small standalone Bluetooth-control demo. The main runtime captures frames, analyzes line and traffic signals, computes navigation commands, translates them to the robot protocol, and sends them asynchronously. The README also documents junction mapping and DFS exploration. Some wiring is supported only by documented behavior or module references; uncertain simulator and phone-page links are omitted or marked unverified.

Main entry points: [`code/main.py`](https://github.com/makkima16/line_follower_vatr/blob/main/code/main.py) (Runtime entry), [`code/simulador.py`](https://github.com/makkima16/line_follower_vatr/blob/main/code/simulador.py) (Closed-loop simulator), [`code/control.py`](https://github.com/makkima16/line_follower_vatr/blob/main/code/control.py) (PD and state machine), [`code/robot.py`](https://github.com/makkima16/line_follower_vatr/blob/main/code/robot.py) (Command sender)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_capture["Video capture"]
  node_phone_server["Phone stream server<br/>[phone_camera.py]"]
  node_camera_page["Camera page<br/>[camera.html]"]
  node_main["Runtime entry<br/>[main.py]"]
end

subgraph group_perception["Perception and navigation"]
  node_vision["Line vision<br/>[vision.py]"]
  node_signals["Signal detection<br/>[senales.py]"]
  node_brain["PD and state machine<br/>[control.py]"]
  node_navigator["Odometry and DFS map<br/>[mapa.py]"]
end

subgraph group_actuation["Control and actuation"]
  node_config["Runtime parameters<br/>[config.py]"]
  node_drivers["Command drivers<br/>[drivers.py]"]
  node_sender["Command sender<br/>[robot.py]"]
  node_robot["Robot transport<br/>[robot.py]"]
end

subgraph group_simulation["Simulation"]
  node_simulator["Closed-loop simulator<br/>[simulador.py]"]
  node_virtual_camera["Virtual camera<br/>[simulador.py]"]
  node_motion_preview["Motion preview<br/>[sim.py]"]
end

subgraph group_legacy["Standalone demo"]
  node_legacy_main["Manual camera demo<br/>[main.py]"]
  node_legacy_robot["Bluetooth robot<br/>[Robot.py]"]
end

node_operator(("Operator"))
node_phone(("Phone camera"))
node_track["Track image"]
node_m_bot(("mBot"))

node_operator -->|"starts"| node_main
node_phone -->|"streams frames"| node_phone_server
node_phone_server -->|"serves page"| node_camera_page
node_main -->|"selects capture"| node_phone_server
node_main -->|"processes frames"| node_vision
node_main -->|"detects signs"| node_signals
node_main -->|"updates state"| node_brain
node_brain -->|"uses navigation"| node_navigator
node_brain -->|"requests commands"| node_drivers
node_main -->|"starts sender"| node_sender
node_sender -->|"gets commands"| node_brain
node_sender -->|"sends messages"| node_robot
node_robot -->|"connects Bluetooth"| node_m_bot
node_main -->|"shows motion"| node_motion_preview
node_simulator -->|"loads map image"| node_track
node_simulator -->|"creates camera"| node_virtual_camera
node_simulator -->|"reuses vision"| node_vision
node_simulator -->|"reuses control"| node_brain
node_simulator -.->|"uses map logic"| node_navigator
node_simulator -.->|"shows trajectory"| node_motion_preview
node_legacy_main -->|"sends motion calls"| node_legacy_robot
node_legacy_robot -->|"connects Bluetooth"| node_m_bot
node_config -.->|"sets parameters"| node_brain
node_config -->|"sets parameters"| node_drivers

click node_phone_server "https://github.com/makkima16/line_follower_vatr/blob/main/code/phone_camera.py"
click node_camera_page "https://github.com/makkima16/line_follower_vatr/blob/main/code/templates/camera.html"
click node_main "https://github.com/makkima16/line_follower_vatr/blob/main/code/main.py"
click node_vision "https://github.com/makkima16/line_follower_vatr/blob/main/code/vision.py"
click node_signals "https://github.com/makkima16/line_follower_vatr/blob/main/code/senales.py"
click node_brain "https://github.com/makkima16/line_follower_vatr/blob/main/code/control.py"
click node_navigator "https://github.com/makkima16/line_follower_vatr/blob/main/code/mapa.py"
click node_config "https://github.com/makkima16/line_follower_vatr/blob/main/code/config.py"
click node_drivers "https://github.com/makkima16/line_follower_vatr/blob/main/code/drivers.py"
click node_sender "https://github.com/makkima16/line_follower_vatr/blob/main/code/robot.py"
click node_robot "https://github.com/makkima16/line_follower_vatr/blob/main/code/robot.py"
click node_simulator "https://github.com/makkima16/line_follower_vatr/blob/main/code/simulador.py"
click node_virtual_camera "https://github.com/makkima16/line_follower_vatr/blob/main/code/simulador.py"
click node_motion_preview "https://github.com/makkima16/line_follower_vatr/blob/main/code/sim.py"
click node_legacy_main "https://github.com/makkima16/line_follower_vatr/blob/main/master_pc/main.py"
click node_legacy_robot "https://github.com/makkima16/line_follower_vatr/blob/main/master_pc/Robot.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_phone_server,node_camera_page,node_main toneBlue
class node_vision,node_signals,node_brain,node_navigator toneAmber
class node_config,node_drivers,node_sender,node_robot toneMint
class node_simulator,node_virtual_camera,node_motion_preview toneRose
class node_legacy_main,node_legacy_robot,node_operator,node_phone,node_track,node_m_bot toneIndigo
```

## Components

### Video capture

- [Phone stream server](https://github.com/makkima16/line_follower_vatr/blob/main/code/phone_camera.py): `code/phone_camera.py`
- [Camera page](https://github.com/makkima16/line_follower_vatr/blob/main/code/templates/camera.html): `code/templates/camera.html`
- [Runtime entry](https://github.com/makkima16/line_follower_vatr/blob/main/code/main.py): `code/main.py`

### Perception and navigation

- [Line vision](https://github.com/makkima16/line_follower_vatr/blob/main/code/vision.py): `code/vision.py`
- [Signal detection](https://github.com/makkima16/line_follower_vatr/blob/main/code/senales.py): `code/senales.py`
- [PD and state machine](https://github.com/makkima16/line_follower_vatr/blob/main/code/control.py): `code/control.py`
- [Odometry and DFS map](https://github.com/makkima16/line_follower_vatr/blob/main/code/mapa.py): `code/mapa.py`

### Control and actuation

- [Runtime parameters](https://github.com/makkima16/line_follower_vatr/blob/main/code/config.py): `code/config.py`
- [Command drivers](https://github.com/makkima16/line_follower_vatr/blob/main/code/drivers.py): `code/drivers.py`
- [Command sender](https://github.com/makkima16/line_follower_vatr/blob/main/code/robot.py): `code/robot.py`
- [Robot transport](https://github.com/makkima16/line_follower_vatr/blob/main/code/robot.py): `code/robot.py`

### Simulation

- [Closed-loop simulator](https://github.com/makkima16/line_follower_vatr/blob/main/code/simulador.py): `code/simulador.py`
- [Virtual camera](https://github.com/makkima16/line_follower_vatr/blob/main/code/simulador.py): `code/simulador.py`
- [Motion preview](https://github.com/makkima16/line_follower_vatr/blob/main/code/sim.py): `code/sim.py`

### Standalone demo

- [Manual camera demo](https://github.com/makkima16/line_follower_vatr/blob/main/master_pc/main.py): `master_pc/main.py`
- [Bluetooth robot](https://github.com/makkima16/line_follower_vatr/blob/main/master_pc/Robot.py): `master_pc/Robot.py`

### Other components

- **Operator**
- **Phone camera**
- **Track image**
- **mBot**

## Connections

- Operator → Runtime entry: starts (evidence: `README.md`)
- Phone camera → Phone stream server: streams frames (evidence: `README.md`)
- Phone stream server → Camera page: serves page (evidence: `README.md`)
- Runtime entry → Phone stream server: selects capture (evidence: `code/main.py`)
- Runtime entry → Line vision: processes frames (evidence: `code/main.py`)
- Runtime entry → Signal detection: detects signs (evidence: `code/main.py`)
- Runtime entry → PD and state machine: updates state (evidence: `code/main.py`)
- PD and state machine → Odometry and DFS map: uses navigation (evidence: `code/control.py`)
- PD and state machine → Command drivers: requests commands (evidence: `code/control.py`)
- Runtime entry → Command sender: starts sender (evidence: `code/main.py`)
- Command sender → PD and state machine: gets commands (evidence: `code/robot.py`)
- Command sender → Robot transport: sends messages (evidence: `code/robot.py`)
- Robot transport → mBot: connects Bluetooth (evidence: `README.md`)
- Runtime entry → Motion preview: shows motion (evidence: `code/main.py`)
- Closed-loop simulator → Track image: loads map image (evidence: `README.md`)
- Closed-loop simulator → Virtual camera: creates camera (evidence: `code/simulador.py`)
- Closed-loop simulator → Line vision: reuses vision (evidence: `README.md`)
- Closed-loop simulator → PD and state machine: reuses control (evidence: `README.md`)
- Closed-loop simulator → Odometry and DFS map: uses map logic (evidence: `code/simulador.py`)
- Closed-loop simulator → Motion preview: shows trajectory
- Manual camera demo → Bluetooth robot: sends motion calls (evidence: `master_pc/main.py`)
- Bluetooth robot → mBot: connects Bluetooth (evidence: `master_pc/Robot.py`)
- Runtime parameters → PD and state machine: sets parameters (evidence: `code/control.py`)
- Runtime parameters → Command drivers: sets parameters (evidence: `code/drivers.py`)
