# richardbwang/rw-template architecture

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

- Interactive diagram: https://gitdiagram.com/richardbwang/rw-template
- Repository: https://github.com/richardbwang/rw-template

## Overview

RW-Template is a VEX V5 competition robotics template. Its main workflow initializes configured devices and heading/odometry, dispatches the selected autonomous routine (or driver loop), and turns motion requests into chassis control using sensor feedback and PID. The graph retains the README’s navigation, odometry, tracking-wheel, and distance-reset capabilities. Several motion implementations were only partially sampled, so their internal call wiring is omitted; those capabilities are represented at the documented module level.

Main entry points: [`src/motor-control.cpp`](https://github.com/richardbwang/rw-template/blob/main/src/motor-control.cpp) (Motion Execution), [`custom/src/user.cpp`](https://github.com/richardbwang/rw-template/blob/main/custom/src/user.cpp) (Mode Orchestration), [`src/pid.cpp`](https://github.com/richardbwang/rw-template/blob/main/src/pid.cpp) (PID Controller), [`custom/src/autonomous.cpp`](https://github.com/richardbwang/rw-template/blob/main/custom/src/autonomous.cpp) (Autonomous Routines)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_competition["Competition Flow"]
  node_main["Competition Entry<br/>[main.cpp]"]
  node_user["Mode Orchestration<br/>[user.cpp]"]
  node_auton["Autonomous Routines<br/>[autonomous.cpp]"]
end

subgraph group_robot["Robot Setup"]
  node_config["Device Configuration<br/>[robot-config.cpp]"]
  node_devices["Robot Devices<br/>[robot-config.h]"]
end

subgraph group_motion["Motion Control"]
  node_motion_api["Motion Commands<br/>[motor-control.h]"]
  node_motion_impl["Motion Execution<br/>[motor-control.cpp]"]
  node_drive["Chassis Control<br/>[motor-control.cpp]"]
  node_turning["Turn And Swing<br/>[motor-control.cpp]"]
  node_point_nav["Point Navigation<br/>[motor-control.cpp]"]
  node_curved_nav["Curved Navigation<br/>[motor-control.cpp]"]
  node_odometry["Odometry Tracking<br/>[motor-control.cpp]"]
  node_distance_reset["Distance Resets<br/>[motor-control.cpp]"]
end

subgraph group_support["Control Support"]
  node_pid["PID Controller<br/>[pid.cpp]"]
  node_pid_header["PID Interface<br/>[pid.h]"]
  node_geometry["Geometry Utilities<br/>[utils.cpp]"]
end

node_vex_competition(("VEX Competition"))
node_vex_hw{{"VEX Hardware"}}

node_vex_competition -->|"starts callbacks"| node_main
node_main -->|"dispatches modes"| node_user
node_user -->|"selects routine"| node_auton
node_user -->|"initializes devices"| node_config
node_config -->|"defines devices"| node_devices
node_config -->|"constructs devices"| node_vex_hw
node_user -->|"starts odometry"| node_motion_impl
node_auton -->|"requests movement"| node_motion_api
node_user -->|"drives chassis"| node_motion_api
node_motion_api -->|"declares commands"| node_motion_impl
node_motion_impl -->|"controls chassis"| node_drive
node_motion_impl -->|"executes turns"| node_turning
node_motion_impl -->|"executes navigation"| node_point_nav
node_motion_impl -->|"executes curves"| node_curved_nav
node_motion_impl -->|"tracks pose"| node_odometry
node_motion_impl -->|"resets position"| node_distance_reset
node_turning -->|"updates control"| node_pid
node_point_nav -->|"updates control"| node_pid
node_curved_nav -->|"updates control"| node_pid
node_motion_impl -->|"uses calculations"| node_geometry
node_motion_impl -->|"reads sensors; drives motors"| node_vex_hw
node_auton -->|"controls arm"| node_pid
node_pid_header -->|"declares interface"| node_pid
node_odometry -->|"reads encoders and IMU"| node_vex_hw
node_distance_reset -->|"reads distance sensors"| node_vex_hw

click node_main "https://github.com/richardbwang/rw-template/blob/main/src/main.cpp"
click node_user "https://github.com/richardbwang/rw-template/blob/main/custom/src/user.cpp"
click node_auton "https://github.com/richardbwang/rw-template/blob/main/custom/src/autonomous.cpp"
click node_config "https://github.com/richardbwang/rw-template/blob/main/custom/src/robot-config.cpp"
click node_devices "https://github.com/richardbwang/rw-template/blob/main/custom/include/robot-config.h"
click node_motion_api "https://github.com/richardbwang/rw-template/blob/main/include/motor-control.h"
click node_motion_impl "https://github.com/richardbwang/rw-template/blob/main/src/motor-control.cpp"
click node_drive "https://github.com/richardbwang/rw-template/blob/main/src/motor-control.cpp"
click node_turning "https://github.com/richardbwang/rw-template/blob/main/src/motor-control.cpp"
click node_point_nav "https://github.com/richardbwang/rw-template/blob/main/src/motor-control.cpp"
click node_curved_nav "https://github.com/richardbwang/rw-template/blob/main/src/motor-control.cpp"
click node_odometry "https://github.com/richardbwang/rw-template/blob/main/src/motor-control.cpp"
click node_distance_reset "https://github.com/richardbwang/rw-template/blob/main/src/motor-control.cpp"
click node_pid "https://github.com/richardbwang/rw-template/blob/main/src/pid.cpp"
click node_pid_header "https://github.com/richardbwang/rw-template/blob/main/include/pid.h"
click node_geometry "https://github.com/richardbwang/rw-template/blob/main/src/utils.cpp"

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_main,node_user,node_auton toneBlue
class node_config,node_devices toneAmber
class node_motion_api,node_motion_impl,node_drive,node_turning,node_point_nav,node_curved_nav,node_odometry,node_distance_reset toneMint
class node_pid,node_pid_header,node_geometry toneRose
class node_vex_competition,node_vex_hw toneIndigo
```

## Components

### Competition Flow

- [Competition Entry](https://github.com/richardbwang/rw-template/blob/main/src/main.cpp): `src/main.cpp`
- [Mode Orchestration](https://github.com/richardbwang/rw-template/blob/main/custom/src/user.cpp): `custom/src/user.cpp`
- [Autonomous Routines](https://github.com/richardbwang/rw-template/blob/main/custom/src/autonomous.cpp): `custom/src/autonomous.cpp`

### Robot Setup

- [Device Configuration](https://github.com/richardbwang/rw-template/blob/main/custom/src/robot-config.cpp): `custom/src/robot-config.cpp`
- [Robot Devices](https://github.com/richardbwang/rw-template/blob/main/custom/include/robot-config.h): `custom/include/robot-config.h`

### Motion Control

- [Motion Commands](https://github.com/richardbwang/rw-template/blob/main/include/motor-control.h): `include/motor-control.h`
- [Motion Execution](https://github.com/richardbwang/rw-template/blob/main/src/motor-control.cpp): `src/motor-control.cpp`
- [Chassis Control](https://github.com/richardbwang/rw-template/blob/main/src/motor-control.cpp): `src/motor-control.cpp`
- [Turn And Swing](https://github.com/richardbwang/rw-template/blob/main/src/motor-control.cpp): `src/motor-control.cpp`
- [Point Navigation](https://github.com/richardbwang/rw-template/blob/main/src/motor-control.cpp): `src/motor-control.cpp`
- [Curved Navigation](https://github.com/richardbwang/rw-template/blob/main/src/motor-control.cpp): `src/motor-control.cpp`
- [Odometry Tracking](https://github.com/richardbwang/rw-template/blob/main/src/motor-control.cpp): `src/motor-control.cpp`
- [Distance Resets](https://github.com/richardbwang/rw-template/blob/main/src/motor-control.cpp): `src/motor-control.cpp`

### Control Support

- [PID Controller](https://github.com/richardbwang/rw-template/blob/main/src/pid.cpp): `src/pid.cpp`
- [PID Interface](https://github.com/richardbwang/rw-template/blob/main/include/pid.h): `include/pid.h`
- [Geometry Utilities](https://github.com/richardbwang/rw-template/blob/main/src/utils.cpp): `src/utils.cpp`

### Other components

- **VEX Competition**
- **VEX Hardware**

## Connections

- VEX Competition → Competition Entry: starts callbacks
- Competition Entry → Mode Orchestration: dispatches modes
- Mode Orchestration → Autonomous Routines: selects routine
- Mode Orchestration → Device Configuration: initializes devices
- Device Configuration → Robot Devices: defines devices
- Device Configuration → VEX Hardware: constructs devices
- Mode Orchestration → Motion Execution: starts odometry
- Autonomous Routines → Motion Commands: requests movement
- Mode Orchestration → Motion Commands: drives chassis
- Motion Commands → Motion Execution: declares commands
- Motion Execution → Chassis Control: controls chassis
- Motion Execution → Turn And Swing: executes turns
- Motion Execution → Point Navigation: executes navigation
- Motion Execution → Curved Navigation: executes curves
- Motion Execution → Odometry Tracking: tracks pose
- Motion Execution → Distance Resets: resets position
- Turn And Swing → PID Controller: updates control
- Point Navigation → PID Controller: updates control
- Curved Navigation → PID Controller: updates control
- Motion Execution → Geometry Utilities: uses calculations
- Motion Execution → VEX Hardware: reads sensors; drives motors
- Autonomous Routines → PID Controller: controls arm
- PID Interface → PID Controller: declares interface
- Odometry Tracking → VEX Hardware: reads encoders and IMU
- Distance Resets → VEX Hardware: reads distance sensors
