PxArticulationReducedCoordinate.h
Go to the documentation of this file.
1 //
2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions
4 // are met:
5 // * Redistributions of source code must retain the above copyright
6 // notice, this list of conditions and the following disclaimer.
7 // * Redistributions in binary form must reproduce the above copyright
8 // notice, this list of conditions and the following disclaimer in the
9 // documentation and/or other materials provided with the distribution.
10 // * Neither the name of NVIDIA CORPORATION nor the names of its
11 // contributors may be used to endorse or promote products derived
12 // from this software without specific prior written permission.
13 //
14 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
15 // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
17 // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
18 // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
19 // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
20 // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
21 // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
22 // OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
24 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25 //
26 // Copyright (c) 2008-2021 NVIDIA Corporation. All rights reserved.
27 // Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved.
28 // Copyright (c) 2001-2004 NovodeX AG. All rights reserved.
29 
30 
31 #ifndef PX_PHYSICS_NX_ARTICULATION_RC
32 #define PX_PHYSICS_NX_ARTICULATION_RC
33 
36 #include "PxArticulationBase.h"
37 #include "foundation/PxVec3.h"
38 #include "foundation/PxTransform.h"
39 #include "solver/PxSolverDefs.h"
40 
41 #if !PX_DOXYGEN
42 namespace physx
43 {
44 #endif
45 
46  PX_ALIGN_PREFIX(16)
48  {
53  }
54  PX_ALIGN_SUFFIX(16);
55 
56  PX_ALIGN_PREFIX(16)
58  {
63  }
64  PX_ALIGN_SUFFIX(16);
65 
66  class PxJoint;
67 
69  {
75  };
76 
78  {
79  public:
80  enum Enum
81  {
82  eVELOCITY = (1 << 0),
83  eACCELERATION = (1 << 1),
84  ePOSITION = (1 << 2),
85  eFORCE = (1 << 3),
86  eLINKVELOCITY = (1 << 4),
87  eLINKACCELERATION = (1 << 5),
88  eROOT = (1 << 6),
89  eALL = (eVELOCITY | eACCELERATION | ePOSITION| eLINKVELOCITY | eLINKACCELERATION | eROOT )
90  };
92  externalForces (NULL),
93  denseJacobian (NULL),
94  massMatrix (NULL),
95  jointVelocity (NULL),
96  jointAcceleration (NULL),
97  jointPosition (NULL),
98  jointForce (NULL),
99  rootLinkData (NULL),
100  coefficientMatrix (NULL),
101  lambda (NULL),
102  scratchMemory (NULL),
103  scratchAllocator (NULL),
104  version (0)
105  {}
106 
107  PxSpatialForce* externalForces; // N = getNbLinks()
108  PxReal* denseJacobian; // N = 6*getDofs()*NumJoints, NumJoints = getNbLinks() - 1
109  PxReal* massMatrix; // N = getDofs()*getDofs()
110  PxReal* jointVelocity; // N = getDofs()
111  PxReal* jointAcceleration; // N = getDofs()
112  PxReal* jointPosition; // N = getDofs()
113  PxReal* jointForce; // N = getDofs()
114  PxSpatialVelocity* linkVelocity; // N = getNbLinks()
115  PxSpatialVelocity* linkAcceleration; // N = getNbLinks()
117 
118  //application need to allocate those memory and assign them to the cache
121 
122  //These three members won't be set to zero when zeroCache get called
123  void* scratchMemory; //this is used for internal calculation
125  PxU32 version; //cache version. If the articulation configuration change, the cache is invalid
126  };
127 
129  PX_FLAGS_OPERATORS(PxArticulationCache::Enum, PxU8)
130 
131 
142 #if PX_VC
143 #pragma warning(push)
144 #pragma warning(disable : 4435)
145 #endif
146 
148  {
149  public:
150 
151  virtual void release() = 0;
152 
159  virtual void setArticulationFlags(PxArticulationFlags flags) = 0;
160 
168  virtual void setArticulationFlag(PxArticulationFlag::Enum flag, bool value) = 0;
169 
173  virtual PxArticulationFlags getArticulationFlags() const = 0;
174 
178  virtual PxU32 getDofs() const = 0;
179 
185  virtual PxArticulationCache* createCache() const = 0;
186 
192  virtual PxU32 getCacheDataSize() const = 0;
193 
199  virtual void zeroCache(PxArticulationCache& cache) = 0;
200 
210  virtual void applyCache(PxArticulationCache& cache, const PxArticulationCacheFlags flag, bool autowake = true) = 0;
211 
220  virtual void copyInternalStateToCache(PxArticulationCache& cache, const PxArticulationCacheFlags flag) const = 0;
221 
229  virtual void releaseCache(PxArticulationCache& cache) const = 0;
230 
236  virtual void packJointData(const PxReal* maximum, PxReal* reduced) const = 0;
237 
243  virtual void unpackJointData(const PxReal* reduced, PxReal* maximum) const = 0;
244 
248  virtual void commonInit() const = 0;
249 
258  virtual void computeGeneralizedGravityForce(PxArticulationCache& cache) const = 0;
259 
268  virtual void computeCoriolisAndCentrifugalForce(PxArticulationCache& cache) const = 0;
269 
278  virtual void computeGeneralizedExternalForce(PxArticulationCache& cache) const = 0;
279 
288  virtual void computeJointAcceleration(PxArticulationCache& cache) const = 0;
289 
299  virtual void computeJointForce(PxArticulationCache& cache) const = 0;
300 
310  virtual void computeDenseJacobian(PxArticulationCache& cache, PxU32& nRows, PxU32& nCols) const = 0;
311 
312 
318  virtual void computeCoefficientMatrix(PxArticulationCache& cache) const = 0;
319 
328  virtual bool computeLambda(PxArticulationCache& cache, PxArticulationCache& initialState, const PxReal* const jointTorque, const PxU32 maxIter) const = 0;
329 
336  virtual void computeGeneralizedMassMatrix(PxArticulationCache& cache) const = 0;
337 
344  virtual void addLoopJoint(PxJoint* joint) = 0;
345 
352  virtual void removeLoopJoint(PxJoint* joint) = 0;
353 
358  virtual PxU32 getNbLoopJoints() const = 0;
359 
372  virtual PxU32 getLoopJoints(PxJoint** userBuffer, PxU32 bufferSize, PxU32 startIndex = 0) const = 0;
373 
378  virtual PxU32 getCoefficientMatrixSize() const = 0;
379 
387  virtual void teleportRootLink(const PxTransform& pose, bool autowake) = 0;
388 
389 
396  virtual PxSpatialVelocity getLinkVelocity(const PxU32 linkId) = 0;
397 
398 
405  virtual PxSpatialVelocity getLinkAcceleration(const PxU32 linkId) = 0;
406 
407  protected:
408  PX_INLINE PxArticulationReducedCoordinate(PxType concreteType, PxBaseFlags baseFlags) : PxArticulationBase(concreteType, baseFlags) {}
411  };
412 
413 #if PX_VC
414 #pragma warning(pop)
415 #endif
416 
417 #if !PX_DOXYGEN
418 } // namespace physx
419 #endif
420 
422 #endif
Definition: GuContactBuffer.h:37
PxReal pad0
Definition: PxArticulationReducedCoordinate.h:50
PxU32 version
Definition: PxArticulationReducedCoordinate.h:125
PxFlags< PxArticulationCache::Enum, PxU8 > PxArticulationCacheFlags
Definition: PxArticulationReducedCoordinate.h:128
Definition: PxArticulationReducedCoordinate.h:47
PxReal pad1
Definition: PxArticulationReducedCoordinate.h:52
PxReal * jointVelocity
Definition: PxArticulationReducedCoordinate.h:110
PxVec3 worldLinAccel
Definition: PxArticulationReducedCoordinate.h:73
float PxReal
Definition: PxSimpleTypes.h:78
PxSpatialVelocity * linkAcceleration
Definition: PxArticulationReducedCoordinate.h:115
PX_INLINE PxArticulationReducedCoordinate(PxType concreteType, PxBaseFlags baseFlags)
Definition: PxArticulationReducedCoordinate.h:408
PxTransform transform
Definition: PxArticulationReducedCoordinate.h:70
PxReal pad0
Definition: PxArticulationReducedCoordinate.h:60
PxVec3 angular
Definition: PxArticulationReducedCoordinate.h:61
PxVec3 linear
Definition: PxArticulationReducedCoordinate.h:59
PxReal pad1
Definition: PxArticulationReducedCoordinate.h:62
PxU16 PxType
Definition: PxBase.h:49
PxReal * denseJacobian
Definition: PxArticulationReducedCoordinate.h:108
Definition: PxArticulationReducedCoordinate.h:77
PxReal * jointAcceleration
Definition: PxArticulationReducedCoordinate.h:111
a base interface providing common functionality for PhysX joints
Definition: PxJoint.h:101
PxVec3 force
Definition: PxArticulationReducedCoordinate.h:49
PxArticulationRootLinkData * rootLinkData
Definition: PxArticulationReducedCoordinate.h:116
a tree structure of bodies connected by joints that is treated as a unit by the dynamics solver ...
Definition: PxArticulationReducedCoordinate.h:147
PxU16 flags
a set of Px1DConstraintFlags
Definition: PxConstraintDesc.h:110
virtual ~PxArticulationReducedCoordinate()
Definition: PxArticulationReducedCoordinate.h:410
PxReal * lambda
Definition: PxArticulationReducedCoordinate.h:120
#define PX_ALIGN_PREFIX(alignment)
Definition: PxPreprocessor.h:409
uint8_t PxU8
Definition: PxSimpleTypes.h:75
PxVec3 worldLinVel
Definition: PxArticulationReducedCoordinate.h:71
class representing a rigid euclidean transform as a quaternion and a vector
Definition: PxTransform.h:48
PxReal * jointPosition
Definition: PxArticulationReducedCoordinate.h:112
PxReal * jointForce
Definition: PxArticulationReducedCoordinate.h:113
PxVec3 worldAngAccel
Definition: PxArticulationReducedCoordinate.h:74
PxVec3 torque
Definition: PxArticulationReducedCoordinate.h:51
PxReal * coefficientMatrix
Definition: PxArticulationReducedCoordinate.h:119
Enum
Definition: PxArticulationReducedCoordinate.h:80
void * scratchMemory
Definition: PxArticulationReducedCoordinate.h:123
PX_INLINE PxArticulationReducedCoordinate(PxBaseFlags baseFlags)
Definition: PxArticulationReducedCoordinate.h:409
a tree structure of bodies connected by joints that is treated as a unit by the dynamics solver ...
Definition: PxArticulationBase.h:56
Container for bitfield flag variables associated with a specific enum type.
Definition: PxFlags.h:73
void * scratchAllocator
Definition: PxArticulationReducedCoordinate.h:124
PxSpatialForce * externalForces
Definition: PxArticulationReducedCoordinate.h:107
PxArticulationCache()
Definition: PxArticulationReducedCoordinate.h:91
Definition: PxArticulationReducedCoordinate.h:68
uint32_t PxU32
Definition: Px.h:48
Enum
Definition: PxSolverDefs.h:280
PxSpatialVelocity * linkVelocity
Definition: PxArticulationReducedCoordinate.h:114
PxVec3 worldAngVel
Definition: PxArticulationReducedCoordinate.h:72
PxReal * massMatrix
Definition: PxArticulationReducedCoordinate.h:109
#define PX_INLINE
Definition: PxPreprocessor.h:336
Definition: PxArticulationReducedCoordinate.h:57
3 Element vector class.
Definition: PxVec3.h:49
struct PxArticulationRootLinkData PX_ALIGN_SUFFIX