AGX Dynamics 2.41.3.0
Loading...
Searching...
No Matches
agx::ElementaryConstraint Class Reference

Elementary constraint base class with interface and global constraint functionality. More...

#include <ElementaryConstraint.h>

+ Inheritance diagram for agx::ElementaryConstraint:

Public Types

typedef agx::Name NameType
 
typedef agx::VectorPOD< agx::ElementaryConstraint * > PtrContainer
 
typedef agx::Vector< agx::ref_ptr< agx::ElementaryConstraint > > RefContainer
 

Public Member Functions

 AGXSTREAM_DECLARE_ABSTRACT_SERIALIZABLE (agx::ElementaryConstraint)
 
void copyRowFrom (const ElementaryConstraint *source, agx::UInt sourceRow, agx::UInt destRow)
 Copy configuration row from the given ElementaryConstraint into this.
 
virtual agx::UInt getBounds (agx::RangeReal *bounds, agx::UInt row, agx::Real h) const
 Returns the bounds of the Lagrange Multipliers (default (-inf, +inf)).
 
agx::Real getCompliance (agx::UInt row=0) const
 
virtual agx::Real getCurrentForce (const agx::UInt row=0) const
 Returns the force applied last time step by this elementary constraint.
 
const agx::RealgetCurrentForces () const
 
agx::Real getDamping (agx::UInt row=0) const
 
agx::Real getElasticity (agx::UInt row=0) const
 
virtual agx::Bool getEnable () const
 
agx::RangeRealgetForceRange (const agx::UInt row=0)
 
const agx::RangeRealgetForceRange (const agx::UInt row=0) const
 
virtual agx::UInt getJacobian (agx::Jacobian6DOFElement *G, agx::UInt numBlocks, agx::UInt row, agx::GWriteState::Enum writeState)
 Returns the Jacobian of this elementary constraint.
 
const agx::ElementaryConstraint::NameTypegetName () const
 
virtual agx::ConstraintNlmcpCallbackgetNlCallback () const
 
agx::UInt getNumRows () const
 
agx::RegularizationParametersgetRegularizationParameters (const agx::UInt row=0)
 
const agx::RegularizationParametersgetRegularizationParameters (const agx::UInt row=0) const
 
virtual agx::UInt getVelocity (agx::Real *v, agx::UInt row) const
 Returns the velocity of this elementary constraint (extra, driving term on the right hand side).
 
virtual agx::UInt getViolation (agx::Real *g, agx::UInt row)
 Returns the violation of this elementary constraint.
 
virtual agx::Bool isActive () const
 An elementary constraint is defined to be active if enabled.
 
virtual agx::Bool isImpacting () const
 
virtual void linearizeCompliance (const agx::Real *violations, agx::Real *epsilons, agx::Real minPerturbation) const
 Modify epsilon so that this ElementaryConstraint appear to be linear in the "normal" deformantion space instead any other space that the ElementaryConstraint may be using.
 
virtual agx::UInt postSolveCallback (const agx::Real *solution, agx::UInt row, agx::Real h)
 Callback after solve, with the solution.
 
virtual void prepare ()
 Prepare call.
 
void reset ()
 Reset call.
 
virtual void restore (agxStream::InputArchive &in) override
 Restore this object from stream.
 
virtual void restoreLightData (agxStream::StorageStream &str) override
 Restore structural independent data from stream.
 
virtual void setAttachmentPair (const agx::AttachmentPair *ap)
 Call for elementary constraints dependent on attachment pairs.
 
void setCompliance (agx::Real compliance)
 
void setCompliance (agx::Real compliance, int row)
 Assign compliance for a given row, or all rows if row = -1 (default).
 
void setDamping (agx::Real damping)
 
void setDamping (agx::Real damping, int row)
 Assign damping for a given row, or all rows if row = -1 (default).
 
void setElasticity (agx::Real elasticity)
 
void setElasticity (agx::Real elasticity, int row)
 Assign elasticity for a given row, or all rows if row = -1 (default).
 
virtual void setEnable (agx::Bool enable)
 Enable/disable this elementary constraint.
 
void setForceRange (agx::RangeReal forceRange, const agx::UInt row=0)
 Assign force range to a given row.
 
void setForceRange (agx::Real lower, agx::Real upper, const agx::UInt row=0)
 Assign force range to a given row.
 
void setName (const agx::ElementaryConstraint::NameType &name)
 Name this elementary constraint.
 
virtual void store (agxStream::OutputArchive &out) const override
 Store this object to stream.
 
virtual void storeLightData (agxStream::StorageStream &str) const override
 Store structural independent data to stream.
 
- 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.
 

Protected Member Functions

 ElementaryConstraint (agx::Bool enable, agx::UInt numRows, agx::RegularizationParameters *regParamsBuffer, agx::Real *lastForcesBuffer, agx::RangeReal *userBoundsBuffer)
 Construct given data.
 
virtual ~ElementaryConstraint ()
 Reference counted object, protected destructor.
 
- 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::Bool m_enable
 enabled
 
agx::ref_ptr< agx::Referencedm_internalData
 custom, internal data
 
agx::Realm_lfs
 last forces
 
agx::ElementaryConstraint::NameType m_name
 name
 
agx::UInt m_numRows
 number of rows
 
agx::RegularizationParametersm_rps
 regularization parameters
 
agx::RangeRealm_ubs
 user bounds

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

Additional Inherited Members

- 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.
 
- 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

Elementary constraint base class with interface and global constraint functionality.

Definition at line 53 of file ElementaryConstraint.h.

Member Typedef Documentation

◆ NameType

◆ PtrContainer

◆ RefContainer

Constructor & Destructor Documentation

◆ ElementaryConstraint()

agx::ElementaryConstraint::ElementaryConstraint ( agx::Bool  enable,
agx::UInt  numRows,
agx::RegularizationParameters regParamsBuffer,
agx::Real lastForcesBuffer,
agx::RangeReal userBoundsBuffer 
)
protected

Construct given data.

Sub-classes are responsible of providing regularization parameters-, force- and bounds data of size numRows.

Parameters
enable- default enabled or disabled
numRows- number of equations of this elementary constraint
regParamsBuffer- buffer (of size numRows) with regularization parameters
lastForcesBuffer- buffer (of size numRows) to store last/current forces
userBoundsBuffer- buffer (of size numRows) with bounds (read/written through set/getForceRange)

◆ ~ElementaryConstraint()

virtual agx::ElementaryConstraint::~ElementaryConstraint ( )
protectedvirtual

Reference counted object, protected destructor.

Member Function Documentation

◆ AGXSTREAM_DECLARE_ABSTRACT_SERIALIZABLE()

agx::ElementaryConstraint::AGXSTREAM_DECLARE_ABSTRACT_SERIALIZABLE ( agx::ElementaryConstraint  )

◆ copyRowFrom()

void agx::ElementaryConstraint::copyRowFrom ( const ElementaryConstraint source,
agx::UInt  sourceRow,
agx::UInt  destRow 
)

Copy configuration row from the given ElementaryConstraint into this.

Parameters
source- The ElementaryConstraint to copy from.
sourceRow- The index of the row in the given ElementaryConstraint to copy from.
destRow- The index to the row in this to which the configuration should be copied.

◆ getBounds()

virtual agx::UInt agx::ElementaryConstraint::getBounds ( agx::RangeReal bounds,
agx::UInt  row,
agx::Real  h 
) const
virtual

Returns the bounds of the Lagrange Multipliers (default (-inf, +inf)).

Note that the bounds buffer has to be provided by the caller.

Note
Dimension of the Lagrange Multipliers are Force * Time (argument h = time step length).
Parameters
bounds- bounds buffer
row- start row in bounds buffer bounds
h- current time step length
Returns
the number of rows used (= elements written) in the bounds buffer

Reimplemented in agx::FrictionController, agx::RangeController, agx::TwistRangeController, agx::ConeLimit, and agx::ElementaryContactPoint.

◆ getCompliance()

agx::Real agx::ElementaryConstraint::getCompliance ( agx::UInt  row = 0) const
Parameters
row- row < getNumRows()
Returns
compliance for row row (row < getNumRows())

◆ getCurrentForce()

virtual agx::Real agx::ElementaryConstraint::getCurrentForce ( const agx::UInt  row = 0) const
virtual

Returns the force applied last time step by this elementary constraint.

Parameters
row- row < getNumRows()
Returns
the force (given row) this elementary constraint applied during the last solve

◆ getCurrentForces()

const agx::Real * agx::ElementaryConstraint::getCurrentForces ( ) const
Returns
array of current forces - length = getNumRows()

◆ getDamping()

agx::Real agx::ElementaryConstraint::getDamping ( agx::UInt  row = 0) const
Parameters
row- row < getNumRows()
Returns
damping for row row (row < getNumRows())

◆ getElasticity()

agx::Real agx::ElementaryConstraint::getElasticity ( agx::UInt  row = 0) const
Parameters
row- row < getNumRows()
Returns
elasticity for row row (row < getNumRows())

◆ getEnable()

virtual agx::Bool agx::ElementaryConstraint::getEnable ( ) const
virtual
Returns
true if this elementary constraint is enabled - otherwise false

◆ getForceRange() [1/2]

agx::RangeReal & agx::ElementaryConstraint::getForceRange ( const agx::UInt  row = 0)
Parameters
row- row < getNumRows()
Returns
current force range at row row

◆ getForceRange() [2/2]

const agx::RangeReal & agx::ElementaryConstraint::getForceRange ( const agx::UInt  row = 0) const
Parameters
row- row < getNumRows()
Returns
current force range at row row

◆ getJacobian()

virtual agx::UInt agx::ElementaryConstraint::getJacobian ( agx::Jacobian6DOFElement G,
agx::UInt  numBlocks,
agx::UInt  row,
agx::GWriteState::Enum  writeState 
)
virtual

Returns the Jacobian of this elementary constraint.

Note that the Jacobian buffer has to be provided by the caller.

Parameters
G- Jacobian buffer
numBlocks- number of blocks in the global Jacobian (e.g., number of bodies in the main constraint)
row- start row in Jacobian buffer
writeState- state of the main constraint (the order in which the Jacobian is written defines this state)
Returns
the number of elements used in G

Reimplemented in agxPowerLine::ElementaryPhysicalDimensionConstraint, agx::ContactNormal, agx::ContactTangent, agx::Dot1, agx::Swing, agx::Dot2, agx::Spherical, agx::SphericalRel, agx::QuatLock, agx::BasicControllerConstraint, agx::ScrewController, agx::Twist, agx::Dot1Slack, agx::Dot2Slack, and agx::SphericalRelSlack.

◆ getName()

const ElementaryConstraint::NameType & agx::ElementaryConstraint::getName ( ) const
Returns
the name of this elementary constraint

Definition at line 1444 of file ElementaryConstraint.h.

References m_name.

◆ getNlCallback()

virtual agx::ConstraintNlmcpCallback * agx::ElementaryConstraint::getNlCallback ( ) const
virtual
Returns
solver callback instance if supported by this elementary constraint

Reimplemented in agx::FrictionController, and agx::GenericElementaryConstraint.

◆ getNumRows()

UInt agx::ElementaryConstraint::getNumRows ( ) const
Returns
number of rows in this elementary constraint

Definition at line 1439 of file ElementaryConstraint.h.

References m_numRows.

◆ getRegularizationParameters() [1/2]

RegularizationParameters * agx::ElementaryConstraint::getRegularizationParameters ( const agx::UInt  row = 0)
Parameters
row- row < getNumRows()
Returns
regularization parameters (holding e.g., compliance and damping) for row row (default: 0)

Definition at line 1427 of file ElementaryConstraint.h.

References agxAssert, m_numRows, and m_rps.

◆ getRegularizationParameters() [2/2]

const RegularizationParameters * agx::ElementaryConstraint::getRegularizationParameters ( const agx::UInt  row = 0) const
Parameters
row- row < getNumRows()
Returns
regularization parameters (holding e.g., compliance and damping) for row row (default: 0)

Definition at line 1433 of file ElementaryConstraint.h.

References agxAssert, m_numRows, and m_rps.

◆ getVelocity()

virtual agx::UInt agx::ElementaryConstraint::getVelocity ( agx::Real v,
agx::UInt  row 
) const
virtual

Returns the velocity of this elementary constraint (extra, driving term on the right hand side).

Note that the velocity buffer has to be provided by the caller.

Parameters
v- velocity buffer
row- start row in velocity buffer v
Returns
the number of rows used (= elements written) in velocity buffer

Reimplemented in agx::ContactTangent, agx::TargetSpeedController, agx::ElectricMotorController, and agx::ElementaryContactPoint.

◆ getViolation()

virtual agx::UInt agx::ElementaryConstraint::getViolation ( agx::Real g,
agx::UInt  row 
)
virtual

Returns the violation of this elementary constraint.

Note that the violation buffer has to be provided by the caller.

Parameters
g- violation buffer
row- start row in violation buffer g
Returns
the number of rows used (= elements written) in violation buffer

Reimplemented in agxPowerLine::ElementaryPhysicalDimensionConstraint, agx::ContactNormal, agx::ContactTangent, agx::Dot1, agx::Swing, agx::Dot2, agx::Spherical, agx::SphericalRel, agx::QuatLock, agx::TargetSpeedController, agx::FrictionController, agx::RangeController, agx::LockController, agx::ScrewController, agx::Twist, agx::TwistRangeController, agx::ConeLimit, agx::Dot1Slack, agx::Dot2Slack, agx::SphericalRelSlack, agx::ElectricMotorController, and agx::ElementaryContactPoint.

◆ isActive()

virtual agx::Bool agx::ElementaryConstraint::isActive ( ) const
virtual

An elementary constraint is defined to be active if enabled.

Yet constraints can be enabled but not active (e.g., RangeController when the range isn't exceeded).

Returns
true if this elementary constraint is active - otherwise false

Reimplemented in agx::FrictionController, agx::RangeController, agx::TwistRangeController, agx::ConeLimit, and agx::GenericElementaryConstraint.

◆ isImpacting()

virtual agx::Bool agx::ElementaryConstraint::isImpacting ( ) const
virtual
Returns
true of this elementary constraint is impacting

Reimplemented in agx::ElementaryContactPoint.

◆ linearizeCompliance()

void agx::ElementaryConstraint::linearizeCompliance ( const agx::Real violations,
agx::Real epsilons,
agx::Real  minPerturbation 
) const
inlinevirtual

Modify epsilon so that this ElementaryConstraint appear to be linear in the "normal" deformantion space instead any other space that the ElementaryConstraint may be using.

For most ElementaryConstraints this does nothing. For QuatLock the epsilon is modified to account for the nonlinear nature of quaternion's relation to the angle of rotation they represent.

This function is called by the engine during constraint preparation for solve.

Reimplemented in agx::QuatLock.

Definition at line 1449 of file ElementaryConstraint.h.

◆ postSolveCallback()

virtual agx::UInt agx::ElementaryConstraint::postSolveCallback ( const agx::Real solution,
agx::UInt  row,
agx::Real  h 
)
virtual

Callback after solve, with the solution.

Parameters
solution- solution of the last solve
row- start row in solution for this elementary constraint
h- current time step length
Returns
number of rows read (= number of rows of this elementary constraint)

Reimplemented in agx::FrictionController.

◆ prepare()

virtual void agx::ElementaryConstraint::prepare ( )
virtual

Prepare call.

After this call the elementary constraint may be activated.

Reimplemented in agx::ElectricMotorController, agx::RangeController, agx::TwistRangeController, and agx::ConeLimit.

◆ reset()

void agx::ElementaryConstraint::reset ( )

Reset call.

Call this to zero the solution vector for the ElementaryConstraint.

◆ restore()

virtual void agx::ElementaryConstraint::restore ( agxStream::InputArchive in)
overridevirtual

Restore this object from stream.

Reimplemented in agx::BasicControllerConstraint, and agxPowerLine::ElementaryPhysicalDimensionConstraint.

◆ restoreLightData()

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

◆ setAttachmentPair()

◆ setCompliance() [1/2]

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

◆ setCompliance() [2/2]

void agx::ElementaryConstraint::setCompliance ( agx::Real  compliance,
int  row 
)

Assign compliance for a given row, or all rows if row = -1 (default).

Parameters
compliance- new compliance
row- row to assign compliance. If i < 0 to assign all rows.

◆ setDamping() [1/2]

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

◆ setDamping() [2/2]

void agx::ElementaryConstraint::setDamping ( agx::Real  damping,
int  row 
)

Assign damping for a given row, or all rows if row = -1 (default).

Note
Calling this method for non-holonomic rows (e.g. Motor1D) has no effect.
Parameters
damping- new damping
row- row to assign damping. If i < 0 to assign all rows.

◆ setElasticity() [1/2]

void agx::ElementaryConstraint::setElasticity ( agx::Real  elasticity)

◆ setElasticity() [2/2]

void agx::ElementaryConstraint::setElasticity ( agx::Real  elasticity,
int  row 
)

Assign elasticity for a given row, or all rows if row = -1 (default).

Parameters
elasticity- new elasticity
row- row to assign elasticity. If i < 0 to assign all rows.

◆ setEnable()

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

Enable/disable this elementary constraint.

Parameters
enable- true to enable, false to disable

◆ setForceRange() [1/2]

void agx::ElementaryConstraint::setForceRange ( agx::RangeReal  forceRange,
const agx::UInt  row = 0 
)

Assign force range to a given row.

Note
row is default 0. I.e., it is not defined to assign forceRange to all rows in one call.
Parameters
forceRange- new force range
row- row < getNumRows()

◆ setForceRange() [2/2]

void agx::ElementaryConstraint::setForceRange ( agx::Real  lower,
agx::Real  upper,
const agx::UInt  row = 0 
)

Assign force range to a given row.

Note
row is default 0. I.e., it is not defined to assign lower and upper to all rows in one call.
Parameters
lower- lower force range (typically <= 0)
upper- upper force range (typically >= 0)
row- row < getNumRows()

◆ setName()

void agx::ElementaryConstraint::setName ( const agx::ElementaryConstraint::NameType name)

Name this elementary constraint.

Parameters
name- new name of this elementary constraint

◆ store()

virtual void agx::ElementaryConstraint::store ( agxStream::OutputArchive out) const
overridevirtual

Store this object to stream.

Reimplemented in agx::BasicControllerConstraint, and agxPowerLine::ElementaryPhysicalDimensionConstraint.

◆ storeLightData()

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

Member Data Documentation

◆ m_enable

agx::Bool agx::ElementaryConstraint::m_enable
protected

enabled

Definition at line 334 of file ElementaryConstraint.h.

◆ m_internalData

agx::ref_ptr<agx::Referenced> agx::ElementaryConstraint::m_internalData
protected

custom, internal data

Definition at line 340 of file ElementaryConstraint.h.

◆ m_lfs

agx::Real* agx::ElementaryConstraint::m_lfs
protected

last forces

Definition at line 338 of file ElementaryConstraint.h.

◆ m_name

agx::ElementaryConstraint::NameType agx::ElementaryConstraint::m_name
protected

name

Definition at line 336 of file ElementaryConstraint.h.

Referenced by getName().

◆ m_numRows

agx::UInt agx::ElementaryConstraint::m_numRows
protected

number of rows

Definition at line 335 of file ElementaryConstraint.h.

Referenced by getNumRows(), and getRegularizationParameters().

◆ m_rps

agx::RegularizationParameters* agx::ElementaryConstraint::m_rps
protected

regularization parameters

Definition at line 337 of file ElementaryConstraint.h.

Referenced by getRegularizationParameters().

◆ m_ubs

agx::RangeReal* agx::ElementaryConstraint::m_ubs
protected

user bounds

Definition at line 339 of file ElementaryConstraint.h.


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