Professional Documents
Culture Documents
Unmanned Aerial
Vehicle
(QUADROTOR)
Abstract
This Quadrotor UAV project is about understanding the dynamics of a flying
machine, controlled via four voltage controlled DC motors, modelling of the same
and designing controllers for all the required control action during its flight time.
We started with understanding the complete motion dynamics of the quad rotor
and proceeded with simulating its flight. We then observed its positions with
respect to the inertial frame, its roll, pitch and yaw angles and then scheming
out the controller design. The rotor dynamics and the performance specifications
of the output parameters were observed for 10 second step response. All the
programs and the simulation models were created using MATLAB R2014a.
Based on the mathematical model, linear control techniques were finally decided
for designing and simulating the controllers. We have used a PID controller for
the required control actions.
The report includes a section to demonstrate original work carried out by team
in powering the entire model. The rotor design is made to work with solar power
along with an external supply. We have included the simulation results for
obtaining the desired voltage for all the 4 rotors with minimal fluctuations.
PAGE 1
Introduction
1.1 Quadrotor principles
A helicopter is a flying vehicle which uses rapidly spinning rotors to push air
downwards, thus creating a thrust force keeping the helicopter aloft.
Conventional helicopters have two rotors. These can be arranged as two
coplanar rotors both providing upward thrust, but spinning in opposite directions
(in order to balance the torques exerted upon the body of the helicopter).
However, these configurations require complicated machinery to control the
direction of motion; a swashplate is used to change the angle of attack on the
main rotors. In order to produce a torque the angle of attack is modulated by the
location of each rotor in each stroke, such that more thrust is produced on one
side of the rotor plane than the other. The complicated design of the rotor and
swashplate mechanism presents some problems, increasing construction costs
and design complexity.
A quadrotor helicopter (quadcopter) is a helicopter which has four equally
spaced rotors, usually arranged at the corners of a square body. With four
independent rotors, the need for a swashplate mechanism is alleviated. The
development of quadcopters has stalled until very recently, because controlling
four independent rotors has proven to be incredibly difficult and impossible
without electronic assistance. The decreasing cost of modern microprocessors
has made electronic and even completely autonomous control of quadcopters
feasible for commercial, military, and even hobbyist purposes. Quadcopter
control is a fundamentally difficult and interesting problem. With six degrees of
freedom (three translational and three rotational) and only four independent
inputs (rotor speeds), quadcopters are severely under-actuated. In order to
achieve six degrees of freedom, rotational and translational motions are coupled.
The resulting dynamics are highly nonlinear, especially after accounting for the
complicated aerodynamic effects. Finally, unlike ground vehicles, helicopters
have very little friction to prevent their motion, so they must provide their own
damping in order to stop moving and remain stable. Together, these factors
create a very interesting control problem. We will present a very simplified
model of quadcopter dynamics and design controllers for our dynamics to follow
a designated trajectory. We will then test our controllers with a numerical
simulation of a quadcopter in flight.
PAGE 2
1.2 Terminologies
Yaw: Yaw is the deviation/Rotating the head of the quadcopter either to
right or left. It is represented by .
Pitch: Pitch is the movement of quadcopter either forward and backward .It
is represented by .
Roll: Roll is making the quadcopter fly sidewards, either to left or right.It is
represented by .
PAGE 3
PAGE 4
PAGE 5
PAGE 6
PAGE 7
PAGE 8
PAGE 9
PID Controller
A proportionalintegralderivative controller (PID controller) is a control loop
feedback mechanism (controller) commonly used in industrial control systems. A
PID controller continuously calculates an error value as the difference between a
desired set point and a measured process variable. The controller attempts to
minimize the error over time by adjustment of a control variable, such as the
position of a control valve, a damper, or the power supplied to a heating element,
to a new value determined by a weighted sum:
where
,
, and
, all non-negative, denote the coefficients for the
proportional, integral, and derivative terms, respectively.
PAGE 10
Gp (open loop)
Gz (open loop)
PAGE 11
As we increase response time Kp, Kd, Ki increases and ts(setteling time) ,tr(rise
time) decreases and Mp(peak overshoot) remains almost constant i.e. fast
response is obtained.
PAGE 12
Gp (open loop)
Gz (open loop)
PAGE 13
Gp (closed loop)
PAGE 14
Gz (closed loop)
Gr (closed loop)
Gp (closed loop)
Gz (closed loop)
Gz (closed loop)
PAGE 16
We found during our analysis that the response of our system corresponding to
step input(voltage in case of motor) was very poor. So to improve the open loop
performance we used the PID controller. We can see from that the performance
and robustness has increased.
Control
The purpose of deriving a mathematical model of a quadcopter is to assist in developing controllers for
physical quad copters. The inputs to our system consist of the angular velocities of each rotor, since all we
can control is the voltages across the motors. Note that in our simplified model, we only use the net torque
for roll, pitch and z-direction motion which can be controlled by controlling the voltage across the motors.
So the inputs are roll torque T, pitch torque T and net thrust torque Th
d
= x
dt
d x T
=
dt I xx
d
= y
dt
d y T
=
dt I yy
PAGE 17
d vz
=K T h
dt
Where K is thrust coefficient
Simulation
Now that we have complete equations of motion describing the dynamics of the
system, we can create a simulation environment in which to test and view the
results of various inputs and controllers. Although more advanced methods are
available, we can quickly write a simulator which utilizes Eulers method for
solving differential equations to evolve the system state. In MATLAB, this
simulator would be written as follows.
Whole program includes the simulate.m file in which quadcopter dynamic
equations are defined. This function must accept a struct containing the physical
parameters of the system. As an argument, it takes the controller function
parameter, simulation start and end time with increment. If no controller is
given, a simulation is run with some pre-determined inputs.
Function computes the states of system based on the dynamic equation as
defined in report. As an output, it returns position in Cartesian plane, yaw, pitch
and roll angles, angular velocity vector and motor inputs. Function controller.m
is defined which takes the value of Kp, Ki and Kd as input arguments. This
function computes total thrust force and input to each motor and updates values
on the basis of error signal.
Another function rotation.m is defined which is used to compute any vector in
inertial frame from body frame. Function visualize.m is used to generate
animated 3D plot of quadcopter model and it also plots the value of angular
position and angular velocity as a function of time.
The simulation code is presented belowsimulate.m
function result = simulate(controller, tstart, tend, dt)
% Physical constants.
g = 9.81;
m = 0.5;
L = 0.25;
k = 3e-6;
b = 1e-7;
I = diag([5e-3, 5e-3, 10e-3]);
kd = 0.25;
% Simulation times, in seconds.
PAGE 18
if nargin < 4
tstart = 0;
tend = 4;
dt = 0.005;
end
ts = tstart:dt:tend;
% Number of points in the simulation.
N = numel(ts);
xout = zeros(3, N);
xdotout = zeros(3, N);
thetaout = zeros(3, N);
thetadotout = zeros(3, N);
inputout = zeros(4, N);
% Struct given to the controller.
controller_params = struct('dt', dt, 'I', I, 'k', k, 'L', L, 'b', b, 'm', m, 'g', g);
% Initial system state.
x = [0; 0; 10];
xdot = zeros(3, 1);
theta = zeros(3, 1);
% If we are running without a controller, do not disturb the system.
if nargin == 0
thetadot = zeros(3, 1);
else
deviation = 300;
thetadot = deg2rad(2 * deviation * rand(3, 1) - deviation);
end
ind = 0;
for t = ts
ind = ind + 1;
% Get input from built-in input or controller.
if nargin == 0
i = input(t);
else
[i, controller_params] = controller(controller_params, thetadot);
end
% Compute forces, torques, and accelerations.
omega = thetadot2omega(thetadot, theta);
a = acceleration(i, theta, xdot, m, g, k, kd);
omegadot = angular_acceleration(i, omega, I, L, b, k);
% Advance system state.
omega = omega + dt * omegadot;
thetadot = omega2thetadot(omega, theta);
theta = theta + dt * thetadot;
xdot = xdot + dt * a;
x = x + dt * xdot;
% Store simulation state for output.
xout(:, ind) = x;
xdotout(:, ind) = xdot;
thetaout(:, ind) = theta;
thetadotout(:, ind) = thetadot;
inputout(:, ind) = i;
PAGE 19
end
end
1, 0, -sin(theta)
0, cos(phi), cos(theta)*sin(phi)
0, -sin(phi), cos(theta)*cos(phi)
end
];
thetadot = inv(W) * omega;
controller.m
function c = controller(name, Kd, Kp, Ki)
if nargin == 1
Kd = 4;
Kp = 3;
Ki = 5.5;
elseif nargin == 2 || nargin > 4
error('Incorrect number of parameters.');
end
end
if strcmpi(name, 'pd')
c = @(state, thetadot) pd_controller(state, thetadot, Kd, Kp);
elseif strcmpi(name, 'pid')
c = @(state, thetadot) pid_controller(state, thetadot, Kd, Kp, Ki);
else
error(sprintf('Unknown controller type "%s"', name));
end
end
function inputs = err2inputs(state, err, total)
e1 = err(1);
e2 = err(2);
e3 = err(3);
Ix = state.I(1, 1);
Iy = state.I(2, 2);
Iz = state.I(3, 3);
k = state.k;
L = state.L;
b = state.b;
inputs = zeros(4, 1);
inputs(1) = total/4 -(2 * b * e1 * Ix + e3 * Iz * k * L)/(4 * b * k * L);
inputs(2) = total/4 + e3 * Iz/(4 * b) - (e2 * Iy)/(2 * k * L);
inputs(3) = total/4 -(-2 * b * e1 * Ix + e3 * Iz * k * L)/(4 * b * k * L);
inputs(4) = total/4 + e3 * Iz/(4 * b) + (e2 * Iy)/(2 * k * L);
end
visualize.m**
function h = visualize_test(data)
figure; plots = [subplot(3, 2, 1:4), subplot(3, 2, 5), subplot(3, 2, 6)];
subplot(plots(1));
pause;
% Create the quadcopter object. Returns a handle to
% the quadcopter itself as well as the thrust-display cylinders.
[t thrusts] = quadcopter;
% Set axis scale and labels.
axis([-10 30 -20 20 5 15]);
zlabel('Height');
title('Quadcopter Flight Simulation');
end
1.5;
PAGE 22
abs(s)]);
s = scales(i);
if s < 0
scalez = makehgtform('yrotate', pi)
* makehgtform('scale', [1, 1,
elseif s > 0
scalez = makehgtform('scale', [1, 1, s]);
end
end
z,
z,
z,
z,
'EdgeColor',
'EdgeColor',
'EdgeColor',
'EdgeColor',
'none',
'none',
'none',
'none',
'FaceColor',
'FaceColor',
'FaceColor',
'FaceColor',
'm');
'y');
'm');
'y');
:)
:)
:)
:)
:)
:)
=
=
=
=
=
=
[4
[4
[4
[4
[1
[1
2
2
2
2
2
2
1
1
6
6
6
6
3];
3] + 4;
8];
8] - 1;
5];
5] + 2;
for i = 1:size(faces, 1)
h(i) = fill3(X(faces(i, :)), Y(faces(i, :)), Z(faces(i, :)), 'r'); hold on;
end
end
end
Finally,
PAGE 25
PAGE 26
high frequency square wave is applied to the MOSFET gate at start up. During
this time MOSFET conducts, placing a short circuit from the right hand side of L
to the negative input supply terminal. Therefore a current flows between the
positive and negative supply terminals through L, which stores energy in
its magnetic field. There is virtually no current flowing in the remainder of the
circuit as the combination of D, C and the load represent a much higher
impedance than the path directly through the heavily conducting MOSFET. As
the MOSFET is rapidly turned off the sudden drop in current causes L to produce
a back EMF in the opposite polarity to the voltage across L during the on period,
to keep the current flowing.
This results in two voltages, the supply voltage V IN and the back EMF VL across L
in series with each other. This higher voltage (V IN +VL), now that there is no
current path through the MOSFET, forward biases D. The resulting current
through D charges up L to VIN +VL (assuming forward voltage drop across D=0)
and also supplies the load. Each time the MOSFET conducts, the cathode of D is
more positive than its anode, due to the charge on C. D is therefore turned off so
the output of the circuit is isolated from the input however the load continues to
be supplied with VIN +VL from the charge on C. Although the charge C drains
away through the load during this period, C is recharged each time the MOSFET
switches off, so maintaining an almost steady output voltage across the load. The
Simulink model as well as the output from the scope are shown below.
It can be seen from the output graphs that the boost converter supplies a
constant voltage to the DC motor and the motor increases its speed to reach a
constant value after 2 seconds. Hence, the transient stability of the motor is
assumed to be good enough for implementation.
PAGE 28
PAGE 29
PAGE 30
The graph shown below shows the output speed response with the input voltage
from a solar cell through a boost converter.
PAGE 31
Conclusion
We derived the equations of motion for a quadcopter, starting with the voltagetorque relation for the DC separately excited motors and working through the
quadcopter kinematics and dynamics. We ignored aero dynamical effects such as
blade-flapping and non-zero free stream velocity, but included air friction as a
linear drag force in all directions. We have used the equations of motion to
create a simulator in which to test and visualize quadcopter control mechanisms.
We have derived the transfer function of this MIMO system.
We began with a simple PD controller. Although the PD controller worked, it left
a significant steady-state error. In order to decrease the steady-state error, we
added an integral term in order to create a PID controller. We tested the PID
controller (with minor modifications to prevent integral wind-up) and found that
it was better at preventing steady-state error than the PD controller when
presented with the same disturbances and using the same proportional and
derivative gains. We also found that tuning the PID controller was difficult, and
would often lead to an unstable system for unknown reasons. We can then also
design the controller parameters than manually tuning the PID controller for
better results.
PAGE 32
References
1. UAVs. New world vistas: Air and space for the 21st centry. Human
systems and biotechnology systems, 7.0:1718,1997.
2. P. Castillo, R. Lozano, and A. Dzul, "Stabilization of a mini rotorcraft
with four rotors," IEEE Control Systems Magazine, vol. 25, pp. 45-50,
Dec. 2005.
3. Lambermont, P., Helicopters and Autogyros of the World, 1958.
4. DraganFly-Innovations, www.rctoys.com, 2003.
5. Pounds, P., Mahony, R., Hynes, P., and Roberts, J., Design of a
FourRotor Aerial Robot, Australian Conference on Robotics and
Automation, Auckland, November 2002.
6. Altug, E., Ostrowski, J. P., and Taylor, C. J., Quadrotor Control Using
Dual Camera Visual Feedback, ICRA, Taipei, September 2003.
7. Bouabdallah, S., Murrieri, P., and Siegwart, R., Design and Control of
an Indoor Micro Quadrotor, ICRA, New Orleans, April 2004.
8. Castillo, P., Dzul, A., and Lozano, R., Real-Time Stabilization and
Tracking of a Four-Rotor Mini Rotorcraft, IEEE Transactions on
Control Systems Technology, Vol. 12, No. 4, 2004.
9. Hamel T. Mahoney r. Lozano r. Et Ostrowski j. Dynamic modelling
and configuration stabilization for an X4-flyer. In the 15me IFAC
world congress, Barcelona, Spain. 2002.
10.
Guenard N. Hamel t. Moreau V, modlisation et laboration de
commande de stabilisation de vitesse et de correction dassiette pour
un drone CIFA, 2004.
11.
E. Altug, J. P. Ostrowski and R. Mahony, Control of a Quadrotor
Helicopter using Visual Feedback, Proceedings of the 2002 IEEE
International Conference on Robotics and Automation, vol. 1, pp. 7277, 2002.
12.
R.Olfati-Saber, Nonlinear Control of Underactuated Mechanical
Systems with Application to Robotics and Aerospace Vehicles. PHD
thesis in Electrical Engineering and Computer Science,
Massachusetts Institute Of Technology, Feb 2001.
13.
Khalaf Salloum Gaeid, Haider A. F. Mohamed, Hew Wooi Ping,
Lokman H. Hassan NNPID Controller for Induction Motors with
Faults University of Malaya& University of Nottingham Malaysia
Campus, The 2 nd International Conference on Control,
Instrumentation & Mechatronic (CIM2009).
14.
B. L. Stevens and F. L. Lewis, Aircraft Control and Simulation.
Hoboken, New Jersey: John Wiley & Sons, Inc., 2nd ed., 2003.
PAGE 33
15.
D. Halliday and R. Resnick, Fundamentals of Physics. John Wiley
& Sons, 3rd ed., 1988.
16.
M. Rauw, FDC 1.2 - A SIMULINK Toolbox for Flight Dynamics
and Control Analysis, February 1998. Available at
http://www.mathworks.com/.
17.
Bouabdallah, S., Becker, M. and Siegwart, R. "Implementation of
an Obstacle Avoidance Controller on the OS4 mini-helicopter".
Accepted for XII Diname International Symposium on Dynamic
Problems of Mechanics. Ilha Bela, Brazil, 2007.
18.
Bouabdallah, S. ,Caprari G. and Siegwart, R. "Design and
Control of an Indoor Coaxial Helicopter". In Proceedings of the IEEE
International Conference on Intelligent Robots and Systems, Being,
China, 2006.
PAGE 34