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-2019 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  class PxJoint;
57 
59  {
65  };
66 
68  {
69  public:
70  enum Enum
71  {
72  eVELOCITY = (1 << 0),
73  eACCELERATION = (1 << 1),
74  ePOSITION = (1 << 2),
75  eFORCE = (1 << 3),
76  eROOT = (1 << 4),
77  eALL = (eVELOCITY | eACCELERATION | ePOSITION| eROOT)
78  };
80  externalForces (NULL),
81  denseJacobian (NULL),
82  massMatrix (NULL),
83  jointVelocity (NULL),
84  jointAcceleration (NULL),
85  jointPosition (NULL),
86  jointForce (NULL),
87  rootLinkData (NULL),
88  coefficientMatrix (NULL),
89  lambda (NULL),
90  scratchMemory (NULL),
91  scratchAllocator (NULL),
92  version (0)
93  {}
94 
95  PxSpatialForce* externalForces; // N = getNbLinks()
96  PxReal* denseJacobian; // N = 6*getDofs()*NumJoints, NumJoints = getNbLinks() - 1
97  PxReal* massMatrix; // N = getDofs()*getDofs()
98  PxReal* jointVelocity; // N = getDofs()
99  PxReal* jointAcceleration; // N = getDofs()
100  PxReal* jointPosition; // N = getDofs()
101  PxReal* jointForce; // N = getDofs()
103 
104  //application need to allocate those memory and assign them to the cache
107 
108  //These three members won't be set to zero when zeroCache get called
109  void* scratchMemory; //this is used for internal calculation
111  PxU32 version; //cache version. If the articulation configuration change, the cache is invalid
112  };
113 
115  PX_FLAGS_OPERATORS(PxArticulationCache::Enum, PxU8)
116 
117 
128 #if PX_VC
129 #pragma warning(push)
130 #pragma warning(disable : 4435)
131 #endif
134  {
135  public:
136 
137  virtual void release() = 0;
138 
145  virtual void setArticulationFlags(PxArticulationFlags flags) = 0;
146 
154  virtual void setArticulationFlag(PxArticulationFlag::Enum flag, bool value) = 0;
155 
159  virtual PxArticulationFlags getArticulationFlags() const = 0;
160 
164  virtual PxU32 getDofs() const = 0;
165 
171  virtual PxArticulationCache* createCache() const = 0;
172 
178  virtual PxU32 getCacheDataSize() const = 0;
179 
185  virtual void zeroCache(PxArticulationCache& cache) = 0;
186 
196  virtual void applyCache(PxArticulationCache& cache, const PxArticulationCacheFlags flag, bool autowake = true) = 0;
197 
206  virtual void copyInternalStateToCache(PxArticulationCache& cache, const PxArticulationCacheFlags flag) const = 0;
207 
215  virtual void releaseCache(PxArticulationCache& cache) const = 0;
216 
222  virtual void packJointData(const PxReal* maximum, PxReal* reduced) const = 0;
223 
229  virtual void unpackJointData(const PxReal* reduced, PxReal* maximum) const = 0;
230 
234  virtual void commonInit() const = 0;
235 
244  virtual void computeGeneralizedGravityForce(PxArticulationCache& cache) const = 0;
245 
254  virtual void computeCoriolisAndCentrifugalForce(PxArticulationCache& cache) const = 0;
255 
264  virtual void computeGeneralizedExternalForce(PxArticulationCache& cache) const = 0;
265 
274  virtual void computeJointAcceleration(PxArticulationCache& cache) const = 0;
275 
285  virtual void computeJointForce(PxArticulationCache& cache) const = 0;
286 
296  virtual void computeDenseJacobian(PxArticulationCache& cache, PxU32& nRows, PxU32& nCols) const = 0;
297 
298 
304  virtual void computeCoefficientMatrix(PxArticulationCache& cache) const = 0;
305 
314  virtual bool computeLambda(PxArticulationCache& cache, PxArticulationCache& initialState, const PxReal* const jointTorque, const PxU32 maxIter) const = 0;
315 
322  virtual void computeGeneralizedMassMatrix(PxArticulationCache& cache) const = 0;
323 
330  virtual void addLoopJoint(PxJoint* joint) = 0;
331 
338  virtual void removeLoopJoint(PxJoint* joint) = 0;
339 
344  virtual PxU32 getNbLoopJoints() const = 0;
345 
358  virtual PxU32 getLoopJoints(PxJoint** userBuffer, PxU32 bufferSize, PxU32 startIndex = 0) const = 0;
359 
364  virtual PxU32 getCoefficientMatrixSize() const = 0;
365 
373  virtual void teleportRootLink(const PxTransform& pose, bool autowake) = 0;
374 
375  protected:
376  PX_INLINE PxArticulationReducedCoordinate(PxType concreteType, PxBaseFlags baseFlags) : PxArticulationBase(concreteType, baseFlags) {}
379  };
380 
381 #if PX_VC
382 #pragma warning(pop)
383 #endif
384 
385 #if !PX_DOXYGEN
386 } // namespace physx
387 #endif
388 
390 #endif
Definition: GuContactBuffer.h:37
PxReal pad0
Definition: PxArticulationReducedCoordinate.h:50
PxU32 version
Definition: PxArticulationReducedCoordinate.h:111
PxFlags< PxArticulationCache::Enum, PxU8 > PxArticulationCacheFlags
Definition: PxArticulationReducedCoordinate.h:114
Definition: PxArticulationReducedCoordinate.h:47
PxReal pad1
Definition: PxArticulationReducedCoordinate.h:52
PxReal * jointVelocity
Definition: PxArticulationReducedCoordinate.h:98
PxVec3 worldLinAccel
Definition: PxArticulationReducedCoordinate.h:63
float PxReal
Definition: PxSimpleTypes.h:78
PX_INLINE PxArticulationReducedCoordinate(PxType concreteType, PxBaseFlags baseFlags)
Definition: PxArticulationReducedCoordinate.h:376
PxTransform transform
Definition: PxArticulationReducedCoordinate.h:60
PxU16 PxType
Definition: PxBase.h:49
PxReal * denseJacobian
Definition: PxArticulationReducedCoordinate.h:96
Definition: PxArticulationReducedCoordinate.h:67
PxReal * jointAcceleration
Definition: PxArticulationReducedCoordinate.h:99
a base interface providing common functionality for PhysX joints
Definition: PxJoint.h:101
PxVec3 force
Definition: PxArticulationReducedCoordinate.h:49
PxArticulationRootLinkData * rootLinkData
Definition: PxArticulationReducedCoordinate.h:102
a tree structure of bodies connected by joints that is treated as a unit by the dynamics solver ...
Definition: PxArticulationReducedCoordinate.h:133
PxU16 flags
a set of Px1DConstraintFlags
Definition: PxConstraintDesc.h:110
virtual ~PxArticulationReducedCoordinate()
Definition: PxArticulationReducedCoordinate.h:378
PxReal * lambda
Definition: PxArticulationReducedCoordinate.h:106
#define PX_ALIGN_PREFIX(alignment)
Definition: PxPreprocessor.h:404
uint8_t PxU8
Definition: PxSimpleTypes.h:75
PxVec3 worldLinVel
Definition: PxArticulationReducedCoordinate.h:61
class representing a rigid euclidean transform as a quaternion and a vector
Definition: PxTransform.h:48
PxReal * jointPosition
Definition: PxArticulationReducedCoordinate.h:100
PxReal * jointForce
Definition: PxArticulationReducedCoordinate.h:101
PxVec3 worldAngAccel
Definition: PxArticulationReducedCoordinate.h:64
PxVec3 torque
Definition: PxArticulationReducedCoordinate.h:51
PxReal * coefficientMatrix
Definition: PxArticulationReducedCoordinate.h:105
Enum
Definition: PxArticulationReducedCoordinate.h:70
void * scratchMemory
Definition: PxArticulationReducedCoordinate.h:109
PX_INLINE PxArticulationReducedCoordinate(PxBaseFlags baseFlags)
Definition: PxArticulationReducedCoordinate.h:377
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:110
PxSpatialForce * externalForces
Definition: PxArticulationReducedCoordinate.h:95
PxArticulationCache()
Definition: PxArticulationReducedCoordinate.h:79
Definition: PxArticulationReducedCoordinate.h:58
uint32_t PxU32
Definition: Px.h:48
Enum
Definition: PxSolverDefs.h:280
PxVec3 worldAngVel
Definition: PxArticulationReducedCoordinate.h:62
PxReal * massMatrix
Definition: PxArticulationReducedCoordinate.h:97
#define PX_INLINE
Definition: PxPreprocessor.h:331
3 Element vector class.
Definition: PxVec3.h:49
struct PxArticulationRootLinkData PX_ALIGN_SUFFIX