What did you make?
I built a quadrotor simulator in MATLAB. The drone starts at the origin and flies through four gates, and the simulator checks whether it actually passed through each one. It’s a 12-state model: position, velocity, roll/pitch/yaw, and spin rates, with torque-driven attitude control instead of a point that can push in any direction. The flight path is made of cubic polynomials between waypoints, and each leg’s timing comes from the distance between gates and a target speed of 2 m/s. I also built an interactive 3D viewer with play/pause, a timeline slider, and several camera angles, including a chase camera (which is my favourite). Gates turn yellow if the drone passes through them and red if it misses.
What was challenging?
This was my first time working with vectors, matrices, and MATLAB entirely, so a lot of it was learning as I went. The hardest bug was in the attitude controller. The drone would spiral in a tightening orbit around a waypoint, and adding more damping made it worse. The real problem was that the attitude loop wasn’t reacting fast enough to keep up with the position loop. I also had a mix-up where my error vector and spin-rate vector were stacked in different orders, so the controller was fixing the wrong axis.
What are you proud of?
I built it up in stages and tested each piece by hand before moving on, from a 1D hover to full torque-driven rotation. Other than that I’m just proud of getting a finished project.
What should people know to test it?
You can watch the flight on the demo site: https://nam2302.github.io/Drone-Simulation-2/
To run it yourself, you need MATLAB with UAV Toolbox. Download the repo, open it in MATLAB, and run main.m. It simulates the flight, prints a gate pass report, and opens the interactive viewer. Try editing the waypoints at the top of main.m, or change the gains (Kp, Kd, Kr, Kw) and see how the flight changes. The inertia values are placeholders, and the gains are hand-tuned, so some waypoint layouts may miss gates.
- 5 devlogs
- 6h