Lokasi ngalangkungan proxy:   [ UP ]  
[Ngawartoskeun bug]   [Panyetelan cookie]                
Skip to content

prxcode/aerocontrol

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

AeroControl: PID-Based Flight Stability Simulation

AeroControl is a Python-based simulation environment designed to model and stabilize aircraft altitude using a Proportional-Integral-Derivative (PID) control loop. This project implements a real-time tuning dashboard to visualize how different control gains affect flight stability under unpredictable atmospheric conditions.


AeroControl

Features

  • Real-Time PID Tuner: Interactive GUI built with Tkinter to adjust $K_p$, $K_i$, and $K_d$ gains on the fly.
  • Stochastic Wind Turbulence: Simulates unpredictable atmospheric gusts using Gaussian noise ($\mu=0, \sigma=2.0$) to test controller robustness.
  • Physics Engine: Models vertical motion using Newton’s Second Law ($F = ma$), accounting for gravity and dynamic thrust.
  • Dynamic Visualization: Live Matplotlib integration to track altitude response, overshoot, and settling time.

The Mathematics

The core of the simulation is the PID controller, which calculates the required thrust $u(t)$ based on the error $e(t)$ between the target and current altitude:

$$u(t) = K_p e(t) + K_i \int_{0}^{t} e(\tau) d\tau + K_d \frac{de(t)}{dt}$$

  • Proportional ($K_p$): Reacts to the current error. Higher values decrease rise time but increase overshoot.
  • Integral ($K_i$): Accumulates past errors to eliminate the steady-state error caused by gravity.
  • Derivative ($K_d$): Predicts future error by calculating the rate of change, providing a damping effect to reduce oscillations.

Tech Stack

  • Language: Python 3.x
  • GUI Framework: Tkinter
  • Math/Physics: NumPy
  • Data Visualization: Matplotlib
  • Domain: Control Theory & Aerospace Engineering

Installation & Setup

  1. Clone the Repository

    git clone https://github.com/prxcode/aerocontrol.git
    cd aerocontrol
  2. Create a Virtual Environment

    python -m venv venv
  3. Activate the Environment

    • Windows: venv\Scripts\activate
    • macOS/Linux: source venv/bin/activate
  4. Install Dependencies

    pip install -r requirements.txt

Usage

Run the main dashboard script:

python main.py

Use the sliders in the control panel to observe how the aircraft reacts to different PID settings while the "Wind Turbulence" toggle is active.


Results & Analysis

The simulation demonstrates a classic underdamped system response:

  • Overshoot: The aircraft initially exceeds the 100m target due to momentum before the derivative term ($K_d$) applies a braking force.
  • Settling Time: The system typically reaches a stable state within ~15-20 seconds with tuned gains.
  • Robustness: With turbulence enabled, the controller continuously adjusts thrust to maintain altitude, proving the effectiveness of the feedback loop.

Possible Future Improvements

  • 3D Dynamics: Expanding the logic to a 6-DOF model (Roll, Pitch, Yaw).
  • Auto-Tuning: Implementing the Ziegler-Nichols method for automated gain calculation.
  • Data Logging: Exporting simulation telemetry to CSV for post-flight analysis.

About

PID Based Flight Stability Simulation

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages