The Mathematica built-in symbol can assemble an estimator-regulator type compensator in a variety of combinations. In this case, we use an optimal regulator for the controller design and an optimal estimator (also known as a Kalman Estimator) to control an unstable, discrete-time state space model with two states:
In[]:=
ssm=StateSpaceModel[{{{0.,-1.},{-0.5,1}},{{1},{2}},{{1,0}},{{0}}}]
Out[]=
0. | -1. | 1 |
-0.5 | 1 | 2 |
1 | 0 | 0 |
There is a positive eigenvalue which makes the system unstable:
In[]:=
Eigenvalues[First[Normal[ssm]]]
Out[]=
{1.36603,-0.366025}
The gains of the optimal estimator can be directly obtained using , while the optimal regulator controller gains are obtained using :
In[]:=
{ℓ,κ}=LQEstimatorGains[{ssm,1,1},{w={{}},v=(
)}],LQRegulatorGainsssm,q=
,r=(
)
0.1 |
4 10 | 0 |
0 | 2 10 |
2 10 |
Out[]=
{{{2.73205},{-3.73205}},{{-12.3562,13.1205}}}
The estimator-regulator is assembled using the computed optimal estimator and controller gains:
In[]:=
cdER=EstimatorRegulator[ssm,{ℓ,κ},"Data"];cdER["Design"]
Out[]=
estimator and regulator
The combination of an Kalman estimator and optimal regulator controller in fact constitutes a special type of regulator, called a linear quadratic gaussian (LQG) regulator, which has it’s own built-in symbol in Mathematica, . It can construct the regulator directly from the covariance matrices {, } and weights {, :
w
v
q
r}
In[]:=
cdLQG=LQGRegulator[{ssm,1,1},{w,v},{q,r},"Data"];cdLQG["Design"]
Out[]=
linear quadratic gaussian regulator
From their respective data controller data objects, we can extract information about each system’s properties as shown below. As expected, the resulting controllers are identical, with both closed-loop systems having the same eigenvalues:
In[]:=
RowDatasetTable{props,EstimatorRegulator[ssm,{ℓ,κ},props]},props,,DatasetTable{props,LQGRegulator[{ssm,1,1},{w,v},{q,r},props]},props,
Out[]=