Lab 2
Lab 2
Anvar Mustafayev
2 Objectives 2
3 Qball-X4 Model 2
3.1 Actuator dynamics . . . . . . . . . . . . . . . . . . . . . . . . 2
3.2 Roll/Pitch model . . . . . . . . . . . . . . . . . . . . . . . . . 3
3.3 Height model . . . . . . . . . . . . . . . . . . . . . . . . . . . 4
3.4 X-Y position model . . . . . . . . . . . . . . . . . . . . . . . . 5
3.5 Yaw model . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
4 Procedure 6
5 Results 10
6 Discussions 16
1
1 Introduction
In this work, students will use QuaRc software.
The targets of QuaRC: It supports Windows (XP, Vista and Win 7),
QNX x86, and Linux ARM. The manager of QuaRC Target runs the
generated real-time code on the selected target. Target might be remote
or local.
2 Objectives
There are three main goals for achieving in this laboratory work:
3 Qball-X4 Model
We are going to talk about dynamics of Qball-X4. Both models, linearized as
well as nonlinear will be used in controller development. The drone has three
axes: X, Y, Z. Roll, pitch and yaw are defined as the angles of rotation along
X, Y, Z correspondingly. The axes which were mentioned before, are defined
with the same orientation as the Qball-X4 sitting upright on the ground.
2
3.1 Actuator dynamics
The first order system is used for calculation of the thrust created by each
propeller.
ω
F =K u (1)
s+ω
u- is PWM input to the actuator;
K- is a positive gain.
J θ̈ = ∆F L
where
∆F = F1 − F2 (4)
3
Parameter Value
ω 15 rad
sec
Jroll 0.03 kg × m2
Jpitch 0.03 kg × m2
M 1.4 kg
Ky 4 N ×m
Jyaw 0.04 kg × m2
L 0.2 m
Table 1
Figure 1
The actuator dynamics for each propeller can be derived by merging the
dynamics of motion for the roll/pitch axis.
θ̇ 0 1 0 θ 0
θ̈ = 0 0 KL θ̇ + 0 ∆U (6)
J
v̇ 0 0 −ω v ω
4
Ṡ = 0
After augmenting this state into the state vector, the system dynamics can
be rewritten as :
θ̇ 0 1 0 0 θ 0
θ̈ 0 0 KL θ̇ 0
= J
0 + ∆U (7)
v̇ 0 0 −ω 0 v ω
ṡ 1 0 0 0 s 0
where
Z- is the height;
r- is a roll angle;
p- is a pitch angle.
The total mass of the drone was given above in Table 1. This equation
expresses that if the roll/pitch angles are non zero thee overall vector will not
be perpendicular to the ground. Considering these angles are approximately
equal to zero, the dynamics equation can be linearized to the following state
space form:
Ż 0 1 0 0 Z 0 0
Z̈ 0 0 4K 0 Ż 0 −g
= M
v̇ 0 0 −ω 0 v + ω u + 0 (9)
ṡ 1 0 0 0 s 0 0
5
3.4 X-Y position model
The total thrust generated by motors as well as changing roll/pitch angles
make drone move along the X and Y axes. Considering that the yaw angle
is close to zero the dynamic of motion in X and Y axes can be written as:
M Ẍ = 4F sin(p)
(10)
M Ÿ = −4F sin(r)
The roll/pitch angles are close to zero, so the following linear state space
equations can be derived for X and Y positions
Ẋ 0 1 0 0 X 0
Ẍ 0 0 4K p 0 Ẋ 0
= M
v̇ 0 0 −ω 0 v + ω u,
ṡ 1 0 0 0 s 0
(11)
Ẏ 0 1 0 0 Y 0
Ÿ 0 0 −4K r 0 Ẏ 0
= M
v̇ 0 0 −ω 0 v + ω u
ṡ 1 0 0 0 s 0
τ = Ky u (12)
where
6
θy - is a yaw angle;
The total torque, ∆τ , can be figured out from the equation below
∆τ = τ1 + τ2 − τ3 − τ4 (14)
The yaw axis dynamics can be rewritten in the state-space form as given
below " #
˙
θy 0 1 θy 0
= + K ∆τ (15)
θ¨y 0 0 θ˙y J
y
y
Figure 2
7
4 Procedure
Initially, we should take in consideration modules mentioned before, such
as: actuator dynamics, roll/pitch model, height model, X-Y position model,
and yaw model. Moreover, we will take constants from Table 1. Open the
Simulink library to create a new model.
8
In this library, under resources drag, from the left side we can see ”Sources”
So, we should click on it and select our function which will be our input.
Figure 4: Sources
9
Figure 5: ”Step” block
And then, we ought to select transfer function and drag drop it on working
area. After that, it is important to change parameters of the transfer function
to the following: K = 120 and ω = 15 rad sec
Also, there is integrator block which we should add two times and add PID
controller
10
Figure 8: Integrator
The ”add” block should come before the step function to help facilitate
a negative feedback
Finally, to start adjust parameters, we should select the last block which is
called ”Scope”
11
All in all, we get model, which will be demonstrated below:
5 Results
In our input we can put 5 which represents five degree pitch angel. To do
that we should click on ”step block” and enter 5 in ”step time”. (Figure 13)
Figure 13
12
Then in configuration parameters, we select the solver option type of two
variables step and press on ”ok” button to save changes.(Figure 14)
Figure 14
13
Taking the output of this step function and put into this scope, so can
we directly compare the input and the output. (Figure 15)
Figure 15
When we run model, the graph which was displayed below should be ob-
tained (Figure 16) Considering how our system reacts on the step input
Figure 16
In the PID block click on ”Tune” which will bring up our PID tuner. There-
fore, we can use this in order to get PID gain values for a stable response.
Moreover, we can use it for detecting output rise time, steady-state er-
ror,overshot and so on.(Figure 17)
14
Figure 17
We can clear round with a response time and update the blog. This will
update the compensotor formulas.(Figure 18)
15
Figure 18
blue line- is p
16
Figure 19
Now, we create the same system with a sinusoidal input to see how system
responds on always varying command. By clicking on on ”sine wave” enter
frequency equal to 2 rad
sec
and then press on ”ok” button to save results.
Figure 20
17
Figure 21
Figure 22
6 Discussions
To sum up, in this laboratory work was figured out how to appropriately
use QuaRC software as well as how to build Simulink module step by step.
Moreover, it assists to evolve skills on PID design and take control of pitch
motion of the drone. Furthermore, this lab includes some exercises which
18
will help students to understand QuaRC at the same time associated tools.
Also, we can see the behavior of the same system in different circumstances,
namely in a sinusoidal input which always has variable commands and step
input.Probably, when the system has step inputs, it is more stable while
during always changeable commands, pitch angle has fluctuations and stays
unstable.
19