Skip to content

09priyamgupta/Quadcopter-PID-Control-MATLAB-Simulation

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 

Repository files navigation

Quadcopter PID Control MATLAB Simulation

A MATLAB-based simulation of quadcopter attitude control using PID controllers and ODE45 integration.

Project Overview

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.

Key Features

  • 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)

Project Structure

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

MATLAB Code Structure

  • 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.

How It Works

  1. Initialization: Set quadcopter parameters, initial states, and PID gains.
  2. Visualization: Set up real-time 3D plots and subplots for state variables.
  3. 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).

Simulation Video

See the project in action: Quadcopter PID Control Simulation – MATLAB (YouTube): https://youtu.be/CwytaAl3_Yg

References

  • 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.

How to Run

  1. Clone/download this repository.
  2. Open main_simulation.m in MATLAB.
  3. Make sure the lib folder is on your MATLAB path.
  4. Run the script. Adjust the reference signals or PID gains for custom experiments.

Project Learnings

  • 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

License

For academic and research use only.

About

MATLAB-based simulation of quadcopter attitude control using PID controllers. Includes dynamic modeling, ODE45-based numerical integration, and visualization of quadcopter roll, pitch, and yaw stabilization. Suitable for research, learning, and development of UAV control strategies.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages