Rigid Body Dynamics Library
CustomConstraint Struct Referenceabstract

Interface to define general-purpose constraints. More...

Public Member Functions

 CustomConstraint (unsigned int constraintCount)
 
virtual ~CustomConstraint ()
 
virtual void CalcConstraintsJacobianAndConstraintAxis (Model &model, unsigned int custom_constraint_id, const Math::VectorNd &Q, ConstraintSet &CS, Math::MatrixNd &G, unsigned int GrowStart, unsigned int GcolStart)=0
 
virtual void CalcGamma (Model &model, unsigned int custom_constraint_id, const Math::VectorNd &Q, const Math::VectorNd &QDot, ConstraintSet &CS, const Math::MatrixNd &Gblock, Math::VectorNd &gamma, unsigned int gammaStartIndex)=0
 
virtual void CalcPositionError (Model &model, unsigned int custom_constraint_id, const Math::VectorNd &Q, ConstraintSet &CS, Math::VectorNd &err, unsigned int errStartIdx)=0
 
virtual void CalcVelocityError (Model &model, unsigned int custom_constraint_id, const Math::VectorNd &Q, const Math::VectorNd &QDot, ConstraintSet &CS, const Math::MatrixNd &Gblock, Math::VectorNd &err, unsigned int errStartIndex)=0
 

Data Fields

unsigned int mConstraintCount
 

Detailed Description

Interface to define general-purpose constraints.

The CustomConstraint interface is a general-purpose interface that is rich enough to define time-varying constraints at the position-level $\phi_p(q,t)=0$, the velocity-level $\phi_v(\dot{q},t)=0$, or the acceleration-level $\phi_a(\ddot{q},t)=0$. These constraints all end up being applied at the acceleration-level by taking successive derivatives until we are left with $\Phi(\ddot{q},\dot{q},q,t)=0$ The interface requires that the user populate

  • G: $ \dfrac{ \partial \Phi(\ddot{q},\dot{q},q,t)}{ \partial \ddot{q}}$
  • constraintAxis: the axis that the constraints are applied along
  • gamma: $ \gamma = - ( \Phi(\ddot{q},\dot{q},q,t) - G \ddot{q})$
  • errPos: The vector of $\phi_p(\dot{q},t)$. If the constraint is a velocity-level constraint or higher this should be set to zero.
  • errVel: The vector of $\phi_v(\dot{q},t)$. If the constraint is an acceleration-level constraint this should be set to zero

The matrix G and the vector gamma are required to compute accelerations that satisfy the desired constraints. The vectors errPos and errVel are required to apply Baumgarte stabilization (a constraint stabilization method) to stabilize the constraint. The interface provides (optional) interfaces for the functions

  • CalcAssemblyPositionError
  • CalcAssemblyPositionErrorJacobian
  • CalcAssemblyVelocityError
  • CalcAssemblyVelocityErrorJacobian

These optional functions are used only during system assembly. This permits a velocity-level constraint (e.g. such as a rolling-without-slipping constraint) to define a position-level constraint to assemble the system (e.g. bring the rolling surfaces into contact with eachother). If you are defining a position-level constraint these optional functions should simply return errPos, G, errVel, and G respectively.

It must be stated that this is an advanced feature of RBDL: you must have an in-depth knowledge of multibody-dynamics in order to write a custom constraint, and to write the corresponding test code to validate that the constraint is working. As a hint the test code in tests/CustomConstraintsTest.cc should contain a forward simulation of a simple system using the constraint and then check to see that system energy is conserved with only a small error and the constraint is also satisfied with only a small error. The observed error should drop as the integrator tolerances are lowered.

Definition at line 1048 of file Constraints.h.

Constructor & Destructor Documentation

◆ CustomConstraint()

CustomConstraint ( unsigned int  constraintCount)
inline

Definition at line 1052 of file Constraints.h.

◆ ~CustomConstraint()

virtual ~CustomConstraint ( )
inlinevirtual

Definition at line 1054 of file Constraints.h.

Member Function Documentation

◆ CalcConstraintsJacobianAndConstraintAxis()

virtual void CalcConstraintsJacobianAndConstraintAxis ( Model model,
unsigned int  custom_constraint_id,
const Math::VectorNd Q,
ConstraintSet CS,
Math::MatrixNd G,
unsigned int  GrowStart,
unsigned int  GcolStart 
)
pure virtual

◆ CalcGamma()

virtual void CalcGamma ( Model model,
unsigned int  custom_constraint_id,
const Math::VectorNd Q,
const Math::VectorNd QDot,
ConstraintSet CS,
const Math::MatrixNd Gblock,
Math::VectorNd gamma,
unsigned int  gammaStartIndex 
)
pure virtual

◆ CalcPositionError()

virtual void CalcPositionError ( Model model,
unsigned int  custom_constraint_id,
const Math::VectorNd Q,
ConstraintSet CS,
Math::VectorNd err,
unsigned int  errStartIdx 
)
pure virtual

◆ CalcVelocityError()

virtual void CalcVelocityError ( Model model,
unsigned int  custom_constraint_id,
const Math::VectorNd Q,
const Math::VectorNd QDot,
ConstraintSet CS,
const Math::MatrixNd Gblock,
Math::VectorNd err,
unsigned int  errStartIndex 
)
pure virtual

Field Documentation

◆ mConstraintCount

unsigned int mConstraintCount

Definition at line 1049 of file Constraints.h.


The documentation for this struct was generated from the following file: