I am attempting to model and control a spherical pendulum. I have derived the equations as follows:
The positions of the mass m:
x = \[ScriptL] Sin[\[Theta][t]] Cos[\[Phi][t]];
y = \[ScriptL] Sin[\[Theta][t]] Sin[\[Phi][t]];
z = \[ScriptL] Cos[\[Theta][t]];
The velocities are hence:
{
\!\(\*OverscriptBox[\(x\), \(.\)]\),
\!\(\*OverscriptBox[\(y\), \(.\)]\),
\!\(\*OverscriptBox[\(z\), \(.\)]\)} = Table[D[q, t], {q, {x, y, z}}]
The Lagrangian is L=T-V and can now be constructed:
T = 1/2 m \[ScriptV]^2
V = -m g z
\[ScriptCapitalL] = T - V
The equations of motion are derived from the Euler-Lagrange formula:
eqns = Table[\!\(
\*SubscriptBox[\(\[PartialD]\), \(t\)]\(D[\[ScriptCapitalL], \(q'\)[t]]\)\) -
D[\[ScriptCapitalL], q[t]] == Subscript[\[ScriptCapitalT],
q], {q, {\[Theta], \[Phi]}}] /. {Subscript[\[ScriptCapitalT], \[Theta]] ->
Subscript[\[ScriptCapitalT], 1][t],
Subscript[\[ScriptCapitalT], \[Phi]] -> Subscript[\[ScriptCapitalT], 2][t]}
The parameters of the system as a list of replacement rules:
pars = {g -> 9.8, m -> 0.5, \[ScriptL] -> 1};
The nonlinear state-space model:
spend = NonlinearStateSpaceModel[
eqns, {\[Theta][t], \[Theta]'[t], \[Phi][t], \[Phi]'[
t]}, {Subscript[\[ScriptCapitalT], 1][t],
Subscript[\[ScriptCapitalT], 2][t]}, {\[Theta][t], \[Phi][t]}, t]/.pars
Linearizing results in error:
ssm = StateSpaceModel[spend]
Curiously, the output response can be simulated:
OutputResponse[{spend, {0.1, 0.3, 0.6, 0.01}}, {0, 0}, {t, 0, 10}];
Plot[%, {t, 0, 10}, PlotRange -> All]
Can anyone help figure out what's wrong with this system? Thanks!
NonlinearStateSpaceModel
accepts such second order odes. The equations of motion have to be in state space form. i.e. first order. See the help example under Aerospace systems for example. Are you sure you are passingNonlinearStateSpaceModel
the equations of motion as first order (i.e. state space form) and not the standard second order equations generated from Euler-Lagrange? (Hard to read you code, since you are using lots of fancy notations). $\endgroup$