AGX Dynamics  2.35.0.1
ElementaryConstraint.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 #pragma once
18 
20 #include <agx/Jacobian.h>
22 #include <agx/BitState.h>
23 
24 #include <agxStream/Serializable.h>
25 
26 #ifdef _MSC_VER
27 # pragma warning(push)
28 # pragma warning(disable: 6011) // Disable warningC6011: dereferencing nullptr pointer
29 #endif
30 
31 namespace agxStream
32 {
33  class OutputArchive;
34  class InputArchive;
35 }
36 
37 namespace agx
38 {
39  class RigidBody;
40  class Frame;
41  class ConstraintNlmcpCallback;
42 
44  namespace GWriteState
45  {
46  enum Enum { NORMAL, IGNORE_FIRST, WRITE_SECOND_FIRST };
47  }
49 
50 
54  {
55  public:
59 
60  public:
65  agx::RegularizationParameters* getRegularizationParameters( const agx::UInt row = 0 );
66 
71  const agx::RegularizationParameters* getRegularizationParameters( const agx::UInt row = 0 ) const;
72 
78  void setCompliance( agx::Real compliance, int row );
79  void setCompliance( agx::Real compliance );
80 
86  void setElasticity(agx::Real elasticity, int row);
87  void setElasticity(agx::Real elasticity);
88 
93  agx::Real getCompliance( agx::UInt row = 0 ) const;
94 
100 
107  void setDamping( agx::Real damping, int row );
108  void setDamping( agx::Real damping );
109 
114  agx::Real getDamping( agx::UInt row = 0 ) const;
115 
119  agx::UInt getNumRows() const;
120 
127  void setForceRange( agx::RangeReal forceRange, const agx::UInt row = 0 );
128 
136  void setForceRange( agx::Real lower, agx::Real upper, const agx::UInt row = 0 );
137 
143 
148  const agx::RangeReal& getForceRange( const agx::UInt row = 0 ) const;
149 
155 
159  const agx::ElementaryConstraint::NameType& getName() const;
160 
164  const agx::Real* getCurrentForces() const;
165 
171  virtual agx::Real getCurrentForce( const agx::UInt row = 0 ) const;
172 
177  virtual void setEnable( agx::Bool enable );
178 
182  virtual agx::Bool getEnable() const;
183 
189  virtual agx::Bool isActive() const;
190 
194  virtual void prepare();
195 
199  void reset();
200 
204  virtual agx::Bool isImpacting() const;
205 
215  virtual agx::UInt getJacobian( agx::Jacobian6DOFElement* G, agx::UInt numBlocks, agx::UInt row, agx::GWriteState::Enum writeState );
216 
225 
234  virtual agx::UInt getVelocity( agx::Real* v, agx::UInt row ) const;
235 
245  virtual agx::UInt getBounds( agx::RangeReal* bounds, agx::UInt row, agx::Real h ) const;
246 
258  virtual void linearizeCompliance(const agx::Real* violations, agx::Real* epsilons, agx::Real minPerturbation) const;
259 
260 #ifndef SWIG
265 #endif
266 
274  virtual agx::UInt postSolveCallback( const agx::Real* solution, agx::UInt row, agx::Real h );
275 
280  virtual void setAttachmentPair( const agx::AttachmentPair* ap );
281 
285  virtual void store( agxStream::OutputArchive& out ) const override;
286 
290  virtual void restore( agxStream::InputArchive& in ) override;
291 
293 
297  virtual void storeLightData( agxStream::StorageStream& str ) const override;
298 
302  virtual void restoreLightData( agxStream::StorageStream& str ) override;
303 
310  void copyRowFrom(const ElementaryConstraint* source, agx::UInt sourceRow, agx::UInt destRow);
311 
312  protected:
323  agx::UInt numRows,
324  agx::RegularizationParameters* regParamsBuffer,
325  agx::Real* lastForcesBuffer,
326  agx::RangeReal* userBoundsBuffer );
327 
332 
333  protected:
342  private:
344 
345  friend class InternalData;
346 
350  agx::Referenced* getInternalData() const;
351 
355  void setInternalData( agx::Referenced* data );
356 
358  };
359 
361 
367  template< agx::UInt N >
369  {
370  public:
376  : ElementaryConstraint( enable, N, m_regParams, m_forces, m_bounds ) {}
377 
378  protected:
383  : ElementaryConstraint( false, N, m_regParams, m_forces, m_bounds ) {}
384 
385  protected:
386  agx::RegularizationParameters m_regParams[ N ];
387  agx::Real m_forces[ N ];
388  agx::RangeReal m_bounds[ N ];
389  };
390 
391 #ifdef SWIG
392  %template(ElementaryConstraint1) agx::ElementaryConstraintN< 1 >;
393  %template(ElementaryConstraint3) agx::ElementaryConstraintN< 3 >;
394 #endif
395 
396  template< agx::UInt N, typename DataT >
398  {
399  public:
405  ElementaryConstraintNData( const DataT& data, agx::Bool enable )
406  : ElementaryConstraintN< N >( enable ), m_data( data ) {}
407 
411  const DataT& getData() const { return m_data; }
412 
416  DataT& getData() { return m_data; }
417 
421  virtual void setAttachmentPair( const agx::AttachmentPair* ap ) override { m_data.set( ap ); }
422 
423  protected:
425  : ElementaryConstraintN< N >(), m_data() {}
426 
427  private:
428  ElementaryConstraintNData& operator=(const ElementaryConstraintNData&) {return *this;}
429  protected:
430  DataT m_data;
431  };
432 
433 #ifdef SWIG
435 #endif
436 
441  {
442  public:
447  Dot1( const agx::Dot1Data& data );
448 
450 
451  protected:
455  Dot1();
456 
460  virtual ~Dot1();
461 
462  virtual agx::UInt getJacobian( agx::Jacobian6DOFElement* G, agx::UInt numBlocks, agx::UInt row, agx::GWriteState::Enum writeState ) override;
463  virtual agx::UInt getViolation( agx::Real* g, agx::UInt row ) override;
464  };
465 
467 
472  public:
477  Swing(const agx::SwingData& data);
478 
479 
481 
482  protected:
486  Swing();
487 
491  virtual ~Swing();
492 
494  agx::GWriteState::Enum writeState) override;
495 
496  virtual agx::UInt getViolation(agx::Real* g, agx::UInt row) override;
497 
501 
502  };
503 
505 
506 
507 #ifdef SWIG
509 #endif
510 
515  {
516  public:
520  Dot2( const agx::Dot2Data& data );
521 
523 
524  protected:
528  Dot2();
529 
533  virtual ~Dot2();
534 
535  virtual agx::UInt getJacobian( agx::Jacobian6DOFElement* G, agx::UInt numBlocks, agx::UInt row, agx::GWriteState::Enum writeState ) override;
536  virtual agx::UInt getViolation( agx::Real* g, agx::UInt row ) override;
537  };
538 
540 
541 #ifdef SWIG
542  %template(ElementaryConstraint3ElementaryConstraintData) agx::ElementaryConstraintNData< 3, agx::ElementaryConstraintData >;
543 #endif
544 
551  {
552  public:
557 
559 
560  protected:
565 
569  virtual ~Spherical();
570 
571  virtual agx::UInt getJacobian( agx::Jacobian6DOFElement* G, agx::UInt numBlocks, agx::UInt row, agx::GWriteState::Enum writeState ) override;
572  virtual agx::UInt getViolation( agx::Real* g, agx::UInt row ) override;
573  };
574 
576 
581  {
582  public:
587 
589 
590  protected:
595 
599  virtual ~SphericalRel();
600 
601  virtual agx::UInt getJacobian( agx::Jacobian6DOFElement* G, agx::UInt numBlocks, agx::UInt row, agx::GWriteState::Enum writeState ) override;
602  virtual agx::UInt getViolation( agx::Real* g, agx::UInt row ) override;
603  };
604 
606 
607 #ifdef SWIG
608  %template(QuatLock3QuatLockData) agx::ElementaryConstraintNData< 3, agx::QuatLockData >;
609 #endif
610 
615  {
616  public:
620  QuatLock( const agx::QuatLockData& data );
621 
623 
624  protected:
629 
633  virtual ~QuatLock();
634 
638  virtual void setAttachmentPair( const agx::AttachmentPair* ap ) override;
639 
640  virtual agx::UInt getJacobian( agx::Jacobian6DOFElement* G, agx::UInt numBlocks, agx::UInt row, agx::GWriteState::Enum writeState ) override;
641  virtual agx::UInt getViolation( agx::Real* g, agx::UInt row ) override;
642 
643  virtual void linearizeCompliance(const agx::Real* violations, agx::Real* epsilons, agx::Real minPerturbation) const override;
644  };
645 
647 
648 #ifdef SWIG
649  %template(BasicControllerConstraint1ConstraintAngleBasedData) agx::ElementaryConstraintNData< 1, agx::ConstraintAngleBasedData >;
650 #endif
651 
656  {
657  public:
664 
666 
667  protected:
672 
676  virtual void store( agxStream::OutputArchive& out ) const override;
677 
681  virtual void restore( agxStream::InputArchive& in ) override;
682 
690  agx::UInt numBlocks,
691  agx::UInt row,
692  agx::GWriteState::Enum writeState ) override;
693 
698  agx::UInt numBlocks,
699  agx::UInt row,
700  agx::GWriteState::Enum writeState,
701  const agx::Vec3& dir1,
702  const agx::Vec3& dir2,
703  agx::Angle::Type type ) const;
704  };
705 
711  {
712  public:
718 
723  void setSpeed( agx::Real speed );
724 
729 
736  void setLocked( agx::Bool locked );
737 
742 
750  void setLockedAtZeroSpeed( agx::Bool lockedAtZeroSpeed );
751 
756 
760  static agx::TargetSpeedController* safeCast( const agx::ElementaryConstraint* targetSpeedController );
761 
763 
767  virtual void storeLightData( agxStream::StorageStream& str ) const override;
768 
772  virtual void restoreLightData( agxStream::StorageStream& str ) override;
773 
774  protected:
775  enum InternalState { NONE = 0, LOCKED = (1<<0), LOCKED_AT_ZERO_SPEED = (1<<1) };
776 
777  protected:
782 
787 
792 
797 
798  virtual agx::UInt getViolation( agx::Real* g, agx::UInt row ) override;
799  virtual agx::UInt getVelocity( agx::Real* v, agx::UInt row ) const override;
800 
801  protected:
805  };
806 
808 
813  {
814  public:
821 
832  void setFrictionCoefficient( agx::Real frictionCoefficient );
833 
838 
853 
858 
864 
869 
873  virtual agx::Bool isActive() const override;
874 
878  static agx::FrictionController* safeCast( const agx::ElementaryConstraint* frictionController );
879 
881 
887  virtual void storeLightData( agxStream::StorageStream& str ) const override;
888 
894  virtual void restoreLightData( agxStream::StorageStream& str ) override;
895 
896 #ifndef SWIG
897  public:
900  const agx::Real* solution,
901  agx::UInt row,
902  agx::Real h );
903 #endif
904 
905  protected:
908 
909  virtual agx::UInt getViolation( agx::Real* g, agx::UInt row ) override;
910  virtual agx::UInt getBounds( agx::RangeReal* bounds, agx::UInt row, agx::Real h ) const override;
911  virtual agx::UInt postSolveCallback( const agx::Real* solution, agx::UInt row, agx::Real h ) override;
912 
913  private:
914  enum Flag : agx::UInt16
915  {
916  NON_LINEAR = 1 << 0
917  };
918  using Flags = agx::BitState<Flag, agx::UInt16>;
919 
920  private:
921  class FrictionControllerNlCallback* getCallback() const;
922 
923  private:
924  Real m_frictionCoefficient;
925  Real m_lastNormalForce;
926  RangeReal m_minimumStaticFrictionBound;
927  ref_ptr<Referenced> m_nlmcpCallback;
928  Flags m_flags;
929  };
930 
935  {
936  public:
941 
947  void setVoltage( agx::Real voltage );
948 
953 
959  void setArmatureResistance( agx::Real armatureResistance );
960 
965 
971  void setTorqueConstant( agx::Real torqueConstant );
972 
977 
981  static agx::ElectricMotorController* safeCast( const agx::ElementaryConstraint* electricMotorController );
982 
984 
988  virtual void storeLightData( agxStream::StorageStream& str ) const override;
989 
993  virtual void restoreLightData( agxStream::StorageStream& str ) override;
994 
995  protected:
998 
1004 
1009 
1010  virtual void prepare() override;
1011  virtual agx::UInt getViolation( agx::Real* v, agx::UInt row ) override;
1012  virtual agx::UInt getVelocity( agx::Real* v, agx::UInt row ) const override;
1013 
1014  protected:
1018  };
1019 
1021 
1027  {
1028  public:
1034 
1039  void setRange( agx::RangeReal range );
1040 
1046  void setRange( agx::Real lower, agx::Real upper );
1047 
1052 
1056  const agx::RangeReal& getRange() const;
1057 
1061  virtual agx::Bool isActive() const override;
1062 
1066  static agx::RangeController* safeCast( const agx::ElementaryConstraint* rangeController );
1067 
1069 
1073  virtual void storeLightData( agxStream::StorageStream& str ) const override;
1074 
1078  virtual void restoreLightData( agxStream::StorageStream& str ) override;
1079 
1080  protected:
1085 
1089  virtual ~RangeController();
1090 
1091  virtual void prepare() override;
1092  virtual agx::UInt getViolation( agx::Real* g, agx::UInt row ) override;
1093  virtual agx::UInt getBounds( agx::RangeReal* bounds, agx::UInt row, agx::Real h ) const override;
1094 
1095  protected:
1098  };
1099 
1101 
1107  {
1108  public:
1114 
1119  void setPosition( agx::Real position );
1120 
1125 
1129  static agx::LockController* safeCast( const agx::ElementaryConstraint* lockController );
1130 
1132 
1136  virtual void storeLightData( agxStream::StorageStream& str ) const override;
1137 
1141  virtual void restoreLightData( agxStream::StorageStream& str ) override;
1142 
1143  protected:
1148 
1152  virtual ~LockController();
1153 
1154  virtual agx::UInt getViolation( agx::Real* g, agx::UInt row ) override;
1155 
1156  protected:
1158  };
1159 
1161 
1163  {
1164  public:
1171 
1176  void setLead( agx::Real lead );
1177 
1182 
1186  static agx::ScrewController* safeCast( const agx::ElementaryConstraint* screwController );
1187 
1189 
1193  virtual void storeLightData( agxStream::StorageStream& str ) const override;
1194 
1198  virtual void restoreLightData( agxStream::StorageStream& str ) override;
1199 
1200  protected:
1205 
1209  virtual ~ScrewController();
1210 
1211  virtual agx::UInt getJacobian( agx::Jacobian6DOFElement* G, agx::UInt numBlocks, agx::UInt row, agx::GWriteState::Enum writeState ) override;
1212  virtual agx::UInt getViolation( agx::Real* g, agx::UInt row ) override;
1213 
1214  protected:
1216  };
1217 
1218 
1219 #ifdef SWIG
1220  %template(TwistTwistData) agx::ElementaryConstraintNData< 1, agx::TwistData >;
1221 #endif
1222 
1227  public:
1232  Twist(const agx::TwistData& data);
1233 
1235 
1236  protected:
1237  virtual void setAttachmentPair(const agx::AttachmentPair* ap) override;
1238 
1243 
1247  virtual ~Twist();
1248 
1250  agx::GWriteState::Enum writeState) override;
1251 
1252  virtual agx::UInt getViolation(agx::Real* g, agx::UInt row) override;
1253  };
1254 
1256 
1258  {
1259  agxAssert( m_rps != nullptr && row < m_numRows );
1260  return &m_rps[ row ];
1261  }
1262 
1264  {
1265  agxAssert( m_rps != nullptr && row < m_numRows );
1266  return &m_rps[ row ];
1267  }
1268 
1270  {
1271  return m_numRows;
1272  }
1273 
1275  {
1276  return m_name;
1277  }
1278 
1280  const agx::Real* /*violations*/, agx::Real* /*epsilons*/, agx::Real /*minPerturbation*/) const
1281  {
1282  }
1283 
1285  inline Referenced* ElementaryConstraint::getInternalData() const
1286  {
1287  return m_internalData;
1288  }
1290 }
1291 
1292 #ifdef _MSC_VER
1293 # pragma warning(pop)
1294 #endif
#define AGXSTREAM_DECLARE_SERIALIZABLE(T)
Use this in a Serializable class to add the required methods Important: Use full namespace in the dec...
Definition: Serializable.h:207
#define AGXPHYSICS_EXPORT
Class for reading a binary stream of serialized data.
Definition: InputArchive.h:52
Class for writing serialized data in binary format to a stream.
Definition: OutputArchive.h:57
Abstract base class for storing/restoring a line/drums with version control.
Definition: StorageStream.h:49
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 "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).
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.
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.
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
Class to hold data for elementary constraints.
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.
Helper class to hold data that is general for elementary constraints.
ElementaryConstraintN(agx::Bool enable)
Construct given enable flag.
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)
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.
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.
const agx::RangeReal & getForceRange(const agx::UInt row=0) const
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.
agx::VectorPOD< agx::ElementaryConstraint * > PtrContainer
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.
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)
void setCompliance(agx::Real compliance, int row)
Assign compliance for a given row, or all rows if row = -1 (default).
virtual agx::ConstraintNlmcpCallback * getNlCallback() const
agx::RangeReal & getForceRange(const agx::UInt row=0)
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.
const agx::Real * getCurrentForces() const
void reset()
Reset call.
agx::Real getElasticity(agx::UInt row=0) const
agx::Vector< agx::ref_ptr< agx::ElementaryConstraint > > RefContainer
agx::Real getDamping(agx::UInt row=0) const
Solver callback class for elementary FrictionController.
Translational or rotational friction controller for Hinge, Prismatic and CylindricalJoint.
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.
static agx::FrictionController * safeCast(const agx::ElementaryConstraint *frictionController)
Utility cast method.
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)
ConstraintNlmcpCallback * getNlCallback() const override
virtual agx::UInt postSolveCallback(const agx::Real *solution, agx::UInt row, agx::Real h) override
Callback after solve, with the solution.
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...
Definition: InternalData.h:33
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.
static agx::LockController * safeCast(const agx::ElementaryConstraint *lockController)
Utility cast method.
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.
LockController(const agx::ConstraintAngleBasedData &data)
Construct given constraint angle based data.
Representation of a name string.
Definition: Name.h:33
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.
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
void setRange(agx::Real lower, agx::Real upper)
Assign range for the constraint angle to between.
const agx::RangeReal & getRange() const
agx::RangeReal & getRange()
void setRange(agx::RangeReal range)
Assign range for the constraint angle to between.
RangeController(const agx::ConstraintAngleBasedData &data)
Construct given constraint angle based data.
virtual ~RangeController()
Reference counted object, protected destructor.
static agx::RangeController * safeCast(const agx::ElementaryConstraint *rangeController)
Utility cast method.
virtual void restoreLightData(agxStream::StorageStream &str) override
Restore structural independent data from stream.
Base class providing referencing counted objects.
Definition: Referenced.h:114
All ghost variables have compliance and damping attributes.
ScrewController()
Default constructor used during restore.
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.
static agx::ScrewController * safeCast(const agx::ElementaryConstraint *screwController)
Utility cast method.
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.
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).
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.
agx::Real getSpeed() const
agx::Bool getLocked() const
TargetSpeedController(const agx::ConstraintAngleBasedData &data)
Construct given constraint angle based data.
static agx::TargetSpeedController * safeCast(const agx::ElementaryConstraint *targetSpeedController)
Utility cast method.
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 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.
Definition: agx/Vector.h:246
Templated vector class.
Definition: agx/Vector.h:53
#define agxAssert(expr)
Definition: debug.h:143
#define DOXYGEN_END_INTERNAL_BLOCK()
Definition: macros.h:97
#define CALLABLE
Definition: macros.h:72
#define DOXYGEN_START_INTERNAL_BLOCK()
Definition: macros.h:96
#define AGX_FORCE_INLINE
Definition: macros.h:58
Flags
Flags for specifying what is enabled in the debug rendering system.
Definition: RenderManager.h:58
This namespace contain classes for streaming classes into archives, ASCII, binary for storage (serial...
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
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.
The agx namespace contains the dynamics/math part of the AGX Dynamics API.
uint16_t UInt16
Definition: Integer.h:39
int32_t Int32
Definition: Integer.h:45
agx::ref_ptr< Dot2 > Dot2Ref
agx::ref_ptr< Swing > SwingRef
agx::ref_ptr< RangeController > RangeControllerRef
bool Bool
Definition: Integer.h:48
agx::ref_ptr< Dot1 > Dot1Ref
uint32_t UInt
Definition: Integer.h:34
agx::ref_ptr< Spherical > SphericalRef
agx::ref_ptr< LockController > LockControllerRef
double Real
Definition: Real.h:42
agx::ref_ptr< ElectricMotorController > ElectricMotorControllerRef
agx::ref_ptr< SphericalRel > SphericalRelRef
agx::ref_ptr< QuatLock > QuatLockRef
agx::ref_ptr< Twist > TwistRef
agx::ref_ptr< TargetSpeedController > TargetSpeedControllerRef