![]() |
AGX Dynamics 2.40.0.0
|
The hinge constraint between two rigid bodies or one rigid body and the world. More...
#include <Hinge.h>
Public Types | |
enum | DOF { ALL_DOF =-1 , TRANSLATIONAL_1 =0 , TRANSLATIONAL_2 =1 , TRANSLATIONAL_3 =2 , ROTATIONAL_1 =3 , ROTATIONAL_2 =4 , NUM_DOF =5 } |
Enum used for specifying which Degree of Freedom (DOF) that should be accessed in calls to for example: constraint->getRegularizationParameters( dof ); constraint->setDamping( damping, dof );. More... | |
![]() | |
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 | |
Hinge () | |
Default constructor. | |
Hinge (const HingeFrame &hf, RigidBody *rb1, RigidBody *rb2=0) | |
Create hinge given a hinge frame (world coordinates) and one or two rigid bodies. | |
Hinge (RigidBody *rb1, Frame *rb1AttachmentFrame, RigidBody *rb2=nullptr, Frame *rb2AttachmentFrame=nullptr) | |
Create hinge given attachment frames and one or two rigid bodies. | |
bool | addRigidBody (RigidBody *rb, Frame *rbAttachmentFrame) |
Create hinge given attachment frame and one body at the time. | |
AGXSTREAM_DECLARE_SERIALIZABLE_BASE (agx::Hinge) | |
int | getNumDOF () const override |
![]() | |
agx::Real | getAngle () const |
This method return the current angle for the 1D constraint. | |
agx::Real | getCurrentSpeed () const |
This methods return the current speed for the 1D constraint. | |
agx::ElectricMotorController * | getElectricMotorController () |
const agx::ElectricMotorController * | getElectricMotorController () const |
agx::FrictionController * | getFrictionController () |
const agx::FrictionController * | getFrictionController () const |
agx::Lock1D * | getLock1D () |
const agx::Lock1D * | getLock1D () const |
agx::Motor1D * | getMotor1D () |
const agx::Motor1D * | getMotor1D () const |
agx::Range1D * | getRange1D () |
const agx::Range1D * | getRange1D () const |
![]() | |
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::Attachment * | getAttachment (agx::UInt i) const |
agx::RigidBodyAttachment * | getAttachment (const agx::RigidBody *rb) const |
agx::AttachmentPair * | getAttachmentPair () const |
agx::RigidBody * | getBodyAt (agx::UInt i) |
const agx::RigidBody * | getBodyAt (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::ElementaryConstraint * | getElementaryConstraint (const agx::UInt index) const |
agx::ElementaryConstraint * | getElementaryConstraintGivenName (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::RegularizationParameters * | getRegularizationParameters (agx::UInt i) |
virtual const agx::RegularizationParameters * | getRegularizationParameters (agx::UInt i) const |
agx::ConstraintImplementation * | getRep () |
const agx::ConstraintImplementation * | getRep () const |
agx::ElementaryConstraint * | getSecondaryConstraint (const agx::UInt index) const |
agx::ElementaryConstraint * | getSecondaryConstraintGivenName (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 |
![]() | |
Interaction () | |
Default constructor. | |
AGXSTREAM_DECLARE_SERIALIZABLE_BASE (agx::Interaction) | |
const agx::Name & | getName () const |
agx::PropertyContainer * | getPropertyContainer () |
const agx::PropertyContainer * | getPropertyContainer () const |
agxSDK::SimulationProxy * | getSimulationProxy () 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. | |
![]() | |
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. | |
Referenced & | operator= (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. | |
![]() | |
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 agxStream::Serializable * | create (agxStream::InputArchive &) |
![]() | |
static agx::Constraint1DOF * | safeCast (const agx::Constraint *constraint) |
Utility method for not so type safe languages. | |
![]() | |
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 agxStream::Serializable * | create (agxStream::InputArchive &) |
![]() | |
template<typename T > | |
static bool | ValidateCast (const Referenced *object) |
![]() | |
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 | |
virtual | ~Hinge () |
virtual void | render (class agxRender::RenderManager *mgr, float scale) const override |
Used internally for debug rendering. | |
![]() | |
Constraint1DOF () | |
virtual | ~Constraint1DOF () |
![]() | |
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 *) |
![]() | |
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. | |
![]() | |
virtual | ~Referenced () |
Destructor. | |
void | allocateObserverVector () const |
void | deleteUsingDeleteHandler () const |
![]() | |
Serializable () | |
Default constructor. | |
Serializable (const Serializable &other) | |
Copy constructor. | |
void | generateUuid () |
Additional Inherited Members | |
![]() | |
static DeleteHandler * | getDeleteHandler () |
static void | setDeleteHandler (DeleteHandler *handler) |
Internal: Set a DeleteHandler to which deletion of all referenced counted objects will be delegated to. | |
![]() | |
agx::ConstraintImplementation * | m_implementation |
![]() | |
Mutex | m_mutex |
ObserverContainer | m_observers |
AtomicValue | m_refCount |
The hinge constraint between two rigid bodies or one rigid body and the world.
The hinge constraint maintains a constant rotational axis between two rigid bodies and allows rotation about this axis. By default, there is no control on the relative angle between the two bodies and in fact, the relative rotational angle is not computed. By using the DOFController object and setting flags and other parameters, the relative angle can be computed. It can also be limited to a given range, locked at a given value, or motorized using a velocity or a position constraint. When a joint limit is reached, an inequality constraint is added to the system to enforce the joint limit. If the motor or lock control is already turned ON, both constraints can be active, and it is up to the solver to compute the correct solution.
When setting up the hinge constraint, the user can simply pass a HingeFrame object to the constraint. The "Z" axis of the frame will then be used as the hinge axis. This is not to say that the constraint will keep that axis in world coordinates, only that at the instant following configuration, the hinge axis will be coincident with the "Z" axis of the given frame. Correspondingly, by default, the joint angle will be computed in the "XY" plane of the given frame so that zero angle corresponds to the hinge frame aligned along the original "X" axis.
In addition, the configuration of the hinge can be done by setting the attachment frames of each of the bodies. When doing that, the constraint will then operate to make the two "Z" axes parallel, and the origins of the two frames coincident.
enum agx::Hinge::DOF |
Enum used for specifying which Degree of Freedom (DOF) that should be accessed in calls to for example: constraint->getRegularizationParameters( dof ); constraint->setDamping( damping, dof );.
agx::Hinge::Hinge | ( | ) |
Default constructor.
Should be used with the addRigidBody method.
agx::Hinge::Hinge | ( | const HingeFrame & | hf, |
RigidBody * | rb1, | ||
RigidBody * | rb2 = 0 |
||
) |
Create hinge given a hinge frame (world coordinates) and one or two rigid bodies.
The hinge axis and attachment point are given in world coordinates.
hf | - HingeFrame defining the hinge |
rb1 | - First body (invalid if null) |
rb2 | - Second body connected with the hinge (if null, first rigid body will be attached in world) |
agx::Hinge::Hinge | ( | RigidBody * | rb1, |
Frame * | rb1AttachmentFrame, | ||
RigidBody * | rb2 = nullptr , |
||
Frame * | rb2AttachmentFrame = nullptr |
||
) |
Create hinge given attachment frames and one or two rigid bodies.
The attachment frame is relative its body with the hinge axis pointing in the z-direction of the attachment frame. If rb2 == rb2AttachmentFrame == 0 the first body will be attached to the world given rb1AttachmentFrame. If rb2 == 0 and rb2AttachmentFrame != 0, then rb2AttachmentFrame will be used as the world frame attachment.
rb1 | - First rigid body (invalid if null) |
rb1AttachmentFrame | - First rigid body attachment frame (invalid if null) |
rb2 | - Second rigid body (if null, first rigid body will be attached in world) |
rb2AttachmentFrame | - Second rigid body attachment frame (invalid if rb2 != 0 and this is null) |
|
protectedvirtual |
Create hinge given attachment frame and one body at the time.
This is only valid for two bodies, i.e., it's not possible to use this method with bodies attached to the world. When the second body has been added, this constraint will calculate its initial state and is after that ready to be added to the simulation.
rb | - Current rigid body to be added to this constraint |
rbAttachmentFrame | - Attachment frame of the current rigid body |
agx::Hinge::AGXSTREAM_DECLARE_SERIALIZABLE_BASE | ( | agx::Hinge | ) |
|
inlinestatic |
|
overridevirtual |
Implements agx::Constraint.
|
overrideprotectedvirtual |
Used internally for debug rendering.
Implements agx::Constraint.