# chj1319/forzaeth_race_stack architecture

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

- Interactive diagram: https://gitdiagram.com/chj1319/forzaeth_race_stack
- Repository: https://github.com/chj1319/forzaeth_race_stack

## Overview

This repository is a ROS 2 autonomous-racing stack for an F1TENTH-scale vehicle, usable with either simulation or hardware. Its principal runtime loop brings in sensor/localization and vehicle state, plans a global or local path, selects racing behavior, and sends drive commands; perception and opponent tracking support avoidance. The tree and excerpts show major subsystems, but not enough runtime wiring to establish most ROS topic connections, so those links are dashed and unverified. The README also cautions that some paper-version capabilities are absent from this ROS 2 stack.

Main entry points: [`controller/controller/controller_manager.py`](https://github.com/chj1319/forzaeth_race_stack/blob/main/controller/controller/controller_manager.py) (Racing Controller), [`state_machine/state_machine/state_machine.py`](https://github.com/chj1319/forzaeth_race_stack/blob/main/state_machine/state_machine/state_machine.py) (Race State Machine), [`base_system/f1tenth_system/ackermann_mux/src/ackermann_mux.cpp`](https://github.com/chj1319/forzaeth_race_stack/blob/main/base_system/f1tenth_system/ackermann_mux/src/ackermann_mux.cpp) (Command Multiplexer), [`perception/perception/detect.py`](https://github.com/chj1319/forzaeth_race_stack/blob/main/perception/perception/detect.py) (Obstacle Detection)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_platform["Vehicle and Simulation"]
  node_teleop["Teleoperation<br/>[joy_teleop.py]"]
  node_mux["Command Multiplexer<br/>[ackermann_mux.cpp]"]
  node_vesc["VESC Interface"]
  node_sim["F1TENTH Simulator<br/>[f110_env.py]"]
end

subgraph group_sensing["Sensing and State"]
  node_lidar["URG LiDAR Driver<br/>[urg_node2.cpp]"]
  node_slam["SLAM and Mapping"]
  node_localization["Particle Localization<br/>[particle_filter.py]"]
  node_state_est["Vehicle State<br/>[carstate_node.py]"]
end

subgraph group_planning["Planning and Perception"]
  node_perception["Obstacle Detection<br/>[detect.py]"]
  node_tracking["Opponent Tracking<br/>[tracking.py]"]
  node_global_plan["Global Trajectory"]
  node_trajectory_opt["Trajectory Optimization"]
  node_local_plan["Local Planning<br/>[spline_planner.py]"]
end

subgraph group_control["Behavior and Control"]
  node_behavior["Race State Machine<br/>[state_machine.py]"]
  node_controller["Racing Controller"]
  node_pure_pursuit["Pure Pursuit<br/>[pp.py]"]
  node_follow_gap["Follow the Gap<br/>[ftg.py]"]
  node_map_control["Map Controller<br/>[map.py]"]
end

subgraph group_support["Stack Services"]
  node_parameters["Parameter Events"]
  node_opponent_pub["Opponent Publisher"]
end

node_operator(("Operator"))

node_operator -.->|"drives"| node_teleop
node_teleop -.->|"submits commands"| node_mux
node_controller -.->|"submits commands"| node_mux
node_mux -.->|"forwards commands"| node_vesc
node_mux -.->|"forwards commands"| node_sim
node_lidar -.->|"provides scans"| node_slam
node_lidar -.->|"provides scans"| node_perception
node_slam -.->|"provides map"| node_localization
node_localization -.->|"provides pose"| node_behavior
node_state_est -.->|"provides state"| node_controller
node_perception -.->|"supplies detections"| node_tracking
node_tracking -.->|"supplies opponents"| node_behavior
node_global_plan -->|"uses optimizer"| node_trajectory_opt
node_global_plan -.->|"provides waypoints"| node_controller
node_local_plan -.->|"provides local path"| node_behavior
node_behavior -.->|"selects behavior"| node_controller
node_controller -->|"uses controller"| node_pure_pursuit
node_controller -->|"uses controller"| node_follow_gap
node_controller -->|"uses controller"| node_map_control
node_controller -.->|"registers updates"| node_parameters
node_behavior -->|"uses callbacks"| node_parameters
node_perception -.->|"provides obstacles"| node_opponent_pub
node_opponent_pub -.->|"publishes opponents"| node_behavior

click node_teleop "https://github.com/chj1319/forzaeth_race_stack/blob/main/base_system/f1tenth_system/teleop_tools/joy_teleop/joy_teleop/joy_teleop.py"
click node_mux "https://github.com/chj1319/forzaeth_race_stack/blob/main/base_system/f1tenth_system/ackermann_mux/src/ackermann_mux.cpp"
click node_vesc "https://github.com/chj1319/forzaeth_race_stack/blob/main/sensors/vesc/vesc_ackermann/src/ackermann_to_vesc.cpp"
click node_sim "https://github.com/chj1319/forzaeth_race_stack/blob/main/base_system/f110_simulator/f1tenth_gym/gym/f110_gym/envs/f110_env.py"
click node_lidar "https://github.com/chj1319/forzaeth_race_stack/blob/main/urg_node2/src/urg_node2.cpp"
click node_slam "https://github.com/chj1319/forzaeth_race_stack/blob/main/slam_toolbox/src/slam_toolbox_common.cpp"
click node_localization "https://github.com/chj1319/forzaeth_race_stack/blob/main/particle_filter/particle_filter/particle_filter.py"
click node_state_est "https://github.com/chj1319/forzaeth_race_stack/blob/main/state_estimation/state_estimation/carstate_node.py"
click node_perception "https://github.com/chj1319/forzaeth_race_stack/blob/main/perception/perception/detect.py"
click node_tracking "https://github.com/chj1319/forzaeth_race_stack/blob/main/perception/perception/tracking.py"
click node_global_plan "https://github.com/chj1319/forzaeth_race_stack/blob/main/planner/global_planner/global_planner/global_planner_logic.py"
click node_trajectory_opt "https://github.com/chj1319/forzaeth_race_stack/blob/main/planner/global_planner/global_planner/global_racetrajectory_optimization/global_racetrajectory_optimization/trajectory_optimizer.py"
click node_local_plan "https://github.com/chj1319/forzaeth_race_stack/blob/main/planner/local_planners/spline_planner/spline_planner/spline_planner.py"
click node_behavior "https://github.com/chj1319/forzaeth_race_stack/blob/main/state_machine/state_machine/state_machine.py"
click node_controller "https://github.com/chj1319/forzaeth_race_stack/blob/main/controller/controller/controller_manager.py"
click node_pure_pursuit "https://github.com/chj1319/forzaeth_race_stack/blob/main/controller/controller/pp.py"
click node_follow_gap "https://github.com/chj1319/forzaeth_race_stack/blob/main/controller/controller/ftg.py"
click node_map_control "https://github.com/chj1319/forzaeth_race_stack/blob/main/controller/controller/map.py"
click node_parameters "https://github.com/chj1319/forzaeth_race_stack/blob/main/stack_master/stack_master/parameter_event_handler.py"
click node_opponent_pub "https://github.com/chj1319/forzaeth_race_stack/blob/main/utilities/nodes/opponent_publisher/opponent_publisher/obstacle_publisher.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_teleop,node_mux,node_vesc,node_sim toneBlue
class node_lidar,node_slam,node_localization,node_state_est toneAmber
class node_perception,node_tracking,node_global_plan,node_trajectory_opt,node_local_plan toneMint
class node_behavior,node_controller,node_pure_pursuit,node_follow_gap,node_map_control toneRose
class node_parameters,node_opponent_pub,node_operator toneIndigo
```

## Components

### Vehicle and Simulation

- [Teleoperation](https://github.com/chj1319/forzaeth_race_stack/blob/main/base_system/f1tenth_system/teleop_tools/joy_teleop/joy_teleop/joy_teleop.py): `base_system/f1tenth_system/teleop_tools/joy_teleop/joy_teleop/joy_teleop.py`
- [Command Multiplexer](https://github.com/chj1319/forzaeth_race_stack/blob/main/base_system/f1tenth_system/ackermann_mux/src/ackermann_mux.cpp): `base_system/f1tenth_system/ackermann_mux/src/ackermann_mux.cpp`
- [VESC Interface](https://github.com/chj1319/forzaeth_race_stack/blob/main/sensors/vesc/vesc_ackermann/src/ackermann_to_vesc.cpp): `sensors/vesc/vesc_ackermann/src/ackermann_to_vesc.cpp`
- [F1TENTH Simulator](https://github.com/chj1319/forzaeth_race_stack/blob/main/base_system/f110_simulator/f1tenth_gym/gym/f110_gym/envs/f110_env.py): `base_system/f110_simulator/f1tenth_gym/gym/f110_gym/envs/f110_env.py`

### Sensing and State

- [URG LiDAR Driver](https://github.com/chj1319/forzaeth_race_stack/blob/main/urg_node2/src/urg_node2.cpp): `urg_node2/src/urg_node2.cpp`
- [SLAM and Mapping](https://github.com/chj1319/forzaeth_race_stack/blob/main/slam_toolbox/src/slam_toolbox_common.cpp): `slam_toolbox/src/slam_toolbox_common.cpp`
- [Particle Localization](https://github.com/chj1319/forzaeth_race_stack/blob/main/particle_filter/particle_filter/particle_filter.py): `particle_filter/particle_filter/particle_filter.py`
- [Vehicle State](https://github.com/chj1319/forzaeth_race_stack/blob/main/state_estimation/state_estimation/carstate_node.py): `state_estimation/state_estimation/carstate_node.py`

### Planning and Perception

- [Obstacle Detection](https://github.com/chj1319/forzaeth_race_stack/blob/main/perception/perception/detect.py): `perception/perception/detect.py`
- [Opponent Tracking](https://github.com/chj1319/forzaeth_race_stack/blob/main/perception/perception/tracking.py): `perception/perception/tracking.py`
- [Global Trajectory](https://github.com/chj1319/forzaeth_race_stack/blob/main/planner/global_planner/global_planner/global_planner_logic.py): `planner/global_planner/global_planner/global_planner_logic.py`
- [Trajectory Optimization](https://github.com/chj1319/forzaeth_race_stack/blob/main/planner/global_planner/global_planner/global_racetrajectory_optimization/global_racetrajectory_optimization/trajectory_optimizer.py): `planner/global_planner/global_planner/global_racetrajectory_optimization/global_racetrajectory_optimization/trajectory_optimizer.py`
- [Local Planning](https://github.com/chj1319/forzaeth_race_stack/blob/main/planner/local_planners/spline_planner/spline_planner/spline_planner.py): `planner/local_planners/spline_planner/spline_planner/spline_planner.py`

### Behavior and Control

- [Race State Machine](https://github.com/chj1319/forzaeth_race_stack/blob/main/state_machine/state_machine/state_machine.py): `state_machine/state_machine/state_machine.py`
- [Racing Controller](https://github.com/chj1319/forzaeth_race_stack/blob/main/controller/controller/controller_manager.py): `controller/controller/controller_manager.py`
- [Pure Pursuit](https://github.com/chj1319/forzaeth_race_stack/blob/main/controller/controller/pp.py): `controller/controller/pp.py`
- [Follow the Gap](https://github.com/chj1319/forzaeth_race_stack/blob/main/controller/controller/ftg.py): `controller/controller/ftg.py`
- [Map Controller](https://github.com/chj1319/forzaeth_race_stack/blob/main/controller/controller/map.py): `controller/controller/map.py`

### Stack Services

- [Parameter Events](https://github.com/chj1319/forzaeth_race_stack/blob/main/stack_master/stack_master/parameter_event_handler.py): `stack_master/stack_master/parameter_event_handler.py`
- [Opponent Publisher](https://github.com/chj1319/forzaeth_race_stack/blob/main/utilities/nodes/opponent_publisher/opponent_publisher/obstacle_publisher.py): `utilities/nodes/opponent_publisher/opponent_publisher/obstacle_publisher.py`

### Other components

- **Operator**

## Connections

- Operator → Teleoperation: drives
- Teleoperation → Command Multiplexer: submits commands
- Racing Controller → Command Multiplexer: submits commands
- Command Multiplexer → VESC Interface: forwards commands
- Command Multiplexer → F1TENTH Simulator: forwards commands
- URG LiDAR Driver → SLAM and Mapping: provides scans
- URG LiDAR Driver → Obstacle Detection: provides scans
- SLAM and Mapping → Particle Localization: provides map
- Particle Localization → Race State Machine: provides pose
- Vehicle State → Racing Controller: provides state
- Obstacle Detection → Opponent Tracking: supplies detections
- Opponent Tracking → Race State Machine: supplies opponents
- Global Trajectory → Trajectory Optimization: uses optimizer (evidence: `planner/global_planner/global_planner/global_planner_logic.py`)
- Global Trajectory → Racing Controller: provides waypoints
- Local Planning → Race State Machine: provides local path
- Race State Machine → Racing Controller: selects behavior
- Racing Controller → Pure Pursuit: uses controller (evidence: `controller/controller/controller_manager.py`)
- Racing Controller → Follow the Gap: uses controller (evidence: `controller/controller/controller_manager.py`)
- Racing Controller → Map Controller: uses controller (evidence: `controller/controller/controller_manager.py`)
- Racing Controller → Parameter Events: registers updates (evidence: `controller/controller/controller_manager.py`)
- Race State Machine → Parameter Events: uses callbacks (evidence: `state_machine/state_machine/state_machine.py`)
- Obstacle Detection → Opponent Publisher: provides obstacles
- Opponent Publisher → Race State Machine: publishes opponents
