-
How does a Quadrotor fly?A journey from physics, mathematics,
control
systems and computer sciencetowards a Controllable Flying
Object
Corrado Santoro
ARSLAB - Autonomous and Robotic Systems LaboratoryDipartimento
di Matematica e Informatica - Universita` di Catania, Italy
[email protected]
Keynote - L.A.P. 1 Course - Jan 10, 2014
Corrado Santoro How does a Quadrotor fly?
-
Overview
1 Why Multi-rotors?2 Structure and Physics of a Quadrotor3 From
Analysis to Driving:
How can I impose a movement to my quadrotor?4 The ideal world
and the real world:
Why we need Control Systems Theory!5 Rates and Angles:
Could I control the attitude?6 What about Altitude or GPS
control?
Corrado Santoro How does a Quadrotor fly?
-
Part I
Why Multi-rotors?
Corrado Santoro How does a Quadrotor fly?
-
Flying Machines
To fly has been one of the dreams of the humansBut the story
tells that building flying machines is not easy!A basic and common
component: the wingTwo kind of flying machines (excluding rockets
andballoons):
1 Fixed wing, i.e. airplanes2 Rotating wing, i.e.
helicopters
Corrado Santoro How does a Quadrotor fly?
-
Design and Implementation problemsAirplanes (fixed wing)
Wing profile and shapeWing and stab size/areaWing loadPosition
of the COGMotion is achieved by driving (mechanically) the mobile
surfaces(aleirons, rudder, elevator)
Helicopters (rotating wing, VTOL)Size and structure of the
rotorMechanical system to control motion inclinationYaw balancing
system for the rotor at tailPosition of the COGMotion is achieved
by (mechanically) changing the inclination ofthe rotor and the
pitch of the rotor wings
Corrado Santoro How does a Quadrotor fly?
-
Multi-rotors ...
are mechanically simple: they have n motors and npropellersdo
not require complex mechanical parts to control theflightcan fly
and move only by changing motor speedare controlled only by a
electronic-/computer-based system
Building them is simple!!
Corrado Santoro How does a Quadrotor fly?
-
Part II
Structure and Physics of a Quadrotor
Corrado Santoro How does a Quadrotor fly?
-
Structure of a Quadrotor (Mechanics)
Four equal propellers generating four thrust forcesTwo possible
configurations: + and Propellers 1 and 3 rotates CW, 2 and 4
rotates CCWRequired to compensate the action/reaction effect
(ThirdNewtons Law)Propellers 1 and 3 have opposite pitch w.r.t. 2
and 4, so allthrusts have the same direction
Corrado Santoro How does a Quadrotor fly?
-
Structure of a Quadrotor (Electronics)
Corrado Santoro How does a Quadrotor fly?
-
Forces and Rotation speeds
1, 2, 3, 4: rotation speeds of the propellersT1,T2,T3,T4: forces
generated by the propellersTi 2i : on the basis of propeller shape,
air density, etc.m: mass of the quadrotormg: weight of the
quadrotor
Corrado Santoro How does a Quadrotor fly?
-
Moments
M1,M2,M3,M4: moments generated by the forcesMi = L Ti
Corrado Santoro How does a Quadrotor fly?
-
Hovering Condition (Equilibrium)
1 Equilibrium of forces: 4i=1 Ti = mg2 Equilibrium of
directions: T1,2,3,4||g3 Equilibrium of moments: 4i=1 Mi = 04
Equilibrium of rotation speeds: (1 +3) (2 +4) = 0
Violating one (or more) of these conditions implies to impose
acertain movement to the quadrotor
Corrado Santoro How does a Quadrotor fly?
-
Reference Systems
There are two reference systems:1 The inertial reference
systems, i.e. the Earth frame
(xE , yE , zE )2 The quadrotor reference system, i.e. the Body
frame
(xB , yB , zB)
Corrado Santoro How does a Quadrotor fly?
-
Euler Angles
Three angles (, , ) define the transformation between thetwo
systems:
Roll, : angle of rotation along axis xB ||xEPitch, : angle of
rotation along axis yB ||yEYaw, : angle of rotation along axis zB
||zE
They are called Euler Angles
Corrado Santoro How does a Quadrotor fly?
-
Angular Speeds
The derivative of (, , ) w.r.t. time are the
angular/rotationspeeds (, , ) of the system:
, Roll rate, Pitch rate, Yaw rate
Corrado Santoro How does a Quadrotor fly?
-
Part III
From Analysis to Driving:How can I impose a movement to my
quadrotor?
Corrado Santoro How does a Quadrotor fly?
-
Hovering Condition (Equilibrium)
1 Equilibrium of forces: 4i=1 Ti = mg2 Equilibrium of
directions: T1,2,3,4||g3 Equilibrium of moments: 4i=1 Mi = 04
Equilibrium of rotation speeds: (1 +3) (2 +4) = 0
As a consequence: = 0 = 0 = 0 = 0 = 0 = 0
Corrado Santoro How does a Quadrotor fly?
-
Going Up and Down
1 No equilibrium of forces: 4i=1 Ti 6= mg2 Equilibrium of
directions: T1,2,3,4||g3 Equilibrium of moments: 4i=1 Mi = 04
Equilibrium of rotation speeds: (1 +3) (2 +4) = 0
By increasing/decreasing the rotation speed of all thepropellers
we can:
Go Up: 4i=1 Ti > mgGo Down: 4i=1 Ti < mg
Euler angles and rates remain 0
Corrado Santoro How does a Quadrotor fly?
-
Yaw Rotation
1 Equilibrium of forces: 4i=1 Ti = mg2 Equilibrium of
directions: T1,2,3,4||g3 Equilibrium of moments: 4i=1 Mi = 04 No
equilibrium of prop speeds: (1 +3) (2 +4) 6= 0
As a consequence: = kY ((1 + 3) (2 + 4)) =
dt
Corrado Santoro How does a Quadrotor fly?
-
Roll Rotation
No equilibrium of moments: 4i=1 Mi 6= 0... by unbalancing
propeller speeds as:
(1 + 4) (2 + 3) 6= 0As a consequence:
= kR((1 + 4) (2 + 3)) =dt
No equilibrium of directions: T1,2,3,4 not parallel to gCorrado
Santoro How does a Quadrotor fly?
-
Roll Rotation and Translated Flight
Total thrust T =4
i=1 Ti is decomposed in:Lift Force:TL = T cosDrag Force:TD = T
sin
Avoiding diving implies TL = T cos = mg thus in translatedflight
we need more power w.r.t. hovering or yawing.
Corrado Santoro How does a Quadrotor fly?
-
Pitch Rotation
No equilibrium of moments: 4i=1 Mi 6= 0... by unbalancing
propeller speeds as:
(1 + 2) (3 + 4) 6= 0As a consequence:
= kP((1 + 2) (3 + 4)) =dt
Also in this case the total thrust is decomposed thus weneed
more power w.r.t. hovering or yawing.
Corrado Santoro How does a Quadrotor fly?
-
Equations of Movement
We assume a common factor of proportionality k and F =
T(we will see that such an assumption is not a problem!): = k((1
+ 4) (2 + 3)) = k1 k2 k3 + k4 = k((1 + 2) (3 + 4)) = k1 + k2 k3 k4
= k((1 + 3) (2 + 4)) = k1 k2 + k3 k4F = k((1 + 2 + 3 + 4)) = k1 +
k2 + k3 + k4
or, using matrices:
F
=
k k k kk k k kk k k kk k k k
1234
Corrado Santoro How does a Quadrotor fly?
-
Equations of Movement
F
=
k k k kk k k kk k k kk k k k
1234
= K
1234
This equation gives the angular velocities of the
quadrotor,given the speed of the propellers.
But if we want to control the quadrotor we must understandhow to
set i in order to impose a certain rotation rate of axis inthe body
frame.
Corrado Santoro How does a Quadrotor fly?
-
Controlling Roll, Pitch and Yaw Rates, and Total Thrust
1234
= K1
F
=
k k k kk k k kk k k kk k k k
F
Corrado Santoro How does a Quadrotor fly?
-
Part IV
The ideal world and the real world:Why we need Control Systems
Theory!
Corrado Santoro How does a Quadrotor fly?
-
Can we really set the rotation rate of
propellers??Motor/Propeller Driving Schema
Drivers, motors and propellers are chosen to be of the sametype
for the four arms.Software (firmware) controls PWM, but ...
1 Are the drivers really all the same?2 Are the motors really
all the same?3 Are the propellers really all the same?4 Is the COG
placed at the center of the quadrotor?
The answer is: In general, No!!Corrado Santoro How does a
Quadrotor fly?
-
Can we really set the rotation rate of
propellers??Motor/Propeller Driving Schema
Same PWM signals applied different driver/motor/propellerchains
provoke different thrust forces, even if the componentsare of the
same type!
Corrado Santoro How does a Quadrotor fly?
-
The Real world effect
ProblemWe need to set i by
1234
= K1
F
but we dont have a direct control on i and propeller thrust
Corrado Santoro How does a Quadrotor fly?
-
The Mathematician/Physicists Solution
Solution ??Lets characterize each driver/motor/propeller chain
and derive thefunctions:
Ti = fi(PWMi )Then, lets invert the functions:
PWMi = f1i (Ti)
But...Characterization is not so easyIf we change a component,
we must repeat the processThere are unpredictable variables, e.g.
air density, wind, etc.
Corrado Santoro How does a Quadrotor fly?
-
The Computer Scientist/Engineer Solution
Solution ??Lets sperimentally tune:
an offset for each channela gain for each channel
until the system behaves as expected!
But...Tuning is not so easyIf we change a component, we must
repeat the processThere are unpredictable variables, e.g. air
density, wind, etc.
Corrado Santoro How does a Quadrotor fly?
-
The Control System Engineer Solution
Solution!!!! Use feedback!1 Measure your variable through a
sensor2 Compare the measured value with your desired set point3
Apply the correction to the system on the basis of the error4 Go to
1
Tuning is easy and, if the controller is properly designed ...it
works no matter the componentsit works also in the presence of
uncontrollable variables, e.g. airdensity, wind, etc.
Corrado Santoro How does a Quadrotor fly?
-
Our ScenarioOur measures:
Actual angular velocities on the three axis ( M , M , M )They
are measured through a 3-axis gyroscope!
Our set-points:Desired angular velocities on the three axis (T ,
T , T )They are given through the remote control
Corrado Santoro How does a Quadrotor fly?
-
Using Feedback to Control the Quadrotor
The overall schema of the feedback controller is:
Corrado Santoro How does a Quadrotor fly?
-
Using Feedback to Control the Quadrotor
Algorithmically
while True doOn T timer tick ;(T , T , T ,F ) = sample remote
control();( M , M , M ) = sample gyro();e := T M ; e := T M ; e :=
T M ;C :=roll rate controller(e);C:=pitch rate controller(e
);
C:=yaw rate controller(e
);
(pwm1,pwm2,pwm3,pwm4)T := K1(CT ,C T ,CT ,F )T ;
send to motors(pwm1,pwm2,pwm3,pwm4);end
Corrado Santoro How does a Quadrotor fly?
-
Using Feedback to Control the Quadrotor
Algorithmically
while True doOn T timer tick ;(T , T , T ,F ) = sample remote
control();( M , M , M ) = sample gyro();e:= T M ; e := T M ; e := T
M ;
C:=roll rate controller(e
);
C :=pitch rate controller(e);C :=yaw rate
controller(e);(pwm1,pwm2,pwm3,pwm4)T := K1(CT ,C T ,CT ,F )
T ;send to motors(pwm1,pwm2,pwm3,pwm4);
end
The key is in the controllers!!
Corrado Santoro How does a Quadrotor fly?
-
The P.I.D. Controller
The most common used controller type is
theProportional-Integral-Derivative controller, represented bythe
following function:
PID FunctionC := xxx rate controller(e);That is:
C(t) := Kpe(t) + Ki t
0e() d + Kd
de(t)dt
In a discrete world (at k th sampling instant):
C(k) := Kpe(k) + Kik
j=0e(j) T + Kd e(k) e(k 1)
T
Corrado Santoro How does a Quadrotor fly?
-
The P.I.D. Controller
PID Function
C(k) := Kpe(k) + Kik
j=0e(j) T + Kd e(k) e(k 1)
T
Constants Kp,Ki ,Kd regulate the behaviour of the controller:Kp
drives the short-term actionKi drives the long-term actionKd drives
the action on the basis of the error trend
Constants Kp,Ki ,Kd are tuned:Using a specific tuning method
(Ziegler-Nichols)Sperimentally by means of trial-and-error
Corrado Santoro How does a Quadrotor fly?
-
Part V
Rates and Angles:Could I control the attitude?
Corrado Santoro How does a Quadrotor fly?
-
Rates are not Angles
The above schema controls rates:suppose a roll angle of = 10obut
no roll rotation (rate), i.e. = 0and no roll rotation command
(sticks set to center) the quadrotor is not horizontal and performs
atranslated flight
Could we control angles instead of rates?Corrado Santoro How
does a Quadrotor fly?
-
Measuring Angles (instead of Rates): Gyros
First we must measure euler angles (, , )!We could do this by
using Gyroscopes, Accelerometers,Magnetometers, but...
Gyroscopes measure angular velocities which can beintegrated in
order to derive the angle (t) =
t0 ()d , but:
Numeric integration is affected by approximation
errorsGyroscopes are affected by an offset, i.e. they givenon-zero
value when the measure should be zeroSuch an offset is not constant
over time and depends onthe temperature
The estimated angle is not reliable!
Corrado Santoro How does a Quadrotor fly?
-
Measuring Angles: Accelerometers
An accelerometer is a sensor measuring the acceleration overthe
three axis (ax ,ay ,az).
If the sensor is static sensed values are the projectionsof g
vector in the sensor reference systemTwo functions (using arctan)
determines pitch and roll: = tan1 ay
az = tan1 ax
a2y+a2z
But if the object is moving (e.g. shaking) otheraccelerations
appear
The computed angles are not reliable!Corrado Santoro How does a
Quadrotor fly?
-
Measuring Angles: Two sensors, No reliability!
GyrosDriftApproximate discrete integration
AccelerometersPrecise only if sensor is not shaking
We have two different source of the same informationwhich are
affected by two different error types.
We can use both measures by fusing them in order to adjustthe
error and obtain a reliable information.
Corrado Santoro How does a Quadrotor fly?
-
Sensor Fusion
Basic Algorithm
while True doOn T timer tick ;(, , ) = sample gyro();(ax ,ay
,az) = sample accel();(, , ) = (, , ) + T (, , ); = tan1(ay/ az); =
tan1(ax/
a2y + a2z);
(, , ) = fusion filter(, , , , );end
Corrado Santoro How does a Quadrotor fly?
-
Sensor Fusion: Algorithms
The key is the filter function!DCM (Direction Cosine
Matrix)Complementary filtersKalman filters
Basic idea:Derive an error function e(t) = real(t)
estimated(t)Design a controller able to guarantee limt e(t) = 0
Corrado Santoro How does a Quadrotor fly?
-
Sensor Fusion: Algorithms
High computational load due to:Rotations in the 3D spaceMatrix
calculations
May we reduce the load?
Corrado Santoro How does a Quadrotor fly?
-
Representing Rotations in 3D
Direction Cosine Matrix
DCM =
cc ssc cs csc + sscs sss + cc css sc
s sc cc
s = sin, c = cos
This matrix is re-computed at each iteration!!
Rotating a vector v = (x , y , z) implies the product DCM v
.
Corrado Santoro How does a Quadrotor fly?
-
Representing Rotations in 3D
QuaternionsA quaternion is a complex number with one real part
and threeimaginary parts:
q = q0 + q1i + q2j + q3ki, j,k = imaginary unitsi2 = j2 = k2 =
ijk = 1
While Complex numbers can be used to represent rotationsin 2D,
Quaternions can be used to represent rotations in 3D.
Corrado Santoro How does a Quadrotor fly?
-
Rotations in 3D and QuaternionsTransformations from Euler angles
to quaternion exist:
q (, , )(, , ) q
Rotating a vector v using a quaternion implies the productqvq
where q is the conjugate of q and v = {0, vx , vy , vz}.The overall
fusion algorithm can be written usingquaternion algebra, thus
avoiding continuous sin, coscalculation.Quaternions avoid gimbal
lock!The attitude can be easily obtained by using:
q (, , )
Corrado Santoro How does a Quadrotor fly?
-
So far so good: Controlling attitude
Attitude control is achieved using (once again)
feedbackcontrollers.We set the Target (desired) Attitude (T , T , T
) fromremote controller.Current quad attitude (M , M , M) is
computed usingsensor fusion.The error signals (differences) are
sent to PID controllerswhose output are the target rates for rate
controllers.The basic model is cascading controllers:
attitudecontrollers which drives rate controllers.
Corrado Santoro How does a Quadrotor fly?
-
Lets remind the schema of Rate Controllers
Corrado Santoro How does a Quadrotor fly?
-
Complete Attitude Controller
Corrado Santoro How does a Quadrotor fly?
-
Control loops: Requirements
Two control loops in the schemarate control (inner);attitude
control (outer);
Attitude control drives rate control, thus rate control musthave
enough time to reach the desired target.Loops must have different
dynamics, i.e. sampling timeTr = rate control sampling timeTa =
attitude control sampling timeTa >> Tr , Ta = nTr , n N ,n
> 1In our quad: Tr = 5ms, Ta = 50ms
Corrado Santoro How does a Quadrotor fly?
-
Finally, the overall algorithm
while True doOn Tr timer tick ;( M , M , M ) = sample gyro();(ax
,ay ,az) = sample accel();(M , M) = fusion filter( M , M , M ,ax
,ay ,az);if after N loops then
(T , T , T ,F ) = sample remote control();T :=roll controller(M
, T );T :=pitch controller(M , T );
endC:=roll rate controller( M , T );
C:=pitch rate controller( M , T );
C:=yaw rate controller(M , T );
(pwm1,pwm2,pwm3,pwm4)T := K1(CT ,C T ,CT ,F )T ;
send to motors(pwm1,pwm2,pwm3,pwm4);end
Corrado Santoro How does a Quadrotor fly?
-
Part VI
What about Altitude or GPS control?
Corrado Santoro How does a Quadrotor fly?
-
Lets repeat the schema!
Do you need another kind of control? Repeat the schema!Identify
your source of measure mIdentify your target tIdentify the
variables to drive vIdentify the sampling timeUse a (PID)
controller v = pid(t ,m)
Corrado Santoro How does a Quadrotor fly?
-
Altitude Control
HT = our target heightHM = measured height (from a sensor)F =
output variable to control (desired thrust)MTr = altitude control
sampling time, M > N
while True doOn Tr timer tick ;...;if after M loops then
HM = sample altitude sensor();F :=altitude controller(HM ,HT
);
end...
end
Corrado Santoro How does a Quadrotor fly?
-
GPS ControlLatT , LonT = our target positionLatM , LonT =
measured position (from a GPS sensor)T , T = target variables to
control (desired pitch and roll)GTr = GPS control sampling time, G
> N
while True doOn Tr timer tick ;...;if after G loops then
(LatM ,LonM) = sample gps();T :=gps lon controller(LonM ,LonT
);T :=gps lat controller(LatM ,LatT );
end...
end
Note: for a proper GPS navigation, a compass (with related
yawcontrol) is mandatory.
Corrado Santoro How does a Quadrotor fly?
-
Vision-based Control
while True doOn Tr timer tick ;...;if after H loops then
(X ,Y ,) = identify target with camera();T :=x controller(X );T
:=y controller(Y );T :=heading controller();
end...
end Corrado Santoro How does a Quadrotor fly?
-
Conclusions
It seems easy ....
Corrado Santoro How does a Quadrotor fly?
-
... but, where is the trick?Are sensors reliable?
Sometimes, NO!Noise due to mechanical vibrations (MEMS-IMU to
befiltered by applying Fourier analysis)False positives due to
wiring problems (Magnetometers,ADC, etc.)
Are execution platforms reliable?Check it!Controllers need
precise (real-time) timingDO NOT Windows to stabilize your
quad!!!You can try with RT-Linux
Is PID Tuning really easy?NO! You must learn it!... and be sure
to have a large set of propellers!!
Are all those things fun?OF COURSE!!!! ^
Corrado Santoro How does a Quadrotor fly?
-
Will Multi-rotors be the future of personaltransportation
systems?
Where do I park my multi-rotor??
Corrado Santoro How does a Quadrotor fly?
-
Demonstration FlightFirst prototype: PROBLEMS!!!
DIY is fun but ...The frame is not well balanced... but the
control will do thejobToo many vibrations (many of them suppressed
usingChebyshev filters)Wrong choice of motors (specs report a
thurst of 400greach, but ...)
Wiring/Electronics problemsCurrent spikes reset the ultrasonic
sensorI2C sometimes locks (a watchdog intervenes and
turn-offmotors)
Firmware problemsStill working on the sensor fusion algorithm,
since it is notsatisfactory (we want more stability...)
Corrado Santoro How does a Quadrotor fly?
-
How does a Quadrotor fly?A journey from physics, mathematics,
control
systems and computer sciencetowards a Controllable Flying
Object
Corrado Santoro
ARSLAB - Autonomous and Robotic Systems LaboratoryDipartimento
di Matematica e Informatica - Universita` di Catania, Italy
[email protected]
Keynote - L.A.P. 1 Course - Jan 10, 2014
Corrado Santoro How does a Quadrotor fly?