0% found this document useful (0 votes)
36 views20 pages

Lab 2

The document describes the dynamics model of a Qball-X4 quadcopter drone. It includes models for the actuator dynamics, roll/pitch dynamics, height dynamics, x-y position dynamics, and yaw dynamics. The models are presented as equations and in state space form. The objectives of the work are to develop PID control of the pitch motion and understand the QuaRC software for drone control.

Uploaded by

anvermustafaev35
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
36 views20 pages

Lab 2

The document describes the dynamics model of a Qball-X4 quadcopter drone. It includes models for the actuator dynamics, roll/pitch dynamics, height dynamics, x-y position dynamics, and yaw dynamics. The models are presented as equations and in state space form. The objectives of the work are to develop PID control of the pitch motion and understand the QuaRC software for drone control.

Uploaded by

anvermustafaev35
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 20

Laboratory ›2

Anvar Mustafayev

Student ID: 40237561


Contents
1 Introduction 2

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.

ˆ QuaRc software is used for controlling drone in real time. It is possible


to run this software in real time on Windows, QXN x86, and Linux
ARM.

QuaRC’s have two components:

ˆ QuaRC Simulink Development Environment (SDE): The component


creates circumstances to generate/build code from MATLAB and Simulink
models.

ˆ 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:

ˆ Evolve skill on PID design;

ˆ Perform PID controlling of pitch motion of the drone;

ˆ Do some exercise to understand QuaRC as well as associated tools.

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;

ω - is the actuator bandwidth;

K- is a positive gain.

The equation 1 was figured out owing to experiments. A variable v is used


for identifying the actuator dynamics,
ω
v= u (2)
s+ω

3.2 Roll/Pitch model


We can consider that the rotations along X and Y are decoupled, the motion
in roll/pitch can be modeled as in Figure h, which was demonstrated in
laboratory 1. Two propellers are rotating in each axis. As we know, it is
possible to find the thrust per motor by using the equation 1. Rotation
around the center of gravity could be founded thanks to difference in the
created thrusts. The roll/pitch, θ angle, can be formulated using the following
dynamics.

J θ̈ = ∆F L

where

J = Jroll = Jpitch (3)

rotational inertia of the drone in roll/pitch axes were demonstrated in Table


1.

L - is a distance between the propeller and the center of gravity, and

∆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

Equation 4 shows the difference of forces generated by the motors. It is


important that the difference of forces are generated owing to different inputs
to the motors, i.e
∆U = U1 − U2 (5)

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 ω

To facilitate the use of an integrator in the feedback structure a fourth state


can be added to the state vector, which is defined as :

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

3.3 Height model


The work of all four propellers helps the Qball-X4 to move along Z axis and
regulate the height. The dynamic model of the drone can be written as:

M Z̈ = 4F cos(r) cos(p) − M g (8)

where

F- is a thrust generated by the work of each propeller;

M- is a total mass of a device;

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

3.5 Yaw model


The torque generated by each motor, τ , is assumed to have the following
relationship with respect to the PWM input, u

τ = Ky u (12)

where

Ky - is a positive gain which was given above in Table 1.

Yaw motion is caused because of the difference between torques created by


two propellers which are rotating clockwise and another two propellers ro-
tated counter-clockwise. The model related to yaw axis was displayed on
Figure 1. The motion in the yaw axis can be modeled using the following
equation
Jy θ¨y = ∆τ (13)
This equation gives two main parameters :

6
θy - is a yaw angle;

jy - is the rotational inertia along the Z axis.

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.

Figure 3: Simulink library

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

Figure 6: Transfer function

Transfer function represents the actuator dynamics. This is thrust created


by each propeller.
After these steps, we should select ”gain” block and add gain of a 0.2 over
0.03, which represents L over J.

Figure 7: Gain block

Also, there is integrator block which we should add two times and add PID
controller

10
Figure 8: Integrator

Figure 9: PID controller

The ”add” block should come before the step function to help facilitate
a negative feedback

Figure 10: Add block

Finally, to start adjust parameters, we should select the last block which is
called ”Scope”

Figure 11: Scope

11
All in all, we get model, which will be demonstrated below:

Figure 12: Final model

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

See changes by reviewing our model (Figure 19) where

yellow line- is our output

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

Finally, by pressing on ”scope” block and running system, we will derive


new result for always varying commands.

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

You might also like