This example demonstrates how to design a lq-controller or a pole placement controller respectively. Compared with example craneController, the plant is smaller to achieve suitable dynamics for animation. The feedback matrices and a simple pre filter for tracking are save to MATLAB files which can be used in ModelicaController library.
It is also shown how to linearize a model of a crane trolley system [1]. The linear model is used as a base for control design
function designStateSpaceController import Modelica.Utilities.Streams.print; import Modelica.ComplexMath; import Modelica.Math.Matrices; import Modelica_LinearSystems2.ComplexMathAdds; import Modelica_LinearSystems2; import Modelica_LinearSystems2.TransferFunction; import Modelica_LinearSystems2.ZerosAndPoles; import Modelica_LinearSystems2.StateSpace; input StateSpace ss = StateSpace(A = [0, 1, 0, 0; 0, 0, 39.2, 0; 0, 0, 0, 1; 0, 0, -49.0, 0], B = [1, 1, 0, 0; 0, 1, 1, 0; 0, 0, 1, 1; 1, 1, 1, 1], C = identity(4), D = zeros(4, 4), yNames = {"s", "v", "phi", "w"}, uNames = {"f", "u2", "u3", "u4"}, xNames = {"s", "v", "phi", "w"}); input Complex pa[:] = {Complex(-1, 0), Complex(-2, 0), Complex(-2, -0.2), Complex(-2, 0.2)} "assigned poles"; output Real K_pa[:, :] "feedback matrix pole assignment controller"; output Real M_pa[:, :] "pre filter pole assignment controller"; output Complex po[size(ss.A, 1)]; end designStateSpaceController;