A Python-based simulator that uses a PID (Proportional-Integral-Derivative) control loop to stabilize a rigid-body spacecraft in 3D space.
This project simulates the rotational dynamics of a spacecraft and implements a feedback control system to bring the vehicle from an initial "error" state (offset orientation) to a target "nadir-pointing" state (0, 0, 0 degrees).
- Physics Engine: Models rigid body dynamics using Euler integration.
- PID Control: Separate gains for Roll, Pitch, and Yaw axes to handle varying moments of inertia.
- Headless Visualization: Automatically generates and saves flight telemetry graphs as PNG files.
The simulator solves the rotational version of Newton's Second Law:
-
$\tau$ (Torque) is the control effort from the PID. -
$I$ (Inertia) represents the mass distribution of the craft. -
$\alpha$ (Acceleration) is the resulting change in rotational speed.
stabilization.mp4
The graph below shows the Step Response of the 3-axis PID controller over a 10-second simulation window.Key Observations:
Convergence: All three axes (Roll, Pitch, and Yaw) successfully converge to the target state (