 |
AGXDynamics
2.35.0.3
|
Go to the documentation of this file.
17 #ifndef AGX_CONSTRAINT_IMPLEMENTATION_H
18 #define AGX_CONSTRAINT_IMPLEMENTATION_H
35 # pragma warning(push)
36 # pragma warning( disable : 4251 ) // class X needs to have dll-interface to be used by clients of class Y
39 #define DEFAULT_COMPLIANCE 1.0E-8
41 #define CONSTRAINT_SUCCESS( success ) \
43 LOGGER_WARNING() << "Unable to create constraint. Constraint cleared." << std::endl << LOGGER_END(); \
45 m_localState.remove( VALID ); \
49 #define CONSTRAINT_SUCCESS_RETURN_BOOL( success ) \
51 LOGGER_WARNING() << "Unable to create constraint. Constraint cleared." << std::endl << LOGGER_END(); \
53 m_localState.remove( VALID ); \
60 class ElementaryConstraint;
62 class RegularizationParameters;
63 class SparseRangeReal;
64 class LSquareComplianceMatrix;
75 : m_numBlocks( 0 ), m_numRows( 0 ), m_numDynBlocks( 0 ) {}
107 DEFAULT_BINARY_TAG = NONE,
108 DEFAULT_MANY_BODY_TAG = MANY_BODY
216 agx::UInt getNumRecurrentMergedBodies()
const;
224 UInt m_numRecurrentMergedBodies;
231 #if !defined(SWIGPYTHON)
346 #if !defined(SWIGPYTHON)
366 virtual bool updateValid();
374 virtual void prepare();
390 virtual int getViolation(
agx::Real* g,
int row );
397 agx::Real calculateViolationVectorAverageSize();
409 virtual void getParameters(
agx::Real* violation,
415 int8_t* indexSetState,
426 virtual int getConstraintVelocity(
agx::Real* v,
int row );
450 void onDirectComplianceMatrix(
Real* data,
unsigned int ld )
const;
464 void postSolveIndexSetCallback(
const int8_t* state );
629 virtual void setEnable(
bool enable);
653 virtual void setEnableComputeForces(
agx::Bool enable );
658 virtual agx::Bool getEnableComputeForces()
const;
746 void setEnableLinearization(
bool enable);
751 bool getEnableLinearization()
const;
803 virtual bool removeElementaryConstraint(
const agx::String& name );
810 virtual bool removeSecondaryConstraint(
const agx::String& name );
839 template<
typename T >
840 T* findSecondaryConstraintGivenType(
const agx::UInt count = 0 )
const;
894 void userAPIsetCompliance(
agx::Real compliance,
int dof );
906 void userAPIsetDamping(
agx::Real damping,
int dof );
939 agx::UInt calculateNumActiveRows()
const;
982 SUPPORTS_COMPLIANCE_MATRIX = 1 << 2
1002 void setSupportsComplianceMatrix(
Bool supportsComplianceMatrix );
1041 virtual bool updateValid()
override;
1049 virtual void prepare()
override;
1073 virtual bool rebind()
override;
1099 virtual void setEnableComputeForces(
agx::Bool enable )
override;
1104 virtual agx::Bool getEnableComputeForces()
const override;
1220 bool bodiesValid()
const;
1225 template<
typename T >
1231 template<
typename T >
1232 const T* getAttachment(
agx::UInt index )
const;
1249 return m_numDynamicBodies;
1254 return m_numDynamicBodies;
1259 return m_numNonStaticBodies;
1264 return m_numNonStaticBodies;
1269 return m_originalInfo;
1274 return m_solverInfo;
1279 return m_permutation;
1284 return m_permutation;
1289 return m_bodyIndices;
1294 return m_bodyIndices;
1301 #if !defined(SWIGPYTHON)
1312 return m_info.numDynamicBodies();
1317 return m_info.numNonStaticBodies();
1340 :
BodyView( state.getSolverInfo(), state.getSolverBodies() ), m_state( state )
1345 :
BodyView( other.m_state.getSolverInfo(), other.m_state.getSolverBodies() ), m_state( other.m_state )
1361 agxAssert( i < m_state.getPermutation().size() );
1362 UInt permutedIndex = (
UInt)m_state.getPermutation()[ i ];
1363 agxAssert( permutedIndex < getNumBodies() );
1364 return getBodyAt( permutedIndex );
1369 agxAssert( i < m_state.getPermutation().size() );
1370 UInt permutedIndex = (
UInt)m_state.getPermutation()[ i ];
1371 agxAssert( permutedIndex < getNumBodies() );
1372 return getBodyAt( permutedIndex );
1375 template<
typename T >
1378 UInt currentNumber = 0;
1380 T* ec =
dynamic_cast< T*
>(
m_sc[ i ].get() );
1381 if ( ec !=
nullptr && currentNumber == count )
1383 currentNumber += ec !=
nullptr;
1398 template<
typename T >
1401 return m_attachmentPair[ index ] !=
nullptr ? m_attachmentPair[ index ]->as< T >() :
nullptr;
1404 template<
typename T >
1407 return m_attachmentPair[ index ] !=
nullptr ? m_attachmentPair[ index ]->as< T >() :
nullptr;
1412 return m_attachmentPair[ 0 ] !=
nullptr && !m_attachmentPair[ 0 ]->objectDeleted() &&
1413 m_attachmentPair[ 1 ] !=
nullptr && !m_attachmentPair[ 1 ]->objectDeleted();
1421 return std::atan2( c * b, c * a );
1436 # pragma warning(pop)
const BodiesInfo & getSolverInfo() const
ElementaryConstraint::RefContainer m_sc
Vector of secondary constraints.
All ghost variables have compliance and damping attributes.
Elementary constraint base class with interface and global constraint functionality.
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.
void setNumBlocks(BlockType numBlocks)
ConstraintRigidBodyContainer m_bodies
Vector with observer pointers to bodies.
BlockStructure m_blockStructure
The block structure; number of block, rows, dynamic blocks etc.
virtual void preSystemCallback(DynamicsSystem *system)
Before prepare, and before the system writes to the data buffers, this constraint gets a call with th...
Constraint attachment class for agx::RigidBody.
const agx::ElementaryConstraint::RefContainer & getSecondaryConstraints() const
Translational or rotational friction controller for Hinge, Prismatic and CylindricalJoint.
void incrementConstraintCount(RigidBody *rb) const
Increment the number of constraints connection to rb.
const ConstraintImplPtrVector & getSubConstraints() const
virtual void removeNotification()
Callback when this constraint is removed from Simulation.
BodyView(const ConstrainedBodiesState::BodiesInfo &info, const ConstraintRigidBodyContainer &bodies)
Internal, use ConstriantImplementation::getUserView().
agx::UInt getNumBodies() const
OutputRef< Serializable > out(const char *name, const Serializable *obj)
Return an object that contain the name and the object that should be serialized to an archive.
Implementation of constraint angle ALONG an axis.
The rigid body class, combining a geometric model and a frame of reference.
This class is an abstract base class for all classes that can be stored and retrieved from an Archive...
const BodiesInfo & getOriginalInfo() const
BlockType dynBlocks() const
bool getSolveIterative() const
#define DOXYGEN_END_INTERNAL_BLOCK()
Implementation of constraint angle ABOUT an axis.
virtual bool getEnable() const
UInt m_blockRowIndex
Start block row for this constraint in the global matrix.
std::pair< Real, Real > RealPair
AttachmentPair m_attachmentPair
#define DOXYGEN_START_INTERNAL_BLOCK()
bool m_enableLinearization
When necessary, tweak the values sent to the solver to make violation depend linearly on force or tor...
Elementary secondary constraint to drive something given target speed (translational or rotational).
Constraint::SolveType getSolveType() const
ConstrainedBodiesState m_constrainedBodiesState
State of the included bodies, updated in updateValid.
void * customData
Custom data for the solvers to store data into.
int m_tag
Tag for this constraint.
Abstract base class for storing/restoring a line/drums with version control.
LocalState m_localState
Current local state, updated all the time, not serialized.
Elementary secondary constraint to keep constraint angle at a given target position.
const BlockStructure & getBlockStructure() const
#define AGXSTREAM_DECLARE_ABSTRACT_SERIALIZABLE(T)
Use this in a pure abstract Serializable class to add the required methods Important: Use full namesp...
const agx::ConstraintRigidBodyContainer & getSolverBodies() const
bool getSolveBoth() const
bool m_enable
User controlled enable flag, constraint ignored by solver if false.
Constraint attachment pair class.
agx::UInt getNumNonStaticBodies() const
virtual agx::Attachment * userAPIgetAttachment(const agx::RigidBody *) const
The agx namespace contains the dynamics/math part of the AGX Dynamics API.
#define AGXPHYSICS_EXPORT
T * findSecondaryConstraintGivenType(const agx::UInt count=0) const
Interface to the bodies, either user or solver, since these bodies can differ when e....
virtual bool rebind()
The general version of rebind takes the first attachment frame and moves the other attachment frame s...
InputRef< T > in(const char *name, T &obj)
Create an object with a name and a reference to the object that should be restored (usually a pointer...
virtual void addNotification()
Callback when this constraint is added to Simulation.
virtual agx::Attachment * userAPIgetAttachment(agx::UInt) const
agx::RigidBody * getPermutedBodyAt(agx::UInt i)
const agx::ElementaryConstraint::RefContainer & getElementaryConstraints() const
agx::RigidBody * getBodyAt(agx::UInt i)
Simulation is a class that bridges the collision space agxCollide::Space and the dynamic simulation s...
virtual void postSystemCallback(DynamicsSystem *system)
Last in the dynamics system step forward loop, this constraint gets a call with the main system.
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...
agx::Bool(* CreateElementaryConstraintsFunction)(class HighLevelConstraintImplementation *)
void setSolveType(Constraint::SolveType type)
Set solve type, either DIRECT, ITERATIVE or DIRECT_AND_ITERATIVE.
Elementary secondary constraint to keep constraint angle within two given values.
ConstraintImplPtrVector & getSubConstraints()
agx::UInt & numDynamicBodies()
Object that holds the state seen from the user and from the solver.
const agx::Int32Vector & getBodyIndices() const
ElementaryConstraint::RefContainer m_ec
Vector of elementary constraints.
std::valarray< agx::Real > RealValarray
For this module, vectors are defined using valarray.
agx::UInt & numNonStaticBodies()
@ ITERATIVE
Solved only in the ITERATIVE solver.
agx::ElementaryConstraint::RefContainer & getSecondaryConstraints()
Class for writing serialized data in binary format to a stream.
AGXPHYSICS_EXPORT void addSecondaryConstraints1DOF(agx::HighLevelConstraintImplementation *constraint, agx::Angle *angle)
Add secondary controllers with default name to the constraint.
Constraint::SolveType m_solveType
Only for supported solvers.
BlockType getNumBlocks() const
Pointer to a entity instance of type Physics.ConstraintForces.
Info with number of dynamic and non-static body counters.
Base class providing referencing counted objects.
Real getAngle(const Vec3 &a, const Vec3 &b, const Vec3 &c)
a and b should be orthogonal
agx::UInt getBlockRowIndex() const
agx::ElementaryConstraint::RefContainer & getElementaryConstraints()
Data from the solver the ConstraintNlmcpCallback is part of.
The base class for a constraint.
virtual agx::AttachmentPair * getAttachmentPair() const
const ConstraintRigidBodyContainer & getBodies() const
const agx::Int32Vector & getPermutation() const
void setNumRows(BlockType numRows)
@ DIRECT_AND_ITERATIVE
Solved both in the ITERATIVE and the DIRECT solver.
Constraint attachment base class for any type of frame.
void setBlockRowIndex(agx::UInt blockRowIndex)
Sets the global start index for this constraint in the global, non-permuted matrix.
SolveType
Specifies in what solvers the constraint will be solved.
AGXPHYSICS_EXPORT void addSecondaryConstraints2DOF(agx::HighLevelConstraintImplementation *constraint, agx::SeparationAngle *sepAngle, agx::RotationalAngle *rotAngle)
Add secondary controllers with default name to the constraint.
SolverBodyView(ConstrainedBodiesState &state)
Internal, use ConstriantImplementation::getSolverView().
The agxSDK namespace contain classes to bridge the collision detection system and the dynamical simul...
UInt m_numRows
Number of rows used by this constraint.
agx::UInt getJacobianRowUsage() const
Vector< RigidBody * > ConstraintRigidBodyContainer
T * getAttachment(agx::UInt index)
agx::BitState< State, Int32 > LocalState
virtual agx::AttachmentPair * getAttachmentPair() const override
BlockType kinBlocks() const
ConstraintImplPtrVector m_subConstraints
Vector with sub-constraints.
Interface to the lower triangle of the compliance matrix block in the system matrix.
The complete physical system with bodies, interactions, data layout, time stepper,...
BlockType getNumRows() const
The object defining a frame of reference and providing transformations operations.
agx::UInt getNumDynamicBodies() const
const ConstrainedBodiesState & getState() const
Essentially a sparse array of bounds.
Interface class used by internal objects running in parallel.