AGX Dynamics 2.38.0.2
Loading...
Searching...
No Matches
ElementaryConstraint.h
Go to the documentation of this file.
1/*
2Copyright 2007-2024. Algoryx Simulation AB.
3
4All AGX source code, intellectual property, documentation, sample code,
5tutorials, scene files and technical white papers, are copyrighted, proprietary
6and confidential material of Algoryx Simulation AB. You may not download, read,
7store, distribute, publish, copy or otherwise disseminate, use or expose this
8material unless having a written signed agreement with Algoryx Simulation AB, or having been
9advised so by Algoryx Simulation AB for a time limited evaluation, or having purchased a
10valid commercial license from Algoryx Simulation AB.
11
12Algoryx Simulation AB disclaims all responsibilities for loss or damage caused
13from using this software, unless otherwise stated in written agreements with
14Algoryx Simulation AB.
15*/
16
17#pragma once
18
20#include <agx/Jacobian.h>
22#include <agx/BitState.h>
23
25
26#ifdef _MSC_VER
27# pragma warning(push)
28# pragma warning(disable: 6011) // Disable warningC6011: dereferencing nullptr pointer
29#endif
30
31namespace agxStream
32{
33 class OutputArchive;
34 class InputArchive;
35}
36
37namespace 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
94
100
107 void setDamping( agx::Real damping, int row );
108 void setDamping( agx::Real damping );
109
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
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:
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:
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:
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:
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:
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:
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
933
934
935
1024
1026
1032 {
1033 public:
1039
1045
1051 void setRange( agx::Real lower, agx::Real upper );
1052
1057
1061 const agx::RangeReal& getRange() const;
1062
1066 virtual agx::Bool isActive() const override;
1067
1072
1074
1078 virtual void storeLightData( agxStream::StorageStream& str ) const override;
1079
1083 virtual void restoreLightData( agxStream::StorageStream& str ) override;
1084
1085 protected:
1090
1095
1096 virtual void prepare() override;
1097 virtual agx::UInt getViolation( agx::Real* g, agx::UInt row ) override;
1098 virtual agx::UInt getBounds( agx::RangeReal* bounds, agx::UInt row, agx::Real h ) const override;
1099
1100 protected:
1103 };
1104
1106
1112 {
1113 public:
1119
1124 void setPosition( agx::Real position );
1125
1130
1135
1137
1141 virtual void storeLightData( agxStream::StorageStream& str ) const override;
1142
1146 virtual void restoreLightData( agxStream::StorageStream& str ) override;
1147
1148 protected:
1153
1158
1159 virtual agx::UInt getViolation( agx::Real* g, agx::UInt row ) override;
1160
1161 protected:
1163 };
1164
1166
1168 {
1169 public:
1176
1181 void setLead( agx::Real lead );
1182
1187
1192
1194
1198 virtual void storeLightData( agxStream::StorageStream& str ) const override;
1199
1203 virtual void restoreLightData( agxStream::StorageStream& str ) override;
1204
1205 protected:
1210
1215
1216 virtual agx::UInt getJacobian( agx::Jacobian6DOFElement* G, agx::UInt numBlocks, agx::UInt row, agx::GWriteState::Enum writeState ) override;
1217 virtual agx::UInt getViolation( agx::Real* g, agx::UInt row ) override;
1218
1219 protected:
1221 };
1222
1223
1224#ifdef SWIG
1226#endif
1227
1232 public:
1237 Twist(const agx::TwistData& data);
1238
1240
1241 protected:
1242 virtual void setAttachmentPair(const agx::AttachmentPair* ap) override;
1243
1248
1252 virtual ~Twist();
1253
1255 agx::GWriteState::Enum writeState) override;
1256
1257 virtual agx::UInt getViolation(agx::Real* g, agx::UInt row) override;
1258 };
1259
1261
1262
1267 public:
1273
1280 void setRange(RangeReal range);
1281
1289
1295
1300 const RangeReal& getRange() const;
1301
1307
1311 virtual Bool isActive() const override;
1312
1314
1315 protected:
1316 virtual void setAttachmentPair(const agx::AttachmentPair* ap) override;
1317
1322
1327
1328 virtual void prepare() override;
1329 virtual agx::UInt getViolation(agx::Real* g, agx::UInt row) override;
1330 virtual agx::UInt getBounds(agx::RangeReal* bounds, agx::UInt row, agx::Real h) const override;
1331
1335 };
1336
1338
1339
1340
1341#ifdef SWIG
1342 %template(ConeLimit1ConeLimitData) agx::ElementaryConstraintNData< 1, agx::ConeLimitData >;
1343#endif
1344
1349 {
1350 public:
1356
1363
1371
1377 void setLimitAngles(Real coneAngle);
1378
1384
1390
1394 virtual Bool isActive() const override;
1395
1400
1402
1403 protected:
1408
1412 virtual ~ConeLimit();
1413
1414 virtual void prepare() override;
1415 virtual UInt getJacobian(Jacobian6DOFElement* G, UInt numBlocks, UInt row, GWriteState::Enum writeState) override;
1416 virtual agx::UInt getViolation(agx::Real* g, agx::UInt row) override;
1417 virtual agx::UInt getBounds(agx::RangeReal* bounds, agx::UInt row, agx::Real h) const override;
1418
1421 };
1422
1424
1425
1426
1428 {
1429 agxAssert( m_rps != nullptr && row < m_numRows );
1430 return &m_rps[ row ];
1431 }
1432
1434 {
1435 agxAssert( m_rps != nullptr && row < m_numRows );
1436 return &m_rps[ row ];
1437 }
1438
1443
1448
1450 const agx::Real* /*violations*/, agx::Real* /*epsilons*/, agx::Real /*minPerturbation*/) const
1451 {
1452 }
1453
1455 inline Referenced* ElementaryConstraint::getInternalData() const
1456 {
1457 return m_internalData;
1458 }
1460}
1461
1462#ifdef _MSC_VER
1463# pragma warning(pop)
1464#endif
#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 reading a binary stream of serialized data.
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).
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::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.
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)
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.
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.
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.
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.
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.
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.
Definition Referenced.h:120
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...
Definition SetVector.h:38
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.
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.
Definition agx/Vector.h:246
Templated vector class.
Definition agx/Vector.h:53
Smart pointer for handling referenced counted objects.
Definition ref_ptr.h:30
#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
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.
uint16_t UInt16
Definition Integer.h:31
int32_t Int32
Definition Integer.h:37
agx::ref_ptr< Dot2 > Dot2Ref
agx::ref_ptr< Swing > SwingRef
agx::ref_ptr< FrictionController > FrictionControllerRef
agx::ref_ptr< RangeController > RangeControllerRef
bool Bool
Definition Integer.h:40
agx::ref_ptr< Dot1 > Dot1Ref
Vec3T< T > min(const Vec3T< T > &lhs, const Vec3T< T > &rhs)
Vec3T< T > max(const Vec3T< T > &lhs, const Vec3T< T > &rhs)
uint64_t UInt
Definition Integer.h:27
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< TwistRangeController > TwistRangeControllerRef
agx::ref_ptr< ConeLimit > ConeLimitRef
agx::ref_ptr< QuatLock > QuatLockRef
agx::ref_ptr< Twist > TwistRef
agx::SetVector< ref_ptr< FrictionController > > FrictionControllerRefSetVector
agx::ref_ptr< TargetSpeedController > TargetSpeedControllerRef