How to Design a Simple PID Controller for Quadcopter Trajectory Tracking
Show older comments
Hello everyone,
I am new to quadcopter control and am trying to design a simple PID controller for trajectory tracking in Simulink.
I am using the UAV Toolbox and started with the example "Simulate UAV Scenario Using UAV Scenario Blocks". My main questions are:
- Plotting a Trajectory: In the provided UAV Scenario scope, how can I plot a desired trajectory (e.g., a reference path) to visualize it against the quadcopter's actual path?
- Controller Design Logic: For the core controller, I need help with the logic. Let's say my desired trajectory point is [x, y, z] and the quadcopter's current position is [xp, yp, zp].
- How do I convert the resulting position error into the correct commands for Roll, Pitch, Yaw Rate, and Thrust?
- I understand this likely requires a cascaded PID structure. Could you please explain the high-level logic or provide a basic example of how the outputs should be calculated from the errors in X, Y, and Z?
Any guidance, code snippets, or pointers to relevant documentation would be greatly appreciated.
Thank you!
2 Comments
Hi @boutegui
If you have obtained the linear state-space matrices (A, B, C, D) of the UAV in your previous post, and you have learned how to properly design a PID controller for a SISO system without blindly auto-tuning the control parameters, then you can extend the mathematical design concepts to UAV control. In this context, "blindly auto-tuning" refers to allowing the machine to auto-tune the control parameters without considering the desired performance requirements, provided that the system is asymptotically stable.
For example, the demo below allows pidtune() to auto-tune the system. However, an overshoot exceeding 20% and a settling time longer than 5 seconds do not satisfy the desired performance criteria.
sys = ss([0 1; 0 0], [0; 1], [1, 0], 0)
C = pidtune(sys, 'PD')
cL = feedback(C*sys, 1);
step(cL), grid on
stepinfo(cL)
William Rose
on 5 Oct 2025
Thumbs up for this comment.
Accepted Answer
More Answers (0)
Categories
Find more on Planning and Control in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!