Chapter 3 Drone
Chapter 3 Drone
Chapter 3 Drone
In this chapter, the quadcopter model, which is formulated using physical system parameters and
dynamics equations, will be designed in Solid works 2018 and implemented in Matlab Simulink
environment by using SimMechanics Link utility which link Matlab Simulink with CAD
program. The Simulink model is used for open loop testing, verification and controller design.
3.1 SolidWorks
SolidWorks is computer aided engineering (CAE) and computer aided design (CAD) software
application with runs of Windows. The software has very advance designing capabilities in the
field do aerospace and robotics. It is one of the most widely used software by engineers from
various field which included, aerospace, robotics, mechanical engineering, civil engineering and
so on. To build the virtual simulation environment in MATLAB and the CAD model for
quadcopter for the controlling purposes, Solidworks 2018 was used for designing process. When
the model was finalized, it was then used with the control of quadcopter by integrating it with
MATLAB/Simulink. When the CAD model of the quadcopter is integrated into
MATLAB/Simulink it creates the complete control model for the quadcopter and all the
dynamics equations are derived automatically. Although, this a very useful technique to build
controls for a quadcopter, it sometimes gives error if the model is not correctly defined in Solid
works. There were a couple of instances when the CAD model was integrated with
MATLAB/Simulink it wrongly derived the motors and propeller controls. This was due the
definition was wrongly defined in the CAD model. Furthermore, the virtual environment was
also included with the CAD model rather than designing it separately again in MATLAB. To
start with, a CAD model was designed in SolidWorks for the quadcopter UAV having precise
physical parameters. This allowed us to extract information about the quadcopter dynamics and
control. It also helped us to understand how much power was required by the motor to rotate the
propeller, which gave us an idea of the battery needs to be used. The CAD modelling designing
of the quadcopter was done in SolidWorks. Figure 3-1 shows the complete model of the
quadcopter. Other components can be seen in Appendix B.
Figure 3-1: CAD model of quadcopter built in SolidWorks for virtual simulation environment
This part of the project is based on simulation the quadcopter in virtual environment. To do this,
MATLAB Simulink were selected to design the control for the quadcopter having a virtual
simulation environment.
3.2.1 MATLAB
3.2.2 SIMULINK
The simulation model is built in stages, that is, at first solid, surface, or hybrid model is created
by CAD program(SolidWorks) . An assembly of elements can be used solely for simulation
studies because in such cases there exists an interaction between individual parts, which in turn
makes it possible to introduce the control system and perform motion analysis. Therefore, each
created simulation model is an assembly of many individual parts or sub-assemblies. For
instance, the sample CAD model presented in Figure 3-1 consists of: 3 assemblies and 62 parts,
but these assemblies include subsequent assemblies or parts, etc. Building of each part of
geometric model in SolidWorks, similar to the ones most currently used for this kind of
applications, begins with defining a 2D geometry that creates a solid or a surface after
completing one of numerous operations (e.g. extrusion or pocket). Then, based on expansion or
modification of the obtained element made by removing or adding material, the creation of parts
is continued. The majority of CAD systems offer normalized elements that can be used to build
assemblies. The product that is the result of the final assembly of components has a permanent
link to the individual part files, which means that changes made in one of the files are
automatically ascribed to the linked files, respectively. The product have its own geometry.
Geometrical models can be used not only for the construction of the simulation model, but in a
very simple way they can be utilized to carry out other types of analysis, such as dynamic
analysis. In this case, the calculation model which takes into account contact connections and
boundary conditions should be worked out.
The next stage of building the simulation model is the implementation of the CAD assembly
model in Matlab/Simulink environment (Fig.3- 2).
For this purpose CAD software and Matlab/ Simulink, the SimMechanics Link utility has to be
installed and linked to the CAD program .
The quadcopter achieve desired motion through controlling the rotors. The rotor is mainly a
Brush less DC motor (BLDC) and a propeller. The quadcopter motor has its own control system
through the electronic speed controller (ESC). The motor receives an input and is expected to
produce a certain output regardless of its control mechanism.
The purpose of motor mixer block is to determine the motors input and thus the rotation speed for
each motor according to which the required thrust and moments are generated achieving the desired
attitude and altitude.
Figure 3-6 : Simulink Model of a Motor Mixer
This simulation method is used to verify that the system built in Simulink is working and
responding as expected. Generally it is the first step in verification.
Changing the thrust of each motor equally only changes the altitude of the quadcopter.
Thus, hovering condition results when the total thrust is equal to the quadcopter weight.
Hovering condition can be expressed by the following equation:
When the total thrust is equal to the quadcopter weight and two rotors of the same
diagonal rotate faster the other two rotors; only the yaw angle changes.
When changing the roll and pitch angles; the system oscillates and gets unstable due to
nonlinearity and absence of the controller.
These observations comply with the mathematical model derived and thus first step in
verification is achieved.
The quadcopter is under actuated system which has four control inputs and six DOF. While
quadcopter can move in vertical axes without changing irrelevant states, it needs to change
attitude when moving in x or y axes. The control system consists of two main loops; inner loop,
which corresponds to orientation control, and outer loop which corresponds to the position
control. The main inner loop consists of two cascaded loops as well; one loop for tracking the
angular rate and another loop for tracking the angle. The inner loop must be at least ten times
faster than the outer loop .Specific roll and pitch angles, which are calculated according to
desired (x, y) coordinates, are compared to the actual angles measured by inertial measurement
unit (IMU) of the system. In the outer loop, the actual position is compared to the desired
position and thus is calculated .The control input vector components as shown in equation serve
as inputs to the control system as shown in the Figure
Figure 3-7: Simplified Comprehensive System Control
The actual quadcopter altitude is measured using barometer sensor. This measured altitude is
then compared to the desired altitude. The error obtained is fed to the altitude controller to
generate U1 signal.
From equation:
Once U1 is calculated by the outer loop, the inner loop commands should now be calculated.
Since the movement along x and y axes is controlled through roll and pitch angles. In real
applications, this is done via the radio control.
Figure 3-9 :Attitude and Heading Controller
Figure 3-10 :Simulink Model for Translating Position (x, y) to Pitch and Roll Angles
Generally this simplified scheme of controller generates signals depending on the error between
the actual and desired state. In this thesis, PID controller is selected to stabilize the quadcopter
because it is intuitive to tune and easy to implement in code with little processing power. PID
controller has three tunable gains; proportional gain Kp, integral gain KI and derivative gain KD.
It can be represented with the following transfer function:
The proportional term Kp is directly proportional to the error, increasing it will increase the rise
time, i.e. making the system response faster. The Integral term KI is proportional to the sum of
the error values accumulated over time; this error often represents a disturbance (wind, modeling
errors, etc.). Increasing KI will decrease steady state error of the feedback system, however, this
term introduces a pole at the origin of the S-plane which might make the system oscillate and
even go unstable. The derivative KD term is a multiple of the rate of change of the error. It is
used to reduce the overshoot and make the system response slower. KD acts as a damper which
allows the use of larger KP value and results in improving steady state performance .Since KD is
acting on the derivative of the error, and not the error itself, it is always used in combination with
Kp and KI.
There are various methods to tune PID controller and determine the best values of control gains.
In this thesis, the values are first determined for simulation purposes and then verified on the
actual system.
The full autopilot controller is obtained by combining all previous controllers together in a single
diagram (subsystem) .These controllers can contain any type of control algorithms.
X-axis Y-axis
Altitude Rolling
Patching Yawing