|
AGX Dynamics
2.37.3.2
|
#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. More... | |
| 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. More... | |
| 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. More... | |
| template<typename T > | |
| T * | getAttachment (agx::UInt index) |
| template<typename T > | |
| const T * | getAttachment (agx::UInt index) const |
| virtual agx::AttachmentPair * | getAttachmentPair () 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. More... | |
| 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. More... | |
| 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. More... | |
| 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. More... | |
| virtual void | postSolveCallback (const agx::Jacobian6DOFElement *jacobians, const agx::Real *solution, agx::Real dt) override |
| Peak at the solution after the solver is done. More... | |
| virtual void | prepare () override |
| Prepares this constraint. More... | |
| 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. More... | |
| 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. More... | |
| 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. More... | |
| virtual bool | updateValid () override |
| Updates the valid conditions for this constraint. More... | |
| virtual agx::Attachment * | userAPIgetAttachment (const agx::RigidBody *rb) const override |
| virtual agx::Attachment * | userAPIgetAttachment (agx::UInt index) const override |
| bool | validateRigidBodiesAndAttachments (RigidBody *rb1, Frame *rb1AttachmentFrame, RigidBody *rb2, Frame *rb2AttachmentFrame) |
Public Member Functions inherited from agx::ConstraintImplementation | |
| ConstraintImplementation () | |
| Default constructor. More... | |
| virtual | ~ConstraintImplementation () |
| Destructor. More... | |
| virtual bool | addElementaryConstraint (const agx::String &name, agx::ElementaryConstraint *elementaryConstraint) |
| Add elementary constraint (like Spherical, Dot1, Dot2 etc) given name. More... | |
| virtual void | addNlCallbacks (agx::SparseRangeReal &sparseRangeReal, const NlmcpCallbackSolverData &solverData) const |
| Interface for non-linear callback from solver. More... | |
| virtual void | addNotification () |
| Callback when this constraint is added to Simulation. More... | |
| virtual bool | addSecondaryConstraint (const agx::String &name, agx::ElementaryConstraint *secondaryConstraint) |
| Add secondary constraint (like motor, range and/or lock etc) given name. More... | |
| agx::UInt | calculateNumActiveRows () const |
| Calculates the current number of active rows, including both elementary and secondary constraints. More... | |
| agx::Real | calculateViolationVectorAverageSize () |
| Gets the average size of the elements in getViolation() by calculating the magnitude and dividing by the number of elements. More... | |
| template<typename T > | |
| T * | findSecondaryConstraintGivenType (const agx::UInt count=0) const |
| bool | getActive () const |
| agx::UInt | getBlockRowIndex () const |
| const BlockStructure & | getBlockStructure () const |
| virtual void | getBounds (agx::RangeReal *bounds, agx::Real dt) const |
| Calculates and pushes the bounds into a sparse range data structure. More... | |
| virtual int | getConstraintVelocity (agx::Real *v, int row) |
| Calculates and pushes the constraint velocities into array given current row. More... | |
| 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. More... | |
| virtual agx::ElementaryConstraint * | getElementaryConstraint (const agx::UInt index) const |
| virtual agx::ElementaryConstraint * | getElementaryConstraint (const agx::String &name) const |
| agx::ElementaryConstraint::RefContainer & | getElementaryConstraints () |
| const agx::ElementaryConstraint::RefContainer & | getElementaryConstraints () const |
| virtual bool | getEnable () const |
| bool | getEnableLinearization () const |
| virtual void | getEpsilon (agx::Real *epsilon, agx::Real h) |
Writes regularization parameters for all active rows into epsilon. More... | |
| agx::FrictionController * | getFrictionController (agx::UInt number=0) const |
| agx::UInt | getJacobianRowUsage () const |
| agx::Lock1D * | getLock1D (agx::UInt number=0) const |
| agx::Motor1D * | getMotor1D (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. More... | |
| agx::Range1D * | getRange1D (agx::UInt number=0) const |
| virtual agx::ElementaryConstraint * | getSecondaryConstraint (const agx::UInt index) const |
| virtual agx::ElementaryConstraint * | getSecondaryConstraint (const agx::String &name) const |
| agx::ElementaryConstraint::RefContainer & | getSecondaryConstraints () |
| const agx::ElementaryConstraint::RefContainer & | getSecondaryConstraints () const |
| bool | getSolveBoth () const |
| bool | getSolveIterative () const |
| SolverBodyView | getSolverView () const |
| Bodies as viewed from the solver. More... | |
| Constraint::SolveType | getSolveType () const |
| ConstraintImplPtrVector & | getSubConstraints () |
| const ConstraintImplPtrVector & | getSubConstraints () const |
| int | getTag () const |
| BodyView | getUserView () const |
| Bodies as viewed from the user. More... | |
| virtual int | getViolation (agx::Real *g, int row) |
| Calculates and pushes the constraint values into array given current row. More... | |
| void | incrementConstraintCount (RigidBody *rb) const |
Increment the number of constraints connection to rb. More... | |
| bool | isImpacting () const |
| bool | isValid () const |
| void | onDirectComplianceMatrix (Real *data, unsigned int ld) const |
| Internal callback from the direct solver with perturbation matrix data. More... | |
| void | postSolveIndexSetCallback (const int8_t *state) |
| Callback after the solver is done about the state of each equation in the constraint. More... | |
| virtual void | postSystemCallback (DynamicsSystem *system) |
| Last in the dynamics system step forward loop, this constraint gets a call with the main system. More... | |
| 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. More... | |
| virtual bool | removeElementaryConstraint (agx::ElementaryConstraint *elementaryConstraint) |
| Remove elementary constraint. More... | |
| virtual bool | removeElementaryConstraint (const agx::String &name) |
| Remove elementary constraint. More... | |
| virtual void | removeNotification () |
| Callback when this constraint is removed from Simulation. More... | |
| virtual bool | removeSecondaryConstraint (agx::ElementaryConstraint *secondaryConstraint) |
| Remove secondary constraint. More... | |
| virtual bool | removeSecondaryConstraint (const agx::String &name) |
| Remove secondary constraint. More... | |
| void | reset () |
| Reset the solution vectors of the primary and secondary elementary constraints in the implementation. More... | |
| void | setBlockRowIndex (agx::UInt blockRowIndex) |
| Sets the global start index for this constraint in the global, non-permuted matrix. More... | |
| virtual void | setEnable (bool enable) |
| Sets the enable flag. More... | |
| void | setEnableLinearization (bool enable) |
| Control whether or not linearization should be performed on the ElementaryConstraints that require it, such as QuatLock. More... | |
| void | setSolveType (Constraint::SolveType type) |
| Set solve type, either DIRECT, ITERATIVE or DIRECT_AND_ITERATIVE. More... | |
| void | sort () |
| This method will sort this constraint by global indexing of the bodies. More... | |
| virtual CALLABLE_IGNORE void | updateComplianceMatrix (LSquareComplianceMatrix matrix) const |
| Callback with read/write access to the compliance matrix of this constraint in the direct solver. More... | |
| agx::Real | userAPIgetCompliance (agx::UInt dof) const |
| agx::Real | userAPIgetCurrentForce (agx::UInt dof) const |
Consider using getLastForce instead. More... | |
| agx::Real | userAPIgetDamping (agx::UInt dof) const |
| agx::RangeReal | userAPIgetForceRange (agx::UInt dof) const |
Get the force range for DOF dof. More... | |
| agx::RegularizationParameters * | userAPIgetRegularizationParameters (agx::UInt i) |
| Get the regularization parameter i, i.e., the regularization parameter for equation i which is constraint dependent. More... | |
| const agx::RegularizationParameters * | userAPIgetRegularizationParameters (agx::UInt i) const |
| void | userAPIsetCompliance (agx::Real compliance, int dof) |
| Set the compliance for constraint row i of this constraint. More... | |
| void | userAPIsetDamping (agx::Real damping, int dof) |
| Set the damping for constraint row i of this constraint. More... | |
| void | userAPIsetForceRange (agx::RangeReal forceRange, agx::Int dof) |
| Assign force range, of an elementary constraint, for a given DOF. More... | |
Public Member Functions inherited from agxStream::Serializable | |
| virtual | ~Serializable () |
| Destructor for normal C++ use but hidden from SWIG bindings. More... | |
| virtual const char * | getClassName () const |
| bool | getEnableSerialization () const |
| bool | getEnableUuidGeneration () |
| agx::UInt32 | getIndex () const |
| This index is given at creation of this object. More... | |
| 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. More... | |
| void | setFinished () |
| Tells this class that it is restored correctly and should not be deleted during destruction of an Archive. More... | |
| void | setUuid (const agx::Uuid &uuid) |
| Explicitly set a Uuid on a serializable object. More... | |
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. More... | |
| BlockStructure | m_blockStructure |
| The block structure; number of block, rows, dynamic blocks etc. More... | |
| ConstraintRigidBodyContainer | m_bodies |
| Vector with observer pointers to bodies. More... | |
| ConstrainedBodiesState | m_constrainedBodiesState |
| State of the included bodies, updated in updateValid. More... | |
| ElementaryConstraint::RefContainer | m_ec |
| Vector of elementary constraints. More... | |
| bool | m_enable |
| User controlled enable flag, constraint ignored by solver if false. More... | |
| bool | m_enableLinearization |
| When necessary, tweak the values sent to the solver to make violation depend linearly on force or torque. More... | |
| LocalState | m_localState |
| Current local state, updated all the time, not serialized. More... | |
| UInt | m_numRows |
| Number of rows used by this constraint. More... | |
| ElementaryConstraint::RefContainer | m_sc |
| Vector of secondary constraints. More... | |
| Constraint::SolveType | m_solveType |
| Only for supported solvers. More... | |
| ConstraintImplPtrVector | m_subConstraints |
| Vector with sub-constraints. More... | |
| int | m_tag |
| Tag for this constraint. More... | |
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. More... | |
Public Attributes inherited from agx::ConstraintImplementation | |
| void * | customData |
| Custom data for the solvers to store data into. More... | |
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. More... | |
| 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. More... | |
Protected Member Functions inherited from agxStream::Serializable | |
| Serializable () | |
| Default constructor. More... | |
| Serializable (const Serializable &other) | |
| Copy constructor. More... | |
| void | generateUuid () |
Definition at line 1028 of file ConstraintImplementation.h.
| typedef agx::Bool(* agx::HighLevelConstraintImplementation::CreateElementaryConstraintsFunction) (HighLevelConstraintImplementation *) |
Definition at line 1190 of file ConstraintImplementation.h.
| agx::HighLevelConstraintImplementation::HighLevelConstraintImplementation | ( | ) |
|
virtual |
| agx::HighLevelConstraintImplementation::AGXSTREAM_DECLARE_ABSTRACT_SERIALIZABLE | ( | agx::HighLevelConstraintImplementation | ) |
| bool agx::HighLevelConstraintImplementation::bodiesValid | ( | ) | const |
Definition at line 1410 of file ConstraintImplementation.h.
|
virtual |
Computes the forces, if valid and enabled.
| jacobians | - jacobians for this constraint |
|
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.
| jacobians | - jacobians for this constraint |
| result | - resulting vector with forces |
result - otherwise false | bool agx::HighLevelConstraintImplementation::construct | ( | RigidBody * | rb1, |
| Frame * | rb1AttachmentFrame, | ||
| RigidBody * | rb2, | ||
| Frame * | rb2AttachmentFrame, | ||
| CreateElementaryConstraintsFunction | = nullptr |
||
| ) |
|
overridevirtual |
If the constraint supports angle calculations and 'dof' is in range, this method returns the angle of the given degree of freedom.
Reimplemented from agx::ConstraintImplementation.
| T * agx::HighLevelConstraintImplementation::getAttachment | ( | agx::UInt | index | ) |
Definition at line 1399 of file ConstraintImplementation.h.
| const T * agx::HighLevelConstraintImplementation::getAttachment | ( | agx::UInt | index | ) | const |
Definition at line 1405 of file ConstraintImplementation.h.
|
inlineoverridevirtual |
Reimplemented from agx::ConstraintImplementation.
Definition at line 1393 of file ConstraintImplementation.h.
|
overridevirtual |
Reimplemented from agx::ConstraintImplementation.
|
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).
| 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. |
retForce and retTorque - otherwise false Reimplemented from agx::ConstraintImplementation.
|
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).
| 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. |
retForce and retTorque - otherwise false Reimplemented from agx::ConstraintImplementation.
|
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).
| 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. |
retForce and retTorque - otherwise false Reimplemented from agx::ConstraintImplementation.
|
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).
| 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. |
retForce and retTorque - otherwise false Reimplemented from agx::ConstraintImplementation.
|
overridevirtual |
Peak at the solution after the solver is done.
| 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.
|
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.
|
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.
Reimplemented from agx::ConstraintImplementation.
|
overridevirtual |
Reimplemented in agxDriveTrain::ElectricMotorConstraintImplementation.
|
overridevirtual |
Reimplemented in agxDriveTrain::ElectricMotorConstraintImplementation.
|
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.
| enable | - true to enable, false to disable |
Reimplemented from agx::ConstraintImplementation.
| bool agx::HighLevelConstraintImplementation::setupOneOrTwoBodySystem | ( | RigidBodyAttachment * | a1, |
| RigidBodyAttachment * | a2 | ||
| ) |
|
overridevirtual |
Reimplemented in agxDriveTrain::ElectricMotorConstraintImplementation.
|
overridevirtual |
Reimplemented in agxDriveTrain::ElectricMotorConstraintImplementation.
|
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.
Reimplemented from agx::ConstraintImplementation.
|
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.
Reimplemented from agx::ConstraintImplementation.
|
overridevirtual |
Reimplemented from agx::ConstraintImplementation.
|
overridevirtual |
Reimplemented from agx::ConstraintImplementation.
| bool agx::HighLevelConstraintImplementation::validateRigidBodiesAndAttachments | ( | RigidBody * | rb1, |
| Frame * | rb1AttachmentFrame, | ||
| RigidBody * | rb2, | ||
| Frame * | rb2AttachmentFrame | ||
| ) |
|
protected |
Definition at line 1243 of file ConstraintImplementation.h.
|
protected |
Definition at line 1244 of file ConstraintImplementation.h.