This project is a simple simulation of vertical drone control using PID controller written in Rust + Bevy. The drone attempts to maintain or reach a target altitude by controlling its thrust in real-time.
In Bevy: vertical axis is Y, and we ignore air resistance for simplicity.
Equation of Motion
In Y direction:
Therefore,
We use Newton's second law for rotation:
Where:
Pitch (X axis):
Roll (Z axis):
Yaw (Y axis):
Where:
| Symbol | Meaning |
|---|---|
| e(t) | Error = Target - Current Altitude |
| K_p | Proportional gain |
| K_i | Integral gain |
| K_d | Derivative gain |
| Control Type | K_p | K_i | K_d |
|---|---|---|---|
| P | 0.50K_u | โ | โ |
| PI | 0.45K_u | 0.54K_u / T_u | โ |
| PID | 0.60K_u | 1.2K_u / T_u | 3K_uT_u / 40 |
You can override the system by pressing:
Pโ Toggle Start Engine on/offSpaceโ Increase Altitude (go up)Left Ctrlโ Decrease Altitude (go down)Wโ Pitch Down (tilt forward)Sโ Pitch Up (tilt backward)Aโ Roll Left (tilt left)Dโ Roll Right (tilt right)Qโ Yaw Left (rotate left)Eโ Yaw Right (rotate right)Rโ Reset Target Altitude to 0 (Only works when engine is off)Escโ Exit the simulation
