$30
COMP 417 Assignment 2
1 Objectives
The main pedagogical objective of this assignment is to provide and demonstrate an understanding of PID control, the most popular yet simple control
methodology, as well as the notion of the inverted pendulum in the specific
form known as a ”cart pole”.
The inverted pendulum is a benchmark in the context of both waling robots
as well as control, where the goal is to balance the pole attached to a cart
through an unactuated (i.e. unpowered) joint, meaning that we need to
control the pole angle by manipulating the cart displacement. Although
PID is indeed a simple controller, it is very widely used due to its ease
of implementation, flexibility and also robustness to noise, and uncertainty.
Thus, it is imperative to get insight into how it works.
The objective is to move the cart (platform) back and forth to keep the pole
balanced and as close to vertical as possible. The controller itself can use the
angle of the pole, and the differential properties of this angle, to compute an
adjustment to the cart’s position.
Note, you are given a base code including the inverted pendulum dynamic
model and also visualization to better evaluate the controller performance.
Modify the controller script while feeding the dynamic model with proper
arguments at each part.
You can run the sample code using the command
python inverted_pendulum.py
and see some of the options using the invocation
python inverted_pendulum.py --help
1
2 States are accessible
Assuming that we have access to the states of the system i.e. the angle to
be controlled:
(A) Design a PID controller to stabilize the angle (keep the pole balanced
and as close to vertical as possible). (30%)
(B) Evaluate and attempt to tune the performance of P-control, PD, PI,
DI. (Not all of these may work well; explain why.) (30%)
(C) A really important issue when designing a controller is its dependency
on the model of the system. This also reveals the robustness of the
controller. Explore the behavior of the PID controller when modifying
the mass of the pendulum and the force of gravity. Try changing these
parameters to see their effects on the controller performance e.g. in
terms of the settling time. (20%)
(D) The other critical aspect of a controller is its ability in rejecting disturbances. For this part, you need to modify the controller code to
model a random input to the system at one or two specific times. For
instance, you can use something like: (20%)
ifnumpy.random.rand() > 0.99 :
action = 10
or you can use the keyboard inputs while controlling the system with
the PID controller. The second approach needs a bit of modification
on the main script (not suggested), while the former one can be implemented in the controller script.
3 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. At each step report the results with a theta vs time plot showing the
controller performance in a conducted simulation with a brief explanation.
Asked to discuss things, give us a summary in two or three lines of what you
got.
2