A minimal quadrotor flight simulator written in Python, designed for academic research and fast prototyping.
-
Lightweight quadrotor simulator
Models quadrotor dynamics down to the force and torque level. Ideal for fast prototyping and algorithm testing. -
Rigidbody dynamics with SE(3) model
Dynamics modeled on the SE(3) Lie group with Runge-Kutta 4th-order integration (RK4).
Includes a default implementation of the nonlinear Geometric Tracking Controller. -
Python-based and easily extendable
Designed for integration with tools like CasADi or PyTorch for advanced control or learning-based development. -
Flight trajectory visualization
Animated 3D visualization of quadrotor motion alongside the desired trajectory.
Before running the simulator, install the required packages:
pip install -r requirements.txtThen run the simulation:
python ./main.pyTrain a RL model for quadrotor control:
python train_rl.py --traj HOVERING --iterations 1000 --n-envs 16 --total-steps 1000000000000
tensorboard --logdir runs/ppo_quadrotor
Download the pre-trained RL model:
mkdir -p runs/ppo_quadrotor/best
cd runs/ppo_quadrotor/best
wget https://github.com/shengwen-tw/quadrotor-sim-py/raw/refs/heads/blob/runs/ppo_quadrotor/best/best_model.zip
Run the simulator with the RL controller:
python main.py --ctrl=RL --plan_yaw_traj=no
quadrotor-sim-py/
├── main.py # Entry point of the simulation
├── requirements.txt # Required Python packages
├── trajectory_planner.py # Trajectory planner
├── dynamics.py # Quadrotor dynamics model
├── quadrotor.py # Quadrotor environment wrapper
├── geometric_control.py # Geometric tracking controller for quadrotor
├── se3_math.py # SE(3) math utilities
├── rigidbody_visualize.py # 3D visualization
├── utils/ # Placeholder
│ └── __init__.py
├── preview.png # Preview image of the simulator
This project is licensed under the MIT License.
Feel free to use, modify, and distribute without restriction.
