AGX Dynamics 2.42.1.1
Loading...
Searching...
No Matches
ElementaryConstraint.h
Go to the documentation of this file.
1/*
2Copyright 2007-2025. 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
21#include <agx/Jacobian.h>
22#include <agx/BitState.h>
23
25
26#include <array>
27
28#ifdef _MSC_VER
29# pragma warning(push)
30# pragma warning(disable: 6011) // Disable warningC6011: dereferencing nullptr pointer
31#endif
32
33namespace agxStream
34{
35 class OutputArchive;
36 class InputArchive;
37}
38
39namespace agx
40{
41 class RigidBody;
42 class Frame;
43 class ConstraintNlmcpCallback;
44
46 namespace GWriteState
47 {
48 enum Enum { NORMAL, IGNORE_FIRST, WRITE_SECOND_FIRST };
49 }
51
52
56 {
57 public:
61
62 public:
67 agx::RegularizationParameters* getRegularizationParameters( const agx::UInt row = 0 );
68
73 const agx::RegularizationParameters* getRegularizationParameters( const agx::UInt row = 0 ) const;
74
80 void setCompliance( agx::Real compliance, int row );
81 void setCompliance( agx::Real compliance );
82
88 void setElasticity(agx::Real elasticity, int row);
89 void setElasticity(agx::Real elasticity);
90
96
102
109 void setDamping( agx::Real damping, int row );
110 void setDamping( agx::Real damping );
111
117
121 agx::UInt getNumRows() const;
122
129 void setForceRange( agx::RangeReal forceRange, const agx::UInt row = 0 );
130
138 void setForceRange( agx::Real lower, agx::Real upper, const agx::UInt row = 0 );
139
145
150 const agx::RangeReal& getForceRange( const agx::UInt row = 0 ) const;
151
157
161 const agx::ElementaryConstraint::NameType& getName() const;
162
167
173 virtual agx::Real getCurrentForce( const agx::UInt row = 0 ) const;
174
179 virtual void setEnable( agx::Bool enable );
180
184 virtual agx::Bool getEnable() const;
185
191 virtual agx::Bool isActive() const;
192
196 virtual void prepare();
197
201 void reset();
202
206 virtual agx::Bool isImpacting() const;
207
217 virtual agx::UInt getJacobian( agx::Jacobian6DOFElement* G, agx::UInt numBlocks, agx::UInt row, agx::GWriteState::Enum writeState );
218
227
236 virtual agx::UInt getVelocity( agx::Real* v, agx::UInt row ) const;
237
247 virtual agx::UInt getBounds( agx::RangeReal* bounds, agx::UInt row, agx::Real h ) const;
248
260 virtual void linearizeCompliance(const agx::Real* violations, agx::Real* epsilons, agx::Real minPerturbation) const;
261
262#ifndef SWIG
267#endif
268
276 virtual agx::UInt postSolveCallback( const agx::Real* solution, agx::UInt row, agx::Real h );
277
282 virtual void setAttachmentPair( const agx::AttachmentPair* ap );
283
287 virtual void store( agxStream::OutputArchive& out ) const override;
288
292 virtual void restore( agxStream::InputArchive& in ) override;
293
295
299 virtual void storeLightData( agxStream::StorageStream& str ) const override;
300
304 virtual void restoreLightData( agxStream::StorageStream& str ) override;
305
312 void copyRowFrom(const ElementaryConstraint* source, agx::UInt sourceRow, agx::UInt destRow);
313
314 protected:
325 agx::UInt numRows,
326 agx::RegularizationParameters* regParamsBuffer,
327 agx::Real* lastForcesBuffer,
328 agx::RangeReal* userBoundsBuffer );
329
334
335 protected:
344 private:
346
347 friend class InternalData;
348
352 agx::Referenced* getInternalData() const;
353
357 void setInternalData( agx::Referenced* data );
358
360 };
361
363
380 template<size_t N>
382 {
383 static constexpr size_t NumRows = N;
384
385 using RealData = std::array<agx::Real, NumRows>;
386 using BoundData = std::array<agx::RangeReal, NumRows>;
387 using RegData = std::array<agx::RegularizationParameters, NumRows>;
388
392 };
393
399 template<agx::UInt N>
401 {
402 public:
408 : ElementaryConstraint( enable,
409 N,
411 m_forces,
412 m_bounds )
413 {
414 }
415
416 protected:
421 : ElementaryConstraint( false,
422 N,
424 m_forces,
425 m_bounds )
426 {
427 }
428
429 protected:
433 };
434
435#ifdef SWIG
436 %template(ElementaryConstraint1) agx::ElementaryConstraintN<1>;
437 %template(ElementaryConstraint3) agx::ElementaryConstraintN<3>;
438#endif
439
440 template<agx::UInt N, typename DataT>
442 {
443 public:
449 ElementaryConstraintNData( const DataT& data, agx::Bool enable )
450 : ElementaryConstraintN<N>( enable )
451 , m_data( data )
452 {
453 }
454
458 const DataT& getData() const { return m_data; }
459
463 DataT& getData() { return m_data; }
464
467
468 public:
472 virtual void setAttachmentPair( const agx::AttachmentPair* ap ) override { m_data.set( ap ); }
473
474 protected:
477 , m_data()
478 {
479 }
480
481 protected:
482 DataT m_data;
483 };
484
485#ifdef SWIG
487#endif
488
493 {
494 public:
499 Dot1( const agx::Dot1Data& data );
500
502
503 protected:
508
512 virtual ~Dot1();
513
514 virtual agx::UInt getJacobian( agx::Jacobian6DOFElement* G, agx::UInt numBlocks, agx::UInt row, agx::GWriteState::Enum writeState ) override;
515 virtual agx::UInt getViolation( agx::Real* g, agx::UInt row ) override;
516 };
517
519
524 public:
529 Swing(const agx::SwingData& data);
530
531
533
534 protected:
539
543 virtual ~Swing();
544
546 agx::GWriteState::Enum writeState) override;
547
548 virtual agx::UInt getViolation(agx::Real* g, agx::UInt row) override;
549
553
554 };
555
557
558
559#ifdef SWIG
561#endif
562
567 {
568 public:
572 Dot2( const agx::Dot2Data& data );
573
575
576 protected:
581
585 virtual ~Dot2();
586
587 virtual agx::UInt getJacobian( agx::Jacobian6DOFElement* G, agx::UInt numBlocks, agx::UInt row, agx::GWriteState::Enum writeState ) override;
588 virtual agx::UInt getViolation( agx::Real* g, agx::UInt row ) override;
589 };
590
592
593#ifdef SWIG
594 %template(ElementaryConstraint3ElementaryConstraintData) agx::ElementaryConstraintNData<3, agx::ElementaryConstraintData>;
595#endif
596
603 {
604 public:
609
611
612 protected:
617
621 virtual ~Spherical();
622
623 virtual agx::UInt getJacobian( agx::Jacobian6DOFElement* G, agx::UInt numBlocks, agx::UInt row, agx::GWriteState::Enum writeState ) override;
624 virtual agx::UInt getViolation( agx::Real* g, agx::UInt row ) override;
625 };
626
628
633 {
634 public:
639
641
642 protected:
647
651 virtual ~SphericalRel();
652
653 virtual agx::UInt getJacobian( agx::Jacobian6DOFElement* G, agx::UInt numBlocks, agx::UInt row, agx::GWriteState::Enum writeState ) override;
654 virtual agx::UInt getViolation( agx::Real* g, agx::UInt row ) override;
655 };
656
658
659#ifdef SWIG
660 %template(QuatLock3QuatLockData) agx::ElementaryConstraintNData<3, agx::QuatLockData>;
661#endif
662
667 {
668 public:
673
675
676 protected:
681
685 virtual ~QuatLock();
686
690 virtual void setAttachmentPair( const agx::AttachmentPair* ap ) override;
691
692 virtual agx::UInt getJacobian( agx::Jacobian6DOFElement* G, agx::UInt numBlocks, agx::UInt row, agx::GWriteState::Enum writeState ) override;
693 virtual agx::UInt getViolation( agx::Real* g, agx::UInt row ) override;
694
695 virtual void linearizeCompliance(const agx::Real* violations, agx::Real* epsilons, agx::Real minPerturbation) const override;
696 };
697
699
700#ifdef SWIG
701 %template(BasicControllerConstraint1ConstraintAngleBasedData) agx::ElementaryConstraintNData<1, agx::ConstraintAngleBasedData>;
702#endif
703
708 {
709 public:
716
718
719 protected:
724
728 virtual void store( agxStream::OutputArchive& out ) const override;
729
733 virtual void restore( agxStream::InputArchive& in ) override;
734
742 agx::UInt numBlocks,
743 agx::UInt row,
744 agx::GWriteState::Enum writeState ) override;
745
750 agx::UInt numBlocks,
751 agx::UInt row,
752 agx::GWriteState::Enum writeState,
753 const agx::Vec3& dir1,
754 const agx::Vec3& dir2,
755 agx::Angle::Type type ) const;
756 };
757
763 {
764 public:
770
775 void setSpeed( agx::Real speed );
776
781
788 void setLocked( agx::Bool locked );
789
794
802 void setLockedAtZeroSpeed( agx::Bool lockedAtZeroSpeed );
803
808
812 static agx::TargetSpeedController* safeCast( const agx::ElementaryConstraint* targetSpeedController );
813
815
819 virtual void storeLightData( agxStream::StorageStream& str ) const override;
820
824 virtual void restoreLightData( agxStream::StorageStream& str ) override;
825
826 protected:
827 enum InternalState { NONE = 0, LOCKED = (1<<0), LOCKED_AT_ZERO_SPEED = (1<<1) };
828
829 protected:
834
839
844
849
850 virtual agx::UInt getViolation( agx::Real* g, agx::UInt row ) override;
851 virtual agx::UInt getVelocity( agx::Real* v, agx::UInt row ) const override;
852
853 protected:
857 };
858
860
865 {
866 public:
873
884 void setFrictionCoefficient( agx::Real frictionCoefficient );
885
890
905
910
916
921
925 virtual agx::Bool isActive() const override;
926
930 static agx::FrictionController* safeCast( const agx::ElementaryConstraint* frictionController );
931
933
939 virtual void storeLightData( agxStream::StorageStream& str ) const override;
940
946 virtual void restoreLightData( agxStream::StorageStream& str ) override;
947
948#ifndef SWIG
949 public:
952 const agx::Real* solution,
953 agx::UInt row,
954 agx::Real h );
955#endif
956
957 protected:
960
961 virtual agx::UInt getViolation( agx::Real* g, agx::UInt row ) override;
962 virtual agx::UInt getBounds( agx::RangeReal* bounds, agx::UInt row, agx::Real h ) const override;
963 virtual agx::UInt postSolveCallback( const agx::Real* solution, agx::UInt row, agx::Real h ) override;
964
965 private:
966 enum Flag : agx::UInt16
967 {
968 NON_LINEAR = 1 << 0
969 };
970 using Flags = agx::BitState<Flag, agx::UInt16>;
971
972 private:
973 class FrictionControllerNlCallback* getCallback() const;
974
975 private:
976 Real m_frictionCoefficient;
977 Real m_lastNormalForce;
978 RangeReal m_minimumStaticFrictionBound;
979 ref_ptr<Referenced> m_nlmcpCallback;
980 Flags m_flags;
981 };
982
985
986
987
992 {
993 public:
998
1004 void setVoltage( agx::Real voltage );
1005
1010
1016 void setArmatureResistance( agx::Real armatureResistance );
1017
1022
1028 void setTorqueConstant( agx::Real torqueConstant );
1029
1034
1038 static agx::ElectricMotorController* safeCast( const agx::ElementaryConstraint* electricMotorController );
1039
1041
1045 virtual void storeLightData( agxStream::StorageStream& str ) const override;
1046
1050 virtual void restoreLightData( agxStream::StorageStream& str ) override;
1051
1052 protected:
1055
1061
1066
1067 virtual void prepare() override;
1068 virtual agx::UInt getViolation( agx::Real* v, agx::UInt row ) override;
1069 virtual agx::UInt getVelocity( agx::Real* v, agx::UInt row ) const override;
1070
1071 protected:
1075 };
1076
1078
1084 {
1085 public:
1091
1097
1103 void setRange( agx::Real lower, agx::Real upper );
1104
1109
1113 const agx::RangeReal& getRange() const;
1114
1118 virtual agx::Bool isActive() const override;
1119
1124
1126
1130 virtual void storeLightData( agxStream::StorageStream& str ) const override;
1131
1135 virtual void restoreLightData( agxStream::StorageStream& str ) override;
1136
1137 protected:
1142
1147
1148 virtual void prepare() override;
1149 virtual agx::UInt getViolation( agx::Real* g, agx::UInt row ) override;
1150 virtual agx::UInt getBounds( agx::RangeReal* bounds, agx::UInt row, agx::Real h ) const override;
1151
1152 protected:
1155 };
1156
1158
1164 {
1165 public:
1171
1176 void setPosition( agx::Real position );
1177
1182
1187
1189
1193 virtual void storeLightData( agxStream::StorageStream& str ) const override;
1194
1198 virtual void restoreLightData( agxStream::StorageStream& str ) override;
1199
1200 protected:
1205
1210
1211 virtual agx::UInt getViolation( agx::Real* g, agx::UInt row ) override;
1212
1213 protected:
1215 };
1216
1218
1220 {
1221 public:
1228
1233 void setLead( agx::Real lead );
1234
1239
1244
1246
1250 virtual void storeLightData( agxStream::StorageStream& str ) const override;
1251
1255 virtual void restoreLightData( agxStream::StorageStream& str ) override;
1256
1257 protected:
1262
1267
1268 virtual agx::UInt getJacobian( agx::Jacobian6DOFElement* G, agx::UInt numBlocks, agx::UInt row, agx::GWriteState::Enum writeState ) override;
1269 virtual agx::UInt getViolation( agx::Real* g, agx::UInt row ) override;
1270
1271 protected:
1273 };
1274
1275
1276#ifdef SWIG
1277 %template(TwistTwistData) agx::ElementaryConstraintNData<1, agx::TwistData>;
1278#endif
1279
1284 public:
1289 Twist(const agx::TwistData& data);
1290
1292
1293 protected:
1294 virtual void setAttachmentPair(const agx::AttachmentPair* ap) override;
1295
1300
1304 virtual ~Twist();
1305
1307 agx::GWriteState::Enum writeState) override;
1308
1309 virtual agx::UInt getViolation(agx::Real* g, agx::UInt row) override;
1310 };
1311
1313
1314
1319 public:
1325
1332 void setRange(RangeReal range);
1333
1341
1347
1352 const RangeReal& getRange() const;
1353
1359
1363 virtual Bool isActive() const override;
1364
1366
1367 protected:
1368 virtual void setAttachmentPair(const agx::AttachmentPair* ap) override;
1369
1374
1379
1380 virtual void prepare() override;
1381 virtual agx::UInt getViolation(agx::Real* g, agx::UInt row) override;
1382 virtual agx::UInt getBounds(agx::RangeReal* bounds, agx::UInt row, agx::Real h) const override;
1383
1387 };
1388
1390
1391
1392
1393#ifdef SWIG
1394 %template(ConeLimit1ConeLimitData) agx::ElementaryConstraintNData<1, agx::ConeLimitData>;
1395#endif
1396
1401 {
1402 public:
1408
1415
1423
1429 void setLimitAngles(Real coneAngle);
1430
1436
1442
1446 virtual Bool isActive() const override;
1447
1452
1454
1455 protected:
1460
1464 virtual ~ConeLimit();
1465
1466 virtual void prepare() override;
1467 virtual UInt getJacobian(Jacobian6DOFElement* G, UInt numBlocks, UInt row, GWriteState::Enum writeState) override;
1468 virtual agx::UInt getViolation(agx::Real* g, agx::UInt row) override;
1469 virtual agx::UInt getBounds(agx::RangeReal* bounds, agx::UInt row, agx::Real h) const override;
1470
1473 };
1474
1476
1477
1478
1480 {
1481 agxAssert( m_rps != nullptr && row < m_numRows );
1482 return &m_rps[ row ];
1483 }
1484
1486 {
1487 agxAssert( m_rps != nullptr && row < m_numRows );
1488 return &m_rps[ row ];
1489 }
1490
1492 {
1493 return m_numRows;
1494 }
1495
1497 {
1498 return m_name;
1499 }
1500
1502 const agx::Real* /*violations*/, agx::Real* /*epsilons*/, agx::Real /*minPerturbation*/) const
1503 {
1504 }
1505
1507 inline Referenced* ElementaryConstraint::getInternalData() const
1508 {
1509 return m_internalData;
1510 }
1512}
1513
1514#ifdef _MSC_VER
1515# pragma warning(pop)
1516#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:51
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 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.
ElementaryConstraintNData(const ElementaryConstraintNData &)=delete
ElementaryConstraintNData & operator=(const ElementaryConstraintNData &)=delete
virtual void setAttachmentPair(const agx::AttachmentPair *ap) override
Data has to support assignment of attachment pair.
ElementaryConstraintNData(const DataT &data, agx::Bool enable)
Construct given data and enable flag.
Helper class to hold data that is general for elementary constraints.
ElementaryConstraintN(agx::Bool enable)
Construct given enable flag.
agx::RangeReal m_bounds[N]
Bounds buffer.
agx::Real m_forces[N]
Forces buffer.
agx::RegularizationParameters m_regParams[N]
Regularization parameters buffer.
ElementaryConstraintN()
Used during serialization restore.
Elementary constraint base class with interface and global constraint functionality.
virtual agx::UInt getBounds(agx::RangeReal *bounds, agx::UInt row, agx::Real h) const
Returns the bounds of the Lagrange Multipliers (default (-inf, +inf)).
virtual void prepare()
Prepare call.
void setDamping(agx::Real damping, int row)
Assign damping for a given row, or all rows if row = -1 (default).
void setElasticity(agx::Real elasticity)
virtual agx::Bool isImpacting() const
virtual void setAttachmentPair(const agx::AttachmentPair *ap)
Call for elementary constraints dependent on attachment pairs.
agx::Real * m_lfs
last forces
agx::RegularizationParameters * getRegularizationParameters(const agx::UInt row=0)
agx::Vector< agx::ref_ptr< agx::ElementaryConstraint > > RefContainer
virtual agx::ConstraintNlmcpCallback * getNlCallback() const
virtual agx::Bool getEnable() const
agx::RangeReal * m_ubs
user bounds
virtual agx::Real getCurrentForce(const agx::UInt row=0) const
Returns the force applied last time step by this elementary constraint.
agx::RangeReal & getForceRange(const agx::UInt row=0)
void setForceRange(agx::Real lower, agx::Real upper, const agx::UInt row=0)
Assign force range to a given row.
const agx::ElementaryConstraint::NameType & getName() const
void copyRowFrom(const ElementaryConstraint *source, agx::UInt sourceRow, agx::UInt destRow)
Copy configuration row from the given ElementaryConstraint into this.
virtual ~ElementaryConstraint()
Reference counted object, protected destructor.
void setForceRange(agx::RangeReal forceRange, const agx::UInt row=0)
Assign force range to a given row.
void setName(const agx::ElementaryConstraint::NameType &name)
Name this elementary constraint.
virtual agx::UInt getJacobian(agx::Jacobian6DOFElement *G, agx::UInt numBlocks, agx::UInt row, agx::GWriteState::Enum writeState)
Returns the Jacobian of this elementary constraint.
void setElasticity(agx::Real elasticity, int row)
Assign elasticity for a given row, or all rows if row = -1 (default).
agx::ElementaryConstraint::NameType m_name
name
virtual void restoreLightData(agxStream::StorageStream &str) override
Restore structural independent data from stream.
virtual void setEnable(agx::Bool enable)
Enable/disable this elementary constraint.
agx::UInt m_numRows
number of rows
virtual agx::UInt getViolation(agx::Real *g, agx::UInt row)
Returns the violation of this elementary constraint.
agx::VectorPOD< agx::ElementaryConstraint * > PtrContainer
ElementaryConstraint(agx::Bool enable, agx::UInt numRows, agx::RegularizationParameters *regParamsBuffer, agx::Real *lastForcesBuffer, agx::RangeReal *userBoundsBuffer)
Construct given data.
virtual agx::Bool isActive() const
An elementary constraint is defined to be active if enabled.
virtual agx::UInt postSolveCallback(const agx::Real *solution, agx::UInt row, agx::Real h)
Callback after solve, with the solution.
void setDamping(agx::Real damping)
const agx::RangeReal & getForceRange(const agx::UInt row=0) const
void setCompliance(agx::Real compliance, int row)
Assign compliance for a given row, or all rows if row = -1 (default).
const agx::Real * getCurrentForces() const
void setCompliance(agx::Real compliance)
virtual void restore(agxStream::InputArchive &in) override
Restore this object from stream.
virtual agx::UInt getVelocity(agx::Real *v, agx::UInt row) const
Returns the velocity of this elementary constraint (extra, driving term on the right hand side).
agx::RegularizationParameters * m_rps
regularization parameters
virtual void linearizeCompliance(const agx::Real *violations, agx::Real *epsilons, agx::Real minPerturbation) const
Modify epsilon so that this ElementaryConstraint appear to be linear in the "normal" deformantion spa...
agx::Real getCompliance(agx::UInt row=0) const
AGXSTREAM_DECLARE_ABSTRACT_SERIALIZABLE(agx::ElementaryConstraint)
virtual void store(agxStream::OutputArchive &out) const override
Store this object to stream.
agx::ref_ptr< agx::Referenced > m_internalData
custom, internal data
virtual void storeLightData(agxStream::StorageStream &str) const override
Store structural independent data to stream.
void reset()
Reset call.
agx::Real getElasticity(agx::UInt row=0) const
agx::Real getDamping(agx::UInt row=0) const
Solver callback class for elementary FrictionController.
Translational or rotational friction controller for Hinge, Prismatic and CylindricalJoint.
ConstraintNlmcpCallback * getNlCallback() const override
void setMinimumStaticFrictionForceRange(agx::RangeReal bound)
Set the minimum force range that this friction controller can apply.
virtual agx::UInt getViolation(agx::Real *g, agx::UInt row) override
Returns the violation of this elementary constraint.
agx::Real getFrictionCoefficient() const
virtual void storeLightData(agxStream::StorageStream &str) const override
/internal
virtual agx::UInt getBounds(agx::RangeReal *bounds, agx::UInt row, agx::Real h) const override
Returns the bounds of the Lagrange Multipliers (default (-inf, +inf)).
FrictionController(const agx::ConstraintAngleBasedData &data)
Construct given angle based data.
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...
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.
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:89
#define CALLABLE
Definition: macros.h:72
#define DOXYGEN_START_INTERNAL_BLOCK()
Definition: macros.h:88
#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.
agx::ref_ptr< RangeController > RangeControllerRef
uint16_t UInt16
Definition: Integer.h:31
int32_t Int32
Definition: Integer.h:37
agx::ref_ptr< Swing > SwingRef
agx::ref_ptr< ConeLimit > ConeLimitRef
agx::ref_ptr< LockController > LockControllerRef
agx::ref_ptr< Dot2 > Dot2Ref
bool Bool
Definition: Integer.h:40
agx::ref_ptr< ElectricMotorController > ElectricMotorControllerRef
Vec3T< T > min(const Vec3T< T > &lhs, const Vec3T< T > &rhs)
Definition: Vec3Template.h:861
Vec3T< T > max(const Vec3T< T > &lhs, const Vec3T< T > &rhs)
Definition: Vec3Template.h:855
uint64_t UInt
Definition: Integer.h:27
agx::ref_ptr< Spherical > SphericalRef
agx::ref_ptr< SphericalRel > SphericalRelRef
double Real
Definition: Real.h:41
agx::ref_ptr< Dot1 > Dot1Ref
agx::ref_ptr< TwistRangeController > TwistRangeControllerRef
agx::ref_ptr< FrictionController > FrictionControllerRef
agx::ref_ptr< TargetSpeedController > TargetSpeedControllerRef
agx::ref_ptr< Twist > TwistRef
agx::SetVector< ref_ptr< FrictionController > > FrictionControllerRefSetVector
agx::ref_ptr< QuatLock > QuatLockRef
Inherit privately before "public agx::ElementaryConstraint" and pass the data to the ElementaryConstr...
std::array< agx::Real, NumRows > RealData
std::array< agx::RegularizationParameters, NumRows > RegData
std::array< agx::RangeReal, NumRows > BoundData