Welcome to the World of Modelling and Simulation

What is Modelling?

This blog is all about system dynamics modelling and simulation applied in the engineering field, especially mechanical, electrical, and ...

Design and Control of a Drone: Beginners' Guide to Build an UAV

This century, we have seen some of the fascinating developments in the field of control and robotics. UAV - Unmanned Aerial Vehicle - or, simply Drone, is a part of this achievements. Now-a-days, every big industry, such as, Amazon, Google, etc. is investing a lot in the research and development of commercially applicable drones. In this article, I would like to present a simple way to design a drone and control it virtually. To do that, one need to have experience on any computer-aided-design (CAD) software, such as AutoCAD, SolidWorks, and so forth, and numerical computational tools, for example, MATLAB. There are various shapes and sizes of the drone available and depending on that, their nomenclatures are different. In this tutorial, I will be using SolidWorks to design the physical structure of a quadcopter - a drone having four rotors/motors to propel. A typical quadcopter may have the following fundamental parts:

1. Propeller Blade
2. Electric Motor
3. Arm to support Motors
4. Base Plate
5. Control System

The design of a quadcopter depends on the applications where it may be implemented. For this tutorial, I have chosen a very basic design as a demonstration purpose. In SolidWorks, if you have a large drawing, it is better to use 'part drawing' template (.SLDPRT) for individual elements and then, assemble all the parts in an assembly file (.SLDASM). At first, I designed the four parts (blade, base plate, arm, and motor) in SolidWorks part files. In the following, those parts are shown below:

Propeller Blades

Electric Motor

Quadcopter Arm

Base Plate

The features that I used to design the four parts above are very straightforward. For example, for the baseplate, I drew a two dimensional (2D) rectangle, and then, extruded it along the vertical axis. Also, the holes were drawn as circles in the main sketch and then, cut holes through them. Once the parts are designed, then you are ready to assemble them in the SolidWorks assembly file. Create a new assembly file and insert those parts. You can duplicate the same part by simply using copy/paste feature with your mouse. Since it is a quadcopter, we need four arms, four motors and four propeller blades, which can be duplicated easily. Now, the task is to assemble them.

Quadcopter Assembly

The dimensions used for the quadcopter are highlighted below by the orthographic drawing. In SolidWorks, the orthographic drawings are easily obtained from the option 'Make 2D Drawings from 3D'. From this, we can select particular views of the 3D object, such as, front or top or side views etc.

Orthographic drawing of the quadcopter

In SolidWorks, there is an add-in named 'Motion Analysis' where we can visualize the motion of the assembly parts asif the body moves in real world. Below, the quadcopter motion is visualized by provided rotations at the four motors.

The physical model that has been developed is now ready to be exported into MATLAB Simulink environment. In SolidWorks, we used the option ‘Export to Simmechanics/Simscape’ to convert the CAD model into MATLAB readable file. The following screenshots show the steps. But, to add the MATLAB link to the SolidWorks, you first need to enable a plug-in in Matlab, here is the link to download and install.

Showing how to access SIMULINK Simscape link

Showing the CAD conversion to SIMULINK model

The Solidworks add-in from Matlab (Simmechanics/Simscape) converts all the design information from the CAD model into its proprietary language so that we can design a controller in Simulink environment independently. There will be several files generated such as 'xml', 'm', and 'step' as a part of this conversion process. Simscape is a powerful tool integrated in MATLAB where multibody systems dynamics are analyzed easily. After the conversion is done, we can open the ‘xml’ file. Here, we need to first run the 'm-file' that contains all the properties of the quadcopter and type 'smimport' that will open the Simulink model, which is equivalent to the original CAD design. The following image shows the Simulink/Simscape representation of the quadcopter CAD model.

SIMULINK SIMSCAPE representation of the CAD Design of Quadcopter

After that, simply run the Simulink model that will produce a similar CAD model in Matlab window shown below.

CAD model shown in MATLAB SIMULINK environment

Now to build a controller, at first, we need to provide motion to the quadcopter. Here, the signal generated from the source block from Simulink library is transferred to the four motors at the coupling of the motor and blades. We use a signal generator from Simulink library. Then, we create an arbitrary signal to drive the quadcopter. The signal goes through the PID controller and eventually goes into the plant or quadcopter assembly. Here, the controller is a proportional, integral, and derivative unit that filters the input signal and sends output to the four motors of the quadcopter. After receiving the signal, the propeller blades start rotating. 

The quadcopter has six degrees of freedom in the 3D simulation space. The motions are translations along the x, y, z axes, and rotations about those axes. We have provided torque at the junctions between rotor blade and motor shaft that actuates the quadcopter drone in the 3D space where it translates as well as rotates. Our task here is to control the quadcopter in 3D space where we would like to drive it in a manner that we are able to control the altitude of it.

Following image shows the complete Simulink model of the quadcopter system. As we see that the input is generated from the signal generator (here it is a step signal) and then passed into the controller. From the controller, it reaches the quadcopter. Finally, the signal from the quadcopter goes back to the controller through the feedback line. Thus, we have a feedback control system for the quadcopter.

PID controller with feedback control system to navigate quadcopter

The next image shows the PID controller for the quadcopter. We use a unit value for both proportional and integral controller, and 0.1 for the derivative controller. There is no definite reason for choosing these values, any values may be taken into account. However, we need to be careful while choosing the values since high derivative values make the system unstable. 

PID Controller

The important aspect of this model based approach for developing a quadcopter controller is to connect or link the appropriate blocks in Simulink/Simscape models so that the whole system function as we want. Following picture shows a portion of the Simscape multibody quadcopter system where we see how the control signal is transferred to the revolute joint of the quadcopter to drive the rotor. From the image, there is an input torque to the Simscape block ‘Revolute2’ that drives the rigid blade, ‘Propeller_Blades_6’. In the block ‘Revolute2’, we selected the option torque, which is provided by the source. This is the mechanism that drives the propeller blades. These blocks are represented as Simscape blocks, but to convert the property and make them compatible for the Simulink blocks, we have to add ‘Simscape to Simulink converter’ in between respective blocks. 

Shows mechanism in Simulink that drives propeller blades

The following plot shows the response of the quadcopter after running a simulation. 
Quadcopter response with time due to input signal
Finally, we are done! You can now navigate your first drone virtually in 3D space just like the following animation from my quadcopter model.

#Quadcopter #Drone #Simulink #Simscape #UAV #ControllerDesign #Blog #Blogger


  1. Very informative and easy to follow. Those who know MATLAB and Simulink, they should be able to design their own drone. Thanks for sharing!

  2. whats the propeller length and the power of the water

  3. Hi! thank you for this tutorial, is very helpful! I have been trying to follow it through, but think I have made some errors in my CAD modelling. Would you be able to share the xml file? Would be helpful in trying some PID tuning