Sale!

MCE 793 Intelligent Control Systems Homework 3 solved

Original price was: $35.00.Current price is: $30.00. $25.50

Category:

Description

5/5 - (6 votes)

Problem 1:
You are going to use locally weighted regression to control a two-link pendulum. Each torque
input for the pendulum is represented by the local model
y = w
>φ(x) = w0 + w1q1 + w2q2 + w3q˙1 + w4q˙2 + w5q¨1 + w6q¨2
where the input is x = [q1 q2 q˙1 q˙2 q¨1 q¨2]
>, q1 is the angle between the first link and horizontal
with counterclockwise positive, q2 is the angle between the second link and first link with
counterclockwise positive, the joint velocities are ˙q1 and ˙q2, the joint accelerations are ¨q1 and ¨q2,
w = [w0 w1 w2 w3 w4 w5 w6]
> is a vector of parameters of the local model, and
φ(x) = [1 q1 q2 q˙1 q˙2 q¨1 q¨2]
> is a vector or basis functions of the local model.
(a) Locally weighted regression. Load the file “doublependulumdata.mat” into your Matlab
workspace. It contains vectors of joint positions, velocities, and accelerations along with torques
sampled from the motion of a double pendulum. This is your training data. Using the training
data and locally-weighted regression do leave-one-out cross validation (LOOCV) and compute the
RMS error of your predictions. This means for each of the data points in the training data set use
all of the other training data to predict the ouput for left out data point. Use the median rather
than the mean to compute RMS to diminish the effect of outliers. Remeber to include the error in
predicting torques for both degrees of freedom.
Use a diagonally-weighted Euclidean distance function of the form
d =
q
(x − q)>M>M(x − q)
where q is a query and M is a diagonal matrix with diagonal elements √
200, √
200, √
10, √
10, 1,
and 1. Use a Gaussian kernel function of the form
k(d) = e
−d
2/h
where h is a scaling factor to be chosen.
1. Compute LOOCV RMS errors for h = 100, h = 1, 000, and h = 10, 000. Report these errors
on the command line using
display([’LOOCV RMS error for h = 100 is’,num2str(LOOCV)]).
2. Using the h that gave the lowest LOOCV RMS error plot your torque predictions against
the actual torques from “doublependulumdata.mat”. Plot individual circles or stars rather
than lines connecting the data points. This should ideally be a straight line with a slope of
one and intercept at zero. Title the figure “Part (a2)” and use appropriate axis labels.
(b) Computed Torque Control. Use computed torque control with no feeback to move the
double pendulum along the desired trajectory contained in the attached file
“desiredtrajecotry.mat”. That is, given the desired trajectory use locally-weighted regression to
compute the torques needed to move the arm along the desired trajectory. The trajectory is a
circle centered at 1 meter above the shoulder of your arm with a radius of 0.25 meters. You will
run a simulation of the motion of the pendulum. Use the attached file “doublependulumstep.m”
to complete your Euler integration steps along with “compute accel2.m”, which is a helper
2 MCE 793
function for the Euler integration step. You do not need to attach these files to your submission.
Use a simulation time step of 0.001 s and use the initial point in the desired trajectory as the
initial condition of your simulation.
1. In one figure plot the torque predictions for both degrees of freedom as functions of time.
Also plot lines that are two standard deviations above and below each torque plot. This
approximately represents the 95% confidence intervals of your predictions. To do this you
will have to compute the variance of the torque prediction at each step in time and take the
square root to get the standard deviation. Title the figure “Part (b1)” and include a legend
and appropriate axis labels.
2. In another figure plot the actual and desired joint angles as functions of time. Title the
figure “Part (b2)” and include a legend and appropriate axis labels.
3. Plot an animation of the pendulum given that the length of the first link is 0.8 meters and
the length of the second link is 0.6 meters. Make sure you plot the desired circular path of
the end of the pendulum with your animation so it is easy to see if your controller worked.
Don’t be too concerned if this doesn’t work terribly well.
(c) Computed Torque Control with Feedback. Repeat part (b) but add feedback torques
τF B to your open-loop torques τF F you computed in part (b). Use the following control law
τ = τF F + Kp(qdes − q) + Kd(˙qdes − ˙q)
where Kp and Kd are feedback gains to tune.
1. In one figure plot the torque you applied in part (b) and the torque you applied in part (c)
for both degrees of freedom as functions of time. If your locally weighted regression worked
well, the diffence in torques when adding feedback should not be large. Title the figure
“Part (c1)” and include a legend and appropriate axis labels.
2. In another figure plot the actual and desired joint angles as functions of time. Title the
figure “Part (c2)” and include a legend and appropriate axis labels.
3. Plot an animation of the pendulum given that the length of the first link is 0.8 meters and
the length of the second link is 0.6 meters. Make sure you plot the desired circular path of
the end of the pendulum with your animation so it is easy to see if your controller worked.

Problem 2:
You are going to use Gaussian process regression to control a two-link pendulum. You GPR
model input is x = [q1 q2 q˙1 q˙2 q¨1 q¨2]
> where q1 is the angle between the first link and
horizontal with counterclockwise positive, q2 is the angle between the second link and first link
with counterclockwise positive, the joint velocities are ˙q1 and ˙q2, and the joint accelerations are ¨q1
and ¨q2. The output is the vector of joint torques applied to the joints of the pendulum.
(a) Gaussian process regression. Load the file “doublependulumdata.mat” into your Matlab
workspace. It contains vectors of joint positions, velocities, and accelerations along with torques
sampled from the motion of a double pendulum. This is your training data. Using the training
data and Gaussian process regression do leave-one-out cross validation (LOOCV) and compute
the RMS error of your predictions. This means for each of the data points in the training data set
use all of the other training data to predict the ouput for left out data point. Remeber to include
the error in predicting torques for both degrees of freedom. Use the following covariance function.
k(x∗, x) = p1 ∗ e
(x−x∗)>(x−x∗)
2∗p
2
2
where x is a input in the training set, x∗ is a query, p1 is the magnitude hyperparameter, and p2 is
the length scale. Set the magnitude hyperparameter p1 = 20 and noise in the training data σ
2 = 1.
1. Compute LOOCV RMS errors for p2 = 30, p2 = 50, and p2 = 100. Report these errors on
the command line using
display([’LOOCV RMS error for p2 = 30 is’,num2str(LOOCV)]).
2. Using the p2 that gave the lowest LOOCV RMS error plot your torque predictions against
the actual torques from “doublependulumdata.mat”. Plot individual circles or stars rather
than lines connecting the data points. This should ideally be a straight line with a slope of
one and intercept at zero. Title the figure “Part (a2)” and use appropriate axis labels.
(b) Computed Torque Control. Use computed torque control with no feeback to move the
double pendulum along the desired trajectory contained in the attached file
“desiredtrajectory.mat”. That is, given the desired trajectory use Gaussian process regression to
compute the torques needed to move the arm along the desired trajectory. Use the p2 that gave
the lowest cross validation error. The trajectory is a circle centered at 1 meter above the shoulder
of your arm with a radius of 0.25 meters. You will run a simulation of the motion of the
pendulum. Use the attached file “doublependulumstep.m” to complete your Euler integration
steps along with “compute accel2.m”, which is a helper function for the Euler integration step.
You do not need to attach these files to your submission. Use a simulation time step of 0.001 s
and use the initial point in the desired trajectory as the initial condition of your simulation.
1. In one figure plot the torque predictions for both degrees of freedom as functions of time.
Also plot lines that are two standard deviations above and below each torque plot. This
approximately represents the 95% confidence intervals of your predictions. To do this you
will have to compute the variance of the torque prediction at each step in time and take the
square root to get the standard deviation. Title the figure “Part (b1)” and include a legend
and appropriate axis labels.

2. In another figure plot the actual and desired joint angles as functions of time. Title the
figure “Part (b2)” and include a legend and appropriate axis labels.
3. Plot an animation of the pendulum given that the length of the first link is 0.8 meters and
the length of the second link is 0.6 meters. Make sure you plot the desired circular path of
the end of the pendulum with your animation so it is easy to see if your controller worked.
Don’t be too concerned if this doesn’t work terribly well.
(c) Computed Torque Control with Feedback. Repeat part (b) but add feedback torques
τF B to your open-loop torques τF F you computed in part (b). Use the following control law
τ = τF F + Kp(qdes − q) + Kd(˙qdes − ˙q)
where Kp and Kd are feedback gains to tune.
1. In one figure plot the torque you applied in part (b) and the torque you applied in part (c)
for both degrees of freedom as functions of time. If your Gaussian process regression worked
well, the diffence in torques when adding feedback should not be large. Title the figure
“Part (c1)” and include a legend and appropriate axis labels.
2. In another figure plot the actual and desired joint angles as functions of time. Title the
figure “Part (c2)” and include a legend and appropriate axis labels.
3. Plot an animation of the pendulum given that the length of the first link is 0.8 meters and
the length of the second link is 0.6 meters. Make sure you plot the desired circular path of
the end of the pendulum with your animation so it is easy to see if your controller worked.