Description
Problem 1:
Consider a single pendulum with the equation of motion:
ml2 ¨θ
3
+
mgl cos θ
2
= τ
where m is the mass of the pendulum, l is the length, θ is the angle from horizontal, and τ is the
torque applied at the base of the pendulum. A model of the pendulum is
y = w>φ(x)
where the y = τ , x = [θ
¨θ]
>, φ(x) = h
g cos θ
2
θ¨
3
i>
and w = [ml ml2
].
(a) Bayesian Regression. Load the file “pendulumdata.mat” into your Matlab workspace.
This is a different file than the one you used in the interactive session last week. It contains
vectors of joint positions, velocities, and accelerations along with torques sampled from the
motion of a single pendulum. Compute the parameters using Bayesian regression taking the data
one sample at a time. This means you will have the same number of parameter estimates as you
have data points. Use a prior estimate of w0 = [1 1] with a prior covariance of S0 = 10I where I
is a 2 × 2 identity matrix. The sensor variance is β
−1 = 0.01.
1. In one figure plot the values of the parameters w as a function of the number of samples
used. Title the figure “Part (a1)”.
2. In a second figure plot the square root of the variance of each parameter as a function of the
number of samples used. Title the figure “Part (a2)”.
3. Make your .m file print in the command window your estimates of m and l. You might use
the command display([’Part (a3): m = ’,num2str(m)]).
(b) Computed Torque Control. Use computed torque control with no feeback to move the
pendulum along the desired trajectory contained in the attached file “desiredtrajecotry.mat”.
Your simulation should use the parameters m = 0.6 kg and l = 4 m. Your controller should use
the final parameters from part (a). Use a simulation time step of 0.001 s.
1. In one figure plot the desired joint angle and the actual joint angle as functions of time from
0 to 6 s. Make a legend to label the two plots and be sure to label your axes. Title the
figure “Part (b1)”.
2. Make your .m file print in the command window the root mean squared error of your
controller in joint angle tracking in radians. That means at each time step compute the
difference between the actual and desired joint angles and square it. Add all the errors over
time together and then take the square root. You might use the command
display([’Part (b2): rms error = ’,num2str(rmserror)]).
3. In a second figure plot an animation of the pendulum with the desired final position of the
end of the pendulum clearly marked with a red circle.
2 MCE 793
(c) Computed Torque Control with Feedback. Use computed torque control with
proportional plus derivative feeback to move the pendulum along the desired trajectory contained
in the attached file “desiredtrajecotry.mat”. Your simulation should use the parameters m = 0.6
kg and l = 4 m. Your controller should use the parameters from part (a). Tune the proportional
and derivative gains until your rms error is below 0.1 rad. Use a simulation time step of 0.001 s.
1. In one figure plot the desired joint angle and the actual joint angle as functions of time from
0 to 6 s. Make a legend to label the two plots and be sure to label your axes. Title the
figure “Part (c1)”.
2. Make your .m file print in the command window the root mean squared error of your
controller in joint angle tracking in radians. That means at each time step compute the
difference between the actual and desired joint angles and square it. Add all the errors over
time together and then take the square root. You might use the command
display([’Part (c2): rms error = ’,num2str(rmserror)]).
3. In a second figure plot an animation of the pendulum with the desired final position of the
end of the pendulum clearly marked with a red circle.
3 MCE 793



