# Using the LQGRegulator to build a human operator model

I'm trying to build a human operator model using an optimal control model in Mathematica:

The vehicle dynamics are given by

a = {{-2, 0}, {1, 0}};
b = {{0}, {1}};
c = {{0, 1}, {1, 0}};
d = {{0}, {1}};


with noise and cost weightings

w = {{4}};
v = {{0.0025}};
q = {{0, 0}, {0, 1}};
r = {{1}};


I generated the state space model and added the time delay ($T_d = 0.2s$) using

ssm = StateSpaceModel[{a, b, c, d}]
td = TransferFunctionModel[SystemsModelDelay[.2]];
ssmWithDelay = SystemsModelSeriesConnect[td, ssm];


Now I am trying model the Kalman estimator and gains ($-l^*$) using a LQG regulator

k = LQGRegulator[{ssm, 1, 1}, {w, v}, {q, r}] // StateSpaceModel


which results in the error

The number of columns in {{},{}} is not equal to the length of {{4}}


I think my problem must be with the noise and cost weightings, but I'm not sure where I went wrong?

-
In the figure, the system 'vehicle dynamics' has two inputs - the disturbance and the feedback input, so probably the b and d matrices need to have two columns as well. – Suba Thomas Mar 19 '13 at 18:46
I thought the disturbance is represented by the $\mathbf{W}$ noise term in $\dot{x}(t) = \mathbf{A}x(t) + \mathbf{B}u(t) + \mathbf{W}(t)$ – Gerrit Mar 20 '13 at 9:16
That is not correct. In general the B matrix is [Bf, Bw, Be] corresponding to feedback, noise, and exogenous (other deterministic) inputs. Refer to the 3rd bullet point in 'Details and Options' in the ref page for LQGRegulator. – Suba Thomas Mar 20 '13 at 13:32
I also think the dimensions of v is incorrect. In LQGRegulator you specify that only the first output is noisy but v has dimensions 2x2. – Suba Thomas Mar 20 '13 at 14:03
Thanks Suba, I've changed the dimensions of v. – Gerrit Apr 4 '13 at 14:33

If the noise and the input $u(t)$ enter the system in the same way you can simply use
ssm = SystemsModelExtract[ssm, {1, 1}]

before calling LQGRegulator
Thanks Bob, that seems to work well. If I understand correctly, when noise and input u (t) enter the system in the same way, {1,1} "doubles" the input, to satisfy the requirement of k = LQGRegulator[{ssm1, 1, 1}, {w, v}, {q, r}] having one noisy measurement and one input? – Gerrit Apr 4 '13 at 14:31