30# pragma warning(disable: 6011)
43 class ConstraintNlmcpCallback;
48 enum Enum { NORMAL, IGNORE_FIRST, WRITE_SECOND_FIRST };
383 static constexpr size_t NumRows = N;
387 using RegData = std::array<agx::RegularizationParameters, NumRows>;
399 template<agx::UInt N>
440 template<agx::UInt N,
typename DataT>
458 const DataT&
getData()
const {
return m_data; }
546 agx::GWriteState::Enum writeState)
override;
744 agx::GWriteState::Enum writeState )
override;
752 agx::GWriteState::Enum writeState,
827 enum InternalState { NONE = 0, LOCKED = (1<<0), LOCKED_AT_ZERO_SPEED = (1<<1) };
970 using Flags = agx::BitState<Flag, agx::UInt16>;
976 Real m_frictionCoefficient;
977 Real m_lastNormalForce;
1307 agx::GWriteState::Enum writeState)
override;
1482 return &
m_rps[ row ];
1488 return &
m_rps[ row ];
1509 return m_internalData;
1515# pragma warning(pop)
#define AGXSTREAM_DECLARE_SERIALIZABLE(T)
Use this in a Serializable class to add the required methods Important: Use full namespace in the dec...
#define AGXPHYSICS_EXPORT
Class for writing serialized data in binary format to a stream.
Abstract base class for storing/restoring a line/drums with version control.
Type
Type, i.e., defines Axis as 'along' or 'about'.
Constraint attachment pair class.
Base class for constraint angle based elementary constraints (secondary constraints).
virtual void restore(agxStream::InputArchive &in) override
Restore this object from stream.
BasicControllerConstraint()
Used during serialization restore.
virtual agx::UInt writeJacobian(agx::Jacobian6DOFElement *G, agx::UInt numBlocks, agx::UInt row, agx::GWriteState::Enum writeState, const agx::Vec3 &dir1, const agx::Vec3 &dir2, agx::Angle::Type type) const
Internal utility method to write the Jacobian given direction and angle type.
AGXSTREAM_DECLARE_ABSTRACT_SERIALIZABLE(agx::BasicControllerConstraint)
virtual void store(agxStream::OutputArchive &out) const override
Store this object to stream.
virtual agx::UInt getJacobian(agx::Jacobian6DOFElement *G, agx::UInt numBlocks, agx::UInt row, agx::GWriteState::Enum writeState) override
Default constraint callback for writing Jacobian.
BasicControllerConstraint(const agx::ConstraintAngleBasedData &data, agx::Bool enable)
Construct given data containing angle and default enable flag.
Basic data holder class for cone limit constraint data.
Elementary secondary constraint to set a conic limit to a BallJoint.
void setLimitAngles(Real a1, Real a2)
Set the cone limit angles, which defines the max angle in two different directions.
virtual void prepare() override
Prepare call.
virtual Bool isActive() const override
Real getCurrentAngle() const
Get the current angle between the centre of the cone limit and the axis limited by the constraint.
virtual UInt getJacobian(Jacobian6DOFElement *G, UInt numBlocks, UInt row, GWriteState::Enum writeState) override
Vec2 getLimitAngles() const
Get the cone limit angles, which defines how much a rod in a ball joint can rotate.
virtual ~ConeLimit()
Reference counted object, protected destructor.
static agx::ConeLimit * safeCast(const agx::ElementaryConstraint *coneLimit)
Utility cast method.
virtual agx::UInt getViolation(agx::Real *g, agx::UInt row) override
Returns the violation of this elementary constraint.
ConeLimit(const ConeLimitData &data)
Constructor for ConeLimit.
virtual agx::UInt getBounds(agx::RangeReal *bounds, agx::UInt row, agx::Real h) const override
Returns the bounds of the Lagrange Multipliers (default (-inf, +inf)).
void setLimitAngles(Real coneAngle)
Set the cone limit angles to the same angle, creating a circular limit.
void setLimitAngles(Vec2 limit)
Set the cone limit angles, which defines the max angle in two different directions.
ConeLimit()
Used during serialization restore.
Basic data holder class for "angle based" (secondary) constraints.
Constraint solver callback interface with context and start rows for context.
Data holder class for elementary constraint Dot1.
Dot1 elementary constraint: Two orthogonal vectors.
Dot1()
Used during serialization restore.
Dot1(const agx::Dot1Data &data)
Construct given Dot1Data.
virtual agx::UInt getJacobian(agx::Jacobian6DOFElement *G, agx::UInt numBlocks, agx::UInt row, agx::GWriteState::Enum writeState) override
Returns the Jacobian of this elementary constraint.
virtual agx::UInt getViolation(agx::Real *g, agx::UInt row) override
Returns the violation of this elementary constraint.
virtual ~Dot1()
Reference counted object, protected destructor.
Data holder class for elementary constraint Dot2.
Dot2 elementary constraint: Separation vector orthogonal to direction vector.
Dot2()
Used during serialization restore.
virtual agx::UInt getViolation(agx::Real *g, agx::UInt row) override
Returns the violation of this elementary constraint.
Dot2(const agx::Dot2Data &data)
Construct given Dot2Data.
virtual ~Dot2()
Reference counted object, protected destructor.
virtual agx::UInt getJacobian(agx::Jacobian6DOFElement *G, agx::UInt numBlocks, agx::UInt row, agx::GWriteState::Enum writeState) override
Returns the Jacobian of this elementary constraint.
Implementation of a electric motor controller.
virtual void storeLightData(agxStream::StorageStream &str) const override
Store structural independent data to stream.
virtual agx::UInt getVelocity(agx::Real *v, agx::UInt row) const override
Returns the velocity of this elementary constraint (extra, driving term on the right hand side).
agx::Real getArmatureResistance() const
virtual void restoreLightData(agxStream::StorageStream &str) override
Restore structural independent data from stream.
void setArmatureResistance(agx::Real armatureResistance)
Assign armature resistance (Ohm).
agx::Real m_armatureResistance
ElectricMotorController(const agx::ConstraintAngleBasedData &data)
Construct given basic controller data.
virtual agx::UInt getViolation(agx::Real *v, agx::UInt row) override
Returns the violation of this elementary constraint.
ElectricMotorController()
void setTorqueConstant(agx::Real torqueConstant)
Assign torque constant of this motor in unit torque per Ampere.
void setVoltage(agx::Real voltage)
Available voltage or voltage drop across the terminals of this motor.
virtual ~ElectricMotorController()
static agx::ElectricMotorController * safeCast(const agx::ElementaryConstraint *electricMotorController)
Utility cast method.
virtual void prepare() override
Prepare call.
agx::Real getVoltage() const
agx::Real getTorqueConstant() const
agx::Real m_torqueConstant
Class to hold data for elementary constraints.
ElementaryConstraintNData(const ElementaryConstraintNData &)=delete
ElementaryConstraintNData & operator=(const ElementaryConstraintNData &)=delete
virtual void setAttachmentPair(const agx::AttachmentPair *ap) override
Data has to support assignment of attachment pair.
ElementaryConstraintNData(const DataT &data, agx::Bool enable)
Construct given data and enable flag.
const DataT & getData() const
ElementaryConstraintNData()
Helper class to hold data that is general for elementary constraints.
ElementaryConstraintN(agx::Bool enable)
Construct given enable flag.
agx::RangeReal m_bounds[N]
Bounds buffer.
agx::Real m_forces[N]
Forces buffer.
agx::RegularizationParameters m_regParams[N]
Regularization parameters buffer.
ElementaryConstraintN()
Used during serialization restore.
Elementary constraint base class with interface and global constraint functionality.
virtual agx::UInt getBounds(agx::RangeReal *bounds, agx::UInt row, agx::Real h) const
Returns the bounds of the Lagrange Multipliers (default (-inf, +inf)).
virtual void prepare()
Prepare call.
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)
virtual agx::Bool isImpacting() const
virtual void setAttachmentPair(const agx::AttachmentPair *ap)
Call for elementary constraints dependent on attachment pairs.
agx::Real * m_lfs
last forces
agx::RegularizationParameters * getRegularizationParameters(const agx::UInt row=0)
agx::Vector< agx::ref_ptr< agx::ElementaryConstraint > > RefContainer
virtual agx::ConstraintNlmcpCallback * getNlCallback() const
virtual agx::Bool getEnable() const
agx::RangeReal * m_ubs
user bounds
virtual agx::Real getCurrentForce(const agx::UInt row=0) const
Returns the force applied last time step by this elementary constraint.
agx::RangeReal & getForceRange(const agx::UInt row=0)
void setForceRange(agx::Real lower, agx::Real upper, const agx::UInt row=0)
Assign force range to a given row.
const agx::ElementaryConstraint::NameType & getName() const
void copyRowFrom(const ElementaryConstraint *source, agx::UInt sourceRow, agx::UInt destRow)
Copy configuration row from the given ElementaryConstraint into this.
virtual ~ElementaryConstraint()
Reference counted object, protected destructor.
void setForceRange(agx::RangeReal forceRange, const agx::UInt row=0)
Assign force range to a given row.
void setName(const agx::ElementaryConstraint::NameType &name)
Name this elementary constraint.
virtual agx::UInt getJacobian(agx::Jacobian6DOFElement *G, agx::UInt numBlocks, agx::UInt row, agx::GWriteState::Enum writeState)
Returns the Jacobian of this elementary constraint.
void setElasticity(agx::Real elasticity, int row)
Assign elasticity for a given row, or all rows if row = -1 (default).
agx::ElementaryConstraint::NameType m_name
name
virtual void restoreLightData(agxStream::StorageStream &str) override
Restore structural independent data from stream.
virtual void setEnable(agx::Bool enable)
Enable/disable this elementary constraint.
agx::UInt m_numRows
number of rows
virtual agx::UInt getViolation(agx::Real *g, agx::UInt row)
Returns the violation of this elementary constraint.
agx::UInt getNumRows() const
agx::VectorPOD< agx::ElementaryConstraint * > PtrContainer
ElementaryConstraint(agx::Bool enable, agx::UInt numRows, agx::RegularizationParameters *regParamsBuffer, agx::Real *lastForcesBuffer, agx::RangeReal *userBoundsBuffer)
Construct given data.
virtual agx::Bool isActive() const
An elementary constraint is defined to be active if enabled.
virtual agx::UInt postSolveCallback(const agx::Real *solution, agx::UInt row, agx::Real h)
Callback after solve, with the solution.
void setDamping(agx::Real damping)
const agx::RangeReal & getForceRange(const agx::UInt row=0) const
void setCompliance(agx::Real compliance, int row)
Assign compliance for a given row, or all rows if row = -1 (default).
const agx::Real * getCurrentForces() const
void setCompliance(agx::Real compliance)
virtual void restore(agxStream::InputArchive &in) override
Restore this object from stream.
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).
agx::RegularizationParameters * m_rps
regularization parameters
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 spa...
agx::Real getCompliance(agx::UInt row=0) const
AGXSTREAM_DECLARE_ABSTRACT_SERIALIZABLE(agx::ElementaryConstraint)
virtual void store(agxStream::OutputArchive &out) const override
Store this object to stream.
agx::ref_ptr< agx::Referenced > m_internalData
custom, internal data
virtual void storeLightData(agxStream::StorageStream &str) const override
Store structural independent data to stream.
agx::Bool m_enable
enabled
agx::Real getElasticity(agx::UInt row=0) const
agx::Real getDamping(agx::UInt row=0) const
Solver callback class for elementary FrictionController.
Translational or rotational friction controller for Hinge, Prismatic and CylindricalJoint.
ConstraintNlmcpCallback * getNlCallback() const override
void setMinimumStaticFrictionForceRange(agx::RangeReal bound)
Set the minimum force range that this friction controller can apply.
virtual agx::UInt getViolation(agx::Real *g, agx::UInt row) override
Returns the violation of this elementary constraint.
agx::Real getFrictionCoefficient() const
virtual void storeLightData(agxStream::StorageStream &str) const override
/internal
virtual agx::UInt getBounds(agx::RangeReal *bounds, agx::UInt row, agx::Real h) const override
Returns the bounds of the Lagrange Multipliers (default (-inf, +inf)).
FrictionController(const agx::ConstraintAngleBasedData &data)
Construct given angle based data.
virtual ~FrictionController()
void setFrictionCoefficient(agx::Real frictionCoefficient)
Assign friction coefficient.
agx::Bool getEnableNonLinearDirectSolveUpdate() const
agx::UInt iterativePostSolveCallback(const agx::ConstraintImplementation *constraint, const agx::Real *solution, agx::UInt row, agx::Real h)
virtual agx::UInt postSolveCallback(const agx::Real *solution, agx::UInt row, agx::Real h) override
Callback after solve, with the solution.
static agx::FrictionController * safeCast(const agx::ElementaryConstraint *frictionController)
Utility cast method.
void setEnableNonLinearDirectSolveUpdate(agx::Bool enable)
Enable/disable non-linear update of the friction conditions given current normal force from the direc...
agx::RangeReal getMinimumStaticFrictionForceRange() const
Get the minimum force range that this friction controller can apply.
virtual void restoreLightData(agxStream::StorageStream &str) override
/internal
virtual agx::Bool isActive() const override
Internal data for any object, ObjT, with methods: agx::Referenced* ObjT::getInternalData() const; voi...
Elementary secondary constraint to keep constraint angle at a given target position.
virtual void storeLightData(agxStream::StorageStream &str) const override
Store structural independent data to stream.
virtual ~LockController()
Reference counted object, protected destructor.
agx::Real getPosition() const
virtual agx::UInt getViolation(agx::Real *g, agx::UInt row) override
Returns the violation of this elementary constraint.
LockController()
Used during serialization restore.
void setPosition(agx::Real position)
Assign new target position.
virtual void restoreLightData(agxStream::StorageStream &str) override
Restore structural independent data from stream.
static agx::LockController * safeCast(const agx::ElementaryConstraint *lockController)
Utility cast method.
LockController(const agx::ConstraintAngleBasedData &data)
Construct given constraint angle based data.
Representation of a name string.
Data holder class for elementary constraint QuatLock.
Locks the three rotational degrees of freedom (relative coordinates).
virtual void setAttachmentPair(const agx::AttachmentPair *ap) override
Propagates ap to custom data from QuatLockData.
virtual agx::UInt getViolation(agx::Real *g, agx::UInt row) override
Returns the violation of this elementary constraint.
virtual agx::UInt getJacobian(agx::Jacobian6DOFElement *G, agx::UInt numBlocks, agx::UInt row, agx::GWriteState::Enum writeState) override
Returns the Jacobian of this elementary constraint.
virtual ~QuatLock()
Reference counted object, protected destructor.
QuatLock()
Used during serialization restore.
QuatLock(const agx::QuatLockData &data)
Construct given data.
virtual void linearizeCompliance(const agx::Real *violations, agx::Real *epsilons, agx::Real minPerturbation) const override
Modify epsilon so that this ElementaryConstraint appear to be linear in the "normal" deformantion spa...
Elementary secondary constraint to keep constraint angle within two given values.
virtual void prepare() override
Prepare call.
virtual agx::UInt getViolation(agx::Real *g, agx::UInt row) override
Returns the violation of this elementary constraint.
RangeController()
Used during serialization restore.
virtual void storeLightData(agxStream::StorageStream &str) const override
Store structural independent data to stream.
const agx::RangeReal & getRange() const
virtual agx::UInt getBounds(agx::RangeReal *bounds, agx::UInt row, agx::Real h) const override
Returns the bounds of the Lagrange Multipliers (default (-inf, +inf)).
virtual agx::Bool isActive() const override
agx::RangeReal & getRange()
void setRange(agx::Real lower, agx::Real upper)
Assign range for the constraint angle to between.
void setRange(agx::RangeReal range)
Assign range for the constraint angle to between.
RangeController(const agx::ConstraintAngleBasedData &data)
Construct given constraint angle based data.
static agx::RangeController * safeCast(const agx::ElementaryConstraint *rangeController)
Utility cast method.
virtual ~RangeController()
Reference counted object, protected destructor.
virtual void restoreLightData(agxStream::StorageStream &str) override
Restore structural independent data from stream.
Base class providing referencing counted objects.
All ghost variables have compliance and damping attributes.
ScrewController()
Default constructor used during restore.
static agx::ScrewController * safeCast(const agx::ElementaryConstraint *screwController)
Utility cast method.
virtual ~ScrewController()
Reference counted object, protected destructor.
virtual void restoreLightData(agxStream::StorageStream &str) override
Restore structural independent data from stream.
virtual void storeLightData(agxStream::StorageStream &str) const override
Store structural independent data to stream.
void setLead(agx::Real lead)
Assign lead, i.e., the distance along the screw's axis that is covered by one complete rotation.
agx::Real getLead() const
ScrewController(const agx::ConstraintAngleBasedData &data)
Construct given basic controller data and default lead of the screw.
virtual agx::UInt getJacobian(agx::Jacobian6DOFElement *G, agx::UInt numBlocks, agx::UInt row, agx::GWriteState::Enum writeState) override
Default constraint callback for writing Jacobian.
virtual agx::UInt getViolation(agx::Real *g, agx::UInt row) override
Returns the violation of this elementary constraint.
This class is a combined container which has the find complexity of a HashTable, deterministic iterat...
Spherical elementary constraint: Two points in world coincide.
SphericalRel(const agx::ElementaryConstraintData &data)
Construct given SphericalRelData.
SphericalRel()
Used during serialization restore.
virtual agx::UInt getViolation(agx::Real *g, agx::UInt row) override
Returns the violation of this elementary constraint.
virtual agx::UInt getJacobian(agx::Jacobian6DOFElement *G, agx::UInt numBlocks, agx::UInt row, agx::GWriteState::Enum writeState) override
Returns the Jacobian of this elementary constraint.
virtual ~SphericalRel()
Reference counted object, protected destructor.
Spherical elementary constraint: Two points in world coincide.
Spherical()
Used during serialization restore.
virtual ~Spherical()
Reference counted object, protected destructor.
Spherical(const agx::ElementaryConstraintData &data)
Construct given SphericalData.
virtual agx::UInt getJacobian(agx::Jacobian6DOFElement *G, agx::UInt numBlocks, agx::UInt row, agx::GWriteState::Enum writeState) override
Returns the Jacobian of this elementary constraint.
virtual agx::UInt getViolation(agx::Real *g, agx::UInt row) override
Returns the violation of this elementary constraint.
Data holder class for elementary swing constraint.
Swing elementary constraint: Two orthogonal vectors with hookean behaviour.
Swing()
Used during serialization restore.
Swing(const agx::SwingData &data)
Construct given SwingData.
virtual agx::UInt getViolation(agx::Real *g, agx::UInt row) override
Returns the violation of this elementary constraint.
virtual ~Swing()
Reference counted object, protected destructor.
virtual agx::UInt getJacobian(agx::Jacobian6DOFElement *G, agx::UInt numBlocks, agx::UInt row, agx::GWriteState::Enum writeState) override
Returns the Jacobian of this elementary constraint.
Elementary secondary constraint to drive something given target speed (translational or rotational).
agx::Int32 m_internalState
virtual agx::UInt getViolation(agx::Real *g, agx::UInt row) override
Returns the violation of this elementary constraint.
void adjustToCurrentState()
Updates state dependent variables.
void setLocked(agx::Bool locked)
If is true the target speed will be interpreted as zero and the current angle is the reference angle.
void setLockedAtZeroSpeed(agx::Bool lockedAtZeroSpeed)
If this state is set and the speed is set to zero, the behavior is identical to 'setLocked( true )'.
agx::Bool getLockedAtZeroSpeed() const
virtual void restoreLightData(agxStream::StorageStream &str) override
Restore structural independent data from stream.
static agx::TargetSpeedController * safeCast(const agx::ElementaryConstraint *targetSpeedController)
Utility cast method.
agx::Real getSpeed() const
agx::Bool getLocked() const
TargetSpeedController(const agx::ConstraintAngleBasedData &data)
Construct given constraint angle based data.
virtual ~TargetSpeedController()
Reference counted object, protected destructor.
virtual agx::UInt getVelocity(agx::Real *v, agx::UInt row) const override
Returns the velocity of this elementary constraint (extra, driving term on the right hand side).
virtual void storeLightData(agxStream::StorageStream &str) const override
Store structural independent data to stream.
void setSpeed(agx::Real speed)
Assign target speed for this controller.
agx::Bool isLocked() const
TargetSpeedController()
Used during serialization restore.
Data holder class for elementary constraint Twist.
Twist range elementary constraint.
virtual Bool isActive() const override
TwistRangeController()
Used during serialization restore.
Real getCurrentAngle()
Get current twist angle.
void setRange(RangeReal range)
Set the max/min angle the constrained body can twist around its z-axis.
virtual ~TwistRangeController()
Reference counted object, protected destructor.
virtual void prepare() override
Prepare call.
virtual void setAttachmentPair(const agx::AttachmentPair *ap) override
Data has to support assignment of attachment pair.
virtual agx::UInt getBounds(agx::RangeReal *bounds, agx::UInt row, agx::Real h) const override
Returns the bounds of the Lagrange Multipliers (default (-inf, +inf)).
TwistRangeController(const TwistData &data)
Construct given TwistData.
void setRange(Real min, Real max)
Set the max/min angle the constrained body can twist around its z-axis.
const RangeReal & getRange() const
Get the range that limits the twist around the z-axis.
virtual agx::UInt getViolation(agx::Real *g, agx::UInt row) override
Returns the violation of this elementary constraint.
RangeReal & getRange()
Get the range that limits the twist around the z-axis.
Twist elementary constraint.
virtual agx::UInt getViolation(agx::Real *g, agx::UInt row) override
Returns the violation of this elementary constraint.
Twist()
Used during serialization restore.
virtual agx::UInt getJacobian(agx::Jacobian6DOFElement *G, agx::UInt numBlocks, agx::UInt row, agx::GWriteState::Enum writeState) override
Returns the Jacobian of this elementary constraint.
virtual ~Twist()
Reference counted object, protected destructor.
Twist(const agx::TwistData &data)
Construct given TwistData.
virtual void setAttachmentPair(const agx::AttachmentPair *ap) override
Data has to support assignment of attachment pair.
Vector containing 'raw' data.
Smart pointer for handling referenced counted objects.
#define DOXYGEN_END_INTERNAL_BLOCK()
#define DOXYGEN_START_INTERNAL_BLOCK()
This namespace contain classes for streaming classes into archives, ASCII, binary for storage (serial...
The agx namespace contains the dynamics/math part of the AGX Dynamics API.
agx::ref_ptr< RangeController > RangeControllerRef
agx::ref_ptr< Swing > SwingRef
agx::ref_ptr< ConeLimit > ConeLimitRef
agx::ref_ptr< LockController > LockControllerRef
agx::ref_ptr< Dot2 > Dot2Ref
agx::ref_ptr< ElectricMotorController > ElectricMotorControllerRef
Vec3T< T > min(const Vec3T< T > &lhs, const Vec3T< T > &rhs)
Vec3T< T > max(const Vec3T< T > &lhs, const Vec3T< T > &rhs)
agx::ref_ptr< Spherical > SphericalRef
agx::ref_ptr< SphericalRel > SphericalRelRef
agx::ref_ptr< Dot1 > Dot1Ref
agx::ref_ptr< TwistRangeController > TwistRangeControllerRef
agx::ref_ptr< FrictionController > FrictionControllerRef
agx::ref_ptr< TargetSpeedController > TargetSpeedControllerRef
agx::ref_ptr< Twist > TwistRef
agx::SetVector< ref_ptr< FrictionController > > FrictionControllerRefSetVector
agx::ref_ptr< QuatLock > QuatLockRef
Inherit privately before "public agx::ElementaryConstraint" and pass the data to the ElementaryConstr...
std::array< agx::Real, NumRows > RealData
std::array< agx::RegularizationParameters, NumRows > RegData
std::array< agx::RangeReal, NumRows > BoundData