# riyatorane/drivetwin architecture

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

- Interactive diagram: https://gitdiagram.com/riyatorane/drivetwin
- Repository: https://github.com/riyatorane/drivetwin

## Overview

AdaptPath3D is a single-script MATLAB prototype for adaptive path planning and collision avoidance in simulated unstructured-road scenarios. The user starts or switches a scenario; the simulation senses nearby road users, predicts their motion, plans a path, applies safety and speed decisions, and follows the path while presenting live state, maps, and metrics. The README documents these capabilities, but the MATLAB source was not provided in the excerpts, so the component boundaries and links below reflect documented behavior rather than inspected function calls.

Main entry points: [`AdaptPath3D.m`](https://github.com/riyatorane/drivetwin/blob/main/AdaptPath3D.m) (Simulation loop)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_simulation["Simulation"]
  node_prototype["Simulation loop<br/>[AdaptPath3D.m]"]
  node_scenarios["Road scenarios<br/>[AdaptPath3D.m]"]
  node_world["Road and traffic<br/>[AdaptPath3D.m]"]
  node_sensing["Range sensing<br/>[AdaptPath3D.m]"]
  node_prediction["Motion prediction<br/>[AdaptPath3D.m]"]
end

subgraph group_planning["Planning and safety"]
  node_planner["Lateral path planner<br/>[AdaptPath3D.m]"]
  node_risk["Clearance and TTC<br/>[AdaptPath3D.m]"]
  node_speed["Speed controller<br/>[AdaptPath3D.m]"]
  node_braking["Emergency braking<br/>[AdaptPath3D.m]"]
  node_steering["Path-following steering<br/>[AdaptPath3D.m]"]
end

subgraph group_interface["Visualization and status"]
  node_renderer["3D scene rendering<br/>[AdaptPath3D.m]"]
  node_dashboard["Live state and metrics<br/>[AdaptPath3D.m]"]
  node_planning_view["Risk and planning map<br/>[AdaptPath3D.m]"]
end

node_user(("Driver / operator"))

node_user -->|"runs"| node_prototype
node_user -->|"selects"| node_scenarios
node_prototype -->|"runs"| node_scenarios
node_prototype -->|"simulates"| node_world
node_prototype -->|"uses"| node_sensing
node_prototype -->|"uses"| node_prediction
node_prototype -->|"replans with"| node_planner
node_prototype -->|"checks"| node_risk
node_prototype -->|"controls"| node_speed
node_prototype -->|"applies"| node_braking
node_prototype -->|"follows path with"| node_steering
node_prototype -->|"renders"| node_renderer
node_prototype -->|"updates"| node_dashboard
node_prototype -->|"shows"| node_planning_view
node_sensing -->|"informs"| node_prediction
node_prediction -->|"informs"| node_planner
node_planner -->|"checked by"| node_risk
node_risk -->|"triggers"| node_braking
node_planner -->|"guides"| node_steering

click node_prototype "https://github.com/riyatorane/drivetwin/blob/main/AdaptPath3D.m"
click node_scenarios "https://github.com/riyatorane/drivetwin/blob/main/AdaptPath3D.m"
click node_world "https://github.com/riyatorane/drivetwin/blob/main/AdaptPath3D.m"
click node_sensing "https://github.com/riyatorane/drivetwin/blob/main/AdaptPath3D.m"
click node_prediction "https://github.com/riyatorane/drivetwin/blob/main/AdaptPath3D.m"
click node_planner "https://github.com/riyatorane/drivetwin/blob/main/AdaptPath3D.m"
click node_risk "https://github.com/riyatorane/drivetwin/blob/main/AdaptPath3D.m"
click node_speed "https://github.com/riyatorane/drivetwin/blob/main/AdaptPath3D.m"
click node_braking "https://github.com/riyatorane/drivetwin/blob/main/AdaptPath3D.m"
click node_steering "https://github.com/riyatorane/drivetwin/blob/main/AdaptPath3D.m"
click node_renderer "https://github.com/riyatorane/drivetwin/blob/main/AdaptPath3D.m"
click node_dashboard "https://github.com/riyatorane/drivetwin/blob/main/AdaptPath3D.m"
click node_planning_view "https://github.com/riyatorane/drivetwin/blob/main/AdaptPath3D.m"

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_prototype,node_scenarios,node_world,node_sensing,node_prediction toneBlue
class node_planner,node_risk,node_speed,node_braking,node_steering toneAmber
class node_renderer,node_dashboard,node_planning_view toneMint
class node_user toneIndigo
```

## Components

### Simulation

- [Simulation loop](https://github.com/riyatorane/drivetwin/blob/main/AdaptPath3D.m): `AdaptPath3D.m`
- [Road scenarios](https://github.com/riyatorane/drivetwin/blob/main/AdaptPath3D.m): `AdaptPath3D.m`
- [Road and traffic](https://github.com/riyatorane/drivetwin/blob/main/AdaptPath3D.m): `AdaptPath3D.m`
- [Range sensing](https://github.com/riyatorane/drivetwin/blob/main/AdaptPath3D.m): `AdaptPath3D.m`
- [Motion prediction](https://github.com/riyatorane/drivetwin/blob/main/AdaptPath3D.m): `AdaptPath3D.m`

### Planning and safety

- [Lateral path planner](https://github.com/riyatorane/drivetwin/blob/main/AdaptPath3D.m): `AdaptPath3D.m`
- [Clearance and TTC](https://github.com/riyatorane/drivetwin/blob/main/AdaptPath3D.m): `AdaptPath3D.m`
- [Speed controller](https://github.com/riyatorane/drivetwin/blob/main/AdaptPath3D.m): `AdaptPath3D.m`
- [Emergency braking](https://github.com/riyatorane/drivetwin/blob/main/AdaptPath3D.m): `AdaptPath3D.m`
- [Path-following steering](https://github.com/riyatorane/drivetwin/blob/main/AdaptPath3D.m): `AdaptPath3D.m`

### Visualization and status

- [3D scene rendering](https://github.com/riyatorane/drivetwin/blob/main/AdaptPath3D.m): `AdaptPath3D.m`
- [Live state and metrics](https://github.com/riyatorane/drivetwin/blob/main/AdaptPath3D.m): `AdaptPath3D.m`
- [Risk and planning map](https://github.com/riyatorane/drivetwin/blob/main/AdaptPath3D.m): `AdaptPath3D.m`

### Other components

- **Driver / operator**

## Connections

- Driver / operator → Simulation loop: runs (evidence: `README.md`)
- Driver / operator → Road scenarios: selects (evidence: `README.md`)
- Simulation loop → Road scenarios: runs (evidence: `README.md`)
- Simulation loop → Road and traffic: simulates (evidence: `README.md`)
- Simulation loop → Range sensing: uses (evidence: `README.md`)
- Simulation loop → Motion prediction: uses (evidence: `README.md`)
- Simulation loop → Lateral path planner: replans with (evidence: `README.md`)
- Simulation loop → Clearance and TTC: checks (evidence: `README.md`)
- Simulation loop → Speed controller: controls (evidence: `README.md`)
- Simulation loop → Emergency braking: applies (evidence: `README.md`)
- Simulation loop → Path-following steering: follows path with (evidence: `README.md`)
- Simulation loop → 3D scene rendering: renders (evidence: `README.md`)
- Simulation loop → Live state and metrics: updates (evidence: `README.md`)
- Simulation loop → Risk and planning map: shows (evidence: `README.md`)
- Range sensing → Motion prediction: informs (evidence: `README.md`)
- Motion prediction → Lateral path planner: informs (evidence: `README.md`)
- Lateral path planner → Clearance and TTC: checked by (evidence: `README.md`)
- Clearance and TTC → Emergency braking: triggers (evidence: `README.md`)
- Lateral path planner → Path-following steering: guides (evidence: `README.md`)
