SYSTEM_DOCS_V2.0
01. PROJECT_OVERVIEW
The Challenge: "Classical" control (PID) and "Modern" control (MPC) are fundamentally different philosophies. One reacts to the past; the other predicts the future. Seeing the difference in real-time is rare.
The Solution: I engineered a comparative physics simulation. It allows users to switch between a standard PID Controller and a Model Predictive Controller (MPC) to visualize how they handle stochastic disturbances and orbital gravity differently—while attempting to stabilize a wireframe cube (or a specific vocaloid plushie) in the void.
02. SOFTWARE_ARCHITECTURE
The system now runs two distinct control engines derived from first principles:
- PID Engine: A reactive loop using error-based feedback ($K_p$, $K_i$, $K_d$) featuring integral anti-windup to handle steady-state drift, and a low-pass filter (exponential moving average) to smooth out derivative noise on the telemetry graphs.
- MPC Engine: A predictive solver that looks $N$ seconds into the future. It utilizes a Kinematic Trajectory Solver to calculate the exact force vector required to zero out velocity and position, employing Feedforward Cancellation to mathematically negate external wind/gravity forces before they affect the payload.
- Performance: Both algorithms run within the 60FPS render budget of the Three.js loop.
- Energy Heuristics: A custom PowerMeter class continuously integrates the control output vector over time, calculating instantaneous and average wattage to demonstrate the thermodynamic cost of different control strategies.
03. INFRASTRUCTURE_&_IOT
Unlike standard cloud hosting, this project is a self-hosted hybrid system running entirely on hardware in my home lab.
- Host: Raspberry Pi 4B (Linux/Debian).
- Network: Exposed securely to the public internet via a Tailscale Funnel (Reverse Proxy).
- Data Pipeline: A custom Python service polls a DHT22 sensor via GPIO pins and writes asynchronous telemetry data to the frontend.
04. LIVE_TELEMETRY
LOCATION: HOME_LAB // VANCOUVER
--------------------------------
LAB_TEMP: --°C
LAB_HUM: --%
CPU_LOAD: --%
RAM_LOAD: --%
* Server vitals polled every 5s. Simulation power usage (Watts) calculated real-time in client.
05. LEARNING_OUTCOMES
Implementing the "Duel" revealed key engineering trade-offs:
- Control Effort vs. Compute: PID is computationally cheap but energetically inefficient under stress, reactively fighting gravity "sag" and wasting power. MPC is computationally expensive but minimizes total control effort by pre-calculating the exact force vectors needed for optimal tracking via feedforward physics.
- Systems Integration: Managed the complexity of switching control laws dynamically without destabilizing the physics engine.
- Full Stack: Bridged the gap between hardware sensors (Python), 3D graphics (Three.js), and real-time control logic.
06. ASSET_CREDITS
"Hatsune Miku Plushie" by revsworks is licensed under Creative Commons Attribution.
"Poteto" by indoingard is licensed under Creative Commons Attribution.
07. GUESTBOOK
Feel free to drop a line in the guestbook below! I read every message and it helps me understand how people perceive the project.