A Python unmanned aircraft simulator based on the book Small Unmanned Aircraft: Theory and Practice by Randy Beard and Tim McLain.
For more information visit https://github.com/randybeard/mavsim_public
The Python UAV Simulator provides a comprehensive environment for simulating the behavior of unmanned aerial vehicles (UAVs). It allows users to explore aircraft dynamics, sensor readings, autopilot behavior, and actuator responses in a controlled simulation framework.
To get started with the Python UAV Simulator, follow these steps:
-
Clone the repository:
git clone https://github.com/pabloramesc/pyUAVsim.git
-
Open the project folder:
cd pyUAVsim
-
Install the required packages:
pip install -r requirements.txt
-
Run the example:
python example.py
The simulator is composed of four main modules, each with distinct responsibilities and submodules. These modules are organized into three levels: Physical, Electrical, and Software.
Forces and Moments: Takes the current aircraft state and control deltas from the actuators. Computes the forces (fx, fy, fz) and moments (l, m, n) acting on the aircraft.
Kinematics and Dynamics: Uses the current state and forces and moments to compute the new state of the aircraft.
Sensors: Simulates sensor readings and noise based on the true aircraft state. Includes IMU (Inertial Measurement Unit), GPS, barometer, etc.
Actuators: Takes autopilot control commands and computes the state of the actuators (servos and DC motors). Outputs the control deltas for the aircraft simulator, closing the loop in the simulation.
Estimation Filters: Applies filters (e.g., Low Pass Filter, Kalman Filter) to sensor readings to estimate the aircraft state.
Controll and Navigation: Uses the estimated state along with mission parameters or joystick/controller input to manage attitude control, path following (line or orbit), path managing, and path planning.
- Main aircraft data handlers:
AircraftParameters
,AircrafState
... - Aircraft forces and moments (gravity, aerodynamic and propulsion) simulation
- Aircraft kinematics and dynamics integration to calculate new state
- Multi functional visualization tool based on Matplotlib
- Trim calculation
- Quaternions support
- Wind and atmospheric models integration
- Realistic sensor data simulation including IMU, GPS, and barometer.
- Actuators simulation (servos and DC motor) with realistic transfer functions
- Estimation filters for airtcraft's state estimation
- Implement all autopilot layers: flight control, path following, path navigator and route manager.
- Mission parametes (waypoints) support
- Add TECS and LQR control
- Add PX4 attitude controller
- Add control gains auto-tuning method
- Implement Genetic Algorithm optimization
- Real-time external joystick/controller and autopilot modes (manual, FBW, auto...) support
- Unity 3D visualiztion framework
To run all the tests and generate a coverage report in HTML:
python -m pytest --cov=simulator --cov-report html
This project is licensed under the MIT - see the LICENSE file for details.