0
$\begingroup$

I have a mathematica notebook to build the state-space model of a system from its differential equations, calculate LQR gains and simulate the system response.

ss = StateSpaceModel[
  {eq1, eq2}, 
  {{xc'[t], 0}, {xc[t], 0}, {\[Theta]'[t], 0}, {\[Theta][t], 0}}, 
  {{F[t], 0}}, 
  {xc[t], \[Theta][t]}, 
  t
]

ssValues = With[{g = 9.8, mc = 0.5, mp = 2, mf = 0.5, lp = 0.3}, Evaluate[ss]]

So far, the system is unstable. Adding LQR:

ssValuesTracked = <|"InputModel" -> ssValues, "TrackedOutputs" -> {1, 2}|>
Q = ...
R = ...
ssValuesTrackedCL = LQRegulatorGains[ssValues, {Q, R}, "Data"]

Which makes the system stable when tracking an input.

r = {1, 0}
Plot[
    Evaluate[
        OutputResponse[{ssValuesTrackedCL, {0, 0.5, 0, 0.2}}, r, {t, 0, 10}]
    ], 
    {t, 0, 10},
    Frame -> True, PlotRange -> All, ImageSize -> 300, GridLines -> Automatic, PlotLegends -> Automatic
]

Which show the response of xc and theta.

The questions is, how do I plot the values of the input u of the closed loop system in the figure below?

enter image description here

$\endgroup$
3
  • 1
    $\begingroup$ Most of the application examples show how this is done. e.g. reference.wolfram.com/language/ref/… $\endgroup$ Mar 15, 2023 at 22:24
  • $\begingroup$ Can you provide a link to explain what does cd["ControllerModel"]? I already tried the examples provided. However, since I don't know what does cd["ControllerModel"] represents, I cannot generalize the examples to other use-cases $\endgroup$ Mar 16, 2023 at 9:11
  • $\begingroup$ Please read the documentation more carefully. In the 'Details and Options' section there are block diagrams showing what ControllerModel is. $\endgroup$ Mar 16, 2023 at 13:19

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.