Model Quadcopter Drone
This example shows how to model a quadcopter that navigates a path to deliver a package. You can download this model in MATLAB® or access it from MATLAB Central File Exchange and GitHub®.
In this example, you learn how to:
Estimate current draw and drone range.
Model the mechanical system using CAD files of the chassis and propellers.
Control altitude and attitude by adjusting motor speeds using cascaded proportional-integral-derivative (PID) controllers.
Provide high-level commands using path following and speed controllers.
Obtain location-specific wind conditions using Python® queries to a weather database.
Test the stability of drone controllers using wind gust profiles.
Explore technical and business trade-offs using profitability analysis in a MATLAB App.
If you have Parallel Computing Toolbox™, you can also use parameter sweeps to:
Vary the mass of the package to see its effect on the quadcopter trajectory.
Vary the target speed of the quadcopter and see if the quadcopter can follow the target path.
You can design the body of the quadcopter in CAD and import the model into Simscape™ Multibody™. To enable fast simulation, the electric motors capture the dynamics of the power conversion in an abstract manner. The quadcopter releases the package when the quadcopter reaches the final waypoint and the drone meets a set of release criteria. For more information about this example, follow these steps to explore the overview that opens in your web browser or see Quadcopter Drone Model in Simscape (MATLAB Central File Exchange).
Clone the up-to-date repository in the current folder using the
Alternatively, choose one of these options. You can download the latest files and versions of the project that are compatible with earlier releases of MATLAB using these options.
Download ZIP files of this project from Quadcopter Drone Model in Simscape (MATLAB Central File Exchange).
Clone the Git™ repository from Quadcopter Drone Model in Simscape (GitHub).
After you use the
gitclone function, MATLAB creates a new folder in the current folder. This example uses projects to manage the supporting files. Open the
Quadcopter_Drone project file. If you have any projects open, MATLAB closes them before loading this project. Configuring the project environment takes several minutes because the model has hundreds of supporting files. Click the Learn More hyperlink on the top-level model canvas to open an overview in your web browser that helps you explore subsystems and the construction of the model. The overview also shows you the main simulation results.
Quadcopter and Control System
The top-level model shows the quadcopter and the control system. Click the hyperlinks on the canvas to plot the positions and velocities of the chassis, and plot the trajectory in 3-D space. You can also plot the current through the battery and the battery state of charge (SOC).
Quadcopter Mechanical and Electrical Systems
Look under the mask of the Quadcopter subsystem. This subsystem models the body, the propellers, and the forces acting on the quadcopter.
Quadcopter Motors and Battery
Inside the Quadcopter subsystem, look under the mask of the Electrical subsystem. This subsystem models the motors and battery.
To find the latest examples from the MathWorks Simscape Team, see MathWorks Simscape Team on MATLAB Central.