# COMP 417 Assignment 4 / Final Project solved

\$30.00

Category:

## Description

1 Objectives
So far, you have been struggling with traditional and RL controllers. The
main pedagogical objective of this assignment is to provide and demonstrate
an understanding of Kalman filter being used alongside any of the covered
controllers. We will take into account the same inverted pendulum case study.
The main difference with the previous assignments is the usage of images as
the accessible data to estimate the required states. In summary, there are
three different issues to be addressed:
1. Visual Tracking: Assuming that the measurements are images given by
a camera, you have to perform object tracking to provide observations
for the Kalman Filtering part.
2. Kalman Filter: Using the observations obtained from the previous step,
you will estimate the states needed to control the system.
3. Controller: Based on the estimated states, you will implement a PID
controller to stabilize the pole angle.
You may use any of the previous provided basic codes; however, note, the
cart and the pole must be displayed in two different colors like the ones in
assignment3, so that you can handle the image processing task.
2 Visual Tracking (25%)
In this section, assume that there is no direct access to the states, but measurements coming from a camera. This provides us with the observations
that can be processed to extract and estimate the required state/states to
control the system.
Write a code to process the incoming images and track the cart-pole system
while providing the controller with the necessary states.
(You may perform some thresholding on the image to extract the center of
1
mass for both the pole and the cart; then, use this information to observe
the pole angle. Be careful, this observation might be noisy!)
3 Kalman Filter (50%)
Implement the Kalman Filter equations to estimate theta and theta dot. For
this part, consider the observation of the pole angle given by the previous
vision part. Note, as the Kalman Filter is a linear algorithm, you are supposed to define a simple linear model while considering (theta, theta − dot)
as the states. Do not use the existing inverted pendulum dynamic as its not
linear.
There are some important points to mention for this part:
1. When defining the model, be careful about the sampling time ∆t in
the model, as it plays a key role in estimating theta − dot correctly.
2. The only observation you have is the images; thus, you are not allowed
to use the provided states directly, unless as ground truth to evaluate
the estimations.
(In the base code that you used for the previous assignments, we assumed the states are accessible (no need to estimate them); Take them
as true values for the purpose of evaluation of your estimator).
3. Note, Q and R are the two main parameters for tuning the Kalman
Filter. Q stands for the covariance of the process noise, while R corresponds to the covariance of the measurement noise. Taking R > Q
means you more trust on the model, whereas Q > R represents that
the measurements are more accurate.
4 Designing the Controller (25%)
Design a PID controller to stabilize the angle using the states estimated in
the previous step (keep the pole balanced and as close to vertical as possible).
2
5 Things to submit
You will need to submit both your code and a report(in pdf format please)
zipped together. Please be concise and report interesting things like challenges.
1. For the vision part, report a plot showing the observations of the angle
vs. its true values. Furthermore, provide us with a visualization of your
results for 3 to 6 consecutive frames so that the tracking procedure can
be seen.
2. For the Kalman Filter part, report the estimated states vs. their true
values. Furthermore, as you have two states to be estimated, report
the estimation error variance of each with respect to time (these can
be obtained from the P matrix).
3. For the controller part, report a plot of theta vs. time showing your
controller performance in a conducted simulation with a brief explanation.
3