MTRN9400-无代写
时间:2024-11-19
MTRN9400 Control of Robotic Systems
ASSIGNMENT 2 - T3 2024
Overview of the Assignment
This assignment focuses on the control of quadcopters and is worth 20% of your total mark in
this course.
The due date is 3:00am on Tuesday Week 12. This deadline is strict and will not be extended.
Marks will be returned within 2 weeks after the submission deadline. You will complete this
assignment individually.
Learning Outcomes
This assignment specifically targets the following learning outcome:
• LO1: Stability analysis and control of nonlinear systems.
• LO2: Understanding different classes of controllers and apply them to robotic systems.
Assignment Specification
This assignment is split into four parts. This document will explain what you are required to
do in each part, and the contribution each part will make to your overall assignment mark. You
are given MATLAB files that will be used for the simulation parts of the assignment.
In this assignment, you will design several controllers for a quadcopter that flies in 1D and 2D
spaces. The marks allocated to each part of the assignment are as follows (total 20 marks):
• Part 1 (4 marks): PD control in 1D
• Part 2 (5 marks): Sliding mode control in 1D
• Part 3 (3.5 marks): Adaptive control in 1D
• Part 4 (5.5 marks): 2D control
• Presentation (2 marks): The criteria include good spelling and grammar, appropriate tech-
nical language, logical structure including using headings and other conventions, appropri-
ate graphical and tabular presentation, caption for graphics and tables, and appropriate
spacing that aids readability.
1
1 Part 1 (4 marks)
In this part, you will control the motion of a quadcopter flying in the z-direction. As explained
in the lecture, the dynamic model of a quadcopter in a 1D space is
z¨ = −g + u1
m
, (1)
where u1 is the thrust generated by the drone motors, g = 9.81 m/s
2 is the gravitational
acceleration, and m is the quadcopter mass. If the mass of the quadcopter is known, a control
law u1 can be designed as
u1(t) = m
(
z¨d(t)− kpe(t)− kde˙(t) + g
)
, (2)
where zd(t) is the desired height of the quadcopter at time t, kp and kd are the control gains,
and
e(t) = z(t)− zd(t). (3)
Then the closed-loop system is obtained from (1)-(3) as
e¨(t) + kd e˙(t) + kp e(t) = 0. (4)
We assume in this part of the assignment that zd is a constant scalar and is equal to 1 m. This
means that we want to control a quadcopter to rise to a height of 1 meter and stays there.
The controller in (2) is already implemented in the provided MATLAB code. Open the code
for Part 1 and then open the ‘System1D 1.m’ file. As shown below, the commented lines at the
top of ‘System1D 1.m’ file (lines 10–14) explain how the state variables are defined.
10 % Inputs:
11 % t : A scalar containing the current time
12 % s : A 2x1 vector containing the current state [z; z dot]
13 % Outputs:
14 % s dot : A 2x1 vector containing [ds1; ds2]
For example, z(t) and z˙(t) are stored respectively in s(1) and s(2). Quadcopter parameters are
also defined in lines 20–24.
20 global QuadParams
21 QuadParams.gravity = 9.81; % gravitational constant
22 QuadParams.mass = 0.28; % mass of quadcopter
23 QuadParams.arm length = 0.086; % wingspan of quadcopter
24 QuadParams.height = 0.05; % height of quadcopter
The desired trajectory of the quadcopter is defined in lines 26–31. The desired height, zd(t), is
stored in s des(1), and z˙d(t) is stored in s des(2). You should not change any of the above parts
in your MATLAB file.
The control law u1 in (2) is implemented in line 48 of ‘System1D 1.m’ file:
2
48 u1 = QuadParams.mass * (z ddot − kp*e − kd*e dot + QuadParams.gravity);
Run the ‘main1D 1.m’ file. By executing this file, a figure will be generated showing a 2D and
a 3D view of the quadcopter position for t between 0 and 5s and also a plot of z(t). You will
see that z(t) converges to zd = 1 m. The steady state error will be printed on the Command
Window.
(a) Change the control law in line 48 of the ‘System1D 1.m’ file to the following PD controller:
u1(t) = −kpe(t)− kde˙(t), (5)
where kp and kd are the proportional and the derivative gains, respectively. These gains
are already defined in lines 46-47 of the code. Do not change their values and run the
‘main1D 1.m’ file.
You will observe that z(t) does not converge to zd = 1. In your report, add a screenshot
from the z-plot that clearly shows the value of z(t) at t ≈ 5s. You can use a ‘Data Tip’ to
get the value of z(t) from the MATLAB figure. Write the value of e(t) at t ≈ 5s in your
report. (1 mark)
(b) Substitute the control law (5) into the system model (1) and write the closed-loop system.
Then obtain the error dynamics (which is the dynamical model that depends on the error
signal e(t) and its time derivatives, but is independent of z(t) and its derivatives). Finally,
write the error dynamics in the state space form and find the equilibrium points. You will
see that the equilibrium point is not at the origin. Verify that the steady-state error you
obtained in the simulation of Part 1(a) is in fact an equilibrium point of the error dynamic.
(2 marks)
(c) Find the range of values for kp and kd such that the absolute value of the steady-state
position error (|e(t)| for a large t) is less than 0.01. You should explain in your report how
you calculated these values. You should analytically choose these values (not by trial and
error using MATLAB) and do not need to add any MATLAB simulation results to your
report for this part; just a mathematical calculation is needed for this part. (1 mark)
2 Part 2 (5 marks)
As we observed in Part 1, a PD controller does not provide a zero steady-state error. So we will
use a robust controller in this part of the assignment. For this part, use the MATLAB files in
‘Part 2’ folder. We continue to assume in this part that zd = 1 m.
Consider the following sliding mode surface
S = e+ ae˙ (6)
where a is a positive constant scalar. We define the sliding mode control as follows:
u1 = m
(
− e˙
a
+ g − ρ sgn(S)
)
(7)
3
(a) Use the Lyapunov candidate V = 12S
2 and find all possible values for a and ρ such that
both e(t) and e˙(t) converge to zero as t→∞. You should add your detailed stability proof
in your report. (2 marks)
(b) Implement the control law (7) in ‘System1D 2’ and choose a and ρ such that e and e˙ converge
to zero within 5 seconds. The sliding mode controller is implemented in lines 41–45 of the
‘System1D 2’ file:
41 rho = 0; % Change this value
42 a = 0.3; % Change this value
43 S = e + a*e dot;
44 ud = QuadParams.mass*(−e dot/a + QuadParams.gravity − rho*sign(S));
45 u1 = ud;
Add the z-plot figure from your simulation to demonstrate z(t) converges to zd. You will get
a full mark if the oscillation in z is damped by 5 seconds (it is OK if there is no oscillation
at all) and z(5) is between 0.997 and 1.003. Use a Data Tip in your figure to show the value
of z(t) at t = 5 s. Write the values you used for a and ρ in your report. (2 marks)
Hint: Use capital letter S in your code to define the sliding surface as the lower case s is
already used in the code. MATLAB has an in-built function, sign, for the signum function.
(c) So far, we observed that a sliding mode controller performs better than a PD controller
as the steady-state error in the sliding mode controller converges to zero. We also know
that sliding mode control is robust against system uncertainties. So we will assume in this
part that there is an unknown constant bias d in the control input which is applied to the
quadcopter rotors as follows
u1(t) = ud(t) + d (8)
where ud is the nominal control law defined as
ud = m
(
− e˙
a
+ g − ρ sgn(S)
)
. (9)
This is a common practical issue when implementing a controller to a real system as the
system actuators may not be able to exactly generate the commanded forces/torques. In
this part of the assignment, we assum there is always a bias in the system’s actuator. Note
that ud in (9) is the same as the controller (7) we used in the previous part.
To implement this biased system in MATLAB, comment line 45 and uncomment line 46 of
the code as shown below:
45 % u1 = ud;
46 u1 = ud − 0.1;
As can be seen above, we assumed the unknown disturbance is d = −0.1. Please note that
this value is unknown to us as control engineers and therefore the controller ud does not use
this value. We added this line to the code so that the quadcopter behaves as if there is a
bias in the thrust force which is generated by the rotors.
Choose a and rho such that the |e(t)| and |e˙(t)| at t = 5 s are less than 0.01. Only add
the values you found for a and rho in your report. No explanation is needed for this part.
4
Also no figure is required. We will check the values you will provide and will then give you
a full mark if the error conditions are satisfied, and zero marks if they are not satisfied. (1
mark)
3 Part 3 (3.5 marks)
We know that adaptive control is also a good controller when there is a disturbance or unknown
term in the system model. So we will use adaptive controller in this part to check its performance.
For the scenario explained in Part 2(c) where there is an unknown constant bias d in u1, we
want to design an adaptive control law that adaptively tunes the unknown parameter d. In this
case, the system model, the control law and the tuning law are as follows
z¨(t) = −g + u1(t)
m
(10)
u1(t) = ud(t) + d (11)
˙ˆ
θ(t) = · · · (12)
where ud and
˙ˆ
θ need to be designed, m and g are known and d is unknown and constant. We
continue to assume zd = 1 m.
To design an adaptive control, one starts with the following Lyapunov function:
V =
[
e e˙
] [ a
2
b
2
b
2
1
2
] [
e
e˙
]
+
1
2
(
θˆ − d
)2
=
a
2
e2 + bee˙+
1
2
e˙2 +
1
2
(
θˆ − d
)2
. (13)
where a and b are constant scalars to be chosen such that the matrix
P =
[
a
2
b
2
b
2
1
2
]
(14)
is positive definite. We then calculate V˙ and obtain that for ud and
˙ˆ
θ defined as
˙ˆ
θ =
b
m
e+
1
m
e˙ (15)
ud = −θˆ + gm+ k1me+ k2me˙, (16)
V˙ becomes negative semi-definite and is in this form
V˙ = aee˙+ be˙2 + k1be
2 + k1ee˙+ k2bee˙+ k2e˙
2
=
[
e e˙
] [ k1b a+k1+k2b2
a+k1+k2b
2 b+ k2
] [
e
e˙
]
(17)
where k1 and k2 are constant scalars to be designed such that the matrix
Q =
[
k1b
a+k1+k2b
2
a+k1+k2b
2 b+ k2
]
(18)
in negative definite.
5
(a) Find specific values for a, b, k1 and k2 such that matrix P in (14) is PD and Q in (18) is
ND. Write these values in your report and explain how you obtained these values (you need
to show these values will make P PD and Q ND.). (2 marks)
(b) In ‘Part 3’ folder, open ‘System1D 3.m’ code. Update gain values in lines 46–49 so that
|e(t)| and |e˙(t)| at t = 5 s are less than 0.01. You may need to tune the gain values so that
the obtained errors are within the desired range. The error values will be displayed in the
Command Window after running the code.
45 % Change the following values
46 a = 0;
47 b = 0;
48 k1 = −1;
49 k2 = −1;
Add a screenshot of Figure 1 generated by MATLAB in your report with a Data Tip in the
z-plot that shows the value of z(5). Also copy and paste the steady-state errors which are
printed in the Command Window. (1.5 marks)
4 Part 4 (5.5 marks)
In this part, you will control a quadcopter in 2D.
(a) Using week 10 Lecture slides (Slide 15), implement the control inputs for u1(t) and u2(t).
Note that you also need to implement the equation that generates ϕc(t) to be able to
implement u2(t)
1. Tune the 6 control gains, kd,z, kp,z, kd,ϕ, kp,ϕ, kd,y, and kp,y, and run the
‘main2.m’ file for two different trajectories: line and sine. You can change these trajectories
in line 18 of the ‘main2D.m’ file:
15 %−−−−−−−−−−−−−−−−−−−−−−−−−− Define Trajectory −−−−−−−−−−−−−−−−−−−−−−−−−−−−%
16 % Uncomment the trajectory that you want to use
17 % available trajectories: 'diamond', 'sine', 'line', 'step'.
18 myTraj = 'sine';
The total position, velocity and angle error will be printed in the Command Window after
you run the code.
You will get the full mark for this part if the the errors for the line and sine trajectories
are less than values displayed in the Command Window, that is, the magnitude of the
position error is less than 0.01, the magnitude of the velocity error is less than 0.03, and the
magnitude of the angle error is less than 0.03. You will get zero mark if the steady state
position, velocity and angle errors for the line and sine trajectories are more than 0.05, 0.1,
and 0.1, respectively. If the error is between the two upper and lower bounds, then we do a
linear interpolation to determine your mark.
Write the gain values and the steady state errors printed on the Command Window in your
report. You need to upload your ‘System2D.m’ file (do not upload the main2D.m file unless
1You can use any method to calculate the derivative of ϕc and we accept it as long as the errors are within
the ranges explained in this part.
6
you made changes to it). This file might be checked to validate your steady state errors.
(3.5 marks)
(b) Explain whether changing kd,z and kp,z values affects the error of the quadcopter position
in the y-direction or not? Why? In your explanation, you should refer to the quadcopter
model in Slide 15 of week 10’s lecture slides. You should also change these values in your
simulation and see how they affect quadcopter’s motion in the y direction. (1 mark)
(c) Explain the relation between (kd,y, kp,y) gains and (kd,ϕ, kp,ϕ) gains. Are they in the same
range or the values of one set of gains are much larger than the other set of gains? (1 mark)
Additional Information
• A plagiarism check will be performed on all assignments and any instances of plagiarism
will be dealt with under the UNSW plagiarism policy (linked from the course outline).
• Please refer to the course outline for late submission policy.
• Please post questions about this assignment in the Assignment 2 channel in Teams.