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

#include <ConstraintImplementation.h>

+ Inheritance diagram for agx::HighLevelConstraintImplementation:

Public Types

typedef agx::Bool(* CreateElementaryConstraintsFunction) (HighLevelConstraintImplementation *)
 
- Public Types inherited from agx::ConstraintImplementation
enum  Tags { NONE = 0 , MANY_BODY = (1<<0) , DEFAULT_BINARY_TAG = NONE , DEFAULT_MANY_BODY_TAG = MANY_BODY }
 

Public Member Functions

 HighLevelConstraintImplementation ()
 
virtual ~HighLevelConstraintImplementation ()
 
 AGXSTREAM_DECLARE_ABSTRACT_SERIALIZABLE (agx::HighLevelConstraintImplementation)
 
bool bodiesValid () const
 
virtual void computeForces (const agx::Jacobian6DOFElement *jacobians)
 Computes the forces, if valid and enabled.
 
virtual agx::Bool computeForces (const agx::Jacobian6DOFElement *jacobians, agx::Vec3Vector &result) const
 Computes forces on rb1 and rb2 given this constraint has been solved and all the elementary constraints have their current force updated.
 
bool construct (RigidBody *rb1, Frame *rb1AttachmentFrame, RigidBody *rb2, Frame *rb2AttachmentFrame, CreateElementaryConstraintsFunction=nullptr)
 
virtual agx::Real getAngle (agx::UInt dof=0) const override
 If the constraint supports angle calculations and 'dof' is in range, this method returns the angle of the given degree of freedom.
 
template<typename T >
T * getAttachment (agx::UInt index)
 
template<typename T >
const T * getAttachment (agx::UInt index) const
 
virtual agx::AttachmentPairgetAttachmentPair () const override
 
virtual agx::Bool getEnableComputeForces () const override
 
virtual agx::Bool getLastForce (agx::UInt bodyIndex, agx::Vec3 &retForce, agx::Vec3 &retTorque, agx::Bool giveForceAtCm=false) const override
 If 'compute forces' is enabled, returns the last force and torque applied by this constraint on the body with bodyIndex.
 
virtual agx::Bool getLastForce (const RigidBody *rb, Vec3 &retForce, Vec3 &retTorque, agx::Bool giveForceAtCm=false) const override
 If 'compute forces' is enabled, returns the last force and torque applied by this constraint on the body rb.
 
virtual agx::Bool getLastLocalForce (agx::UInt bodyIndex, agx::Vec3 &retForce, agx::Vec3 &retTorque, agx::Bool giveForceAtCm=false) const override
 If 'compute forces' is enabled, returns the last force and torque applied by this constraint on the body with bodyIndex.
 
virtual agx::Bool getLastLocalForce (const agx::RigidBody *rb, agx::Vec3 &retForce, agx::Vec3 &retTorque, agx::Bool giveForceAtCm=false) const override
 If 'compute forces' is enabled, returns the last force and torque applied by this constraint on the body rb.
 
virtual void postSolveCallback (const agx::Jacobian6DOFElement *jacobians, const agx::Real *solution, agx::Real dt) override
 Peak at the solution after the solver is done.
 
virtual void prepare () override
 Prepares this constraint.
 
virtual bool rebind () override
 The general version of rebind takes the first attachment frame and moves the other attachment frame so they have the exact same world transform.
 
virtual void restore (agxStream::InputArchive &in) override
 
virtual void restoreLightData (agxStream::StorageStream &str) override
 
virtual void setEnableComputeForces (agx::Bool enable) override
 Enable (or disable) computation of the forces applied to the dynamic bodies in this constraint.
 
bool setupOneOrTwoBodySystem (RigidBodyAttachment *a1, RigidBodyAttachment *a2)
 
virtual void store (agxStream::OutputArchive &out) const override
 
virtual void storeLightData (agxStream::StorageStream &str) const override
 
virtual size_t updateJacobian (agx::Jacobian6DOFElement *jacobians) override
 Updates the Jacobian matrices.
 
virtual bool updateValid () override
 Updates the valid conditions for this constraint.
 
virtual agx::AttachmentuserAPIgetAttachment (agx::UInt index) const override
 
virtual agx::AttachmentuserAPIgetAttachment (const agx::RigidBody *rb) const override
 
bool validateRigidBodiesAndAttachments (RigidBody *rb1, Frame *rb1AttachmentFrame, RigidBody *rb2, Frame *rb2AttachmentFrame)
 
- Public Member Functions inherited from agx::ConstraintImplementation
 ConstraintImplementation ()
 Default constructor.
 
virtual ~ConstraintImplementation ()
 Destructor.
 
virtual bool addElementaryConstraint (const agx::String &name, agx::ElementaryConstraint *elementaryConstraint)
 Add elementary constraint (like Spherical, Dot1, Dot2 etc) given name.
 
virtual void addNlCallbacks (agx::SparseRangeReal &sparseRangeReal, const NlmcpCallbackSolverData &solverData) const
 Interface for non-linear callback from solver.
 
virtual void addNotification ()
 Callback when this constraint is added to Simulation.
 
virtual bool addSecondaryConstraint (const agx::String &name, agx::ElementaryConstraint *secondaryConstraint)
 Add secondary constraint (like motor, range and/or lock etc) given name.
 
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.
 
agx::Real calculateViolationVectorAverageSize ()
 Gets the average size of the elements in getViolation() by calculating the magnitude and dividing by the number of elements.
 
template<typename T >
T * findSecondaryConstraintGivenType (const agx::UInt count=0) const
 
bool getActive () const
 
virtual agx::Real getAngle (agx::UInt=0) const
 If the constraint supports angle calculations and 'dof' is in range, this method returns the angle of the given degree of freedom.
 
virtual agx::AttachmentPairgetAttachmentPair () const
 
agx::UInt getBlockRowIndex () const
 
const BlockStructuregetBlockStructure () const
 
virtual void getBounds (agx::RangeReal *bounds, agx::Real dt) const
 Calculates and pushes the bounds into a sparse range data structure.
 
virtual int getConstraintVelocity (agx::Real *v, int row)
 Calculates and pushes the constraint velocities into array given current row.
 
virtual agx::Real getCurrentSpeed (agx::UInt=0) const
 If this method is implemented, a call to this method will return the current speed of the angle.
 
virtual agx::ElementaryConstraintgetElementaryConstraint (const agx::String &name) const
 
virtual agx::ElementaryConstraintgetElementaryConstraint (const agx::UInt index) const
 
agx::ElementaryConstraint::RefContainergetElementaryConstraints ()
 
const agx::ElementaryConstraint::RefContainergetElementaryConstraints () const
 
virtual bool getEnable () const
 
virtual agx::Bool getEnableComputeForces () const
 
bool getEnableLinearization () const
 
virtual void getEpsilon (agx::Real *epsilon, agx::Real h)
 Writes regularization parameters for all active rows into epsilon.
 
agx::FrictionControllergetFrictionController (agx::UInt number=0) const
 
agx::UInt getJacobianRowUsage () const
 
virtual 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.
 
virtual 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.
 
virtual 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.
 
virtual 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::Lock1DgetLock1D (agx::UInt number=0) const
 
agx::Motor1DgetMotor1D (agx::UInt number=0) const
 
virtual void getParameters (agx::Real *violation, agx::Real *epsilon, agx::Real *damping, bool *holonomic, agx::Real *velocity, agx::RangeReal *bounds, int8_t *indexSetState, agx::Real h, agx::Real minPerturbation=agx::Real(1E-10))
 Writes solver parameters such as damping and holonomic.
 
agx::Range1DgetRange1D (agx::UInt number=0) const
 
virtual agx::ElementaryConstraintgetSecondaryConstraint (const agx::String &name) const
 
virtual agx::ElementaryConstraintgetSecondaryConstraint (const agx::UInt index) const
 
agx::ElementaryConstraint::RefContainergetSecondaryConstraints ()
 
const agx::ElementaryConstraint::RefContainergetSecondaryConstraints () const
 
bool getSolveBoth () const
 
bool getSolveIterative () const
 
SolverBodyView getSolverView () const
 Bodies as viewed from the solver.
 
Constraint::SolveType getSolveType () const
 
ConstraintImplPtrVectorgetSubConstraints ()
 
const ConstraintImplPtrVectorgetSubConstraints () const
 
int getTag () const
 
BodyView getUserView () const
 Bodies as viewed from the user.
 
virtual int getViolation (agx::Real *g, int row)
 Calculates and pushes the constraint values into array given current row.
 
void incrementConstraintCount (RigidBody *rb) const
 Increment the number of constraints connection to rb.
 
bool isImpacting () const
 
bool isValid () const
 
void onDirectComplianceMatrix (Real *data, unsigned int ld) const
 Internal callback from the direct solver with perturbation matrix data.
 
virtual void postSolveCallback (const agx::Jacobian6DOFElement *jacobians, const agx::Real *solution, agx::Real dt)
 Peak at the solution after the solver is done.
 
void postSolveIndexSetCallback (const int8_t *state)
 Callback after the solver is done about the state of each equation in the constraint.
 
virtual void postSystemCallback (DynamicsSystem *system)
 Last in the dynamics system step forward loop, this constraint gets a call with the main system.
 
virtual void prepare ()
 Prepares this constraint.
 
virtual void preSystemCallback (DynamicsSystem *system)
 Before prepare, and before the system writes to the data buffers, this constraint gets a call with the main system it's in.
 
virtual bool rebind ()
 The general version of rebind takes the first attachment frame and moves the other attachment frame so they have the exact same world transform.
 
virtual bool removeElementaryConstraint (agx::ElementaryConstraint *elementaryConstraint)
 Remove elementary constraint.
 
virtual bool removeElementaryConstraint (const agx::String &name)
 Remove elementary constraint.
 
virtual void removeNotification ()
 Callback when this constraint is removed from Simulation.
 
virtual bool removeSecondaryConstraint (agx::ElementaryConstraint *secondaryConstraint)
 Remove secondary constraint.
 
virtual bool removeSecondaryConstraint (const agx::String &name)
 Remove secondary constraint.
 
void reset ()
 Reset the solution vectors of the primary and secondary elementary constraints in the implementation.
 
void setBlockRowIndex (agx::UInt blockRowIndex)
 Sets the global start index for this constraint in the global, non-permuted matrix.
 
virtual void setEnable (bool enable)
 Sets the enable flag.
 
virtual void setEnableComputeForces (agx::Bool enable)
 Enable (or disable) computation of the forces applied to the dynamic bodies in this constraint.
 
void setEnableLinearization (bool enable)
 Control whether or not linearization should be performed on the ElementaryConstraints that require it, such as QuatLock.
 
void setSolveType (Constraint::SolveType type)
 Set solve type, either DIRECT, ITERATIVE or DIRECT_AND_ITERATIVE.
 
void sort ()
 This method will sort this constraint by global indexing of the bodies.
 
virtual CALLABLE_IGNORE void updateComplianceMatrix (LSquareComplianceMatrix matrix) const
 Callback with read/write access to the compliance matrix of this constraint in the direct solver.
 
virtual size_t updateJacobian (agx::Jacobian6DOFElement *jacobians)
 Updated storing of Jacobian matrices.
 
virtual bool updateValid ()
 Updates the valid conditions for this constraint.
 
virtual agx::AttachmentuserAPIgetAttachment (agx::UInt) const
 
virtual agx::AttachmentuserAPIgetAttachment (const agx::RigidBody *) const
 
agx::Real userAPIgetCompliance (agx::UInt dof) const
 
agx::Real userAPIgetCurrentForce (agx::UInt dof) const
 Consider using getLastForce instead.
 
agx::Real userAPIgetDamping (agx::UInt dof) const
 
agx::RangeReal userAPIgetForceRange (agx::UInt dof) const
 Get the force range for DOF dof.
 
agx::RegularizationParametersuserAPIgetRegularizationParameters (agx::UInt i)
 Get the regularization parameter i, i.e., the regularization parameter for equation i which is constraint dependent.
 
const agx::RegularizationParametersuserAPIgetRegularizationParameters (agx::UInt i) const
 
void userAPIsetCompliance (agx::Real compliance, int dof)
 Set the compliance for constraint row i of this constraint.
 
void userAPIsetDamping (agx::Real damping, int dof)
 Set the damping for constraint row i of this constraint.
 
void userAPIsetForceRange (agx::RangeReal forceRange, agx::Int dof)
 Assign force range, of an elementary constraint, for a given DOF.
 
- 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 Attributes

AttachmentPair m_attachmentPair
 
Vec3Vector m_lastForces
 
- Protected Attributes inherited from agx::ConstraintImplementation
UInt m_blockRowIndex
 Start block row for this constraint in the global matrix.
 
BlockStructure m_blockStructure
 The block structure; number of block, rows, dynamic blocks etc.
 
ConstraintRigidBodyContainer m_bodies
 Vector with observer pointers to bodies.
 
ConstrainedBodiesState m_constrainedBodiesState
 State of the included bodies, updated in updateValid.
 
ElementaryConstraint::RefContainer m_ec
 Vector of elementary constraints.
 
bool m_enable
 User controlled enable flag, constraint ignored by solver if false.
 
bool m_enableLinearization
 When necessary, tweak the values sent to the solver to make violation depend linearly on force or torque.
 
LocalState m_localState
 Current local state, updated all the time, not serialized.
 
UInt m_numRows
 Number of rows used by this constraint.
 
ElementaryConstraint::RefContainer m_sc
 Vector of secondary constraints.
 
Constraint::SolveType m_solveType
 Only for supported solvers.
 
ConstraintImplPtrVector m_subConstraints
 Vector with sub-constraints.
 
int m_tag
 Tag for this constraint.
 

Additional Inherited Members

- 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.
 
- Public Attributes inherited from agx::ConstraintImplementation
void * customData
 Custom data for the solvers to store data into.
 
- Protected Types inherited from agx::ConstraintImplementation
using LocalState = agx::BitState< State, Int32 >
 
enum  State : Int32 { VALID = 1 << 0 , IMPACTING = 1 << 1 , SUPPORTS_COMPLIANCE_MATRIX = 1 << 2 }
 
- Protected Member Functions inherited from agx::ConstraintImplementation
void setSimulation (agxSDK::Simulation *simulation)
 Set the Simulation this constraint belongs to.
 
void setSupportsComplianceMatrix (Bool supportsComplianceMatrix)
 Enable/disable compliance matrix callbacks from the direct solver where read/write access to the compliance matrix will be available in an implementation of updateComplianceMatrix.
 
- Protected Member Functions inherited from agxStream::Serializable
 Serializable ()
 Default constructor.
 
 Serializable (const Serializable &other)
 Copy constructor.
 
void generateUuid ()
 

Detailed Description

Definition at line 1034 of file ConstraintImplementation.h.

Member Typedef Documentation

◆ CreateElementaryConstraintsFunction

typedef agx::Bool(* agx::HighLevelConstraintImplementation::CreateElementaryConstraintsFunction) (HighLevelConstraintImplementation *)

Definition at line 1196 of file ConstraintImplementation.h.

Constructor & Destructor Documentation

◆ HighLevelConstraintImplementation()

agx::HighLevelConstraintImplementation::HighLevelConstraintImplementation ( )

◆ ~HighLevelConstraintImplementation()

virtual agx::HighLevelConstraintImplementation::~HighLevelConstraintImplementation ( )
virtual

Member Function Documentation

◆ AGXSTREAM_DECLARE_ABSTRACT_SERIALIZABLE()

agx::HighLevelConstraintImplementation::AGXSTREAM_DECLARE_ABSTRACT_SERIALIZABLE ( agx::HighLevelConstraintImplementation  )

◆ bodiesValid()

bool agx::HighLevelConstraintImplementation::bodiesValid ( ) const
Returns
true if one or more bodies are deleted

Definition at line 1416 of file ConstraintImplementation.h.

◆ computeForces() [1/2]

virtual void agx::HighLevelConstraintImplementation::computeForces ( const agx::Jacobian6DOFElement jacobians)
virtual

Computes the forces, if valid and enabled.

Parameters
jacobians- jacobians for this constraint

◆ computeForces() [2/2]

virtual agx::Bool agx::HighLevelConstraintImplementation::computeForces ( const agx::Jacobian6DOFElement jacobians,
agx::Vec3Vector result 
) const
virtual

Computes forces on rb1 and rb2 given this constraint has been solved and all the elementary constraints have their current force updated.

The vector result will be of size 3 * numBodies, where the entries are: [forceOnRb1 torqueOnRb1 addedTorqueDueToAnchorPosRb1 forceOnRb2 torqueOnRb2 addedTorqueDueToAnchorPosRb2] Note that the size is 3 if rb2 == nullptr.

Parameters
jacobians- jacobians for this constraint
result- resulting vector with forces
Returns
true if data was written to result - otherwise false

◆ construct()

bool agx::HighLevelConstraintImplementation::construct ( RigidBody rb1,
Frame rb1AttachmentFrame,
RigidBody rb2,
Frame rb2AttachmentFrame,
CreateElementaryConstraintsFunction  = nullptr 
)

◆ getAngle()

virtual agx::Real agx::HighLevelConstraintImplementation::getAngle ( agx::UInt  dof = 0) const
overridevirtual

If the constraint supports angle calculations and 'dof' is in range, this method returns the angle of the given degree of freedom.

Returns
the angle given degree of freedom - if 'dof' is out of range or if this constraint doesn't support angles this method returns 0

Reimplemented from agx::ConstraintImplementation.

◆ getAttachment() [1/2]

template<typename T >
T * agx::HighLevelConstraintImplementation::getAttachment ( agx::UInt  index)
Returns
the constraint attachment of given type (should always be valid to call after init of a constraint)

Definition at line 1405 of file ConstraintImplementation.h.

◆ getAttachment() [2/2]

template<typename T >
const T * agx::HighLevelConstraintImplementation::getAttachment ( agx::UInt  index) const
Returns
the constraint attachment of given type (should always be valid to call after init of a constraint)

Definition at line 1411 of file ConstraintImplementation.h.

◆ getAttachmentPair()

AttachmentPair * agx::HighLevelConstraintImplementation::getAttachmentPair ( ) const
inlineoverridevirtual
Returns
the constraint attachment pair

Reimplemented from agx::ConstraintImplementation.

Definition at line 1399 of file ConstraintImplementation.h.

◆ getEnableComputeForces()

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

Reimplemented from agx::ConstraintImplementation.

◆ getLastForce() [1/2]

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

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

Reimplemented from agx::ConstraintImplementation.

◆ getLastForce() [2/2]

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

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

Reimplemented from agx::ConstraintImplementation.

◆ getLastLocalForce() [1/2]

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

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

Reimplemented from agx::ConstraintImplementation.

◆ getLastLocalForce() [2/2]

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

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

Reimplemented from agx::ConstraintImplementation.

◆ postSolveCallback()

virtual void agx::HighLevelConstraintImplementation::postSolveCallback ( const agx::Jacobian6DOFElement jacobians,
const agx::Real solution,
agx::Real  dt 
)
overridevirtual

Peak at the solution after the solver is done.

Parameters
jacobians- Jacobian rows for this constraint (index 0 is first dynamic body first row)
solution- solution (impulse - divide by dt to get force)
dt- time step size used to get solution

Reimplemented from agx::ConstraintImplementation.

◆ prepare()

virtual void agx::HighLevelConstraintImplementation::prepare ( )
overridevirtual

Prepares this constraint.

Update attachment transforms given the current transforms of the bodies (in most cases equivalent to calculate the Jacobian), compute the joint angles (if this constraint supports that) and calculates the amount of data needed.

Reimplemented from agx::ConstraintImplementation.

◆ rebind()

virtual bool agx::HighLevelConstraintImplementation::rebind ( )
overridevirtual

The general version of rebind takes the first attachment frame and moves the other attachment frame so they have the exact same world transform.

This means that the first rigid body is the reference (other is another rigid body or world). E.g., Prismatic and Hinge axis will be preserved seen from the reference body.

Returns
true if successful - otherwise false

Reimplemented from agx::ConstraintImplementation.

◆ restore()

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

◆ restoreLightData()

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

◆ setEnableComputeForces()

virtual void agx::HighLevelConstraintImplementation::setEnableComputeForces ( agx::Bool  enable)
overridevirtual

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

Reimplemented from agx::ConstraintImplementation.

◆ setupOneOrTwoBodySystem()

bool agx::HighLevelConstraintImplementation::setupOneOrTwoBodySystem ( RigidBodyAttachment a1,
RigidBodyAttachment a2 
)

◆ store()

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

◆ storeLightData()

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

◆ updateJacobian()

virtual size_t agx::HighLevelConstraintImplementation::updateJacobian ( agx::Jacobian6DOFElement jacobians)
overridevirtual

Updates the Jacobian matrices.

The elementary constraints pushes data into this constraints Jacobian matrices. For some solvers this is equivalent to push the data into the global matrix.

Returns
the number of rows this constraint uses (could differ from time step to time step)

Reimplemented from agx::ConstraintImplementation.

◆ updateValid()

virtual bool agx::HighLevelConstraintImplementation::updateValid ( )
overridevirtual

Updates the valid conditions for this constraint.

This constraint is not valid if for example; one or more bodies are removed (either from simulation or deallocated), one or more bodies are disabled or the number of dynamic bodies in this constraint is zero.

Returns
m_valid, true if valid, otherwise false

Reimplemented from agx::ConstraintImplementation.

◆ userAPIgetAttachment() [1/2]

virtual agx::Attachment * agx::HighLevelConstraintImplementation::userAPIgetAttachment ( agx::UInt  index) const
overridevirtual
Returns
the constraint attachment at index

Reimplemented from agx::ConstraintImplementation.

◆ userAPIgetAttachment() [2/2]

virtual agx::Attachment * agx::HighLevelConstraintImplementation::userAPIgetAttachment ( const agx::RigidBody rb) const
overridevirtual
Returns
the rigid body attachment given a rigid body (returns 0 if invalid)

Reimplemented from agx::ConstraintImplementation.

◆ validateRigidBodiesAndAttachments()

bool agx::HighLevelConstraintImplementation::validateRigidBodiesAndAttachments ( RigidBody rb1,
Frame rb1AttachmentFrame,
RigidBody rb2,
Frame rb2AttachmentFrame 
)

Member Data Documentation

◆ m_attachmentPair

AttachmentPair agx::HighLevelConstraintImplementation::m_attachmentPair
protected

Definition at line 1249 of file ConstraintImplementation.h.

◆ m_lastForces

Vec3Vector agx::HighLevelConstraintImplementation::m_lastForces
protected

Definition at line 1250 of file ConstraintImplementation.h.


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