CogniPilot

MODELICA LIBRARY · ENGINEERING REFERENCE

package

RigidBody

Reusable rigid-body dynamics

State and forces

State stores world position, body velocity, a scalar-first body-to-world quaternion and body angular velocity. Wrench supplies non-gravity body force and body torque. Gravity is applied by the dynamics in world negative z.

Use stateDerivative for an explicit vector field or extend RigidBody6DOF for a continuous Modelica plant. Mass must be positive and inertia symmetric positive definite.

Level hover example

model LevelHover
  extends RigidBody.RigidBody6DOF(mass=1.5);
equation
  F_b = {0,0,mass*g};
  M_b = zeros(3);
end LevelHover;

At the default level orientation and zero initial motion, thrust balances gravity. Add vehicle forces in a derived model rather than including gravity in F_b a second time. Energy and power helpers support independent checks of force, velocity and frame conventions.

Members

NameKindDescription
StaterecordRigid-body state in world position and body velocity coordinates
StateDerivativerecordDerivative corresponding to RigidBody.State
WrenchrecordExternal non-gravity wrench expressed in the body frame
TwistrecordBody-frame flow variable power-conjugate to RigidBody.Wrench
ParametersrecordPhysical parameters used by the pure rigid-body vector field
validParametersfunctionPhysical-domain predicate for mass, gravity, and symmetric positive-definite inertia
worldPositionRatefunctionWorld-position component of the rigid-body vector field
bodyVelocityRatefunctionBody-velocity component of the rigid-body vector field
attitudeRatefunctionQuaternion component of the rigid-body vector field
bodyAngularVelocityRatefunctionBody-angular-velocity component of the rigid-body vector field
stateDerivativeComponentsfunctionArray outputs of the pure rigid-body vector field for equation-based models
stateDerivativefunctionPure rigid-body vector field shared by simulation and formal analysis
kineticEnergyfunctionTranslational plus rotational kinetic storage
potentialEnergyfunctionUniform-gravity potential energy with world z upward
mechanicalEnergyfunctionRigid-body mechanical storage function
bodyTwistfunctionExtract the power-port flow variable from a rigid-body state
portPowerfunctionBilinear wrench/twist supply rate
wrenchPowerfunctionSupply rate for a body-frame wrench
powerBalanceResidualfunctionMechanical-energy rate minus wrench supply; zero certifies lossless passivity
RigidBody6DOFmodelSix-degree-of-freedom rigid body
Examplespackage

Modelica declarations and implementation

Show parameters, interfaces and source

Parameters, inputs, outputs, defaults and equations from the source file.

package RigidBody "Reusable rigid-body dynamics"
  annotation(uses(LieGroups, LinearAlgebra),
    Documentation(info = "<html>
    <h4>State and forces</h4>
<p><a href=\"modelica://RigidBody.State\">State</a> stores world position, body
velocity, a scalar-first body-to-world quaternion and body angular velocity.
<a href=\"modelica://RigidBody.Wrench\">Wrench</a> supplies non-gravity body force
and body torque. Gravity is applied by the dynamics in world negative z.</p>
<p>Use <a href=\"modelica://RigidBody.stateDerivative\">stateDerivative</a> for an
explicit vector field or extend
<a href=\"modelica://RigidBody.RigidBody6DOF\">RigidBody6DOF</a> for a continuous
Modelica plant. Mass must be positive and inertia symmetric positive definite.</p>
<h4>Level hover example</h4>
<pre>model LevelHover
  extends RigidBody.RigidBody6DOF(mass=1.5);
equation
  F_b = {0,0,mass*g};
  M_b = zeros(3);
end LevelHover;</pre>
<p>At the default level orientation and zero initial motion, thrust balances
gravity. Add vehicle forces in a derived model rather than including gravity
in F_b a second time. Energy and power helpers support independent checks of
force, velocity and frame conventions.</p>
    </html>"));
end RigidBody;