Basic rigid-body model representing a system of rigid-bodies connected by 1-6 DoF joints. More...
Public Member Functions | |
TypeName ("rigidBodyModel") | |
Runtime type information. More... | |
rigidBodyModel (const Time &time) | |
Null-constructor which adds the single root-body at the origin. More... | |
rigidBodyModel (const Time &time, const dictionary &dict) | |
Construct from dictionary. More... | |
virtual | ~rigidBodyModel () |
Destructor. More... | |
const Time & | time () const |
Return the time. More... | |
label | nBodies () const |
Return the number of bodies in the model (bodies().size()) More... | |
PtrList< rigidBody > | bodies () const |
Return the list of the bodies in the model. More... | |
const DynamicList< label > & | lambda () const |
List of indices of the parent of each body. More... | |
const PtrList< joint > & | joints () const |
Return the list of joints in the model. More... | |
label | nDoF () const |
Return the number of degrees of freedom of the model. More... | |
bool | unitQuaternions () const |
Return true if any of the joints using quaternions. More... | |
const vector & | g () const |
Return the acceleration due to gravity. More... | |
vector & | g () |
Allow the acceleration due to gravity to be set. More... | |
const word & | name (const label bodyID) const |
Return the name of body with the given ID. More... | |
const rigidBodyInertia & | I (const label i) const |
Return the inertia of body i. More... | |
const spatialVector & | v (const label i) const |
Return the spatial velocity of the bodies. More... | |
const spatialVector & | a (const label i) const |
Return the spatial acceleration of the bodies. More... | |
virtual label | join (const label parentID, const spatialTransform &XT, autoPtr< joint > jointPtr, autoPtr< rigidBody > bodyPtr) |
Join the given body to the parent with ID parentID via the given. More... | |
label | join (const label parentID, const spatialTransform &XT, autoPtr< joints::composite > cJoint, autoPtr< rigidBody > bodyPtr) |
Join the given body to the parent with ID parentID via the given. More... | |
label | merge (const label parentID, const spatialTransform &X, autoPtr< rigidBody > bodyPtr) |
Merge the given body with transform X into the parent with ID. More... | |
bool | merged (label bodyID) const |
Return true if the body with given ID has been merged with a parent. More... | |
label | master (label bodyID) const |
Return the ID of the master body for a sub-body otherwise. More... | |
label | mergedBodyIndex (const label mergedBodyID) const |
Return the index of the merged body in the mergedBody list. More... | |
label | mergedBodyID (const label mergedBodyIndex) const |
Return the merged body ID for the given merged body index. More... | |
const subBody & | mergedBody (label mergedBodyID) const |
Return the merged body for the given body ID. More... | |
label | bodyID (const word &name) const |
Return the ID of the body with the given name. More... | |
spatialTransform | X0 (const label bodyId) const |
Return the current transform to the global frame for the given body. More... | |
vector | masterPoint (const label bodyID, const vector &p) const |
spatialVector | v (const label bodyID, const vector &p) const |
Return the velocity of the given point on the given body. More... | |
void | applyRestraints (scalarField &tau, Field< spatialVector > &fx, const rigidBodyModelState &state) const |
Apply the restraints and accumulate the internal joint forces. More... | |
void | forwardDynamics (rigidBodyModelState &state, const scalarField &tau, const Field< spatialVector > &fx) const |
Calculate the joint acceleration qDdot from the joint state q,. More... | |
void | forwardDynamicsCorrection (const rigidBodyModelState &state) const |
Correct the velocity and acceleration of the bodies in the model. More... | |
virtual void | write (Ostream &) const |
Write. More... | |
bool | read (const dictionary &dict) |
Read coefficients dictionary and update system parameters,. More... | |
Protected Member Functions | |
virtual label | join_ (const label parentID, const spatialTransform &XT, autoPtr< joint > jointPtr, autoPtr< rigidBody > bodyPtr) |
Join the given body to the parent with ID parentID via the given. More... | |
Protected Attributes | |
const Time & | time_ |
Reference to time database. More... | |
PtrList< rigidBody > | bodies_ |
List of the bodies. More... | |
PtrList< subBody > | mergedBodies_ |
Bodies may be merged into existing bodies, the inertia of which is. More... | |
HashTable< label > | bodyIDs_ |
Lookup-table of the IDs of the bodies. More... | |
DynamicList< label > | lambda_ |
List of indices of the parent of each body. More... | |
PtrList< joint > | joints_ |
Each body it attached with a joint which are held on this list. More... | |
DynamicList< spatialTransform > | XT_ |
Transform from the parent body frame to the joint frame. More... | |
label | nDoF_ |
The number of degrees of freedom of the model. More... | |
bool | unitQuaternions_ |
True if any of the joints using quaternions. More... | |
PtrList< restraint > | restraints_ |
Motion restraints. More... | |
vector | g_ |
Acceleration due to gravity. More... | |
DynamicList< spatialTransform > | Xlambda_ |
Transform from the parent body to the current body. More... | |
DynamicList< spatialTransform > | X0_ |
Transform for external forces to the bodies reference frame. More... | |
DynamicList< spatialVector > | v_ |
The spatial velocity of the bodies. More... | |
DynamicList< spatialVector > | a_ |
The spatial acceleration of the bodies. More... | |
DynamicList< spatialVector > | c_ |
The velocity dependent spatial acceleration of the joints. More... | |
DynamicList< spatialTensor > | IA_ |
Velocity-product acceleration. More... | |
DynamicList< spatialVector > | pA_ |
Articulated body bias force. More... | |
DynamicList< compactSpatialTensor > | S_ |
Motion subspace for joints with 3 degrees of freedom. More... | |
DynamicList< spatialVector > | S1_ |
Motion subspace for joints with 1 degrees of freedom. More... | |
DynamicList< compactSpatialTensor > | U_ |
Sub-expression IA.S in the forward-dynamics algorithm. More... | |
DynamicList< spatialVector > | U1_ |
Sub-expression IA.S1 in the forward-dynamics algorithm. More... | |
DynamicList< tensor > | Dinv_ |
Sub-expression (S^T.U)^-1 in the forward-dynamics algorithm. More... | |
DynamicList< vector > | u_ |
Sub-expression tau - S^T.pA in the forward-dynamics algorithm. More... | |
Friends | |
Ostream & | operator<< (Ostream &, const rigidBodyModel &) |
Basic rigid-body model representing a system of rigid-bodies connected by 1-6 DoF joints.
This class holds various body and joint state fields needed by the kinematics and forward-dynamics algorithms presented in
reference:
Featherstone, R. (2008). Rigid body dynamics algorithms. Springer. Chapter 4.
Definition at line 83 of file rigidBodyModel.H.
rigidBodyModel | ( | const Time & | time | ) |
Null-constructor which adds the single root-body at the origin.
Definition at line 169 of file rigidBodyModel.C.
rigidBodyModel | ( | const Time & | time, |
const dictionary & | dict | ||
) |
Construct from dictionary.
Definition at line 178 of file rigidBodyModel.C.
References rigidBodyModel::bodyID(), dict, dictionary::found(), dictionary::get(), rigidBodyModel::join(), rigidBodyModel::merge(), Time::New(), rigidBodyModel::read(), and dictionary::subDict().
|
virtual |
Destructor.
Definition at line 224 of file rigidBodyModel.C.
|
protectedvirtual |
Join the given body to the parent with ID parentID via the given.
joint with transform from the parent frame to the joint frame XT.
Definition at line 122 of file rigidBodyModel.C.
References subBody::masterID(), subBody::masterXT(), rigidBody::name(), joint::nDoF(), and joint::unitQuaternion().
TypeName | ( | "rigidBodyModel" | ) |
Runtime type information.
|
inline |
Return the time.
Definition at line 31 of file rigidBodyModelI.H.
References rigidBodyModel::time_.
Referenced by rigidBodyMotion::read().
|
inline |
Return the number of bodies in the model (bodies().size())
Definition at line 37 of file rigidBodyModelI.H.
|
inline |
Return the list of the bodies in the model.
Definition at line 44 of file rigidBodyModelI.H.
|
inline |
List of indices of the parent of each body.
Definition at line 51 of file rigidBodyModelI.H.
|
inline |
Return the list of joints in the model.
Definition at line 58 of file rigidBodyModelI.H.
|
inline |
Return the number of degrees of freedom of the model.
used to set the size of the of joint state fields q, qDot and qDdot.
Definition at line 64 of file rigidBodyModelI.H.
Referenced by rigidBodyModelState::rigidBodyModelState().
|
inline |
Return true if any of the joints using quaternions.
Definition at line 70 of file rigidBodyModelI.H.
|
inline |
Return the acceleration due to gravity.
Definition at line 76 of file rigidBodyModelI.H.
Referenced by rigidBodyMotion::rigidBodyMotion().
|
inline |
Allow the acceleration due to gravity to be set.
after model construction
Definition at line 82 of file rigidBodyModelI.H.
|
inline |
Return the name of body with the given ID.
Definition at line 88 of file rigidBodyModelI.H.
|
inline |
Return the inertia of body i.
Definition at line 105 of file rigidBodyModelI.H.
|
inline |
Return the spatial velocity of the bodies.
Definition at line 112 of file rigidBodyModelI.H.
|
inline |
Return the spatial acceleration of the bodies.
Definition at line 118 of file rigidBodyModelI.H.
|
virtual |
Join the given body to the parent with ID parentID via the given.
joint with transform from the parent frame to the joint frame XT.
Definition at line 230 of file rigidBodyModel.C.
References autoPtr< T >::ptr().
Referenced by rigidBodyModel::rigidBodyModel().
Foam::label join | ( | const label | parentID, |
const spatialTransform & | XT, | ||
autoPtr< joints::composite > | cJoint, | ||
autoPtr< rigidBody > | bodyPtr | ||
) |
Join the given body to the parent with ID parentID via the given.
composite joint (specified as a list of co-located joints) with transform from the parent frame to the joint frame XT. Composite joins are useful to represent complex joints with degrees of freedom other than 1 or 3 which are directly supported.
Definition at line 264 of file rigidBodyModel.C.
References autoPtr< T >::ptr(), and UPtrList< T >::size().
Foam::label merge | ( | const label | parentID, |
const spatialTransform & | X, | ||
autoPtr< rigidBody > | bodyPtr | ||
) |
Merge the given body with transform X into the parent with ID.
parentID. The parent body assumes the properties of the combined body (inertia etc.) and the merged body is held on a separate list for reference.
Definition at line 322 of file rigidBodyModel.C.
References subBody::masterID(), subBody::masterXT(), subBody::name(), Foam::name(), and autoPtr< T >::reset().
Referenced by rigidBodyModel::rigidBodyModel().
|
inline |
Return true if the body with given ID has been merged with a parent.
Definition at line 123 of file rigidBodyModelI.H.
|
inline |
Return the ID of the master body for a sub-body otherwise.
return the given body ID
Definition at line 129 of file rigidBodyModelI.H.
|
inline |
Return the index of the merged body in the mergedBody list.
from the given body ID
Definition at line 150 of file rigidBodyModelI.H.
|
inline |
Return the merged body ID for the given merged body index.
in the mergedBody list
Definition at line 143 of file rigidBodyModelI.H.
|
inline |
Return the merged body for the given body ID.
Definition at line 157 of file rigidBodyModelI.H.
References Foam::abort(), Foam::FatalError, and FatalErrorInFunction.
|
inline |
Return the ID of the body with the given name.
Definition at line 170 of file rigidBodyModelI.H.
References Foam::name().
Referenced by rigidBodyMeshMotion::rigidBodyMeshMotion(), rigidBodyMeshMotionSolver::rigidBodyMeshMotionSolver(), and rigidBodyModel::rigidBodyModel().
Foam::spatialTransform X0 | ( | const label | bodyId | ) | const |
Return the current transform to the global frame for the given body.
Definition at line 380 of file rigidBodyModel.C.
References subBody::masterID(), and subBody::masterXT().
Referenced by restraint::bodyPoint().
|
inline |
Definition at line 176 of file rigidBodyModelI.H.
References Foam::inv(), p, and Foam::Zero.
|
inline |
Return the velocity of the given point on the given body.
Definition at line 197 of file rigidBodyModelI.H.
void applyRestraints | ( | scalarField & | tau, |
Field< spatialVector > & | fx, | ||
const rigidBodyModelState & | state | ||
) | const |
Apply the restraints and accumulate the internal joint forces.
into the tau field and external forces into the fx field
Definition at line 34 of file forwardDynamics.C.
References rigidBodyModel::applyRestraints(), DebugInfo, forAll, and rigidBodyModel::restraints_.
Referenced by rigidBodyModel::applyRestraints().
void forwardDynamics | ( | rigidBodyModelState & | state, |
const scalarField & | tau, | ||
const Field< spatialVector > & | fx | ||
) | const |
Calculate the joint acceleration qDdot from the joint state q,.
velocity qDot, internal force tau (in the joint frame) and external force fx (in the global frame) using the articulated body algorithm (Section 7.3 and Table 7.1)
Definition at line 56 of file forwardDynamics.C.
References Field< Type >::block(), joint::XSvc::c, DebugInfo, DebugInFunction, Foam::endl(), Foam::I, Foam::inv(), joint::jcalc(), joint::nDoF(), Foam::nl, rigidBodyModelState::q(), rigidBodyModelState::qDdot(), rigidBodyModelState::qDot(), joint::XSvc::S, joint::XSvc::S1, UList< T >::size(), T, joint::XSvc::v, x, Vector< Cmpt >::x(), joint::XSvc::X, Vector< Cmpt >::y(), Vector< Cmpt >::z(), and Foam::Zero.
Referenced by rigidBodyMotion::forwardDynamics().
void forwardDynamicsCorrection | ( | const rigidBodyModelState & | state | ) | const |
Correct the velocity and acceleration of the bodies in the model.
from the given joint state fields following an integration step of the forwardDynamics
Definition at line 209 of file forwardDynamics.C.
References Field< Type >::block(), joint::XSvc::c, DebugInfo, DebugInFunction, Foam::endl(), joint::jcalc(), joint::nDoF(), rigidBodyModelState::q(), rigidBodyModelState::qDdot(), rigidBodyModelState::qDot(), joint::XSvc::S, joint::XSvc::S1, joint::XSvc::v, joint::XSvc::X, and Foam::Zero.
|
virtual |
Write.
Reimplemented in rigidBodyMotion.
Definition at line 395 of file rigidBodyModel.C.
References Foam::endl(), forAll, Foam::indent(), Foam::name(), Foam::nl, and os().
Referenced by Foam::RBD::operator<<().
bool read | ( | const dictionary & | dict | ) |
Read coefficients dictionary and update system parameters,.
restraints but not the current state
Definition at line 456 of file rigidBodyModel.C.
References dict.
Referenced by rigidBodyModel::rigidBodyModel().
|
friend |
|
protected |
Reference to time database.
Definition at line 103 of file rigidBodyModel.H.
Referenced by rigidBodyModel::time().
List of the bodies.
The 0'th body represents the fixed origin and is constructed automatically. The subsequent (moving) bodies are appended by the join member function.
Definition at line 111 of file rigidBodyModel.H.
Bodies may be merged into existing bodies, the inertia of which is.
updated to represent the combined body which is more efficient than attaching them with fixed joints. These 'merged' bodies are held on this list.
Definition at line 117 of file rigidBodyModel.H.
|
protected |
Lookup-table of the IDs of the bodies.
Definition at line 120 of file rigidBodyModel.H.
|
protected |
List of indices of the parent of each body.
Definition at line 123 of file rigidBodyModel.H.
Each body it attached with a joint which are held on this list.
Definition at line 126 of file rigidBodyModel.H.
|
protected |
Transform from the parent body frame to the joint frame.
Definition at line 129 of file rigidBodyModel.H.
|
protected |
The number of degrees of freedom of the model.
used to set the size of the of joint state fields q, qDot and qDdot.
Definition at line 133 of file rigidBodyModel.H.
|
protected |
True if any of the joints using quaternions.
Definition at line 136 of file rigidBodyModel.H.
Motion restraints.
Definition at line 139 of file rigidBodyModel.H.
Referenced by rigidBodyModel::applyRestraints().
|
protected |
Acceleration due to gravity.
Definition at line 145 of file rigidBodyModel.H.
|
mutableprotected |
Transform from the parent body to the current body.
Definition at line 151 of file rigidBodyModel.H.
|
mutableprotected |
Transform for external forces to the bodies reference frame.
Definition at line 154 of file rigidBodyModel.H.
|
mutableprotected |
The spatial velocity of the bodies.
Definition at line 160 of file rigidBodyModel.H.
|
mutableprotected |
The spatial acceleration of the bodies.
Definition at line 163 of file rigidBodyModel.H.
|
mutableprotected |
The velocity dependent spatial acceleration of the joints.
Definition at line 166 of file rigidBodyModel.H.
|
mutableprotected |
Velocity-product acceleration.
Articulated body inertia
Definition at line 174 of file rigidBodyModel.H.
|
mutableprotected |
Articulated body bias force.
Definition at line 177 of file rigidBodyModel.H.
|
mutableprotected |
Motion subspace for joints with 3 degrees of freedom.
Definition at line 183 of file rigidBodyModel.H.
|
mutableprotected |
Motion subspace for joints with 1 degrees of freedom.
Definition at line 186 of file rigidBodyModel.H.
|
mutableprotected |
Sub-expression IA.S in the forward-dynamics algorithm.
Definition at line 189 of file rigidBodyModel.H.
|
mutableprotected |
Sub-expression IA.S1 in the forward-dynamics algorithm.
Definition at line 192 of file rigidBodyModel.H.
|
mutableprotected |
Sub-expression (S^T.U)^-1 in the forward-dynamics algorithm.
Definition at line 195 of file rigidBodyModel.H.
|
mutableprotected |
Sub-expression tau - S^T.pA in the forward-dynamics algorithm.
Definition at line 198 of file rigidBodyModel.H.