A comprehensive, production-ready PID (Proportional-Integral-Derivative) control system with real-time visualization, safety monitoring, and automated tuning capabilities. Designed for educational purposes and drone control applications.
- Advanced PID Implementation: Full PID controller with configurable parameters
- Noise-Robust Control: Enhanced PID with filtering and disturbance rejection
- Auto-Tuning: Automatic parameter optimization using system identification
- Output Limiting: Configurable saturation and anti-windup protection
- Component Analysis: Real-time monitoring of P, I, D terms
- Real-Time Safety Monitor: Continuous system health checking
- Emergency Stop: Instant system shutdown capability
- Performance Metrics: Settling time, overshoot, steady-state error tracking
- Alert System: Automated warnings for system anomalies
- Comprehensive Logging: Automatic flight data recording
- Log Management: Intelligent cleanup and storage optimization
- Performance Analytics: Historical data analysis and reporting
- Export Capabilities: CSV and JSON data export
- Professional GUI: Modern dark-theme interface with CustomTkinter
- Real-Time Visualization: 6-panel dashboard with live plotting
- Flight Modes: Pre-configured settings for different scenarios
- Interactive Controls: Intuitive parameter adjustment and system control
- Python 3.8 or higher
- Windows, macOS, or Linux
-
Clone or download this repository
-
Install dependencies:
pip install -r requirements.txt
For the complete integrated experience:
python integrated_pid_system.pyFor basic PID functionality:
python pid_controller.pyPID-Controller/
βββ π± Core Application
β βββ integrated_pid_system.py # Main integrated application
β βββ pid_controller.py # Core PID controller class
β βββ pid_gui_app.py # Basic GUI application
β
βββ π§ Advanced Features
β βββ noise_robust_pid.py # Enhanced PID with filtering
β βββ system_identification.py # Auto-tuning algorithms
β βββ flight_mode_manager.py # Flight mode presets
β βββ system_validation.py # System validation tools
β
βββ π‘οΈ Safety & Monitoring
β βββ safety_monitor.py # Real-time safety monitoring
β βββ data_logger.py # Data logging and management
β
βββ π§ͺ Testing & Validation
β βββ test_pid.py # Comprehensive unit tests
β βββ logs/ # Flight data storage
β
βββ π Documentation
βββ README.md # This file
βββ FLIGHT_MODES_GUIDE.md # Flight mode documentation
βββ requirements.txt # Python dependencies
βββ LICENSE # MIT License
-
Launch the Application
python integrated_pid_system.py
-
Start the System
- Click
βΆοΈ Start Systemto begin simulation - Monitor the real-time dashboard
- Click
-
Configure Parameters
- Adjust Kp, Ki, Kd values manually
- Or use
π― Auto-Tunefor automatic optimization
-
Monitor Performance
- Watch the 6-panel real-time visualization
- Check safety status indicators
- Review performance metrics
-
Emergency Controls
- Use
π EMERGENCY STOPfor immediate shutdown - Reset system with
π Resetbutton
- Use
The system includes pre-configured flight modes:
- π Stable Hover: Gentle, stable flight
- π― Precision: High-accuracy positioning
- β‘ Sport: Fast, responsive control
- πΈ Camera: Smooth movements for filming
- πͺοΈ Windy: Enhanced disturbance rejection
- Select appropriate flight mode
- Click
π― Auto-Tune - System automatically identifies plant characteristics
- Optimal PID parameters calculated and applied
- Performance validated and reported
from pid_controller import PIDController
# Initialize controller
pid = PIDController(
kp=1.0, # Proportional gain
ki=0.1, # Integral gain
kd=0.05, # Derivative gain
setpoint=0.0, # Target value
output_limits=(-100, 100) # Output saturation
)
# Update controller
output = pid.update(current_value, dt=0.01)
# Get component analysis
components = pid.get_components() # Returns P, I, D termsfrom noise_robust_pid import NoiseRobustPIDController
# Enhanced PID with filtering
robust_pid = NoiseRobustPIDController(
kp=1.0, ki=0.1, kd=0.05,
lpf_cutoff=10.0, # Low-pass filter frequency
notch_freq=50.0, # Notch filter frequency
noise_threshold=0.1 # Noise detection threshold
)from safety_monitor import SafetyMonitor
# Create safety monitor
safety = SafetyMonitor(
max_error=5.0,
max_output=100.0,
stability_window=50
)
# Check system safety
is_safe, alerts = safety.check_safety(error, output, dt)# Run all tests
python test_pid.py
# Run specific test
python -m unittest test_pid.TestPIDController.test_proportional_only- β PID controller initialization and parameter setting
- β Proportional, integral, and derivative control
- β Output limiting and anti-windup
- β Step response and stability testing
- β Performance metrics calculation
- β Safety monitoring functionality
The system includes automated validation tests:
- Settling time measurement
- Overshoot calculation
- Steady-state error analysis
- Stability assessment
The system automatically calculates and displays:
- Settling Time: Time to reach Β±2% of setpoint
- Overshoot: Maximum deviation beyond setpoint
- Steady-State Error: Final error after settling
- Rise Time: Time to reach 90% of setpoint
- Control Effort: RMS of control signal
- Continuous error magnitude checking
- Output saturation detection
- System stability analysis
- Performance degradation alerts
- Immediate system shutdown capability
- Safe parameter reset functionality
- Automatic data preservation
- Error state recovery
- Parameter limit enforcement
- Output range protection
- Integral windup prevention
- Noise spike filtering
- Kp (Proportional): Controls response speed and steady-state error
- Ki (Integral): Eliminates steady-state error, can cause instability
- Kd (Derivative): Improves stability, sensitive to noise
- Update Rate: Control loop frequency (default: 100 Hz)
- Data Logging: Automatic logging with configurable retention
- Safety Thresholds: Customizable safety limits
- Visualization: Real-time plotting configuration
- Reduce Kp gain
- Increase derivative gain (Kd)
- Check for noise in sensor data
- Increase Kp gain
- Verify system is not saturated
- Check for mechanical limitations
- Increase Ki gain
- Verify integral term is functioning
- Check for external disturbances
- Use emergency stop immediately
- Reduce all gains by 50%
- Enable noise filtering
Enable debug logging for detailed analysis:
import logging
logging.basicConfig(level=logging.DEBUG)We welcome contributions! Please:
- Fork the repository
- Create a feature branch
- Follow PEP 8 coding standards
- Add comprehensive tests
- Update documentation
- Submit a pull request
- Use type hints for all function parameters
- Include comprehensive docstrings
- Maintain test coverage above 90%
- Follow the existing code structure
- Document any new dependencies
numpy>=2.3.1: Numerical computationsmatplotlib>=3.10.3: Plotting and visualizationcustomtkinter>=5.2.2: Modern GUI frameworkscipy>=1.16.0: Scientific computing (optional)control>=0.10.2: Control systems library
scipy: Required for auto-tuning functionalitypandas: Enhanced data analysis capabilities
This software is designed for educational and simulation purposes.
When integrating with real hardware:
β οΈ Always maintain manual override capability- π§ͺ Test thoroughly in controlled environments
- π Follow all applicable safety regulations
- π‘οΈ Implement proper fail-safe mechanisms
- π Monitor system performance continuously
- π« Never rely solely on software safety systems
MIT License - See LICENSE file for details.
- Control theory implementation based on classical PID design
- GUI framework powered by CustomTkinter
- Visualization using Matplotlib
- Testing framework using Python unittest
π― Ready to start? Run python integrated_pid_system.py and experience professional PID control!
For questions, issues, or contributions, please visit our GitHub repository.