# do-gongil/ivh-vtd-controller architecture

> Architecture diagram of the GitHub repository do-gongil/ivh-vtd-controller, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-11-30). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/do-gongil/ivh-vtd-controller
- Repository: https://github.com/do-gongil/ivh-vtd-controller

## Overview

This repository is an autonomous-driving controller for the VTD simulator. A route CSV and OpenDRIVE map are planned into a lane-level path, converted into a runtime route with speed limits, then followed in a 20 Hz TCP lockstep loop using simulator state and object perception; controls and run records are sent out. Separate scenario utilities align or generate test scenarios, and a route-sweep tool exercises planner robustness. The README documents the main runtime flow; some utility relationships are supported by imports in the source index rather than inspected implementation excerpts.

Main entry points: [`run_controller.py`](https://github.com/do-gongil/ivh-vtd-controller/blob/main/run_controller.py) (Driving Entrypoint), [`hlfma/route.py`](https://github.com/do-gongil/ivh-vtd-controller/blob/main/hlfma/route.py) (Runtime Route), [`hlfma/planner.py`](https://github.com/do-gongil/ivh-vtd-controller/blob/main/hlfma/planner.py) (Route Planner), [`hlfma/odr.py`](https://github.com/do-gongil/ivh-vtd-controller/blob/main/hlfma/odr.py) (Road Network)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_inputs["Route Inputs"]
  node_route_csv["Waypoint CSV"]
  node_map["OpenDRIVE Map"]
  node_run_config["Run Configuration<br/>[config.py]"]
end

subgraph group_planning["Map and Planning"]
  node_odr["Road Network<br/>[odr.py]"]
  node_planner["Route Planner<br/>[planner.py]"]
  node_route["Runtime Route<br/>[route.py]"]
end

subgraph group_driving["Runtime Driving"]
  node_entrypoint["Driving Entrypoint<br/>[run_controller.py]"]
  node_tcp_client["Lockstep Client<br/>[hlvtd.py]"]
  node_controller["Driving Controller<br/>[controller.py]"]
  node_perception["Object Perception<br/>[perception.py]"]
  node_runlog[("Run Logging<br/>[runlog.py]")]
end

subgraph group_scenario_tools["Scenario Utilities"]
  node_scenario_align["Scenario Alignment<br/>[scenario.py]"]
  node_scenario_builder["Scenario Builder<br/>[build_scenario.py]"]
  node_scenario_maker["NPC Scenario Maker<br/>[make_scenario.py]"]
end

subgraph group_analysis_tools["Planner Analysis"]
  node_route_sweep["Route Robustness Sweep<br/>[sweep_routes.py]"]
end

node_driver(("Route Operator"))
node_vtd["VTD Simulator"]

node_driver -->|"starts run"| node_entrypoint
node_route_csv -->|"provides route"| node_entrypoint
node_map -->|"loads map"| node_odr
node_run_config -->|"configures run"| node_entrypoint
node_entrypoint -->|"loads network"| node_odr
node_entrypoint -->|"plans waypoints"| node_planner
node_planner -->|"queries roads"| node_odr
node_entrypoint -->|"builds runtime route"| node_route
node_route -->|"uses path points"| node_planner
node_route -->|"uses network"| node_odr
node_route -->|"uses vehicle limits"| node_run_config
node_entrypoint -->|"runs controller"| node_controller
node_entrypoint -->|"steps simulator"| node_tcp_client
node_entrypoint -->|"records run"| node_runlog
node_controller -->|"reads route"| node_route
node_controller -->|"relates objects"| node_perception
node_controller -->|"sends controls"| node_tcp_client
node_tcp_client -->|"exchanges lockstep packets"| node_vtd
node_vtd -->|"returns simulator state"| node_tcp_client
node_controller -->|"writes events"| node_runlog
node_scenario_builder -->|"aligns ego"| node_scenario_align
node_scenario_align -->|"projects onto map"| node_odr
node_scenario_builder -->|"plans test route"| node_planner
node_scenario_maker -->|"plans test route"| node_planner
node_scenario_maker -->|"uses runtime route"| node_route
node_route_sweep -->|"sweeps plans"| node_planner
node_route_sweep -->|"loads network"| node_odr

click node_run_config "https://github.com/do-gongil/ivh-vtd-controller/blob/main/hlfma/config.py"
click node_odr "https://github.com/do-gongil/ivh-vtd-controller/blob/main/hlfma/odr.py"
click node_planner "https://github.com/do-gongil/ivh-vtd-controller/blob/main/hlfma/planner.py"
click node_route "https://github.com/do-gongil/ivh-vtd-controller/blob/main/hlfma/route.py"
click node_entrypoint "https://github.com/do-gongil/ivh-vtd-controller/blob/main/run_controller.py"
click node_tcp_client "https://github.com/do-gongil/ivh-vtd-controller/blob/main/hlfma/hlvtd.py"
click node_controller "https://github.com/do-gongil/ivh-vtd-controller/blob/main/hlfma/controller.py"
click node_perception "https://github.com/do-gongil/ivh-vtd-controller/blob/main/hlfma/perception.py"
click node_runlog "https://github.com/do-gongil/ivh-vtd-controller/blob/main/hlfma/runlog.py"
click node_scenario_align "https://github.com/do-gongil/ivh-vtd-controller/blob/main/tools/scenario.py"
click node_scenario_builder "https://github.com/do-gongil/ivh-vtd-controller/blob/main/tools/build_scenario.py"
click node_scenario_maker "https://github.com/do-gongil/ivh-vtd-controller/blob/main/tools/make_scenario.py"
click node_route_sweep "https://github.com/do-gongil/ivh-vtd-controller/blob/main/tools/sweep_routes.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_route_csv,node_map,node_run_config toneBlue
class node_odr,node_planner,node_route toneAmber
class node_entrypoint,node_tcp_client,node_controller,node_perception,node_runlog,node_driver toneMint
class node_scenario_align,node_scenario_builder,node_scenario_maker toneRose
class node_route_sweep,node_vtd toneIndigo
```

## Components

### Route Inputs

- **Waypoint CSV**
- **OpenDRIVE Map**
- [Run Configuration](https://github.com/do-gongil/ivh-vtd-controller/blob/main/hlfma/config.py): `hlfma/config.py`

### Map and Planning

- [Road Network](https://github.com/do-gongil/ivh-vtd-controller/blob/main/hlfma/odr.py): `hlfma/odr.py`
- [Route Planner](https://github.com/do-gongil/ivh-vtd-controller/blob/main/hlfma/planner.py): `hlfma/planner.py`
- [Runtime Route](https://github.com/do-gongil/ivh-vtd-controller/blob/main/hlfma/route.py): `hlfma/route.py`

### Runtime Driving

- [Driving Entrypoint](https://github.com/do-gongil/ivh-vtd-controller/blob/main/run_controller.py): `run_controller.py`
- [Lockstep Client](https://github.com/do-gongil/ivh-vtd-controller/blob/main/hlfma/hlvtd.py): `hlfma/hlvtd.py`
- [Driving Controller](https://github.com/do-gongil/ivh-vtd-controller/blob/main/hlfma/controller.py): `hlfma/controller.py`
- [Object Perception](https://github.com/do-gongil/ivh-vtd-controller/blob/main/hlfma/perception.py): `hlfma/perception.py`
- [Run Logging](https://github.com/do-gongil/ivh-vtd-controller/blob/main/hlfma/runlog.py): `hlfma/runlog.py`

### Scenario Utilities

- [Scenario Alignment](https://github.com/do-gongil/ivh-vtd-controller/blob/main/tools/scenario.py): `tools/scenario.py`
- [Scenario Builder](https://github.com/do-gongil/ivh-vtd-controller/blob/main/tools/build_scenario.py): `tools/build_scenario.py`
- [NPC Scenario Maker](https://github.com/do-gongil/ivh-vtd-controller/blob/main/tools/make_scenario.py): `tools/make_scenario.py`

### Planner Analysis

- [Route Robustness Sweep](https://github.com/do-gongil/ivh-vtd-controller/blob/main/tools/sweep_routes.py): `tools/sweep_routes.py`

### Other components

- **Route Operator**
- **VTD Simulator**

## Connections

- Route Operator → Driving Entrypoint: starts run (evidence: `README.md`)
- Waypoint CSV → Driving Entrypoint: provides route (evidence: `README.md`)
- OpenDRIVE Map → Road Network: loads map (evidence: `hlfma/odr.py`)
- Run Configuration → Driving Entrypoint: configures run (evidence: `README.md`)
- Driving Entrypoint → Road Network: loads network (evidence: `run_controller.py`)
- Driving Entrypoint → Route Planner: plans waypoints (evidence: `README.md`)
- Route Planner → Road Network: queries roads (evidence: `hlfma/planner.py`)
- Driving Entrypoint → Runtime Route: builds runtime route (evidence: `README.md`)
- Runtime Route → Route Planner: uses path points (evidence: `hlfma/route.py`)
- Runtime Route → Road Network: uses network (evidence: `hlfma/route.py`)
- Runtime Route → Run Configuration: uses vehicle limits (evidence: `hlfma/route.py`)
- Driving Entrypoint → Driving Controller: runs controller (evidence: `README.md`)
- Driving Entrypoint → Lockstep Client: steps simulator (evidence: `run_controller.py`)
- Driving Entrypoint → Run Logging: records run (evidence: `README.md`)
- Driving Controller → Runtime Route: reads route (evidence: `hlfma/controller.py`)
- Driving Controller → Object Perception: relates objects (evidence: `README.md`)
- Driving Controller → Lockstep Client: sends controls (evidence: `README.md`)
- Lockstep Client → VTD Simulator: exchanges lockstep packets (evidence: `README.md`)
- VTD Simulator → Lockstep Client: returns simulator state (evidence: `README.md`)
- Driving Controller → Run Logging: writes events (evidence: `README.md`)
- Scenario Builder → Scenario Alignment: aligns ego (evidence: `tools/build_scenario.py`)
- Scenario Alignment → Road Network: projects onto map (evidence: `tools/scenario.py`)
- Scenario Builder → Route Planner: plans test route (evidence: `tools/build_scenario.py`)
- NPC Scenario Maker → Route Planner: plans test route (evidence: `tools/make_scenario.py`)
- NPC Scenario Maker → Runtime Route: uses runtime route (evidence: `tools/make_scenario.py`)
- Route Robustness Sweep → Route Planner: sweeps plans (evidence: `tools/sweep_routes.py`)
- Route Robustness Sweep → Road Network: loads network (evidence: `tools/sweep_routes.py`)
