A MATLAB-based simulation of quadcopter attitude control using PID controllers and ODE45 integration.
This project simulates the 3D attitude control of a quadcopter using PID controllers in MATLAB. The simulation numerically integrates the quadcopter’s nonlinear equations of motion using the ODE45 solver and visualizes both the drone’s trajectory and the state response. The modeling parameters and control structure are based on academic coursework and references.
- Full 12-state nonlinear quadcopter model (position, velocity, Euler angles, angular rates)
- Modular MATLAB code with object-oriented design (Drone class)
- Separate helper functions for coordinate transformations (e.g., RPY2Rot)
- Real-time 3D visualization and state plotting
- Commanded roll, pitch, yaw setpoint tracking
- Easy modification of controller gains and reference commands
- Crash detection logic (for learning and debugging)
Quadcopter-PID-Control-MATLAB-Simulation/ ├── main_simulation.m ├── lib/ │ ├── Drone.m │ └── RPY2Rot.m ├── problem_statement/ │ ├── AE 450 Final Project(2019).pdf │ └── AE450_Lec10_Quadcopter_Dynamics_and_Control.pdf ├── README.md
- main_simulation.m : Main script to initialize parameters, run the control loop, and visualize results.
- lib/Drone.m : Class definition for the quadcopter including states, equations of motion, and PID attitude control logic.
- lib/RPY2Rot.m : Helper function for rotation matrix calculation from Euler angles.
- Initialization: Set quadcopter parameters, initial states, and PID gains.
- Visualization: Set up real-time 3D plots and subplots for state variables.
- Control Loop:
- At each step, the quadcopter is given a reference command (e.g., +10° roll).
- The Drone class applies the PID controller and updates the state.
- The simulation visualizes the drone’s motion and control response in real time.
- The simulation ends if the quadcopter "crashes" (e.g., hits the ground).
See the project in action: Quadcopter PID Control Simulation – MATLAB (YouTube): https://youtu.be/CwytaAl3_Yg
- AE 450 Final Project(2019).pdf: Project statement, control objectives, and requirements.
- AE450_Lec10_Quadcopter_Dynamics_and_Control.pdf: Lecture notes with dynamic modeling and PID control background.
- Clone/download this repository.
- Open main_simulation.m in MATLAB.
- Make sure the lib folder is on your MATLAB path.
- Run the script. Adjust the reference signals or PID gains for custom experiments.
- Modeling and simulating full nonlinear quadcopter dynamics
- Implementing PID controllers for multi-DOF stabilization
- Real-time MATLAB visualization and animation techniques
- Hands-on experience with object-oriented MATLAB code
For academic and research use only.