A modular six degree-of-freedom flight dynamics simulator for hybrid vertical takeoff and landing (VTOL) aircraft, implementing hierarchical flight control with gain scheduling and smooth mode transitions.
Current Phase: Control System Architecture Complete
The simulator has a fully implemented modular architecture with advanced flight control systems. The physics engine is stable and validated. Control gains require further tuning for stable flight across all regimes.
- Complete 6-DOF rigid body dynamics with quaternion attitude representation
- Runge-Kutta 4 numerical integration (stable, no NaN propagation)
- Modular aerodynamics (wing theory, propeller models, atmosphere)
- Hierarchical control system with gain scheduling
- Control allocation matrix for mixed VTOL/cruise propulsion
- Smooth transition management between flight modes
- CSV telemetry export with organized flight logs
- Control gain tuning for stable hover and transition
- Extended flight envelope testing
- Wind and turbulence models
The simulator implements a professional VTOL control architecture:
High Level: Flight Mode Manager (hover, transition, cruise)
    ↓
Mid Level:  Gain Scheduling (airspeed-based PID adaptation)
    ↓
Low Level:  Control Allocation (optimal actuator distribution)
    ↓
Hardware:   Motor Commands (VTOL fans + cruise propellers)
Gain Scheduling (control/gain_schedule.rs)
- Separate PID gains for hover, transition, and cruise regimes
- Smooth interpolation based on airspeed
- Prevents control discontinuities during mode changes
Control Allocation (control/control_allocation.rs)
- Maps desired forces/moments to actuator commands
- Handles over/under-actuated configurations
- Optimal distribution via pseudo-inverse
Transition Manager (control/transition_manager.rs)
- State machine for flight mode transitions
- Automatic mode switching based on conditions
- Smooth blending factors for propulsion systems
# Build the simulator (optimized)
cargo build --release
# Run hover test at 5m altitude
cargo run --release -- --hover
# Run takeoff to 400m altitude
cargo run --release -- --takeoff
# Use tiltrotor configuration
cargo run --release -- --tiltrotor --hover
# Help and options
cargo run --release -- --helpDuring runs, the status line shows power metrics:
t=  12.0s | Alt=  25.4m | Vel=  3.1m/s | Thrust=  982N | V=22.8V I=45.2A P=1029W SoC= 78%
- --hover: Maintain stable position at 5m altitude (default)
- --takeoff: Climb from ground to 400m altitude
- --tiltrotor: Use tiltrotor aircraft instead of lift+cruise configuration
Flight data is automatically saved to timestamped CSV files:
- Hover flights: flights/hover/flight_[timestamp].csv
- Takeoff flights: flights/takeoff/flight_[timestamp].csv
Each CSV contains:
- Time, position (x,y,z), velocity (vx,vy,vz)
- Attitude (roll,pitch,yaw), angular rates (wx,wy,wz)
- Airspeed, altitude, control outputs
- Power: voltage,current,power_w,energy_wh,soc,time_remaining_s
src/
├── math/               # Vector3, Quaternion, coordinate transforms
├── physics/            # 6-DOF dynamics, RK4 integration
├── aero/              # Wing/propeller models, atmosphere
├── control/           # Control system modules
│   ├── pid.rs         # PID controller with anti-windup
│   ├── flight_mode.rs # Flight mode definitions
│   ├── gain_schedule.rs    # Airspeed-based gain scheduling
│   ├── control_allocation.rs # Actuator allocation matrix
│   ├── transition_manager.rs # Mode transition logic
│   ├── autopilot_v2.rs     # Main autopilot implementation
│   └── autopilot.rs   # Legacy autopilot (deprecated)
├── config/            # Aircraft and simulation configs
└── sim/               # Simulation engine, telemetry
- 4 vertical lift fans for VTOL operations
- 1 forward propeller for cruise flight
- Blown wing for enhanced low-speed lift
- Optimal for efficiency in forward flight
- 4 tiltable propellers
- Transition from vertical to horizontal thrust
- Shared propulsion for all flight modes
- Higher mechanical complexity
- Newton-Euler rigid body equations
- Quaternion kinematics (no gimbal lock)
- Body-fixed reference frame with NED convention
- Forces computed and summed in body frame
- Finite wing corrections with aspect ratio effects
- Continuous stall model for smooth transitions
- Propeller momentum theory for hover
- Blade element theory for forward flight
- LiPo-style battery model with configurable pack:
- capacity_mah,- cells,- c_rating
- internal_resistance_mohm_per_cell,- cutoff_per_cell_v
- Default is a 6S 10,000 mAh pack with moderate IR
 
- Voltage sag computed from open-circuit voltage minus I·R drop
- Discharge curve approximates flat mid-SoC and knees at ends
- Instantaneous power draw derived from motor thrust demand; electrical draw accounts for efficiency
- Thrust is scaled when power is limited by voltage sag, current limit, or cutoff
- Simulation ends cleanly when the pack is depleted (voltage below cutoff or energy exhausted)
- Single coherent control system with mode adaptation
- No hard switching between control laws
- Gain scheduling provides smooth parameter variation
- Control allocation handles actuator redundancy
- 
Control Instability: Current PID gains cause oscillations in hover mode. The control architecture is correct but requires parameter tuning. 
- 
Thrust Scaling: Base thrust values may not match aircraft mass correctly, leading to inadequate lift. 
- 
Visualization: Bevy-based 3D visualization has API compatibility issues with current version. 
Near term:
- Systematic gain tuning using frequency domain analysis
- Implement auto-tuning for PID parameters
- Add wind disturbance models
- Create automated test scenarios
Long term:
- Linear Quadratic Regulator (LQR) control
- Model Predictive Control (MPC) for transitions
- Hardware-in-the-loop simulation support
- Multi-vehicle coordination
Requirements:
- Rust 1.70 or later
- No additional system dependencies for core simulator
# Clone repository
cd eclipse
# Run tests
cargo test
# Build with optimizations
cargo build --release
# Run with debug output
RUST_LOG=debug cargo runBattery parameters live in the aircraft config. Defaults are provided for built-in configurations. To tweak the pack, edit src/config/aircraft.rs and adjust the battery field on AircraftConfig (e.g., capacity, cells, C-rating). Example snippet:
Self {
    battery: crate::power::BatteryConfig {
        capacity_mah: 8000.0,
        cells: 6,
        c_rating: 25.0,
        internal_resistance_mohm_per_cell: 2.0,
        cutoff_per_cell_v: 3.2,
        nominal_cell_v: 3.7,
        full_cell_v: 4.2,
        motor_efficiency: 0.9,
    },
}Telemetry now includes energy and remaining time estimates for quick flight-time checks.
Support the development of Eclipse Flight Dynamics Simulator:
https://www.patreon.com/14815116/join
Your sponsorship helps maintain and expand this open-source flight dynamics research platform.
The project follows a modular architecture where each system has a single responsibility. When contributing:
- Maintain clean separation between physics, aerodynamics, and control
- Use proper aerospace conventions (NED frame, quaternion normalization)
- Add unit tests for mathematical functions
- Document control parameters and their effects
- Stevens, B. L., Lewis, F. L., & Johnson, E. N. (2015). Aircraft Control and Simulation (3rd ed.)
- Diebel, J. (2006). Representing Attitude: Euler Angles, Unit Quaternions, and Rotation Vectors
- Beard, R. W., & McLain, T. W. (2012). Small Unmanned Aircraft: Theory and Practice
MIT License - See LICENSE file for details