Description
Main concepts of this lab
■ Observer design.
■ Output feedback stabilization.
■ Observer sensitivity to measurement noise.
■ Effect of linearization error on observer performance.
1 Introduction
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