AGX Dynamics 2.41.2.0
Loading...
Searching...
No Matches
agx::Constraint Class Referenceabstract

The base class for a constraint. More...

#include <Constraint.h>

+ Inheritance diagram for agx::Constraint:

Public Types

enum  SolveType { DIRECT = 1 , ITERATIVE = (1<<2) , DIRECT_AND_ITERATIVE = (DIRECT | ITERATIVE) }
 Specifies in what solvers the constraint will be solved. More...
 

Public Member Functions

agx::Bool addElementaryConstraint (const agx::Name &name, agx::ElementaryConstraint *elementaryConstraint)
 Add elementary constraint (like Spherical, Dot1, Dot2 etc) given name.
 
agx::Bool addSecondaryConstraint (const agx::Name &name, agx::ElementaryConstraint *secondaryConstraint)
 Add secondary constraint (like motor, range and/or lock etc) given name.
 
 AGXSTREAM_DECLARE_ABSTRACT_SERIALIZABLE (agx::Constraint)
 
template<typename T >
T * as ()
 Try to do dynamic_cast on the constraint and return a pointer to the casted constraint.
 
template<typename T >
const T * as () const
 Try to do dynamic_cast on the constraint and return a pointer to the casted constraint.
 
RealVector calculateCurrentViolation () const
 Calculates the current violation of the ordinary degrees of freedom of this constraint, e.g., three translational and two rotational (total 5 elements) of a hinge, i.e., controllers DOF are not included.
 
agx::UInt calculateNumActiveRows () const
 Calculates the current number of active rows, including both elementary and secondary constraints.
 
template<typename T >
ref_ptr< T > createFromBody (Vec3 bodyPoint, Vec3 bodyAxis, RigidBody *rb1, RigidBody *rb2)
 
template<typename T >
ref_ptr< T > createFromWorld (Vec3 worldPoint, Vec3 worldAxis, RigidBody *rb1, RigidBody *rb2)
 
agx::AttachmentgetAttachment (agx::UInt i) const
 
agx::RigidBodyAttachmentgetAttachment (const agx::RigidBody *rb) const
 
agx::AttachmentPairgetAttachmentPair () const
 
agx::RigidBodygetBodyAt (agx::UInt i)
 
const agx::RigidBodygetBodyAt (agx::UInt i) const
 
virtual agx::Real getCompliance (agx::UInt dof) const
 Get the compliance for DOF i.
 
agx::Real getCurrentForce (agx::UInt dof) const
 Consider using getLastForce instead.
 
virtual Real getDamping (agx::UInt dof) const
 Get the damping for DOF dof.
 
virtual agx::Real getElasticity (agx::UInt dof) const
 Get the elasticity for DOF i.
 
agx::ElementaryConstraintgetElementaryConstraint (const agx::UInt index) const
 
agx::ElementaryConstraintgetElementaryConstraintGivenName (const agx::Name &name) const
 Find elementary constraint given name.
 
agx::Bool getEnable () const
 
agx::Bool getEnableComputeForces () const
 
bool getEnableDebugRendering () const
 
bool getEnableLinearization () const
 
agx::UInt32 getEntityId () const
 
agx::RangeReal getForceRange (agx::UInt dof=0) const
 Get the force range for DOF dof.
 
agx::Bool getLastForce (agx::UInt bodyIndex, agx::Vec3 &retForce, agx::Vec3 &retTorque, agx::Bool giveForceAtCm=false) const
 If 'compute forces' is enabled, returns the last force and torque applied by this constraint on the body with bodyIndex.
 
agx::Bool getLastForce (const agx::RigidBody *rb, agx::Vec3 &retForce, agx::Vec3 &retTorque, agx::Bool giveForceAtCm=false) const
 If 'compute forces' is enabled, returns the last force and torque applied by this constraint on the body rb.
 
agx::Bool getLastLocalForce (agx::UInt bodyIndex, agx::Vec3 &retForce, agx::Vec3 &retTorque, agx::Bool giveForceAtCm=false) const
 If 'compute forces' is enabled, returns the last force and torque applied by this constraint on the body with bodyIndex.
 
agx::Bool getLastLocalForce (const agx::RigidBody *rb, agx::Vec3 &retForce, agx::Vec3 &retTorque, agx::Bool giveForceAtCm=false) const
 If 'compute forces' is enabled, returns the last force and torque applied by this constraint on the body rb.
 
agx::UInt getNumBodies () const
 returns the number of bodies involved
 
virtual int getNumDOF () const =0
 
agx::UInt getNumElementaryConstraints () const
 
agx::UInt getNumSecondaryConstraints () const
 
virtual agx::RegularizationParametersgetRegularizationParameters (agx::UInt i)
 
virtual const agx::RegularizationParametersgetRegularizationParameters (agx::UInt i) const
 
agx::ConstraintImplementationgetRep ()
 
const agx::ConstraintImplementationgetRep () const
 
agx::ElementaryConstraintgetSecondaryConstraint (const agx::UInt index) const
 
agx::ElementaryConstraintgetSecondaryConstraintGivenName (const agx::Name &name) const
 Find secondary constraint given name.
 
agx::Constraint::SolveType getSolveType () const
 
agx::Bool getValid () const
 
agx::Bool isEnabled () const
 
virtual agx::Bool rebind ()
 Rebind this constraint, i.e., use current state as the initial configuration.
 
agx::Bool removeElementaryConstraint (agx::ElementaryConstraint *elementaryConstraint)
 Remove elementary constraint.
 
agx::Bool removeElementaryConstraint (const agx::Name &name)
 Remove elementary constraint.
 
agx::Bool removeSecondaryConstraint (agx::ElementaryConstraint *secondaryConstraint)
 Remove secondary constraint.
 
agx::Bool removeSecondaryConstraint (const agx::Name &name)
 Remove secondary constraint.
 
virtual void render (class agxRender::RenderManager *mgr, float scale) const =0
 Inherited method of how to render this constraint into DebugRenderer.
 
void restore (agxStream::InputArchive &in) override
 
virtual void restoreLightData (agxStream::StorageStream &str) override
 
void setCompliance (agx::Real compliance)
 Set the compliance of this constraint for all DOFs.
 
virtual void setCompliance (agx::Real compliance, agx::Int dof)
 Set the compliance of this constraint for the i:th DOF.
 
void setDamping (agx::Real damping)
 Set the damping of this constraint for all DOFs.
 
virtual void setDamping (agx::Real damping, agx::Int dof)
 Set the damping of this constraint for the i:th DOF.
 
virtual void setElasticity (agx::Real elasticity)
 Set the elasticity of this constraint for all DOFs.
 
virtual void setElasticity (agx::Real elasticity, agx::Int dof)
 Set the elasticity of this constraint for the i:th DOF.
 
virtual void setEnable (agx::Bool enable)
 Enable/disable a constraint.
 
void setEnableComputeForces (agx::Bool enable)
 Enable (or disable) computation of the forces applied to the dynamic bodies in this constraint.
 
void setEnableDebugRendering (agx::Bool enable)
 Enable/disable debug rendering of this constraint.
 
void setEnableLinearization (bool enable)
 Pass true to enable linearization of constraint compliance.
 
void setForceRange (agx::RangeReal forceRange)
 Assign force range for all DOF of the elementary constraints.
 
void setForceRange (agx::RangeReal forceRange, agx::Int dof)
 Assign force range, of an elementary constraint, for a given DOF.
 
void setForceRange (agx::Real lower, agx::Real upper, agx::Int dof)
 Assign force range, of an elementary constraint, for a given DOF.
 
void setSolveType (agx::Constraint::SolveType solveType)
 Specify the solve type for this constraint.
 
void store (agxStream::OutputArchive &out) const override
 
virtual void storeLightData (agxStream::StorageStream &str) const override
 
- Public Member Functions inherited from agx::Interaction
 Interaction ()
 Default constructor.
 
 AGXSTREAM_DECLARE_SERIALIZABLE_BASE (agx::Interaction)
 
const agx::NamegetName () const
 
agx::PropertyContainergetPropertyContainer ()
 
const agx::PropertyContainergetPropertyContainer () const
 
agxSDK::SimulationProxygetSimulationProxy () const
 
agx::Bool hasPropertyContainer () const
 
virtual void postSystemCallback (agx::DynamicsSystem *)
 Called after all post step events, after solve.
 
virtual void preSystemCallback (agx::DynamicsSystem *)
 Called after all pre step events, before solve.
 
void setName (const agx::Name &name)
 Name this interaction.
 
void setPropertyContainer (agx::PropertyContainer *propertyContainer)
 Assign a new property container.
 
virtual void updateForce (agx::DynamicsSystem *dynamicsSystem)
 This virtual method is implemented so that it computes the interaction forces on all the physical bodies implicated.
 
- Public Member Functions inherited from agx::Referenced
 Referenced ()
 Default constructor.
 
 Referenced (const Referenced &)
 
template<typename T >
T * as ()
 Subclass casting.
 
template<typename T >
const T * as () const
 
template<typename T >
T * asSafe ()
 Safe subclass casting, return nullptr if template type does not match.
 
template<typename T >
const T * asSafe () const
 
int getReferenceCount () const
 
template<typename T >
bool is () const
 Subclass test.
 
Referencedoperator= (const Referenced &)
 Assignment operator. Will increment the number of references to the referenced object.
 
void reference (void *ptr=nullptr) const
 Explicitly increment the reference count by one, indicating that this object has another pointer which is referencing it.
 
void unreference (void *ptr=nullptr) const
 Decrement the reference count by one, indicating that a pointer to this object is referencing it.
 
void unreference_nodelete () const
 Decrement the reference count by one, indicating that a pointer to this object is referencing it.
 
- Public Member Functions inherited from agxStream::Serializable
virtual ~Serializable ()
 Destructor for normal C++ use but hidden from SWIG bindings.
 
virtual const char * getClassName () const
 
bool getEnableSerialization () const
 
bool getEnableUuidGeneration ()
 
agx::UInt32 getIndex () const
 This index is given at creation of this object.
 
virtual StorageAgent * getStorageAgent () const =0
 
agx::Uuid getUuid () const
 
bool isFinished () const
 
void setEnableSerialization (bool flag)
 Set to false to disable serialization of this object.
 
void setFinished ()
 Tells this class that it is restored correctly and should not be deleted during destruction of an Archive.
 
void setUuid (const agx::Uuid &uuid)
 Explicitly set a Uuid on a serializable object.
 

Static Public Member Functions

static agx::Bool calculateFramesFromBody (agx::Vec3 bodyPoint, agx::Vec3 bodyAxis, agx::Vec3 secondBodyAxis, const agx::RigidBody *body, agx::Frame *bodyFrame, const agx::RigidBody *otherBody, agx::Frame *otherFrame)
 Calculates the constraint attachment frames given point and axes in body coordinates of body.
 
static agx::Bool calculateFramesFromBody (agx::Vec3 bodyPoint, agx::Vec3 bodyAxis, const agx::RigidBody *body, agx::Frame *bodyFrame, const agx::RigidBody *otherBody, agx::Frame *otherFrame)
 Calculates the constraint attachment frames given point and axis in body coordinates of body.
 
static agx::Bool calculateFramesFromWorld (agx::Vec3 worldPoint, agx::Vec3 worldAxis, agx::Vec3 secondWorldAxis, const agx::RigidBody *rb1, agx::Frame *rb1Frame, const agx::RigidBody *rb2, agx::Frame *rb2Frame)
 Given a point and two axes in world, this function calculates each local attachment frame for one or two bodies.
 
static agx::Bool calculateFramesFromWorld (agx::Vec3 worldPoint, agx::Vec3 worldAxis, const agx::RigidBody *rb1, agx::Frame *rb1Frame, const agx::RigidBody *rb2, agx::Frame *rb2Frame)
 Given a point and an axis in world, this function calculates each local attachment frame for one or two bodies.
 
template<typename T >
static agx::ref_ptr< T > createFromBody (agx::Vec3 bodyPoint, agx::Vec3 bodyAxis, agx::RigidBody *rb1, agx::RigidBody *rb2=nullptr)
 Creates a constraint given a point and an axis in rb1 model frame.
 
template<typename T >
static agx::ref_ptr< T > createFromWorld (agx::Vec3 worldPoint, agx::Vec3 worldAxis, agx::RigidBody *rb1, agx::RigidBody *rb2=nullptr)
 Creates a constraint given a point and an axis in world frame.
 
- Static Public Member Functions inherited from agx::Interaction
static agxStream::Serializablecreate (agxStream::InputArchive &)
 
- Static Public Member Functions inherited from agx::Referenced
template<typename T >
static bool ValidateCast (const Referenced *object)
 
- Static Public Member Functions inherited from agxStream::Serializable
static void setEnableUuidGeneration (bool flag)
 Specify if there should be UUID:s generated for each new Serializable object. By default it is enabled.
 

Protected Member Functions

 Constraint ()
 
virtual ~Constraint ()
 
virtual void addNotification () override
 Called when added to a simulation.
 
virtual void postSystemCallback (agx::DynamicsSystem *dynamicsSystem) override
 Called after all post step events, after solve.
 
virtual void preSystemCallback (agx::DynamicsSystem *dynamicsSystem) override
 Called after all pre step events, before solve.
 
virtual void removeNotification () override
 Called when removed from a simulation.
 
void setRep (agx::ConstraintImplementation *_rep)
 
virtual void setSimulation (agxSDK::Simulation *simulation) override
 Assign simulation.
 
virtual void setSystem (agx::DynamicsSystem *)
 
- Protected Member Functions inherited from agx::Interaction
virtual ~Interaction ()
 Reference counted object, protected destructor.
 
virtual void addNotification ()
 Called when added to a simulation.
 
virtual void removeNotification ()
 Called when removed from a simulation.
 
virtual void setSimulation (agxSDK::Simulation *simulation)
 Assign simulation.
 
- Protected Member Functions inherited from agx::Referenced
virtual ~Referenced ()
 Destructor.
 
void allocateObserverVector () const
 
void deleteUsingDeleteHandler () const
 
- Protected Member Functions inherited from agxStream::Serializable
 Serializable ()
 Default constructor.
 
 Serializable (const Serializable &other)
 Copy constructor.
 
void generateUuid ()
 

Protected Attributes

agx::ConstraintImplementationm_implementation
 
- Protected Attributes inherited from agx::Referenced
Mutex m_mutex
 
ObserverContainer m_observers
 
AtomicValue m_refCount
 

Additional Inherited Members

- Static Protected Member Functions inherited from agx::Referenced
static DeleteHandlergetDeleteHandler ()
 
static void setDeleteHandler (DeleteHandler *handler)
 Internal: Set a DeleteHandler to which deletion of all referenced counted objects will be delegated to.
 

Detailed Description

The base class for a constraint.

This is an interface class for all constraints. The virtual functions are place holders for the computation of Jacobians and constraint value. In addition, there are interfaces defined here to setup the interacting bodies.

Consider the case of two constrained rigid bodies. Before the constraint is applied, the relative motion is the manifold \(R^3\times SO(3)\). If the constraint is a prismatic joint, the remaining manifold of relative motion is just \(R\), the Real line. We put a chart on that manifold so we can put a value on the extension of the prismatic joint. On the resulting joint coordinate, we might then enforce a secondary constraint such as joint limits, a position lock, or a driver that imposes a velocity.

The constraint processing consists of the following stages: -perform necessary geometric computation from rigid bodies' kinematic data -evaluate the constraint value and basic Jacobians -configure dynamical parameters (compliance and damping) -compute joint angles according to manifold chart if needed -if there are secondary constraints:

  1. compute the value of the constraint
  2. compute the secondary Jacobian by collapsing recursion
  3. add rows to the constraint Jacobian
  4. configure dynamics parameters (compliance and damping) -if there are effort constraints
  5. for simple limits, add these to parameters
  6. for additional limits, register these with corresponding Jacobians

Definition at line 88 of file Constraint.h.

Member Enumeration Documentation

◆ SolveType

Specifies in what solvers the constraint will be solved.

Enumerator
DIRECT 

Solved only in the DIRECT solver.

ITERATIVE 

Solved only in the ITERATIVE solver.

DIRECT_AND_ITERATIVE 

Solved both in the ITERATIVE and the DIRECT solver.

Definition at line 92 of file Constraint.h.

Constructor & Destructor Documentation

◆ Constraint()

agx::Constraint::Constraint ( )
protected

◆ ~Constraint()

virtual agx::Constraint::~Constraint ( )
protectedvirtual

Member Function Documentation

◆ addElementaryConstraint()

agx::Bool agx::Constraint::addElementaryConstraint ( const agx::Name name,
agx::ElementaryConstraint elementaryConstraint 
)

Add elementary constraint (like Spherical, Dot1, Dot2 etc) given name.

General for elementary constraints is that their input is based on body relative data (far from general).

Returns
true if this constraint supports the elementary constraint and the elementary constraint will be used - otherwise false

◆ addNotification()

virtual void agx::Constraint::addNotification ( )
overrideprotectedvirtual

Called when added to a simulation.

Reimplemented from agx::Interaction.

Reimplemented in agx::IGenericConstraint, and agxDriveTrain::VelocityConstraint.

◆ addSecondaryConstraint()

agx::Bool agx::Constraint::addSecondaryConstraint ( const agx::Name name,
agx::ElementaryConstraint secondaryConstraint 
)

Add secondary constraint (like motor, range and/or lock etc) given name.

General for secondary constraints is that their input is based on the current constraint angle.

Returns
true if this constraint supports the secondary constraint and the secondary constraint will be used - otherwise false

◆ AGXSTREAM_DECLARE_ABSTRACT_SERIALIZABLE()

agx::Constraint::AGXSTREAM_DECLARE_ABSTRACT_SERIALIZABLE ( agx::Constraint  )

◆ as() [1/2]

template<typename T >
T * agx::Constraint::as

Try to do dynamic_cast on the constraint and return a pointer to the casted constraint.

Definition at line 940 of file Constraint.h.

◆ as() [2/2]

template<typename T >
const T * agx::Constraint::as

Try to do dynamic_cast on the constraint and return a pointer to the casted constraint.

Definition at line 947 of file Constraint.h.

◆ calculateCurrentViolation()

RealVector agx::Constraint::calculateCurrentViolation ( ) const

Calculates the current violation of the ordinary degrees of freedom of this constraint, e.g., three translational and two rotational (total 5 elements) of a hinge, i.e., controllers DOF are not included.

Returns
violation vector of size getNumDOF()

◆ calculateFramesFromBody() [1/2]

static agx::Bool agx::Constraint::calculateFramesFromBody ( agx::Vec3  bodyPoint,
agx::Vec3  bodyAxis,
agx::Vec3  secondBodyAxis,
const agx::RigidBody body,
agx::Frame bodyFrame,
const agx::RigidBody otherBody,
agx::Frame otherFrame 
)
static

Calculates the constraint attachment frames given point and axes in body coordinates of body.

The frames' z-axis will be aligned with the bodyAxis and its y-axis will be normal to the bodyAxis-secondBodyAxis plane.

Parameters
bodyPoint- point in body coordinates of reference rigid body "body"
bodyAxis- axis in body coordinates of reference rigid body "body"
secondBodyAxis- non-parallel axis to bodyAxis in body coordinates of reference rigid body "body"
body- reference body, invalid if null
bodyFrame- reference body attachment frame, invalid if null
otherBody- other rigid body, if null otherFrame will be calculated in world frame
otherFrame- other frame, invalid if null
Returns
true if the calculations succeeded - otherwise false

◆ calculateFramesFromBody() [2/2]

static agx::Bool agx::Constraint::calculateFramesFromBody ( agx::Vec3  bodyPoint,
agx::Vec3  bodyAxis,
const agx::RigidBody body,
agx::Frame bodyFrame,
const agx::RigidBody otherBody,
agx::Frame otherFrame 
)
static

Calculates the constraint attachment frames given point and axis in body coordinates of body.

Parameters
bodyPoint- point in body coordinates of reference rigid body "body"
bodyAxis- axis in body coordinates of reference rigid body "body"
body- reference body, invalid if null
bodyFrame- reference body attachment frame, invalid if null
otherBody- other rigid body, if null otherFrame will be calculated in world frame
otherFrame- other frame, invalid if null
Returns
true if the calculations succeeded - otherwise false

◆ calculateFramesFromWorld() [1/2]

static agx::Bool agx::Constraint::calculateFramesFromWorld ( agx::Vec3  worldPoint,
agx::Vec3  worldAxis,
agx::Vec3  secondWorldAxis,
const agx::RigidBody rb1,
agx::Frame rb1Frame,
const agx::RigidBody rb2,
agx::Frame rb2Frame 
)
static

Given a point and two axes in world, this function calculates each local attachment frame for one or two bodies.

The frames' z-axis will be aligned with the worldAxis and its y-axis will be normal to the worldAxis-secondWorldAxis plane. The first body, rb1, has to be valid. If the second body, rb2, is zero the second frame, rb2Frame, will be given in world frame.

Parameters
worldPoint- point in world
worldAxis- axis in world (for example prismatic- or hinge axis)
secondWorldAxis- axis in world (must be non-parallel to worldAxis)
rb1- first rigid body, invalid if null
rb1Frame- frame to calculate for rb1, invalid if null
rb2- second rigid body, if null rb2Frame will be given in world
rb2Frame- frame to calculate for rb2, invalid if null
Returns
true if the calculations succeeded - otherwise false (if false, rb1Frame and rb2Frame are not touched)

◆ calculateFramesFromWorld() [2/2]

static agx::Bool agx::Constraint::calculateFramesFromWorld ( agx::Vec3  worldPoint,
agx::Vec3  worldAxis,
const agx::RigidBody rb1,
agx::Frame rb1Frame,
const agx::RigidBody rb2,
agx::Frame rb2Frame 
)
static

Given a point and an axis in world, this function calculates each local attachment frame for one or two bodies.

The first body, rb1, has to be valid. If the second body, rb2, is zero the second frame, rb2Frame, will be given in world frame.

Parameters
worldPoint- point in world
worldAxis- axis in world (for example prismatic- or hinge axis)
rb1- first rigid body, invalid if null
rb1Frame- frame to calculate for rb1, invalid if null
rb2- second rigid body, if null rb2Frame will be given in world
rb2Frame- frame to calculate for rb2, invalid if null
Returns
true if the calculations succeeded - otherwise false (if false, rb1Frame and rb2Frame are not touched)

◆ calculateNumActiveRows()

agx::UInt agx::Constraint::calculateNumActiveRows ( ) const

Calculates the current number of active rows, including both elementary and secondary constraints.

The result can be used to allocate temporary buffers for additional calls to solver related methods, e.g., getViolation.

Returns
the (current) total number of active rows in this constraint

◆ createFromBody() [1/2]

template<typename T >
static agx::ref_ptr< T > agx::Constraint::createFromBody ( agx::Vec3  bodyPoint,
agx::Vec3  bodyAxis,
agx::RigidBody rb1,
agx::RigidBody rb2 = nullptr 
)
static

Creates a constraint given a point and an axis in rb1 model frame.

Seen from body one frame - both relative attachment frames will coincide at the given point with their z-axes pointing in the axis direction.

Parameters
bodyPoint- constraint center point given in first body's frame
bodyAxis- constraint axis given in first body's frame
rb1- first rigid body (not defined if null)
rb2- second rigid body, if null, rb1 will be attached in world
Returns
the constraint of type T

◆ createFromBody() [2/2]

template<typename T >
ref_ptr< T > agx::Constraint::createFromBody ( Vec3  bodyPoint,
Vec3  bodyAxis,
RigidBody rb1,
RigidBody rb2 
)

Definition at line 929 of file Constraint.h.

◆ createFromWorld() [1/2]

template<typename T >
static agx::ref_ptr< T > agx::Constraint::createFromWorld ( agx::Vec3  worldPoint,
agx::Vec3  worldAxis,
agx::RigidBody rb1,
agx::RigidBody rb2 = nullptr 
)
static

Creates a constraint given a point and an axis in world frame.

Both relative attachment frames will coincide at the given world point with their z-axes pointing in the given world axis direction.

Parameters
worldPoint- constraint center point given in the world frame
worldAxis- constraint axis given in world frame
rb1- first rigid body (not defined if null)
rb2- second rigid body, if null, rb1 will be attached in world
Returns
the constraint of type T

◆ createFromWorld() [2/2]

template<typename T >
ref_ptr< T > agx::Constraint::createFromWorld ( Vec3  worldPoint,
Vec3  worldAxis,
RigidBody rb1,
RigidBody rb2 
)

Definition at line 919 of file Constraint.h.

◆ getAttachment() [1/2]

agx::Attachment * agx::Constraint::getAttachment ( agx::UInt  i) const
Returns
the attachment frame for body with index i (call equal to constraint->getAttachment( constraint->getBodyAt( i ) ))

◆ getAttachment() [2/2]

agx::RigidBodyAttachment * agx::Constraint::getAttachment ( const agx::RigidBody rb) const
Returns
the attachment frame for rb if present - otherwise 0

◆ getAttachmentPair()

agx::AttachmentPair * agx::Constraint::getAttachmentPair ( ) const
Returns
the attachment pair if this constraint supports it - otherwise 0

◆ getBodyAt() [1/2]

agx::RigidBody * agx::Constraint::getBodyAt ( agx::UInt  i)
Returns
rigid body at index i (the bodies are ordered as they were added)

◆ getBodyAt() [2/2]

const agx::RigidBody * agx::Constraint::getBodyAt ( agx::UInt  i) const
Returns
rigid body at index i (the bodies are ordered as they were added)

◆ getCompliance()

virtual agx::Real agx::Constraint::getCompliance ( agx::UInt  dof) const
virtual

Get the compliance for DOF i.

Note that indices > number of DOF for this constraint is not defined, so compliance of index 0 will be returned.

Parameters
dof- index of the requested DOF
Returns
compliance for the given DOF

Reimplemented in agx::DistanceJoint, agx::SingleControllerConstraint1DOF, and agxWire::EyeNodeArea.

◆ getCurrentForce()

agx::Real agx::Constraint::getCurrentForce ( agx::UInt  dof) const

Consider using getLastForce instead.

This method returns the magnitude of the force in a given degree of freedom (DOF). Enabled controllers in the given DOF will NOT be included, agx::ElementaryConstraint::getCurrentForce has to be used for that.

Returns
the current force magnitude (i.e., the force magnitude last time step) in given DOF >= 0 && <= NUM_DOFS
See also
setEnableComputeForces and getLastForce

◆ getDamping()

virtual Real agx::Constraint::getDamping ( agx::UInt  dof) const
virtual

Get the damping for DOF dof.

Note that indices > number of DOF for this constraint is not defined, so damping of index 0 will be returned.

Parameters
dof- index of the requested DOF
Returns
damping for the given DOF

Reimplemented in agx::DistanceJoint, agx::SingleControllerConstraint1DOF, and agxWire::EyeNodeArea.

◆ getElasticity()

virtual agx::Real agx::Constraint::getElasticity ( agx::UInt  dof) const
virtual

Get the elasticity for DOF i.

Note that indices > number of DOF for this constraint is not defined, so elasticity of index 0 will be returned.

Parameters
dof- index of the requested DOF
Returns
elasticity for the given DOF

◆ getElementaryConstraint()

agx::ElementaryConstraint * agx::Constraint::getElementaryConstraint ( const agx::UInt  index) const
Parameters
index- index of the elementary constraint
Returns
elementary constraint given index

◆ getElementaryConstraintGivenName()

agx::ElementaryConstraint * agx::Constraint::getElementaryConstraintGivenName ( const agx::Name name) const

Find elementary constraint given name.

Parameters
name- name of the elementary constraint
Returns
elementary constraint given name

◆ getEnable()

agx::Bool agx::Constraint::getEnable ( ) const
Returns
true if the constraint is enabled.

◆ getEnableComputeForces()

agx::Bool agx::Constraint::getEnableComputeForces ( ) const
Returns
true if this constraint has been enabled to compute the forces applied to its bodies - otherwise false

◆ getEnableDebugRendering()

bool agx::Constraint::getEnableDebugRendering ( ) const
Returns
true if this constraints debug rendering is enabled - otherwise false

◆ getEnableLinearization()

bool agx::Constraint::getEnableLinearization ( ) const
Returns
true if constraint compliance linearization is enabled for this constraint. False otherwise.

◆ getEntityId()

agx::UInt32 agx::Constraint::getEntityId ( ) const
Returns
the entity id of the constraint

◆ getForceRange()

agx::RangeReal agx::Constraint::getForceRange ( agx::UInt  dof = 0) const

Get the force range for DOF dof.

Note
Indices > number of DOF for this constraint is not defined, an infinite force range will be returned.
For controllers (secondary constraints), use their specific method, e.g., constraint->getMotor1D()->getForceRange().
Parameters
dof- index of the requested DOF

◆ getLastForce() [1/2]

agx::Bool agx::Constraint::getLastForce ( agx::UInt  bodyIndex,
agx::Vec3 retForce,
agx::Vec3 retTorque,
agx::Bool  giveForceAtCm = false 
) const

If 'compute forces' is enabled, returns the last force and torque applied by this constraint on the body with bodyIndex.

The force is given in world coordinates and is the one applied at the anchor position of this constraint.

The result includes force and torque from this constraint including all enabled controllers (e.g., motors, locks, ranges).

See also
setEnableComputeForces
Parameters
bodyIndex- index of body, if number of bodies = 1 and bodyIndex = 1, the force and torque applied to "the world body" is returned
retForce- the force applied by this constraint on body at bodyIndex last solve
retTorque- the torque applied by this constraint on body at bodyIndex last solve
giveForceAtCm- this parameter affects the resulting torque. The default behavior (giveForceAtCm = false) calculates the force applied by this constraint at the anchor position. Letting giveForceAtCm = true, the force will be applied at center of mass, affecting the torque as \( T_{new} = T - r \times F \) where r is the vector from the anchor point to the center of mass of the body.
Returns
true if resulting force and torque was written to retForce and retTorque - otherwise false

◆ getLastForce() [2/2]

agx::Bool agx::Constraint::getLastForce ( const agx::RigidBody rb,
agx::Vec3 retForce,
agx::Vec3 retTorque,
agx::Bool  giveForceAtCm = false 
) const

If 'compute forces' is enabled, returns the last force and torque applied by this constraint on the body rb.

The force is given in world coordinates and is the one applied at the anchor position of this constraint.

The result includes force and torque from this constraint including all enabled controllers (e.g., motors, locks, ranges).

See also
setEnableComputeForces
Parameters
rb- body in this constraint. If this constraint is attached in world, nullptr can be used.
retForce- the force applied by this constraint on body rb at the last solve
retTorque- the torque applied by this constraint on body rb at the last solve
giveForceAtCm- this parameter affects the resulting torque. The default behavior (giveForceAtCm = false) calculates the force applied by this constraint at the anchor position. Letting giveForceAtCm = true, the force will be applied at center of mass, affecting the torque as \(T_{new} = T - r \times F\) where r is the vector from the anchor point to the center of mass of the body.
Returns
true if resulting force and torque was written to retForce and retTorque - otherwise false

◆ getLastLocalForce() [1/2]

agx::Bool agx::Constraint::getLastLocalForce ( agx::UInt  bodyIndex,
agx::Vec3 retForce,
agx::Vec3 retTorque,
agx::Bool  giveForceAtCm = false 
) const

If 'compute forces' is enabled, returns the last force and torque applied by this constraint on the body with bodyIndex.

The force is given in the frame of the constraint.

The result includes force and torque from this constraint including all enabled controllers (e.g., motors, locks, ranges).

See also
setEnableComputeForces
Parameters
bodyIndex- index of body, if number of bodies = 1 and bodyIndex = 1, the force and torque applied to "the world body" is returned
retForce- the force applied by this constraint on body at bodyIndex last solve
retTorque- the torque applied by this constraint on body at bodyIndex last solve
giveForceAtCm- this parameter affects the resulting torque. The default behavior (giveForceAtCm = false) calculates the force applied by this constraint at the anchor position. Letting giveForceAtCm = true, the force will be applied at center of mass, affecting the torque as \(T_{new} = T - r \times F\) where r is the vector from the anchor point to the center of mass of the body.
Returns
true if resulting force and torque was written to retForce and retTorque - otherwise false

◆ getLastLocalForce() [2/2]

agx::Bool agx::Constraint::getLastLocalForce ( const agx::RigidBody rb,
agx::Vec3 retForce,
agx::Vec3 retTorque,
agx::Bool  giveForceAtCm = false 
) const

If 'compute forces' is enabled, returns the last force and torque applied by this constraint on the body rb.

The force is given in the frame of the constraint.

The result includes force and torque from this constraint including all enabled controllers (e.g., motors, locks, ranges).

See also
setEnableComputeForces
Parameters
rb- body in this constraint. If this constraint is attached in world, nullptr can be used.
retForce- the force applied by this constraint on body rb at the last solve
retTorque- the torque applied by this constraint on body rb at the last solve
giveForceAtCm- this parameter affects the resulting torque. The default behavior (giveForceAtCm = false) calculates the force applied by this constraint at the anchor position. Letting giveForceAtCm = true, the force will be applied at center of mass, affecting the torque as \(T_{new} = T - r \times F\) where r is the vector from the anchor point to the center of mass of the body.
Returns
true if resulting force and torque was written to retForce and retTorque - otherwise false

◆ getNumBodies()

agx::UInt agx::Constraint::getNumBodies ( ) const

returns the number of bodies involved

◆ getNumDOF()

◆ getNumElementaryConstraints()

agx::UInt agx::Constraint::getNumElementaryConstraints ( ) const
Returns
the number of elementary constraints

◆ getNumSecondaryConstraints()

agx::UInt agx::Constraint::getNumSecondaryConstraints ( ) const
Returns
the number of secondary constraints

◆ getRegularizationParameters() [1/2]

virtual agx::RegularizationParameters * agx::Constraint::getRegularizationParameters ( agx::UInt  i)
virtual
Returns
a pointer to the regularization parameter object of this constraint for the i:th DOF

Reimplemented in agx::DistanceJoint, and agx::SingleControllerConstraint1DOF.

◆ getRegularizationParameters() [2/2]

virtual const agx::RegularizationParameters * agx::Constraint::getRegularizationParameters ( agx::UInt  i) const
virtual
Returns
a pointer to the regularization parameter object of this constraint for the i:th DOF

Reimplemented in agx::DistanceJoint, and agx::SingleControllerConstraint1DOF.

◆ getRep() [1/2]

ConstraintImplementation * agx::Constraint::getRep ( )
inline
Returns
a pointer to the internal constraint implementation

Definition at line 908 of file Constraint.h.

Referenced by agxSDK::MergeSplitHandler::getProperties().

◆ getRep() [2/2]

const ConstraintImplementation * agx::Constraint::getRep ( ) const
inline
Returns
a pointer to the internal constraint implementation

Definition at line 913 of file Constraint.h.

◆ getSecondaryConstraint()

agx::ElementaryConstraint * agx::Constraint::getSecondaryConstraint ( const agx::UInt  index) const
Parameters
index- index of the secondary constraint
Returns
secondary constraint given index

◆ getSecondaryConstraintGivenName()

agx::ElementaryConstraint * agx::Constraint::getSecondaryConstraintGivenName ( const agx::Name name) const

Find secondary constraint given name.

Parameters
name- name of the elementary constraint
Returns
elementary constraint given name

◆ getSolveType()

agx::Constraint::SolveType agx::Constraint::getSolveType ( ) const
Returns
the current solve type for this constraint
Note
Solve type is ignored by iterative solvers.

◆ getValid()

agx::Bool agx::Constraint::getValid ( ) const
Returns
true if this constraints is valid It is possible for a constraint to declare itself invalid during a simulation. This may happen if for example a body that is included in this constraint is removed from the simulation.

◆ isEnabled()

agx::Bool agx::Constraint::isEnabled ( ) const
Returns
true if the constraint is enabled.

◆ postSystemCallback()

virtual void agx::Constraint::postSystemCallback ( agx::DynamicsSystem )
overrideprotectedvirtual

Called after all post step events, after solve.

Reimplemented from agx::Interaction.

◆ preSystemCallback()

virtual void agx::Constraint::preSystemCallback ( agx::DynamicsSystem )
overrideprotectedvirtual

Called after all pre step events, before solve.

Reimplemented from agx::Interaction.

◆ rebind()

virtual agx::Bool agx::Constraint::rebind ( )
virtual

Rebind this constraint, i.e., use current state as the initial configuration.

Returns
true if the rebinding is successful - false otherwise

◆ removeElementaryConstraint() [1/2]

agx::Bool agx::Constraint::removeElementaryConstraint ( agx::ElementaryConstraint elementaryConstraint)

Remove elementary constraint.

Parameters
elementaryConstraint- elementary constraint to remove
Returns
true if removed

◆ removeElementaryConstraint() [2/2]

agx::Bool agx::Constraint::removeElementaryConstraint ( const agx::Name name)

Remove elementary constraint.

Parameters
name- name of the elementary constraint to remove
Returns
true if removed

◆ removeNotification()

virtual void agx::Constraint::removeNotification ( )
overrideprotectedvirtual

Called when removed from a simulation.

Reimplemented from agx::Interaction.

Reimplemented in agx::IGenericConstraint.

◆ removeSecondaryConstraint() [1/2]

agx::Bool agx::Constraint::removeSecondaryConstraint ( agx::ElementaryConstraint secondaryConstraint)

Remove secondary constraint.

Parameters
secondaryConstraint- secondary constraint to remove
Returns
true if removed

◆ removeSecondaryConstraint() [2/2]

agx::Bool agx::Constraint::removeSecondaryConstraint ( const agx::Name name)

Remove secondary constraint.

Parameters
name- name of the secondary constraint to remove
Returns
true if removed

◆ render()

◆ restore()

void agx::Constraint::restore ( agxStream::InputArchive in)
override

◆ restoreLightData()

virtual void agx::Constraint::restoreLightData ( agxStream::StorageStream str)
overridevirtual

◆ setCompliance() [1/2]

void agx::Constraint::setCompliance ( agx::Real  compliance)

Set the compliance of this constraint for all DOFs.

Parameters
compliance- value of compliance

◆ setCompliance() [2/2]

virtual void agx::Constraint::setCompliance ( agx::Real  compliance,
agx::Int  dof 
)
virtual

Set the compliance of this constraint for the i:th DOF.

Parameters
compliance- value of compliance
dof- index of the requested DOF (-1 indicates all)

Reimplemented in agxWire::EyeNodeArea, agx::DistanceJoint, and agx::SingleControllerConstraint1DOF.

Referenced by agxModel::BeamStiffnessDamping::apply().

◆ setDamping() [1/2]

void agx::Constraint::setDamping ( agx::Real  damping)

Set the damping of this constraint for all DOFs.

Parameters
damping- value of damping

◆ setDamping() [2/2]

virtual void agx::Constraint::setDamping ( agx::Real  damping,
agx::Int  dof 
)
virtual

Set the damping of this constraint for the i:th DOF.

Parameters
damping- value of damping
dof- index of the requested DOF (-1 indicates all).

Reimplemented in agxWire::EyeNodeArea, agx::DistanceJoint, and agx::SingleControllerConstraint1DOF.

Referenced by agxModel::BeamStiffnessDamping::apply().

◆ setElasticity() [1/2]

virtual void agx::Constraint::setElasticity ( agx::Real  elasticity)
virtual

Set the elasticity of this constraint for all DOFs.

Parameters
elasticity- value of elasticity

◆ setElasticity() [2/2]

virtual void agx::Constraint::setElasticity ( agx::Real  elasticity,
agx::Int  dof 
)
virtual

Set the elasticity of this constraint for the i:th DOF.

Elasticity is 1 / compliance.

Parameters
elasticity- value of elasticity
dof- index of the requested DOF (-1 indicates all)

◆ setEnable()

virtual void agx::Constraint::setEnable ( agx::Bool  enable)
virtual

Enable/disable a constraint.

Parameters
enable- If true the constraint will be enabled.

◆ setEnableComputeForces()

void agx::Constraint::setEnableComputeForces ( agx::Bool  enable)

Enable (or disable) computation of the forces applied to the dynamic bodies in this constraint.

Matrix-vector operation to compute the forces after solve.

See also
getLastForce
Parameters
enable- true to enable, false to disable

Referenced by agxSDK::ConstraintLogListener::addConstraint().

◆ setEnableDebugRendering()

void agx::Constraint::setEnableDebugRendering ( agx::Bool  enable)

Enable/disable debug rendering of this constraint.

◆ setEnableLinearization()

void agx::Constraint::setEnableLinearization ( bool  enable)

Pass true to enable linearization of constraint compliance.

This makes constraint violation a linear function of the force or torque used to violate the constraint also for the elementary constraint types for which this isn't already the case, such as QuatLock. The effect of this is that the parameters sent to the solver by the constraint are tweaked to make the constrain more closely follow Hook's law.

Setting this to true has no effect on most constraints. It does have an effect on the rotational part of AngularLockJoint, LockJoint, and Prismatic.

When false, the default, the resulting violation of any QuatLock in the constraint is linear in quaternion space instead of degrees and radians.

◆ setForceRange() [1/3]

void agx::Constraint::setForceRange ( agx::RangeReal  forceRange)

Assign force range for all DOF of the elementary constraints.

Note
Using this method will NOT change the force range of the controllers (secondary constraints), if present. Use their specific methods instead, e.g., constraint->getMotor1D()->setForceRange( fRange ).
Parameters
forceRange- value of force range for all elementary DOFs

◆ setForceRange() [2/3]

void agx::Constraint::setForceRange ( agx::RangeReal  forceRange,
agx::Int  dof 
)

Assign force range, of an elementary constraint, for a given DOF.

Note
For controllers (secondary constraints), use their specific methods, e.g., constraint->getMotor1D()->setForceRange( fRange ).
Parameters
forceRange- value of force range for the given DOF
dof- index of the DOF (-1 indicates all)

◆ setForceRange() [3/3]

void agx::Constraint::setForceRange ( agx::Real  lower,
agx::Real  upper,
agx::Int  dof 
)

Assign force range, of an elementary constraint, for a given DOF.

Note
For controllers (secondary constraints), use their specific methods, e.g., constraint->getMotor1D()->setForceRange( fLower, fUpper ).
Parameters
lower- lower value of force range for the given DOF
upper- lower value of force range for the given DOF
dof- index of the DOF (-1 indicates all)

◆ setRep()

void agx::Constraint::setRep ( agx::ConstraintImplementation _rep)
protected

◆ setSimulation()

virtual void agx::Constraint::setSimulation ( agxSDK::Simulation simulation)
overrideprotectedvirtual

Assign simulation.

Be careful.

Reimplemented from agx::Interaction.

◆ setSolveType()

void agx::Constraint::setSolveType ( agx::Constraint::SolveType  solveType)

Specify the solve type for this constraint.

Valid is DIRECT (default for non-iterative solvers), ITERATIVE or DIRECT_AND_ITERATIVE where DIRECT_AND_ITERATIVE means that this constraint will be solved both direct and iterative.

Parameters
solveType- new solve type for this constraint
Note
Solve type is ignored by iterative solvers.

◆ setSystem()

virtual void agx::Constraint::setSystem ( agx::DynamicsSystem )
inlineprotectedvirtual

Definition at line 658 of file Constraint.h.

◆ store()

void agx::Constraint::store ( agxStream::OutputArchive out) const
override

◆ storeLightData()

virtual void agx::Constraint::storeLightData ( agxStream::StorageStream str) const
overridevirtual

Member Data Documentation

◆ m_implementation

agx::ConstraintImplementation* agx::Constraint::m_implementation
protected

Definition at line 677 of file Constraint.h.


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