Lab 4 – ECE410F Output Feedback Stabilization of a Cart-Pendulum Robot

$30.00

Download Details:

  • Name: lab4-sb7oj7.zip
  • Type: zip
  • Size: 1.45 MB

Description

Rate this product

In the previous lab, you designed a feedback controller for the cart-pendulum which stabilized the upright equilibrium. That controller, however, was a full-state feedback. That is, it required direct knowledge of all of the states
of the cart-pendulum. Such knowledge of the complete state of a system is not typically available. In our case,
we suppose that we do not have access to the velocity of the cart, or to the angular velocity of the pendulum.
In this lab, you will design an observer which reconstructs the full state of the system from the available outputs,
and combine this observer with the state feedback controller from the previous lab to obtain an output feedback
controller. You will also investigate the impact of measurement noise on both the observer in isolation, as well as
its impact on your overall controller.
Throughout the lab, you will be guided through a number of steps which will require you to write Matlab
code. You will write your code in a Matlab script called labx.m, where x is the lab number. You will submit this
code as a group. Your code should provide certain outputs (figures, numbers, and the like). A request for output
is highlighted with a shaded area of text, such as the following.
Output 1. Print the eigenvalues of the matrix.
Parts of the text containing directions for the writing of your Matlab code will be highlighted in a different
colour, such as this:
Create a function pendulum.m. The first line of the function will be
function xdot = pendulum(t,x,parameters)
1
2 Submission guidelines and mark breakdown
Marks are assigned to groups. Members of each group get identical marks, unless special circumstances occur.
The group lab mark will be made up of three components.
Matlab code 6 pts
Lab report 4 pts
Total 10 pts
Matlab code. Your code should be clean and readable, and it should contain abundant commentary, so that
the instructors may follow your development and check its correctness. This component of the mark will be based
on the correctness of the code and its readability, and it will be assigned as follows:
0 out of 6 the code is absent
1 out of 6 the code is largely incomplete
2 out of 6 the code is largely complete, but there are parts missing and the outputs are incorrect
3 out of 6 the code is complete, but it does not produce correct outputs
4 out of 6 the code is complete, it produces correct outputs, but there is no commentary in the code,
and/or the code is poorly organized
5 out of 6 the code is complete, correct, and contains some but insufficient commentary, and/or its
organization is below par
6 out of 6 the code is complete, correct, and the commentary and organzation are adequate so that it is
easy to read
Lab report. Write a concise report containing the requested outputs, but don’t just print out a bunch of matrices
and figures. Add some flesh to the outpus that are requested within the lab document so that one can follow the
logical development of the lab. Aim for a style like this:
Output 1. The following are the bases of the subspaces V and W that were obtained:
(…)
We observe that the columns of V were already linearly independent, while those of W weren’t. We further
note that (…).
Output 2. Below the solution of the differential equation. There are three figures. The first two figures depict
x1(t) and x2(t), while the third figure depicts the orbit.
Do not screenshot Matlab figures. Rather, save them as jpeg files (or other formats) and include then in the
report in the appropriate order.
When the lab document asks you to comment on something, strive to provide meaningful, insightful commentary, that demonstrates you have understood your own work and how it connects to the course concepts. This
portion of the mark will be assigned as follows:
0 out of 4 the report is either absent, or a simple printout of the Matlab outputs without commentary
1 out of 4 the report is incomplete and the commentary is inadequate
2 out of 4 the report is incomplete xor the commentary is inadequate
3 out of 4 the report is complete and the commentary is adequate, but lacks insight/clear understanding
4 out of 4 the report is complete and the commentary is adequate and demonstrates clear understanding
2
3 Observability and state estimation
Matlab commands
obsv(A,C) Forms the observability matrix of the pair (A, C).
Our first task is to confirm that our system is observable. Recall that a pair (A, C) is observable if and only the
rank of the observability matrix is equal to the dimension of the state space.
Create a file lab4.m, and in it do the following:
• Include all the relevant material from lab 3 to obtain the linearization of the cart-pendulum system.
• Using the command obsv, construct the observability matrix of the pair (A, C), check the rank of this matrix,
and confirm that the system is observable.
3.1 Noiseless state estimation
The linearized pendulum from lab 3 has the form
x˙ = Ax + Bu
y = Cx,
where x =

z z˙ θ
˙θ]
⊤ and y =

z θ

is the vector of sensed variables.
An observer for the system above has the form,
˙xˆ = Axˆ + Bu + L(Cxˆ − y).
Letting x˜ = x − xˆ be the estimation error, the error dynamics are
˙x˜ = (A + LC)x˜ ,
and so we want the matrix A + LC to have eigenvalues in the open left-hand plane.
The eigenvalues of A + LC can be arbitrarily assigned by a choice of L if and only if the pair (A, C) is observable.
Once observability has been ascertained, we assign the eigenvalues of A + LC by using duality: we design K to
assign the eigenvalues of A
⊤ + C
⊤K, and then set L = K
⊤.
Return to lab4.m
• Using the Matlab place function with the matrices A
⊤ and C
⊤, design L1 such that the eigenvalues of
A + L1C are at {−10, −11, −12, −13}. N.B. Remember that Matlab uses the convention that u = −Kx.
• Repeat the above to design L2, now placing the eigenvalues at {−40, −41, −42, −43}.
3
Before integrating the observer with the controller, we will first investigate its performance purely as a tool for
estimation. That is, we will simulate our system using the original full state feedback controller, and the behaviour
of the observer will not affect the performance of the plant. The block diagram of the setup we have in mind is
this.
S C
O
c
K
u
v
y
X
x
z
e
F
E
Note that, in the structure above, the observer has no effect on the state feedback control loop. It is used merely
as a tool to estimate the state.
Return to your file lab4.m.
• For the state feedback controller, find K such that the eigenvalues of (A + BK) are at {−5.1, −5.2, −5.3, −5.4}.
You will use this vector K throughout the lab.
• Using whichever method your prefer (i.e. either in a file or using anonymous functions), define a function
expressing the dynamics of the system
x˙ = (A + BK)x, y = Cx
˙xˆ = (A + LC)xˆ + BKx − Ly.
Do this for both L1 and L2.
• Simulate this system using the initial condition (−0.5, 0, −π/4, 0) for x, and (0, 0, 0, 0) for xˆ. Use the same
simulation parameters as in lab 3.
• Produce a figure containing four subplots depicting the components of the estimation error x˜ = xˆ − x versus
time. In subplot i, superimpose the i-th component of the estimation error x˜(t) for the two integrations with
gains L1 and L2.
• Repeat the above, but now use the nonlinear dynamics for x:
x˙ = f(x, Kx)
˙xˆ = (A + LC)xˆ + BKx − Ly.
The first differential equation represents the nonlinear cart-pendulum dynamics with control input u = Kx.
Output 1. • Print the observer gain matrices L1 and L2.
4
• Produce the two figures requested above.
• Comment on how the estimation error differs between the linear and nonlinear system.
3.2 State estimation with measurement noise
Matlab commands
randn(m,n) Generate an array with m rows and n columns containing normally
distributed random numbers with zero mean and unit variance
interp1(xs, ys, x) Interpolate the values given in ys corresponding to the points xs at the
point x
In the previous section, you should have noticed substantially better performance when using L2 instead of L1, in
the sense that the estimation error converged to zero more quickly. In this section, we will explore some of the
downsides of using larger observer gains, specifically the impact of measurement noise.
The method we use to simulate noise in our system will necessarily be ad hoc in order to avoid difficulties
associated with continuous time stochastic processes. We first quickly review how to generate a random vector of
specified covariance Σ. Since a covariance matrix is positive definite, it has a Cholesky decomposition
Σ = LL⊤ ,
where L is a lower triangular matrix. Given a vector x0,1 of normally distributed random variables with zero mean
and unit variance, the vector
x = Lx0,1
will be normally distributed with zero mean and covariance Σ.
Return to your file lab4.m.
• Using the Matlab randn function, create an array of 1000 2 × 1 random vectors with mean and covariance
µ =

0
0
#
Σ =

0.005 0
0 0.001#
• Create an anonymous function W(t) interpolating this array over your integration interval.
• Create new functions simulating the state feedback control system plus the observer. The setup is identical
to the one used to produce output 1, but now the plant output y = Cx is replaced with the noisy output
y = Cx + W in the observer:
x˙ = (A + BK)x, y = Cx+W
˙xˆ = (A + LC)xˆ + BKx − Ly.
5
• Simulate the system as before, using both L1 and L2 and produce one figure showing the estimation error
x˜ = x − xˆ for the two cases. This figure will contain four subplots. Each subplot will display a component of
the estimation error as a function of time. The results obtained for the gains L1 and L2 will be superimposed
on each subplot.
• Calculate the mean squared estimation error (MSE) over the final 5 seconds of each simulation. If X˜ is an
N × 4 matrix whose columns are the samples of the components of the estimation error x˜, the MSE of the
i-th component is (1/N) ∑
N
k=1

X˜(k, i)
2
.
Output 2. • Produce the figure requested above.
• Comment on the difference between L1 and L2.
• Compare and contrast the MSEs associated with L1 and L2. Which one is larger, and why, in your opinion?
Try to think in terms of frequency response. For the sake of argument, set u = 0, so the observer reduces to
˙xˆ = (A + LC)xˆ − Ly.
This is an LTI system with input y and output xˆ. As the spectrum of A + LC is shifted to the left of the
complex plane, the observer bandwidth grows larger. You can convince yourself that this is the case by
simplifying the problem and assuming that y and xˆ, as well as A, L, C are scalars. In this case you can easily
draw the Bode magnitude plot of the frequency response and see the effect of making A + LC be a large
negative number. Develop this insight and use it to justify your experimental observations.
4 Output feedback control
Now we will use the observer in the feedback loop to generate the control input. As before, we will first study the
noiseless case, then investigate the effects of noise on the output feedback control loop.
4.1 Noiseless output feedback control
The separation theorem (see Section 7.4) guarantees that if we separately design a stabilizing state feedback and a
stable observer, then the combined output feedback controller
˙xˆ = (A + LC + BK)xˆ − Ly
u = Kxˆ
will stabilize the linear system. The block diagram of the closed-loop system is below.

K
x˙ = Ax + Bu
y = Cx + Du
˙xˆ = (A + BK + LC)xˆ − Ly
u y

Compare the above to the block diagram in Section 3, and note that the observer is now enclosed in the feedback
loop, whereas before the observer was an exogenous object to the feedback loop, used for state estimation but not
for control.
Return to your file lab4.m.
• Again using whichever method your prefer, define a function expressing the dynamics of the system
x˙ = Ax + BKxˆ, y = Cx
˙xˆ = (A + LC + BK)xˆ − Ly
• Numerically integrate this system using the initial condition (−0.5, 0, −π/4, 0) for x, and (0, 0, 0, 0) for xˆ.
Perform two integrations, using the observer gains L1 and L2.
• Produce a figure containing four subplots. On subplot i, superimpose three graphs:
1. The i-th component of the plant state signal under state feedback control (you obtained this in Section 3.1).
2. The i-th component of the plant state signal under output feedback control with gain L1.
3. The i-th component of the plant state signal under output feedback control with gain L2.
You obtained the latter two signals just above.
• Produce another figure like the one above, but now using the nonlinear cart-pendulum model. In other
words, simulate the dynamics of
x˙ = f(x, Kxˆ)
˙xˆ = (A + LC + BK)xˆ − Ly,
where the first equation represents the nonlinear cart-pendulum model with control input u = Kxˆ (hence under
output feedback control). Once again, perform two integrations, with gains L1 and L2, and create four subplots as
in the previous point.
Output 3. • Produce the two figures requested above.
• Output feedback control with linearized plant: Comment on how the behaviour of the closed-loop system
is different from using the state feedback controller. When the observer convergence is faster (with gain L2),
one expects the plant state signals to resemble more closely the signals one would obtain with state feedback
control (see Section 7.10.1 of the textbook). Is that the case here?
7
• Output feedback control with nonlinear plant: What are the effects of the observer convergence speed on the
solutions of the nonlinear plant?
4.2 Output feedback control with measurement noise
Finally, we will examine the impact of measurement noise on the closed-loop nonlinear system.
Return to lab4.m.
• Modify the functions simulating the nonlinear closed-loop system above, replacing, in the observer, the
output y = Cx with y = Cx + W, where W is again a noise term with the same parameters as above.
• Simulate the nonlinear plant with observer. Perform two integrations, with observer gains L1 and L2.
• Create one figure containing four subplots. On subplot i, superimpose the i-th component of the plant state
under output feedback control and gain L1, and the i-th component of the same with gain L2.
Output 4. • Produce the figure requested above.
• Compare with the results you obtained in the last point of output 3. What are the effects of measurement
noise on the performance of the closed-loop system?
• How is the observer speed (gains L1 vs L2) impact the performance?
• Justify your observations in light of the results you obtained in Section 3.2. There you gained insight on
the noise sensitivity of the observer estimate as a function of the observer gain. Apply this insight here to
explain the results you obtained.