# Estimator Design Using Feedback Linearization

Feedback linearization also allows for the design of nonlinear estimators using linear techniques. Estimate the yaw angle and the yaw rate for a ship with hull length and speed , based on Norrbin's model and using feedback linearization. »

 In[1]:= Xpars = {Subscript[n, 3] -> 1, Subscript[n, 1] -> 1, Subscript[n, 2] -> 0, Subscript[n, 0] -> 0};
 In[2]:= Xasys = AffineStateSpaceModel[(2 l/v) \[Psi]''[t] + Subscript[n, 3] \[Psi]'[t]^3 + Subscript[n, 2] \[Psi]'[t]^2 + Subscript[n, 1] \[Psi]'[t] + Subscript[n, 0] == (v/l) \[Delta][t], \[Psi][t], \[Delta][t], \[Psi][t], t] /. pars /. {l -> 45}
 Out[2]=

The model is completely feedback linearizable.

 In[3]:= X\[ScriptCapitalF] = FeedbackLinearize[asys]
 Out[3]=

Compute a set of estimator gains using pole placement.

 In[4]:= XEstimatorGains[\[ScriptCapitalF]["LinearSystem"], {-2 + I, -2 - I}]
 Out[4]=

Assemble the nonlinear estimator.

 In[5]:= XEstimatorGains[\[ScriptCapitalF]["LinearSystem"], {-2 + I, -2 - I}]; \[ScriptL] = \[ScriptCapitalF][{"OriginalSystemEstimator", %}]
 Out[5]=

Plot the estimated state trajectories for a specific ship speed.

 In[6]:= Xinp = -UnitStep[t] + UnitStep[t - 1]; ics = {-2, 1};
 In[7]:= Xesr = OutputResponse[ SystemsModelDelete[\[ScriptL] /. v -> 5, None, -1], Join[{inp}, OutputResponse[{asys /. v -> 5, ics}, inp, {t, 0, 10}]], {t, 0, 10}];
 In[8]:= XPlot[esr, {t, 0, 10}, PlotStyle -> Dashed, PlotRange -> All, PlotLegends -> {"Yaw (\[Psi])", "Yaw rate (\[Psi]')"}]
 Out[8]=

Compute the actual state trajectories.

 In[9]:= Xsr = StateResponse[{asys /. v -> 5, ics}, inp, {t, 0, 10}]
 Out[9]=

Compare the actual and estimated yaw angles and yaw rates.

 In[10]:= XTable[Plot[{sr[[i]], esr[[i]]}, {t, 0, 5}, PlotStyle -> {Automatic, Dashed}, PlotLegends -> {"Actual", "Estimated"}, PlotRange -> All, PlotLabel -> Switch[i, 1, "Yaw Angle", _, "Yaw rate"]], {i, {1, 2}}]
 Out[10]=

## Mathematica + Mathematica Online

Questions? Comments? Contact a Wolfram expert »