# marcuszhu67/fdu-introduction-to-electronic-systems architecture

> Architecture diagram of the GitHub repository marcuszhu67/fdu-introduction-to-electronic-systems, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-09-28). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/marcuszhu67/fdu-introduction-to-electronic-systems
- Repository: https://github.com/marcuszhu67/fdu-introduction-to-electronic-systems

## Overview

This is a Raspberry Pi/OpenCV vision-car project. The principal workflow is camera-based green-target search and approach, encoder-guided orbit, then yellow/wall-aware finish navigation and stopping; `CarRunner` coordinates perception, motion, and encoder feedback. A separate interactive calibration workflow tests hardware and visual thresholds, while the HSV tuner supports manual threshold exploration. The main implementation is concentrated in `car_main.py`; calibration and tuner relationships are based on the README and sampled excerpts, so unsampled details are not expanded.

Main entry points: [`car_main.py`](https://github.com/marcuszhu67/fdu-introduction-to-electronic-systems/blob/main/car_main.py) (CarRunner), [`calibrate_car.py`](https://github.com/marcuszhu67/fdu-introduction-to-electronic-systems/blob/main/calibrate_car.py) (Calibration Session), [`hsv_tuner.py`](https://github.com/marcuszhu67/fdu-introduction-to-electronic-systems/blob/main/hsv_tuner.py) (HSV Tuner), [`例程/color_tracker2.py`](https://github.com/marcuszhu67/fdu-introduction-to-electronic-systems/blob/main/%E4%BE%8B%E7%A8%8B/color_tracker2.py) (Color Tracker Example)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_driving["Autonomous Driving"]
  node_runner["CarRunner<br/>[car_main.py]"]
  node_search["Green Search<br/>[car_main.py]"]
  node_approach["Green Approach<br/>[car_main.py]"]
  node_orbit["Green Orbit<br/>[car_main.py]"]
  node_finish["Finish Navigation<br/>[car_main.py]"]
  node_detector["Color Detector<br/>[car_main.py]"]
  node_history["Vision History<br/>[car_main.py]"]
end

subgraph group_hardware["Hardware I/O"]
  node_motor["Motor Controller<br/>[car_main.py]"]
  node_encoder["Encoder Counter<br/>[car_main.py]"]
  node_config["CarConfig<br/>[car_main.py]"]
end

subgraph group_calibration["Calibration Tools"]
  node_cal_session["Calibration Session<br/>[calibrate_car.py]"]
  node_hsv_tuner["HSV Tuner<br/>[hsv_tuner.py]"]
  node_sample_tracker["Color Tracker Example<br/>[color_tracker2.py]"]
  node_cal_hardware["Calibration Hardware<br/>[calibrate_car.py]"]
end

node_operator(("Operator"))
node_camera(("USB Camera"))
node_gpio_hw["GPIO Hardware"]

node_operator -->|"starts or stops"| node_runner
node_runner -->|"opens and reads"| node_camera
node_runner -->|"processes frames"| node_detector
node_detector -->|"returns detections"| node_runner
node_runner -->|"updates history"| node_history
node_runner -->|"dispatches state"| node_search
node_runner -->|"dispatches state"| node_approach
node_runner -->|"dispatches state"| node_orbit
node_runner -->|"dispatches state"| node_finish
node_search -->|"commands motion"| node_motor
node_search -->|"reads counts"| node_encoder
node_approach -->|"commands motion"| node_motor
node_approach -->|"reads counts"| node_encoder
node_orbit -->|"commands motion"| node_motor
node_orbit -->|"reads counts"| node_encoder
node_finish -->|"commands motion"| node_motor
node_finish -->|"reads counts"| node_encoder
node_motor -->|"drives motors"| node_gpio_hw
node_gpio_hw -->|"signals pulses"| node_encoder
node_cal_session -->|"captures frames"| node_camera
node_cal_session -->|"requests detections"| node_detector
node_cal_session -->|"tests motion"| node_motor
node_cal_session -->|"measures pulses"| node_encoder
node_cal_session -->|"uses GPIO"| node_cal_hardware
node_cal_hardware -->|"drives and reads"| node_gpio_hw
node_operator -->|"runs calibration"| node_cal_session
node_operator -->|"adjusts thresholds"| node_hsv_tuner
node_hsv_tuner -->|"reads frames"| node_camera
node_operator -.->|"runs example"| node_sample_tracker
node_sample_tracker -.->|"reads frames"| node_camera

click node_runner "https://github.com/marcuszhu67/fdu-introduction-to-electronic-systems/blob/main/car_main.py"
click node_search "https://github.com/marcuszhu67/fdu-introduction-to-electronic-systems/blob/main/car_main.py"
click node_approach "https://github.com/marcuszhu67/fdu-introduction-to-electronic-systems/blob/main/car_main.py"
click node_orbit "https://github.com/marcuszhu67/fdu-introduction-to-electronic-systems/blob/main/car_main.py"
click node_finish "https://github.com/marcuszhu67/fdu-introduction-to-electronic-systems/blob/main/car_main.py"
click node_detector "https://github.com/marcuszhu67/fdu-introduction-to-electronic-systems/blob/main/car_main.py"
click node_history "https://github.com/marcuszhu67/fdu-introduction-to-electronic-systems/blob/main/car_main.py"
click node_motor "https://github.com/marcuszhu67/fdu-introduction-to-electronic-systems/blob/main/car_main.py"
click node_encoder "https://github.com/marcuszhu67/fdu-introduction-to-electronic-systems/blob/main/car_main.py"
click node_config "https://github.com/marcuszhu67/fdu-introduction-to-electronic-systems/blob/main/car_main.py"
click node_cal_session "https://github.com/marcuszhu67/fdu-introduction-to-electronic-systems/blob/main/calibrate_car.py"
click node_hsv_tuner "https://github.com/marcuszhu67/fdu-introduction-to-electronic-systems/blob/main/hsv_tuner.py"
click node_sample_tracker "https://github.com/marcuszhu67/fdu-introduction-to-electronic-systems/blob/main/%E4%BE%8B%E7%A8%8B/color_tracker2.py"
click node_cal_hardware "https://github.com/marcuszhu67/fdu-introduction-to-electronic-systems/blob/main/calibrate_car.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_runner,node_search,node_approach,node_orbit,node_finish,node_detector,node_history toneBlue
class node_motor,node_encoder,node_config toneAmber
class node_cal_session,node_hsv_tuner,node_sample_tracker,node_cal_hardware toneMint
class node_operator,node_camera,node_gpio_hw toneIndigo
```

## Components

### Autonomous Driving

- [CarRunner](https://github.com/marcuszhu67/fdu-introduction-to-electronic-systems/blob/main/car_main.py): `car_main.py`
- [Green Search](https://github.com/marcuszhu67/fdu-introduction-to-electronic-systems/blob/main/car_main.py): `car_main.py`
- [Green Approach](https://github.com/marcuszhu67/fdu-introduction-to-electronic-systems/blob/main/car_main.py): `car_main.py`
- [Green Orbit](https://github.com/marcuszhu67/fdu-introduction-to-electronic-systems/blob/main/car_main.py): `car_main.py`
- [Finish Navigation](https://github.com/marcuszhu67/fdu-introduction-to-electronic-systems/blob/main/car_main.py): `car_main.py`
- [Color Detector](https://github.com/marcuszhu67/fdu-introduction-to-electronic-systems/blob/main/car_main.py): `car_main.py`
- [Vision History](https://github.com/marcuszhu67/fdu-introduction-to-electronic-systems/blob/main/car_main.py): `car_main.py`

### Hardware I/O

- [Motor Controller](https://github.com/marcuszhu67/fdu-introduction-to-electronic-systems/blob/main/car_main.py): `car_main.py`
- [Encoder Counter](https://github.com/marcuszhu67/fdu-introduction-to-electronic-systems/blob/main/car_main.py): `car_main.py`
- [CarConfig](https://github.com/marcuszhu67/fdu-introduction-to-electronic-systems/blob/main/car_main.py): `car_main.py`

### Calibration Tools

- [Calibration Session](https://github.com/marcuszhu67/fdu-introduction-to-electronic-systems/blob/main/calibrate_car.py): `calibrate_car.py`
- [HSV Tuner](https://github.com/marcuszhu67/fdu-introduction-to-electronic-systems/blob/main/hsv_tuner.py): `hsv_tuner.py`
- [Color Tracker Example](https://github.com/marcuszhu67/fdu-introduction-to-electronic-systems/blob/main/%E4%BE%8B%E7%A8%8B/color_tracker2.py): `例程/color_tracker2.py`
- [Calibration Hardware](https://github.com/marcuszhu67/fdu-introduction-to-electronic-systems/blob/main/calibrate_car.py): `calibrate_car.py`

### Other components

- **Operator**
- **USB Camera**
- **GPIO Hardware**

## Connections

- Operator → CarRunner: starts or stops
- CarRunner → USB Camera: opens and reads
- CarRunner → Color Detector: processes frames
- Color Detector → CarRunner: returns detections
- CarRunner → Vision History: updates history
- CarRunner → Green Search: dispatches state
- CarRunner → Green Approach: dispatches state
- CarRunner → Green Orbit: dispatches state
- CarRunner → Finish Navigation: dispatches state
- Green Search → Motor Controller: commands motion
- Green Search → Encoder Counter: reads counts
- Green Approach → Motor Controller: commands motion
- Green Approach → Encoder Counter: reads counts
- Green Orbit → Motor Controller: commands motion
- Green Orbit → Encoder Counter: reads counts
- Finish Navigation → Motor Controller: commands motion
- Finish Navigation → Encoder Counter: reads counts
- Motor Controller → GPIO Hardware: drives motors
- GPIO Hardware → Encoder Counter: signals pulses
- Calibration Session → USB Camera: captures frames
- Calibration Session → Color Detector: requests detections
- Calibration Session → Motor Controller: tests motion
- Calibration Session → Encoder Counter: measures pulses
- Calibration Session → Calibration Hardware: uses GPIO
- Calibration Hardware → GPIO Hardware: drives and reads
- Operator → Calibration Session: runs calibration
- Operator → HSV Tuner: adjusts thresholds
- HSV Tuner → USB Camera: reads frames
- Operator → Color Tracker Example: runs example
- Color Tracker Example → USB Camera: reads frames
