Jurnal PID
Jurnal PID
Abstract—This paper focuses on modeling and controlling for the physical modeling part. The final task focuses on a
a nonlinear quadcopter plant system using two different Processor-in-the-Loop simulation (PIL) which verify whether
approaches. The first represents a pure mathematical model the deployed C/C++ code in the hardware target matched the
calculated based on Euler Lagrange formalism using only
Matlab/Simulink environment, the second one shows a physical simulation design, for this purpose a LAUNCHXL-F28377s
model (CAD model) imported from Solidworks to Simscape DSP platform was chosen to accomplish this task.
multibody which include a 3d simulation environment. The
controller part of both models are constituted from two cascaded
loop, an inner-loop for attitude control and an outer-loop for II. M ATHEMATICAL M ODELING AND C ONTROL D ESIGN
position and altitude control. Finally, in order to make sure that
the result obtained in the simulation environment matched the This section presents the working principle of a 6 DOF
real implementation, the paper offers a processor-in-the loop quadcopter with a full detailed description of its dynamics, the
simulation using as a hardware target LAUNCHXL-F28377s.
mathematical model system is obtained using Euler-Lagrange
Keywords: Quadcopter, PD control, nonlinear control, position formalism with the assumption that:
control, attitude control, PIL simulation • The components of the system are rigid bodies.
• The body mass is concentrated at the center of gravity.
I. I NTRODUCTION • The body axes are the principal axes for the quadcopter.
Research in the field of drones is essentially • The rotational speed of the rotors relative to the ground
multidisciplinary. Indeed it involves very varied fields is not taken in consideration.
such as aerodynamics, signal and image processing, control • The lift and the drag are proportional to the square of the
design mechanics, composite materials, real-time computing, speed rotation of the motors.
etc. Recently the interest in drones seems to be increasing in
multiple applications such as agriculture, products and goods
transport or even for military applications and intervention
in hostile environments [1] [2] [3]. We can imagine a drone
that explores a contaminated building or tunnel and to make
a first observation before any human intervention.
A. Mathematical Modeling 2) Expression of Kinetic and Potential Energy :
In order to define the quadcopter model we need to identify
Let [XY Z]
an orthonormal base constituting a fixed refer-
the system with appropriate coordinate frames. The inertial
coordinate frame or earth reference frame is considered as ence frame. If the rigid body rotates three times according to
a fixed coordinate at the ground, while the body coordinate aeronautics angles, then by using equation 1 we have:
frame is attached to the center of the quadcopter and its axis ⎛ ⎞
x
are parallel with the earth reference frame. The transition rXY Z = R(φ, θ, ψ) ⎝ y ⎠ (3)
between the two coordinate frames is assured by introducing z
three elementary rotation angles φ, θ, ψ which are defined in
the following way fig.2:
rX = cos(ψ)cos(θ)x + [cos(ψ)sin(θ)sin(φ) − sin(ψ)cos(φ)]y
Rotation of φ(t) around the x-axis (angle: −π/2 ≤ φ ≤ π/2) + [cos(ψ)sin(θ)cos(φ) + sin(ψ)sin(φ)]z
Rotation of θ(t) around the y-axis (angle: −π/2 ≤ θ ≤ π/2) rY = sin(ψ)cos(θ)x + [sin(ψ)sin(θ)sin(φ) + cos(ψ)cos(φ)]y
Rotation of ψ(t) around the z-axis (angle: −π ≤ ψ ≤ π )
+ [sin(ψ)sin(θ)cos(φ) − sin(φ)cos(ψ)]z
The rotation matrices are given by :
⎛ ⎞ rZ = −sin(θ)x + cos(θ)sin(φ)y + cos(θ)cos(φ)z
1 0 0
R(x, φ) = ⎝ 0 cos(φ) −sin(φ) ⎠ By deriving and simplifying those equations, we obtain
0 sin(φ) cos(φ) the corresponding speed of rX , rY and rZ which can be
represented as :
⎛ ⎞
cos(θ) 0 sin(θ) ⎛ ⎞ ⎛ ⎞⎛ ⎞
νX (x, y, z) νxx ν xy ν xz x
R(y, θ) = ⎝ 0 1 0 ⎠
⎝ νY (x, y, z) ⎠ = ⎝ νyx νyy νyz ⎠ ⎝ y ⎠
−sin(θ) 0 cos(θ)
νZ (x, y, z) ν zx ν zy ν zz z
⎛ ⎞ The squared norm of the speed is calculated by:
cos(ψ) −sin(ψ) 0
2 2
R(z, ψ) = ⎝ sin(ψ) cos(ψ) 0 ⎠ νx,y,z = νX + νY2 + νZ2 ⎛ ⎞⎛ ⎞
0 0 1 x2 xy xz ν ix
νi2=X,Y,Z = ν ix ν iy ν iz ⎝ xy y2 yz ⎠ ⎝ νiy ⎠
By multiplying the three matrices, we obtain an orthogonal
xz yz z2 ν iz
matrix representing the transformation between two frames
in equation 1: By developing the expression and introducing inertial
⎛ ⎞
elements, the kinetic energy can be expressed in the following
c(ψ)c(θ) c(ψ)s(θ)s(φ) − s(ψ)c(φ) c(ψ)s(θ)c(φ) + s(ψ)s(φ) way:
R= ⎝ s(ψ)c(θ) s(ψ)s(θ)s(φ) + c(ψ)c(φ) s(ψ)s(θ)c(φ) − s(φ)c(ψ) ⎠ (1)
−s(θ) c(θ)s(φ) c(θ)c(φ) 1
2 1
2
T = Ix φ̇ − ψ̇sin(θ) + Iy θ̇cos(φ) + ψ̇sin(φ)cos(θ)
1) Euler Lagrange formalism: 2 2
Developing the mathematical model using Euler-Lagrange 1
2
+ Iz θ̇sin(φ) − ψ̇cos(φ)cos(θ)
formalism [8] [9] using kinetic and potential energies. The 2
1 2 2
1 2
general Lagrange equation is given by the equation 2: Ix = y + z dm; Iy = x + z 2 dm;
2 2
d ∂L ∂L 1 2
Γi = − ; With L = T − V (2) Iz = x + y 2 dm
dt ∂ q˙i ∂qi 2
Ix , Iy andIz represents the moments of inertia of the system.
Γi : Generalized forces given by non-conservative forces.
The potential energy is calculated by the following equation:
qi : Generalized coordinates.
T : Total kinetic energy.
V = g (−sin(θ)x + sin(φ)cos(θ)y + cos(φ)cos(θ)z) dm
V : Total potential energy.
V = xdm (−gsin(θ)) + ydm (gsin(φ)cos(θ))
+ zdm (gcos(φ)cos(θ))
Psi
Zero-Order <z_des>
Hold2
<Phi>
X
<X> <Y> Zero-Order
References Position_Controller <Theta>
Hold3
Y
<Z> Z
Attitude_Controller Quadrotor System
Outer Loop
Fig. 3. Quadcopter plant model with the controller form Simulink environment
MODEL
zr +
-
PID Altude
Controller U1 Let consider the error: ε2 = x2 − α1 ⇒ ε˙2 = x˙2 − α˙1
x y z ⇒ ε˙2 = a1 x4 x6 + a2 x4 Ωr + b1 U2 − α˙1
R
Motor
V˙2 (ε1 , ε2 ) = −c1 ε21 −ε1 ε2 +ε2 [a1 x4 x6 +a2 x4 Ωr +b1 U2 − α˙1 ]
REV
C
-
S PS
Voltage -
V˙2 (ε1 , ε2 ) = −c1 ε21 +ε2 [−ε1 +a1 x4 x6 +a2 x4 Ωr +b1 U2 − α˙1 ]
Source1
BRK
Mechanical
Subsystem Rotational Subsystem1
H-Bridge Reference
Reference
The control input U2 for Roll command is obtained B. Processor-In-the-Loop (PIL) Simulation
with the assumption of x¨1d = 0 and V˙2 (ε1 , ε2 ) < 0:
⇒ U2 = b11 [ε1 − a1 x4 x6 − a2 x4 Ωr − c2 ε2 − c1 (c1 ε1 + ε2 )] The design of any controller requires the mathematical
development of the model in question followed by adjustments
The same structure was used to calculate Pitch and of its parameters which depend on the structure and nature
Yaw commands with the consideration of: of the plant model. However, the real implementation of this
ε3 = x3d − x3 controller takes into account several variables that can affect
ε4 = x4 − x3d
˙ − c 3 ε3 the performance of the system, meaning that the deployed
ε5 = x5d − x5 code will not necessarily behave as the simulated one. The
ε6 = x6 − x5d
˙ − c 5 ε5 PIL technique makes it possible to verify if the implemented
c/c++ code on a processor target correspond well to the result
⇒ U3 = 1 obtained during the simulation.
b2 [ε3 − a3 x2 x6 − a4 x2 Ωr − c4 ε4 − c3 (c3 ε3 + ε4 )]
1 PIL requires drivers to communicate the computer platform
⇒ U4 = b3 [ε5 − a5 x2 x4 − c6 ε6 − c5 (c5 ε5 + ε6 )]
with the aimed hardware. The resulting object code generated
in the PC links with other test-management functionality and
The outer loop command is maintained as the previous
is then downloaded, typically to an off-the-shelf evaluation
section with a PID controller of position and altitude.
board with the target processor. The simulation tool, running
III. P HYSICAL M ODELING AND PIL S IMULATION on the PC machine, then communicates with the downloaded
A. Physical Modeling software, typically via a serial communication link.
Physical modeling or simscape multibody simulation
environment for 3d mechanical systems is considered one of
the strongest tools which simplify the build up of dynamic Plant Model
systems and integrates with others physical modeling libraries +
in Matlab/Simscape environment, making dynamic system PIL Block
modeling much easier without the need of deriving equations
which differs from the standard Simulink modeling approach
Matlab/Simulink envirement
and is particularly suited to simulate systems that consist of
real physical components [10]. Unlike Simulink input/output
connection based design, the component models in simscape
have physical connections which enable modeling physical PC Serial port
phi :1[2]
0.6
0.4
0.4
This section discusses some simulation results of the 6DOF
0.2 0.2
quadcopter model and the process of the verification under the
0 0
real C2000 processor. All the shown figures were taken from
-0.2
Matlab/Simulink envirement. -0.2
-0.4
-0.4
-0.6
TABLE I
-0.6
-0.8
Q UADCOPTER PARAMETERS
0 20 40 60 0 20 40 60
Parameters Value
Ix 7.2 × 10−3 kg.m2 Fig. 8. Roll command Fig. 9. Pitch command
Iy 7.2 × 10−3 kg.m2 1
30
1.1 × 10−2 kg.m2
0.9 Y ref:1[1]
Iz Yaw ref:1[1]
yaw :1[2]
Y :1[2]
0.8
25
Jr 6.3 × 10−5 kg.m2 0.7
20
l 0.2 m 0.6
0.5
g 9.81 m/s2 0.4
15
m 0.55 kg 0.3 10
0 20 40 60 80 0 20 40 60 80
A. PID Control Approach Results Fig. 10. Forced yaw to 1 Fig. 11. X command
1
The parameters of the controller are shown in the table: 30
0.9
X ref:1[1]
X :1[2] Yaw ref:1[1]
25 0.8 yaw :1[2]
0.7
Kpφ 280.55 15
0.5
0.4
Kdφ 6.15 10 0.3
Kdψ 0.95
Kpx 10 Fig. 12. Y command Fig. 13. Z command
Kdx 3
Position controller
Kpy 10
Outer Loop B. Backsteping Controller Approach Results
Kdy 3
Kpz 2.83 × 105
Altitude controller
Kdz 6.15 × 103 The parameters of the Backsteping attitude controller are in
TABLE II the table:
PARAMETERS OF THE CONTROLLER
TABLE III
BACKSTEPING CONTROLLER PARAMETERS
The desired trajectory of the quadcopter is as follow:
Parameters Value
30 X
c1 27.79
20
10
c2 285.74
0 c3 4.70
30 Y
20
c4 45.02
10 c5 4.55
0
c6 21.67
0 20 40 60 8
Z
4
V. C ONCLUSION