AGXDynamics  2.35.0.2
ConstraintImplementation.h
Go to the documentation of this file.
1 /*
2 Copyright 2007-2022. Algoryx Simulation AB.
3 
4 All AGX source code, intellectual property, documentation, sample code,
5 tutorials, scene files and technical white papers, are copyrighted, proprietary
6 and confidential material of Algoryx Simulation AB. You may not download, read,
7 store, distribute, publish, copy or otherwise disseminate, use or expose this
8 material unless having a written signed agreement with Algoryx Simulation AB, or having been
9 advised so by Algoryx Simulation AB for a time limited evaluation, or having purchased a
10 valid commercial license from Algoryx Simulation AB.
11 
12 Algoryx Simulation AB disclaims all responsibilities for loss or damage caused
13 from using this software, unless otherwise stated in written agreements with
14 Algoryx Simulation AB.
15 */
16 
17 #ifndef AGX_CONSTRAINT_IMPLEMENTATION_H
18 #define AGX_CONSTRAINT_IMPLEMENTATION_H
19 
20 #include <agxSDK/SimulationProxy.h>
21 
22 #include <agx/FrictionModel.h>
23 #include <agx/RigidBody.h>
24 #include <agx/SVec.h>
25 #include <agxStream/Serializable.h>
26 #include <agx/agx_hash_types.h>
27 #include <agx/Constraint.h>
28 #include <agx/Jacobian.h>
31 #include <agx/BitState.h>
32 #include <agx/agx_valarray_types.h>
33 
34 #ifdef _MSC_VER
35 # pragma warning(push)
36 # pragma warning( disable : 4251 ) // class X needs to have dll-interface to be used by clients of class Y
37 #endif
38 
39 #define DEFAULT_COMPLIANCE 1.0E-8
40 
41 #define CONSTRAINT_SUCCESS( success ) \
42  if ( !(success) ) { \
43  LOGGER_WARNING() << "Unable to create constraint. Constraint cleared." << std::endl << LOGGER_END(); \
44  m_bodies.clear(); \
45  m_localState.remove( VALID ); \
46  return; \
47  }
48 
49 #define CONSTRAINT_SUCCESS_RETURN_BOOL( success ) \
50  if ( !(success) ) { \
51  LOGGER_WARNING() << "Unable to create constraint. Constraint cleared." << std::endl << LOGGER_END(); \
52  m_bodies.clear(); \
53  m_localState.remove( VALID ); \
54  return false; \
55  }
56 
57 namespace agx
58 {
59  // Forward declaration
60  class ElementaryConstraint;
61  class Constraint;
62  class RegularizationParameters;
63  class SparseRangeReal;
64  class LSquareComplianceMatrix;
66 
68  typedef std::pair< Real, Real > RealPair;
69 
71  {
72  public:
73  typedef UInt16 BlockType;
75  : m_numBlocks( 0 ), m_numRows( 0 ), m_numDynBlocks( 0 ) {}
76 
77  AGX_FORCE_INLINE void setNumBlocks( BlockType numBlocks ) { m_numBlocks = numBlocks; }
78  AGX_FORCE_INLINE void setNumRows( BlockType numRows ) { m_numRows = numRows; }
79 
80  AGX_FORCE_INLINE BlockType getNumBlocks() const { return m_numBlocks; }
81  AGX_FORCE_INLINE BlockType getNumRows() const { return m_numRows; }
82 
83  AGX_FORCE_INLINE BlockType& blocks() { return m_numBlocks; }
84  AGX_FORCE_INLINE BlockType& rows() { return m_numRows; }
85  AGX_FORCE_INLINE BlockType blocks() const { return m_numBlocks; }
86  AGX_FORCE_INLINE BlockType rows() const { return m_numRows; }
87 
88  AGX_FORCE_INLINE BlockType& dynBlocks() { return m_numDynBlocks; }
89  AGX_FORCE_INLINE BlockType dynBlocks() const { return m_numDynBlocks; }
90  AGX_FORCE_INLINE BlockType kinBlocks() const { return (BlockType)(m_numBlocks - m_numDynBlocks); }
91 
92  AGX_FORCE_INLINE void reset() { m_numBlocks = m_numRows = m_numDynBlocks = 0; }
93 
94  private:
95  BlockType m_numBlocks;
96  BlockType m_numRows;
97  BlockType m_numDynBlocks;
98  };
99 
101  {
102  public:
103  enum Tags
104  {
105  NONE = 0,
106  MANY_BODY = (1<<0),
107  DEFAULT_BINARY_TAG = NONE,
108  DEFAULT_MANY_BODY_TAG = MANY_BODY
109  };
110 
115  {
116  public:
121  {
122  public:
123  BodiesInfo();
124 
128  agx::UInt& numDynamicBodies();
129 
133  agx::UInt numDynamicBodies() const;
134 
138  agx::UInt& numNonStaticBodies();
139 
143  agx::UInt numNonStaticBodies() const;
144 
145  private:
146  agx::UInt m_numDynamicBodies;
147  agx::UInt m_numNonStaticBodies;
148  };
149 
150  public:
155 
160  void reset( agx::UInt numBodies );
161 
166  agx::Bool increment( agx::RigidBody* rb );
167 
172  agx::Bool finalize( agx::Bool valid );
173 
177  const BodiesInfo& getOriginalInfo() const;
178 
182  const BodiesInfo& getSolverInfo() const;
183 
187  const agx::Int32Vector& getPermutation() const;
188 
192  agx::Int32Vector& getPermutation();
193 
197  const agx::Int32Vector& getBodyIndices() const;
198 
202  agx::Int32Vector& getBodyIndices();
203 
207  const agx::ConstraintRigidBodyContainer& getSolverBodies() const;
208 
216  agx::UInt getNumRecurrentMergedBodies() const;
217 
218  private:
219  BodiesInfo m_originalInfo;
220  BodiesInfo m_solverInfo;
222  Int32Vector m_permutation;
223  Int32Vector m_bodyIndices;
224  UInt m_numRecurrentMergedBodies;
225  };
226 
231  #if !defined(SWIGPYTHON)
233  {
234  public:
240 
244  BodyView( const BodyView& other );
245 
249  agx::UInt getNumDynamicBodies() const;
250 
254  agx::UInt getNumNonStaticBodies() const;
255 
259  agx::UInt getNumBodies() const;
260 
264  agx::RigidBody* getBodyAt( agx::UInt i );
265 
269  const agx::RigidBody* getBodyAt( agx::UInt i ) const;
270 
274  const ConstraintRigidBodyContainer& getBodies() const;
275 
279  BodyView& operator = ( const BodyView& ) = delete;
280 
281  private:
283  const ConstraintRigidBodyContainer& m_bodies;
284  };
285 
287  {
288  public:
294 
298  SolverBodyView( const SolverBodyView& other );
299 
303  const ConstrainedBodiesState& getState() const;
304 
308  ConstrainedBodiesState& getState();
309 
313  agx::RigidBody* getPermutedBodyAt( agx::UInt i );
314 
318  const agx::RigidBody* getPermutedBodyAt( agx::UInt i ) const;
319 
320  private:
324  inline SolverBodyView& operator = ( const SolverBodyView& ) { agxAbort(); return *this; }
325 
326  private:
327  ConstrainedBodiesState& m_state;
328  };
329  #endif
330 
331  public:
337 
341  virtual ~ConstraintImplementation();
342 
346  #if !defined(SWIGPYTHON)
347  BodyView getUserView() const;
348 
352  SolverBodyView getSolverView() const;
353  #endif
354 
355  // ****************************************************************************
356  // Callbacks from solvers *****************************************************
357  // ****************************************************************************
358 
366  virtual bool updateValid();
367 
374  virtual void prepare();
375 
382  virtual size_t updateJacobian( agx::Jacobian6DOFElement* jacobians );
383 
390  virtual int getViolation( agx::Real* g, int row );
391 
397  agx::Real calculateViolationVectorAverageSize();
398 
404  virtual void getEpsilon( agx::Real* epsilon, agx::Real h );
405 
409  virtual void getParameters( agx::Real* violation,
410  agx::Real* epsilon,
411  agx::Real* damping,
412  bool* holonomic,
413  agx::Real* velocity,
414  agx::RangeReal* bounds,
415  int8_t* indexSetState,
416  agx::Real h,
417  agx::Real minPerturbation = agx::Real( 1E-10 ) );
418 
426  virtual int getConstraintVelocity( agx::Real* v, int row );
427 
435  virtual void getBounds( agx::RangeReal* bounds, agx::Real dt ) const;
436 
445  virtual void updateComplianceMatrix( LSquareComplianceMatrix matrix ) const;
446 
450  void onDirectComplianceMatrix( Real* data, unsigned int ld ) const;
451 
458  virtual void postSolveCallback( const agx::Jacobian6DOFElement* jacobians, const agx::Real* solution, agx::Real dt );
459 
464  void postSolveIndexSetCallback( const int8_t* state );
465 
472  virtual void preSystemCallback( DynamicsSystem* system );
473 
479  virtual void postSystemCallback( DynamicsSystem* system );
480 
486  void sort();
487 
491  void reset();
492 
496  virtual void addNlCallbacks( agx::SparseRangeReal& sparseRangeReal, const NlmcpCallbackSolverData& solverData ) const;
497 
498  // ****************************************************************************
499 
500  // ****************************************************************************
501  // Methods used by the solvers ************************************************
502  // ****************************************************************************
503 
507  AGX_FORCE_INLINE agx::UInt getJacobianRowUsage() const { return m_numRows; }
508 
512  AGX_FORCE_INLINE const BlockStructure& getBlockStructure() const { return m_blockStructure; }
513 
518  AGX_FORCE_INLINE void setBlockRowIndex( agx::UInt blockRowIndex ) { m_blockRowIndex = blockRowIndex; }
519 
523  AGX_FORCE_INLINE agx::UInt getBlockRowIndex() const { return m_blockRowIndex; }
524 
529  AGX_FORCE_INLINE bool getSolveIterative() const { return m_solveType == Constraint::ITERATIVE; }
530 
534  AGX_FORCE_INLINE bool getSolveBoth() const { return m_solveType == Constraint::DIRECT_AND_ITERATIVE; }
535 
539  AGX_FORCE_INLINE void setSolveType( Constraint::SolveType type ) { m_solveType = type; }
540 
544  AGX_FORCE_INLINE Constraint::SolveType getSolveType() const { return m_solveType; }
545 
549  AGX_FORCE_INLINE bool isImpacting() const { return m_localState.Is( IMPACTING ); }
550 
555  AGX_FORCE_INLINE void incrementConstraintCount( RigidBody* rb ) const { agxAssert( rb ); if (rb) rb->incrementNumConstraints(); }
556 
560  AGX_FORCE_INLINE int getTag() const { return m_tag; }
561 
562 #ifndef SWIG
563  void* customData;
564 #endif
565 
566  // ****************************************************************************
567 
568  // ****************************************************************************
569  // Callbacks from the simulation during add and remove of this constraint *****
570  // ****************************************************************************
571 
575  virtual void addNotification() {}
576 
580  virtual void removeNotification() {}
581 
582  // ****************************************************************************
583 
584  // ****************************************************************************
585  // Methods used by non-implementation constraints but not the 'end user' ******
586  // ****************************************************************************
587 
593 
599 
604  AGX_FORCE_INLINE const ConstraintImplPtrVector& getSubConstraints() const { return m_subConstraints; }
605 
606  // ****************************************************************************
607  // Methods used by 'the user' *************************************************
608  // ****************************************************************************
609 
617  virtual bool rebind() { return false; }
618 
623  virtual AGX_FORCE_INLINE bool getEnable() const { return m_enable; }
624 
629  virtual void setEnable(bool enable);
630 
634  AGX_FORCE_INLINE bool getActive() const { return m_enable && m_localState.Is( VALID ); }
635 
639  AGX_FORCE_INLINE bool isValid() const { return m_localState.Is( VALID ); }
640 
641  // ****************************************************************************
642 
643  // ****************************************************************************
644  // Methods for user API, these should not be used internally ******************
645  // ****************************************************************************
646 
653  virtual void setEnableComputeForces( agx::Bool enable );
654 
658  virtual agx::Bool getEnableComputeForces() const;
659 
679  virtual agx::Bool getLastForce( agx::UInt bodyIndex, agx::Vec3& retForce, agx::Vec3& retTorque, agx::Bool giveForceAtCm = false ) const;
680 
699  virtual agx::Bool getLastForce( const agx::RigidBody* rb, agx::Vec3& retForce, agx::Vec3& retTorque, agx::Bool giveForceAtCm = false ) const;
700 
719  virtual agx::Bool getLastLocalForce( agx::UInt bodyIndex, agx::Vec3& retForce, agx::Vec3& retTorque, agx::Bool giveForceAtCm = false ) const;
720 
738  virtual agx::Bool getLastLocalForce( const agx::RigidBody* rb, agx::Vec3& retForce, agx::Vec3& retTorque, agx::Bool giveForceAtCm = false ) const;
739 
746  void setEnableLinearization(bool enable);
747 
751  bool getEnableLinearization() const;
752 
756  virtual agx::Attachment* userAPIgetAttachment( const agx::RigidBody* /*rb*/ ) const { return nullptr; }
757 
761  virtual agx::Attachment* userAPIgetAttachment( agx::UInt /*index*/ ) const { return nullptr; }
762 
766  virtual agx::AttachmentPair* getAttachmentPair() const { return nullptr; }
767 
774  virtual bool addElementaryConstraint( const agx::String& name, agx::ElementaryConstraint* elementaryConstraint );
775 
782  virtual bool addSecondaryConstraint( const agx::String& name, agx::ElementaryConstraint* secondaryConstraint );
783 
789  virtual bool removeElementaryConstraint( agx::ElementaryConstraint* elementaryConstraint );
790 
796  virtual bool removeSecondaryConstraint( agx::ElementaryConstraint* secondaryConstraint );
797 
803  virtual bool removeElementaryConstraint( const agx::String& name );
804 
810  virtual bool removeSecondaryConstraint( const agx::String& name );
811 
816  virtual agx::ElementaryConstraint* getElementaryConstraint( const agx::UInt index ) const;
817 
822  virtual agx::ElementaryConstraint* getElementaryConstraint( const agx::String& name ) const;
823 
828  virtual agx::ElementaryConstraint* getSecondaryConstraint( const agx::UInt index ) const;
829 
834  virtual agx::ElementaryConstraint* getSecondaryConstraint( const agx::String& name ) const;
835 
839  template< typename T >
840  T* findSecondaryConstraintGivenType( const agx::UInt count = 0 ) const;
841 
845  agx::Motor1D* getMotor1D( agx::UInt number = 0 ) const;
846 
850  agx::Lock1D* getLock1D( agx::UInt number = 0 ) const;
851 
855  agx::Range1D* getRange1D( agx::UInt number = 0 ) const;
856 
860  agx::FrictionController* getFrictionController( agx::UInt number = 0 ) const;
861 
866  virtual agx::Real getAngle( agx::UInt /*dof*/ = 0 ) const { return 0; }
867 
873  virtual agx::Real getCurrentSpeed( agx::UInt /*dof*/ = 0 ) const { return 0; }
874 
881  agx::RegularizationParameters* userAPIgetRegularizationParameters( agx::UInt i );
882  const agx::RegularizationParameters* userAPIgetRegularizationParameters( agx::UInt i ) const;
883 
887  agx::Real userAPIgetCompliance( agx::UInt dof ) const;
888 
894  void userAPIsetCompliance( agx::Real compliance, int dof );
895 
899  agx::Real userAPIgetDamping( agx::UInt dof ) const;
900 
906  void userAPIsetDamping( agx::Real damping, int dof );
907 
914  void userAPIsetForceRange( agx::RangeReal forceRange, agx::Int dof );
915 
922  agx::RangeReal userAPIgetForceRange( agx::UInt dof ) const;
923 
931  agx::Real userAPIgetCurrentForce( agx::UInt dof ) const;
932 
939  agx::UInt calculateNumActiveRows() const;
940 
941 
942  // **************************************************************************
943 
945 
946 
951  agx::RealValarray getCompliance() const;
952 
956  agx::Referenced* getInternalData() const;
957 
961  void setInternalData( agx::Referenced* data );
962 
966  AGX_FORCE_INLINE agxSDK::SimulationProxy* getSimulationProxy() { return m_simulationProxy; }
967  AGX_FORCE_INLINE const agxSDK::SimulationProxy* getSimulationProxy() const { return m_simulationProxy; }
968 
969  agx::Physics::ConstraintForcesPtr getForceData();
970  void setForceData(agx::Physics::ConstraintForcesPtr forceData);
971 
972  virtual void storeLightData( agxStream::StorageStream& ) const {}
973  virtual void restoreLightData( agxStream::StorageStream& ) {}
974 
976 
977  protected:
978  enum State : Int32
979  {
980  VALID = 1 << 0, // Replaces m_valid.
981  IMPACTING = 1 << 1, // Replaces m_impactState.
982  SUPPORTS_COMPLIANCE_MATRIX = 1 << 2 // Set if this constraint supports write access to the compliance matrix
983  // allocated in the system matrix.
984  };
985 
986  using LocalState = agx::BitState<State, Int32>;
987 
988  protected:
989  friend class Constraint;
994  void setSimulation( agxSDK::Simulation* simulation );
995 
1002  void setSupportsComplianceMatrix( Bool supportsComplianceMatrix );
1003 
1004  protected:
1014  int m_tag;
1016  private:
1017  agxSDK::SimulationProxyRef m_simulationProxy;
1018  Physics::ConstraintForcesPtr m_forceData;
1019  ref_ptr<Referenced> m_internalData;
1020 
1021  protected:
1023  bool m_enable;
1026  };
1027 
1029  {
1030  public:
1033 
1041  virtual bool updateValid() override;
1042 
1049  virtual void prepare() override;
1050 
1056  virtual size_t updateJacobian( agx::Jacobian6DOFElement* jacobians ) override;
1057 
1064  virtual void postSolveCallback( const agx::Jacobian6DOFElement* jacobians, const agx::Real* solution, agx::Real dt ) override;
1065 
1073  virtual bool rebind() override;
1074 
1079  virtual void computeForces( const agx::Jacobian6DOFElement* jacobians );
1080 
1091  virtual agx::Bool computeForces( const agx::Jacobian6DOFElement* jacobians, agx::Vec3Vector& result ) const;
1092 
1099  virtual void setEnableComputeForces( agx::Bool enable ) override;
1100 
1104  virtual agx::Bool getEnableComputeForces() const override;
1105 
1125  virtual agx::Bool getLastForce( agx::UInt bodyIndex, agx::Vec3& retForce, agx::Vec3& retTorque, agx::Bool giveForceAtCm = false ) const override;
1126 
1145  virtual agx::Bool getLastForce( const RigidBody* rb, Vec3& retForce, Vec3& retTorque, agx::Bool giveForceAtCm = false ) const override;
1146 
1165  virtual agx::Bool getLastLocalForce( agx::UInt bodyIndex, agx::Vec3& retForce, agx::Vec3& retTorque, agx::Bool giveForceAtCm = false ) const override;
1166 
1184  virtual agx::Bool getLastLocalForce( const agx::RigidBody* rb, agx::Vec3& retForce, agx::Vec3& retTorque, agx::Bool giveForceAtCm = false ) const override;
1185 
1186  // **************************************************************************
1187  // Internal utility methods for one or two body constraints *****************
1188  // **************************************************************************
1189 
1191 
1192  bool construct( RigidBody* rb1, Frame* rb1AttachmentFrame, RigidBody* rb2, Frame* rb2AttachmentFrame, CreateElementaryConstraintsFunction = nullptr );
1193  bool setupOneOrTwoBodySystem( RigidBodyAttachment* a1, RigidBodyAttachment* a2 );
1194  bool validateRigidBodiesAndAttachments( RigidBody* rb1, Frame* rb1AttachmentFrame, RigidBody* rb2, Frame* rb2AttachmentFrame );
1195 
1199  virtual agx::Attachment* userAPIgetAttachment( const agx::RigidBody* rb ) const override;
1200 
1204  virtual agx::Attachment* userAPIgetAttachment( agx::UInt index ) const override;
1205 
1209  virtual agx::AttachmentPair* getAttachmentPair() const override;
1210 
1215  virtual agx::Real getAngle( agx::UInt dof = 0 ) const override;
1216 
1220  bool bodiesValid() const;
1221 
1225  template< typename T >
1226  T* getAttachment( agx::UInt index );
1227 
1231  template< typename T >
1232  const T* getAttachment( agx::UInt index ) const;
1233 
1235 
1236  virtual void restore( agxStream::InputArchive& in ) override;
1237  virtual void store( agxStream::OutputArchive& out ) const override;
1238 
1239  virtual void storeLightData( agxStream::StorageStream& str ) const override;
1240  virtual void restoreLightData( agxStream::StorageStream& str ) override;
1241 
1242  protected:
1245  };
1246 
1248  {
1249  return m_numDynamicBodies;
1250  }
1251 
1253  {
1254  return m_numDynamicBodies;
1255  }
1256 
1258  {
1259  return m_numNonStaticBodies;
1260  }
1261 
1263  {
1264  return m_numNonStaticBodies;
1265  }
1266 
1268  {
1269  return m_originalInfo;
1270  }
1271 
1273  {
1274  return m_solverInfo;
1275  }
1276 
1278  {
1279  return m_permutation;
1280  }
1281 
1283  {
1284  return m_permutation;
1285  }
1286 
1288  {
1289  return m_bodyIndices;
1290  }
1291 
1293  {
1294  return m_bodyIndices;
1295  }
1296 
1298  {
1299  return m_bodies;
1300  }
1301 #if !defined(SWIGPYTHON)
1303  {
1304  }
1305 
1307  {
1308  }
1309 
1311  {
1312  return m_info.numDynamicBodies();
1313  }
1314 
1316  {
1317  return m_info.numNonStaticBodies();
1318  }
1319 
1321  {
1322  return m_bodies.size();
1323  }
1325  {
1326  agxAssert( i < getNumBodies() ); return m_bodies[ i ];
1327  }
1328 
1330  {
1331  agxAssert( i < getNumBodies() ); return m_bodies[ i ];
1332  }
1333 
1335  {
1336  return m_bodies;
1337  }
1338 
1340  : BodyView( state.getSolverInfo(), state.getSolverBodies() ), m_state( state )
1341  {
1342  }
1343 
1345  : BodyView( other.m_state.getSolverInfo(), other.m_state.getSolverBodies() ), m_state( other.m_state )
1346  {
1347  }
1348 
1350  {
1351  return m_state;
1352  }
1353 
1355  {
1356  return m_state;
1357  }
1358 
1360  {
1361  agxAssert( i < m_state.getPermutation().size() );
1362  UInt permutedIndex = (UInt)m_state.getPermutation()[ i ];
1363  agxAssert( permutedIndex < getNumBodies() );
1364  return getBodyAt( permutedIndex );
1365  }
1366 
1368  {
1369  agxAssert( i < m_state.getPermutation().size() );
1370  UInt permutedIndex = (UInt)m_state.getPermutation()[ i ];
1371  agxAssert( permutedIndex < getNumBodies() );
1372  return getBodyAt( permutedIndex );
1373  }
1374 #endif
1375  template< typename T >
1377  {
1378  UInt currentNumber = 0;
1379  for ( UInt i = 0, num = m_sc.size(); i < num; ++i ) {
1380  T* ec = dynamic_cast< T* >( m_sc[ i ].get() );
1381  if ( ec != nullptr && currentNumber == count )
1382  return ec;
1383  currentNumber += ec != nullptr;
1384  }
1385 
1386  return nullptr;
1387  }
1388 
1390 
1392 
1394  {
1395  return const_cast< AttachmentPair* >( &m_attachmentPair );
1396  }
1397 
1398  template< typename T >
1400  {
1401  return m_attachmentPair[ index ] != nullptr ? m_attachmentPair[ index ]->as< T >() : nullptr;
1402  }
1403 
1404  template< typename T >
1406  {
1407  return m_attachmentPair[ index ] != nullptr ? m_attachmentPair[ index ]->as< T >() : nullptr;
1408  }
1409 
1411  {
1412  return m_attachmentPair[ 0 ] != nullptr && !m_attachmentPair[ 0 ]->objectDeleted() &&
1413  m_attachmentPair[ 1 ] != nullptr && !m_attachmentPair[ 1 ]->objectDeleted();
1414  }
1415 
1419  AGX_FORCE_INLINE Real getAngle( const Vec3& a, const Vec3& b, const Vec3& c )
1420  {
1421  return std::atan2( c * b, c * a );
1422  }
1423 
1428 
1433 } // namespace agx
1434 
1435 #ifdef _MSC_VER
1436 # pragma warning(pop)
1437 #endif
1438 
1439 
1440 #endif /* _CONSTRAINTIMPLEMENTATION_H_ */
agx::BlockStructure::dynBlocks
BlockType & dynBlocks()
Definition: ConstraintImplementation.h:88
agx::ConstraintImplementation::ConstrainedBodiesState::getSolverInfo
const BodiesInfo & getSolverInfo() const
Definition: ConstraintImplementation.h:1272
Jacobian.h
agx::ConstraintImplementation::m_sc
ElementaryConstraint::RefContainer m_sc
Vector of secondary constraints.
Definition: ConstraintImplementation.h:1006
agx::RegularizationParameters
All ghost variables have compliance and damping attributes.
Definition: RegularizationParameters.h:29
agx::ElementaryConstraint
Elementary constraint base class with interface and global constraint functionality.
Definition: ElementaryConstraint.h:53
agx::BlockStructure::reset
void reset()
Definition: ConstraintImplementation.h:92
agx::ConstraintImplementation::getCurrentSpeed
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.
Definition: ConstraintImplementation.h:873
agx::BlockStructure::setNumBlocks
void setNumBlocks(BlockType numBlocks)
Definition: ConstraintImplementation.h:77
agx::ConstraintImplementation::m_bodies
ConstraintRigidBodyContainer m_bodies
Vector with observer pointers to bodies.
Definition: ConstraintImplementation.h:1008
agx::ConstraintImplementation::m_blockStructure
BlockStructure m_blockStructure
The block structure; number of block, rows, dynamic blocks etc.
Definition: ConstraintImplementation.h:1012
agx::Real
double Real
Definition: Real.h:42
SimulationProxy.h
agx::ConstraintImplementation::preSystemCallback
virtual void preSystemCallback(DynamicsSystem *system)
Before prepare, and before the system writes to the data buffers, this constraint gets a call with th...
Definition: ConstraintImplementation.h:1389
agx::Jacobian6DOFElementT
Definition: Jacobian.h:104
agx::RigidBodyAttachment
Constraint attachment class for agx::RigidBody.
Definition: Attachment.h:207
agx::ConstraintImplementation::getSecondaryConstraints
const agx::ElementaryConstraint::RefContainer & getSecondaryConstraints() const
Definition: ConstraintImplementation.h:598
agx::FrictionController
Translational or rotational friction controller for Hinge, Prismatic and CylindricalJoint.
Definition: ElementaryConstraint.h:812
agx::ConstraintImplementation::incrementConstraintCount
void incrementConstraintCount(RigidBody *rb) const
Increment the number of constraints connection to rb.
Definition: ConstraintImplementation.h:555
agx::ConstraintImplementation::getActive
bool getActive() const
Definition: ConstraintImplementation.h:634
agx::ConstraintImplementation::getSubConstraints
const ConstraintImplPtrVector & getSubConstraints() const
Definition: ConstraintImplementation.h:604
agx::ConstraintImplementation::removeNotification
virtual void removeNotification()
Callback when this constraint is removed from Simulation.
Definition: ConstraintImplementation.h:580
agx::Vector< RigidBody * >
agx::ConstraintImplementation::BodyView::BodyView
BodyView(const ConstrainedBodiesState::BodiesInfo &info, const ConstraintRigidBodyContainer &bodies)
Internal, use ConstriantImplementation::getUserView().
Definition: ConstraintImplementation.h:1302
agx::ConstraintImplementation::BodyView::getNumBodies
agx::UInt getNumBodies() const
Definition: ConstraintImplementation.h:1320
agxStream::out
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.
Definition: OutputArchive.h:412
BitState.h
agx::SeparationAngle
Implementation of constraint angle ALONG an axis.
Definition: ConstraintAngle.h:207
agx::Container::size
size_t size() const
Definition: Container.h:134
agx::RigidBody
The rigid body class, combining a geometric model and a frame of reference.
Definition: RigidBody.h:54
agxStream::Serializable
This class is an abstract base class for all classes that can be stored and retrieved from an Archive...
Definition: Serializable.h:44
agx::ConstraintImplementation::ConstrainedBodiesState::getOriginalInfo
const BodiesInfo & getOriginalInfo() const
Definition: ConstraintImplementation.h:1267
CALLABLE
#define CALLABLE
Definition: macros.h:72
agx::BlockStructure::dynBlocks
BlockType dynBlocks() const
Definition: ConstraintImplementation.h:89
agx::ConstraintImplementation::getSolveIterative
bool getSolveIterative() const
Definition: ConstraintImplementation.h:529
DOXYGEN_END_INTERNAL_BLOCK
#define DOXYGEN_END_INTERNAL_BLOCK()
Definition: macros.h:97
Constraint.h
agx::RotationalAngle
Implementation of constraint angle ABOUT an axis.
Definition: ConstraintAngle.h:126
agx::ConstraintImplementation::getEnable
virtual bool getEnable() const
Definition: ConstraintImplementation.h:623
agx::ConstraintImplementation::m_blockRowIndex
UInt m_blockRowIndex
Start block row for this constraint in the global matrix.
Definition: ConstraintImplementation.h:1013
agx::RealPair
std::pair< Real, Real > RealPair
Definition: ConstraintImplementation.h:68
agx::HighLevelConstraintImplementation::m_attachmentPair
AttachmentPair m_attachmentPair
Definition: ConstraintImplementation.h:1243
CALLABLE_IGNORE
#define CALLABLE_IGNORE
Definition: macros.h:74
DOXYGEN_START_INTERNAL_BLOCK
#define DOXYGEN_START_INTERNAL_BLOCK()
Definition: macros.h:96
agx::ConstraintImplementation::isValid
bool isValid() const
Definition: ConstraintImplementation.h:639
agx::Int
int32_t Int
Definition: Integer.h:35
agx::ConstraintImplementation::m_enableLinearization
bool m_enableLinearization
When necessary, tweak the values sent to the solver to make violation depend linearly on force or tor...
Definition: ConstraintImplementation.h:1024
agx::TargetSpeedController
Elementary secondary constraint to drive something given target speed (translational or rotational).
Definition: ElementaryConstraint.h:710
agxAssert
#define agxAssert(expr)
Definition: debug.h:143
agx::ConstraintImplementation::getSolveType
Constraint::SolveType getSolveType() const
Definition: ConstraintImplementation.h:544
agx::ConstraintImplementation::m_constrainedBodiesState
ConstrainedBodiesState m_constrainedBodiesState
State of the included bodies, updated in updateValid.
Definition: ConstraintImplementation.h:1009
agx::ConstraintImplementation::customData
void * customData
Custom data for the solvers to store data into.
Definition: ConstraintImplementation.h:563
agx::ConstraintImplementation
Definition: ConstraintImplementation.h:100
agx::ConstraintImplementation::m_tag
int m_tag
Tag for this constraint.
Definition: ConstraintImplementation.h:1014
agxStream::StorageStream
Abstract base class for storing/restoring a line/drums with version control.
Definition: StorageStream.h:48
agx::ConstraintImplementation::m_localState
LocalState m_localState
Current local state, updated all the time, not serialized.
Definition: ConstraintImplementation.h:1025
agx::LockController
Elementary secondary constraint to keep constraint angle at a given target position.
Definition: ElementaryConstraint.h:1106
agx::ConstraintImplementation::getBlockStructure
const BlockStructure & getBlockStructure() const
Definition: ConstraintImplementation.h:512
AGXSTREAM_DECLARE_ABSTRACT_SERIALIZABLE
#define AGXSTREAM_DECLARE_ABSTRACT_SERIALIZABLE(T)
Use this in a pure abstract Serializable class to add the required methods Important: Use full namesp...
Definition: Serializable.h:221
agx::ConstraintImplementation::ConstrainedBodiesState::getSolverBodies
const agx::ConstraintRigidBodyContainer & getSolverBodies() const
Definition: ConstraintImplementation.h:1297
agx::ConstraintImplementation::getSolveBoth
bool getSolveBoth() const
Definition: ConstraintImplementation.h:534
ConstraintForcesEntity.h
agx_valarray_types.h
agx::ConstraintImplementation::m_enable
bool m_enable
User controlled enable flag, constraint ignored by solver if false.
Definition: ConstraintImplementation.h:1023
agx::AttachmentPair
Constraint attachment pair class.
Definition: Attachment.h:300
agx::VectorPOD< Int32 >
agx::ConstraintImplementation::BodyView::getNumNonStaticBodies
agx::UInt getNumNonStaticBodies() const
Definition: ConstraintImplementation.h:1315
agx::ConstraintImplementation::userAPIgetAttachment
virtual agx::Attachment * userAPIgetAttachment(const agx::RigidBody *) const
Definition: ConstraintImplementation.h:756
agx
The agx namespace contains the dynamics/math part of the AGX Dynamics API.
Definition: AddedMassInteraction.h:22
AGXPHYSICS_EXPORT
#define AGXPHYSICS_EXPORT
agx::ConstraintImplementation::SolverBodyView
Definition: ConstraintImplementation.h:286
agx::ConstraintImplementation::getTag
int getTag() const
Definition: ConstraintImplementation.h:560
agx::ConstraintImplementation::findSecondaryConstraintGivenType
T * findSecondaryConstraintGivenType(const agx::UInt count=0) const
Definition: ConstraintImplementation.h:1376
agx::ConstraintImplementation::BodyView
Interface to the bodies, either user or solver, since these bodies can differ when e....
Definition: ConstraintImplementation.h:232
agx::ConstraintImplementation::rebind
virtual bool rebind()
The general version of rebind takes the first attachment frame and moves the other attachment frame s...
Definition: ConstraintImplementation.h:617
agxStream::in
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...
Definition: InputArchive.h:400
agx::ConstraintImplementation::addNotification
virtual void addNotification()
Callback when this constraint is added to Simulation.
Definition: ConstraintImplementation.h:575
agx::ConstraintImplementation::userAPIgetAttachment
virtual agx::Attachment * userAPIgetAttachment(agx::UInt) const
Definition: ConstraintImplementation.h:761
agx::UInt16
uint16_t UInt16
Definition: Integer.h:39
agx::ConstraintImplementation::SolverBodyView::getPermutedBodyAt
agx::RigidBody * getPermutedBodyAt(agx::UInt i)
Definition: ConstraintImplementation.h:1367
agx::ConstraintImplementation::getElementaryConstraints
const agx::ElementaryConstraint::RefContainer & getElementaryConstraints() const
Definition: ConstraintImplementation.h:592
agx::ConstraintImplementation::BodyView::getBodyAt
agx::RigidBody * getBodyAt(agx::UInt i)
Definition: ConstraintImplementation.h:1324
agx::ref_ptr< SimulationProxy >
agxSDK::Simulation
Simulation is a class that bridges the collision space agxCollide::Space and the dynamic simulation s...
Definition: Simulation.h:126
agx::ConstraintImplementation::postSystemCallback
virtual void postSystemCallback(DynamicsSystem *system)
Last in the dynamics system step forward loop, this constraint gets a call with the main system.
Definition: ConstraintImplementation.h:1391
agx::ConstraintImplementation::getAngle
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...
Definition: ConstraintImplementation.h:866
agx::CreateElementaryConstraintsFunction
agx::Bool(* CreateElementaryConstraintsFunction)(class HighLevelConstraintImplementation *)
Definition: AngularJointBase.h:24
agx::ConstraintImplementation::setSolveType
void setSolveType(Constraint::SolveType type)
Set solve type, either DIRECT, ITERATIVE or DIRECT_AND_ITERATIVE.
Definition: ConstraintImplementation.h:539
agx::RangeController
Elementary secondary constraint to keep constraint angle within two given values.
Definition: ElementaryConstraint.h:1026
FrictionModel.h
agxAbort
#define agxAbort()
Definition: debug.h:164
agx::ConstraintImplementation::getSubConstraints
ConstraintImplPtrVector & getSubConstraints()
Definition: ConstraintImplementation.h:603
agx::ConstraintImplementation::ConstrainedBodiesState::BodiesInfo::numDynamicBodies
agx::UInt & numDynamicBodies()
Definition: ConstraintImplementation.h:1247
agx::ConstraintImplementation::ConstrainedBodiesState
Object that holds the state seen from the user and from the solver.
Definition: ConstraintImplementation.h:114
agx::ConstraintImplementation::isImpacting
bool isImpacting() const
Definition: ConstraintImplementation.h:549
agx::ConstraintImplementation::ConstrainedBodiesState::getBodyIndices
const agx::Int32Vector & getBodyIndices() const
Definition: ConstraintImplementation.h:1287
agx::ConstraintImplementation::m_ec
ElementaryConstraint::RefContainer m_ec
Vector of elementary constraints.
Definition: ConstraintImplementation.h:1005
agx::RealValarray
std::valarray< agx::Real > RealValarray
For this module, vectors are defined using valarray.
Definition: agx_valarray_types.h:27
agx::BlockStructure::rows
BlockType & rows()
Definition: ConstraintImplementation.h:84
agx::ConstraintImplementation::ConstrainedBodiesState::BodiesInfo::numNonStaticBodies
agx::UInt & numNonStaticBodies()
Definition: ConstraintImplementation.h:1257
agx_hash_types.h
agx::HighLevelConstraintImplementation::m_lastForces
Vec3Vector m_lastForces
Definition: ConstraintImplementation.h:1244
agx::Constraint::ITERATIVE
@ ITERATIVE
Solved only in the ITERATIVE solver.
Definition: Constraint.h:95
agx::ConstraintImplementation::getSecondaryConstraints
agx::ElementaryConstraint::RefContainer & getSecondaryConstraints()
Definition: ConstraintImplementation.h:597
agxStream::OutputArchive
Class for writing serialized data in binary format to a stream.
Definition: OutputArchive.h:56
Serializable.h
agx::addSecondaryConstraints1DOF
AGXPHYSICS_EXPORT void addSecondaryConstraints1DOF(agx::HighLevelConstraintImplementation *constraint, agx::Angle *angle)
Add secondary controllers with default name to the constraint.
agx::HighLevelConstraintImplementation
Definition: ConstraintImplementation.h:1028
agx::ConstraintImplementation::m_solveType
Constraint::SolveType m_solveType
Only for supported solvers.
Definition: ConstraintImplementation.h:1022
agxStream::InputArchive
Class for reading a binary stream of serialized data.
Definition: InputArchive.h:51
agx::HighLevelConstraintImplementation::bodiesValid
bool bodiesValid() const
Definition: ConstraintImplementation.h:1410
agx::BlockStructure::BlockStructure
BlockStructure()
Definition: ConstraintImplementation.h:74
RigidBody.h
agx::BlockStructure::blocks
BlockType blocks() const
Definition: ConstraintImplementation.h:85
agx::BlockStructure::getNumBlocks
BlockType getNumBlocks() const
Definition: ConstraintImplementation.h:80
agx::Physics::ConstraintForcesPtr
Pointer to a entity instance of type Physics.ConstraintForces.
Definition: ConstraintForcesEntity.h:234
agx::ConstraintImplementation::ConstrainedBodiesState::BodiesInfo
Info with number of dynamic and non-static body counters.
Definition: ConstraintImplementation.h:120
agx::Referenced
Base class providing referencing counted objects.
Definition: Referenced.h:113
agx::ConstraintImplementation::State
State
Definition: ConstraintImplementation.h:978
agx::getAngle
Real getAngle(const Vec3 &a, const Vec3 &b, const Vec3 &c)
a and b should be orthogonal
Definition: ConstraintImplementation.h:1419
ElementaryConstraint.h
agx::UInt
uint32_t UInt
Definition: Integer.h:34
agx::ConstraintImplementation::getBlockRowIndex
agx::UInt getBlockRowIndex() const
Definition: ConstraintImplementation.h:523
agx::Bool
bool Bool
Definition: Integer.h:48
agx::ConstraintImplementation::getElementaryConstraints
agx::ElementaryConstraint::RefContainer & getElementaryConstraints()
Definition: ConstraintImplementation.h:591
agx::NlmcpCallbackSolverData
Data from the solver the ConstraintNlmcpCallback is part of.
Definition: NlmcpCallback.h:191
agx::Constraint
The base class for a constraint.
Definition: Constraint.h:88
agx::ConstraintImplementation::getAttachmentPair
virtual agx::AttachmentPair * getAttachmentPair() const
Definition: ConstraintImplementation.h:766
agx::ConstraintImplementation::BodyView::getBodies
const ConstraintRigidBodyContainer & getBodies() const
Definition: ConstraintImplementation.h:1334
agx::ConstraintImplementation::ConstrainedBodiesState::getPermutation
const agx::Int32Vector & getPermutation() const
Definition: ConstraintImplementation.h:1277
agx::BlockStructure::setNumRows
void setNumRows(BlockType numRows)
Definition: ConstraintImplementation.h:78
SVec.h
agx::Constraint::DIRECT_AND_ITERATIVE
@ DIRECT_AND_ITERATIVE
Solved both in the ITERATIVE and the DIRECT solver.
Definition: Constraint.h:96
agx::Attachment
Constraint attachment base class for any type of frame.
Definition: Attachment.h:36
agx::ConstraintImplementation::setBlockRowIndex
void setBlockRowIndex(agx::UInt blockRowIndex)
Sets the global start index for this constraint in the global, non-permuted matrix.
Definition: ConstraintImplementation.h:518
agx::BlockStructure
Definition: ConstraintImplementation.h:70
agx::Constraint::SolveType
SolveType
Specifies in what solvers the constraint will be solved.
Definition: Constraint.h:92
agx::addSecondaryConstraints2DOF
AGXPHYSICS_EXPORT void addSecondaryConstraints2DOF(agx::HighLevelConstraintImplementation *constraint, agx::SeparationAngle *sepAngle, agx::RotationalAngle *rotAngle)
Add secondary controllers with default name to the constraint.
agx::AgXString< std::string >
agx::Angle
Constraint angle class.
Definition: ConstraintAngle.h:31
agx::ConstraintImplementation::SolverBodyView::SolverBodyView
SolverBodyView(ConstrainedBodiesState &state)
Internal, use ConstriantImplementation::getSolverView().
Definition: ConstraintImplementation.h:1339
agxSDK
The agxSDK namespace contain classes to bridge the collision detection system and the dynamical simul...
Definition: Constraint.h:30
agx::ConstraintImplementation::m_numRows
UInt m_numRows
Number of rows used by this constraint.
Definition: ConstraintImplementation.h:1011
agx::Range< Real >
agx::ConstraintImplementation::getJacobianRowUsage
agx::UInt getJacobianRowUsage() const
Definition: ConstraintImplementation.h:507
agx::Vec3T< Real >
agx::ConstraintRigidBodyContainer
Vector< RigidBody * > ConstraintRigidBodyContainer
Definition: ConstraintImplementation.h:65
agx::HighLevelConstraintImplementation::getAttachment
T * getAttachment(agx::UInt index)
Definition: ConstraintImplementation.h:1399
agx::ConstraintImplementation::LocalState
agx::BitState< State, Int32 > LocalState
Definition: ConstraintImplementation.h:986
agx::HighLevelConstraintImplementation::getAttachmentPair
virtual agx::AttachmentPair * getAttachmentPair() const override
Definition: ConstraintImplementation.h:1393
agx::BlockStructure::blocks
BlockType & blocks()
Definition: ConstraintImplementation.h:83
agx::BlockStructure::kinBlocks
BlockType kinBlocks() const
Definition: ConstraintImplementation.h:90
agx::ConstraintImplementation::m_subConstraints
ConstraintImplPtrVector m_subConstraints
Vector with sub-constraints.
Definition: ConstraintImplementation.h:1010
agx::LSquareComplianceMatrix
Interface to the lower triangle of the compliance matrix block in the system matrix.
Definition: LSquareComplianceMatrix.h:84
agx::DynamicsSystem
The complete physical system with bodies, interactions, data layout, time stepper,...
Definition: DynamicsSystem.h:65
agx::BlockStructure::getNumRows
BlockType getNumRows() const
Definition: ConstraintImplementation.h:81
agx::Int32
int32_t Int32
Definition: Integer.h:45
agx::ConstraintImplementation::Tags
Tags
Definition: ConstraintImplementation.h:103
agx::Frame
The object defining a frame of reference and providing transformations operations.
Definition: Frame.h:67
agx::BlockStructure::rows
BlockType rows() const
Definition: ConstraintImplementation.h:86
agx::ConstraintImplementation::BodyView::getNumDynamicBodies
agx::UInt getNumDynamicBodies() const
Definition: ConstraintImplementation.h:1310
agx::ConstraintImplementation::SolverBodyView::getState
const ConstrainedBodiesState & getState() const
Definition: ConstraintImplementation.h:1349
agx::BlockStructure::BlockType
UInt16 BlockType
Definition: ConstraintImplementation.h:73
AGX_FORCE_INLINE
#define AGX_FORCE_INLINE
Definition: macros.h:58
agx::SparseRangeReal
Essentially a sparse array of bounds.
Definition: SparseTypes.h:73
agxSDK::SimulationProxy
Interface class used by internal objects running in parallel.
Definition: SimulationProxy.h:49