Course materials · Control Engineering II

Reference Tracking and Optimal Control

English translation

Execution conditions

MATLAB · Control System Toolbox

Learning objectives

Examine why reference error remains even with a stable controller, and compare tracking performance with control-input cost.

Choosing reference gain for reference tracking

Starting conditions

A=[01−2−3]A=\left[\begin{array}{cc}0&1\\-2&-3\end{array}\right], B=[01]B=\left[\begin{array}{c}0\\1\end{array}\right], C=[10]C=\left[\begin{array}{cc}1&0\end{array}\right], K=[63]K=\left[\begin{array}{cc}6&3\end{array}\right], r=1r=1, x(0)=0.

Procedure

  1. Use N=1N=1 and N=8N=8 in turn to calculate unit-step responses on the same time axis. Record the responses and steady-state outputs side by side.
  2. For 0=(A−BK)xss+BNr0=(A-BK)x_{ss}+BNr under r=1r=1, derive xssx_{ss} in terms of N. Use yss=Cxssy_{ss}=Cx_{ss} to find N satisfying yss=1y_{ss}=1, and show your calculations.
  3. Compare the directly calculated N with the final values of both responses, and explain what the reference gain changed.

Results to retain

  • Both step responses and steady-state values, and the equation used to obtain N.
A=[0 1;-2 -3]; B=[0;1]; C=[1 0]; K=place(A,B,[-2 -4]);
N=-1/(C*((A-B*K)\B)); disp(K); disp(N); assert(abs(N-8)<1e-10);
t=linspace(0,5,1001)'; figure; hold on
for gain=[1 N]
y=lsim(ss(A-B*K,B*gain,C,0),ones(size(t)),t);
plot(t,y,'DisplayName',sprintf('N=%g',gain));
end
xlabel('Time [s]'); ylabel('Position'); legend; grid on
 

Record results and self-check

N
Steady-state value
Closed-loop Pole

Points to check

  • Do the directly calculated steady-state outputs match the final values of each simulation?
  • Do closed-loop poles remain unchanged when N changes?

Trade-off between output error and input cost

Starting conditions

Q=diag(q,1)Q=\mathrm{diag}(q,1), q∈{1,25}q\in\{1,25\}, and R=[1]R=\left[\begin{array}{c}1\end{array}\right]. Use x(0)=[10]x(0)=\left[\begin{array}{c}1\\0\end{array}\right], r=0r=0.

Procedure

  1. Solve the CARE for each Q and calculate K=R−1B⊤PK=R^{-1}B^\top P.
  2. Plot position and control input on the same time axis.
  3. Compare the integral of squared position error and the integral of squared input separately.

Results to retain

  • Position and input plots and a comparison table of both integrals.
figure; hold on
for q=[1 25]
[Kq,P]=lqr(A,B,diag([q 1]),1);
x=initial(ss(A-B*Kq,zeros(2,1),eye(2),zeros(2,1)),[1;0],t); u=-x*Kq';
disp(q); disp(Kq); disp([trapz(t,x(:,1).^2) trapz(t,u.^2)]);
plot(t,x(:,1),'DisplayName',sprintf('q=%g',q));
end
xlabel('Time [s]'); ylabel('Position'); legend; grid on
% TODO: Add control-input plots and poles.
 

Record results and self-check

q
K
Position-error integral
Input cost

Points to check

  • Are both Q matrices positive definite, with R>0R>0?
  • Do all poles of A−BKA-BK have negative real parts?

Reference tracking with model error

Starting conditions

Design using nominal B, and change only the actual input gain to Bactual=gBB_{\mathrm{actual}}=gB and g∈{.8,1,1.2}g\in\{.8,1,1.2\}. Use K=[63]K=\left[\begin{array}{cc}6&3\end{array}\right], N=8N=8, r=1r=1.

Procedure

  1. Find the poles and final step-response value for each actual model.
  2. Check whether N calculated from the nominal model also achieves the exact reference in every actual model.
  3. Distinguish the roles of reference-gain adjustment and integral-error feedback.

Results to retain

  • Three response curves and a table of final values and errors.
K=[6 3]; figure; hold on
for g=[.8 1 1.2]
Ba=g*B; Acl=A-Ba*K; steady=-C*(Acl\(Ba*8));
y=lsim(ss(Acl,Ba*8,C,0),ones(size(t)),t); disp(g); disp(eig(Acl)); disp(steady);
plot(t,y,'DisplayName',sprintf('g=%g',g));
end
xlabel('Time [s]'); ylabel('Position'); legend; grid on
% TODO: Explain the cause of the error and the role of integral-error feedback.
 

Record results and self-check

Input gain
Pole
Final value
Tracking error

Points to check

  • Were both the feedback and reference terms multiplied by the actual B_actual?
  • Did you check stability before calculating final values?

Official examples and data