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 
40 #if !PX_DOXYGEN
41 namespace physx
42 {
43 #endif
44 
45  namespace Cm
46  {
47  class SpatialVector;
48  }
49 
50  class PxContactJoint;
51 
53  {
54  enum Enum
55  {
56  eFIX_BASE = (1 << 0)
57  };
58  };
59 
60  class PxJoint;
61 
63  PX_FLAGS_OPERATORS(PxArticulationFlag::Enum, PxU8)
64 
65  //PxKinematicJacobian is in world space 6x6 matrix
67  {
68  public:
69  //in each single column, top part is angular term and bottom is linear term
70  PxReal j[6][6];//[column][row]
71 
73  };
74 
76  {
82  };
83 
85  {
86  public:
87  enum Enum
88  {
89  eVELOCITY = (1 << 0),
90  eACCELERATION = (1 << 1),
91  ePOSITION = (1 << 2),
92  eFORCE = (1 << 3),
93  eROOT = (1 << 4),
94  eALL = (eVELOCITY | eACCELERATION | ePOSITION| eROOT)
95  };
96  PxArticulationCache() : coefficientMatrix(NULL), lambda(NULL)
97  {}
98 
99  Cm::SpatialVector* externalForces; // N = getNbLinks()
100  PxKinematicJacobian* jacobian; // Jacobian matrix, N = NumJoints, NumJoints = getNbLinks() - 1
101  PxReal* denseJacobian; // Dense Jacobian, N = 6*getDofs()*NumJoints, NumJoints = getNbLinks() - 1
102  PxReal* massMatrix; // N = getDofs()*getDofs()
103  PxReal* jointVelocity; // N = getDofs()
104  PxReal* jointAcceleration; // N = getDofs()
105  PxReal* jointPosition; // N = getDofs()
106  PxReal* jointForce; // N = getDofs()
108 
109  //application need to allocate those memory and assign them to the cache
112 
113 
114 
115  //These three members won't be set to zero when zeroCache get called
116  void* scratchMemory; //this is used for internal calculation
118  PxU32 version; //cache version. If the articulation configulation change, the cache is invalid
119  };
120 
122  PX_FLAGS_OPERATORS(PxArticulationCache::Enum, PxU8)
123 
124 
135 #if PX_VC
136 #pragma warning(push)
137 #pragma warning(disable : 4435)
138 #endif
139 
141  {
142  public:
143 
144  virtual void release() = 0;
145 
152  virtual void setArticulationFlags(PxArticulationFlags flags) = 0;
153 
161  virtual void setArticulationFlag(PxArticulationFlag::Enum flag, bool value) = 0;
162 
166  virtual PxArticulationFlags getArticulationFlags() const = 0;
167 
171  virtual PxU32 getDofs() const = 0;
172 
178  virtual PxArticulationCache* createCache() const = 0;
179 
185  virtual PxU32 getCacheDataSize() const = 0;
186 
192  virtual void zeroCache(PxArticulationCache& cache) = 0;
193 
203  virtual void applyCache(PxArticulationCache& cache, const PxArticulationCacheFlags flag, bool autowake = true) = 0;
204 
213  virtual void copyInternalStateToCache(PxArticulationCache& cache, const PxArticulationCacheFlags flag) const = 0;
214 
222  virtual void releaseCache(PxArticulationCache& cache) const = 0;
223 
229  virtual void packJointData(const PxReal* maximum, PxReal* reduced) const = 0;
230 
236  virtual void unpackJointData(const PxReal* reduced, PxReal* maximum) const = 0;
237 
241  virtual void commonInit() const = 0;
242 
251  virtual void computeGeneralizedGravityForce(PxArticulationCache& cache) const = 0;
252 
261  virtual void computeCoriolisAndCentrifugalForce(PxArticulationCache& cache) const = 0;
262 
271  virtual void computeGeneralizedExternalForce(PxArticulationCache& cache) const = 0;
272 
281  virtual void computeJointAcceleration(PxArticulationCache& cache) const = 0;
282 
292  virtual void computeJointForce(PxArticulationCache& cache) const = 0;
293 
301  virtual void computeKinematicJacobian(const PxU32 linkID, PxArticulationCache& cache) const = 0;
302 
312  virtual void computeDenseJacobian(PxArticulationCache& cache, PxU32& nRows, PxU32& nCols) const = 0;
313 
314 
320  virtual void computeCoefficientMatrix(PxArticulationCache& cache) const = 0;
321 
330  virtual bool computeLambda(PxArticulationCache& cache, PxArticulationCache& initialState, const PxReal* const jointTorque, const PxU32 maxIter) const = 0;
331 
338  virtual void computeGeneralizedMassMatrix(PxArticulationCache& cache) const = 0;
339 
346  virtual void addLoopJoint(PxJoint* joint) = 0;
347 
354  virtual void removeLoopJoint(PxJoint* joint) = 0;
355 
360  virtual PxU32 getNbLoopJoints() const = 0;
361 
374  virtual PxU32 getLoopJoints(PxJoint** userBuffer, PxU32 bufferSize, PxU32 startIndex = 0) const = 0;
375 
380  virtual PxU32 getCoefficientMatrixSize() const = 0;
381 
389  virtual void teleportRootLink(const PxTransform& pose, bool autowake) = 0;
390 
391  protected:
392  PX_INLINE PxArticulationReducedCoordinate(PxType concreteType, PxBaseFlags baseFlags) : PxArticulationBase(concreteType, baseFlags) {}
395  };
396 
397 #if PX_VC
398 #pragma warning(pop)
399 #endif
400 
401 #if !PX_DOXYGEN
402 } // namespace physx
403 #endif
404 
406 #endif
Definition: GuContactBuffer.h:37
PxU32 nbColumns
Definition: PxArticulationReducedCoordinate.h:72
PxU32 version
Definition: PxArticulationReducedCoordinate.h:118
PxFlags< PxArticulationCache::Enum, PxU8 > PxArticulationCacheFlags
Definition: PxArticulationReducedCoordinate.h:121
PxReal * jointVelocity
Definition: PxArticulationReducedCoordinate.h:103
PxVec3 worldLinAccel
Definition: PxArticulationReducedCoordinate.h:80
float PxReal
Definition: PxSimpleTypes.h:78
Definition: PxArticulationReducedCoordinate.h:66
PX_INLINE PxArticulationReducedCoordinate(PxType concreteType, PxBaseFlags baseFlags)
Definition: PxArticulationReducedCoordinate.h:392
PxTransform transform
Definition: PxArticulationReducedCoordinate.h:77
Definition: PxArticulationReducedCoordinate.h:52
PxFlags< PxArticulationFlag::Enum, PxU8 > PxArticulationFlags
Definition: PxArticulationReducedCoordinate.h:60
PxU16 PxType
Definition: PxBase.h:49
PxReal * denseJacobian
Definition: PxArticulationReducedCoordinate.h:101
Definition: PxArticulationReducedCoordinate.h:84
PxKinematicJacobian * jacobian
Definition: PxArticulationReducedCoordinate.h:100
PxReal * jointAcceleration
Definition: PxArticulationReducedCoordinate.h:104
a joint that maintains an upper or lower bound (or both) on the distance between two points on differ...
Definition: PxContactJoint.h:95
a base interface providing common functionality for PhysX joints
Definition: PxJoint.h:101
PxArticulationRootLinkData * rootLinkData
Definition: PxArticulationReducedCoordinate.h:107
a tree structure of bodies connected by joints that is treated as a unit by the dynamics solver ...
Definition: PxArticulationReducedCoordinate.h:140
PxU16 flags
a set of Px1DConstraintFlags
Definition: PxConstraintDesc.h:110
virtual ~PxArticulationReducedCoordinate()
Definition: PxArticulationReducedCoordinate.h:394
PxReal * lambda
Definition: PxArticulationReducedCoordinate.h:111
uint8_t PxU8
Definition: PxSimpleTypes.h:75
PxVec3 worldLinVel
Definition: PxArticulationReducedCoordinate.h:78
class representing a rigid euclidean transform as a quaternion and a vector
Definition: PxTransform.h:48
PxReal * jointPosition
Definition: PxArticulationReducedCoordinate.h:105
PxReal * jointForce
Definition: PxArticulationReducedCoordinate.h:106
PxVec3 worldAngAccel
Definition: PxArticulationReducedCoordinate.h:81
PxReal * coefficientMatrix
Definition: PxArticulationReducedCoordinate.h:110
Cm::SpatialVector * externalForces
Definition: PxArticulationReducedCoordinate.h:99
Enum
Definition: PxArticulationReducedCoordinate.h:87
void * scratchMemory
Definition: PxArticulationReducedCoordinate.h:116
PX_INLINE PxArticulationReducedCoordinate(PxBaseFlags baseFlags)
Definition: PxArticulationReducedCoordinate.h:393
Definition: PxArticulationReducedCoordinate.h:45
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:117
PxArticulationCache()
Definition: PxArticulationReducedCoordinate.h:96
Definition: PxArticulationReducedCoordinate.h:75
uint32_t PxU32
Definition: Px.h:48
Enum
Definition: PxArticulationReducedCoordinate.h:54
PxVec3 worldAngVel
Definition: PxArticulationReducedCoordinate.h:79
PxReal * massMatrix
Definition: PxArticulationReducedCoordinate.h:102
#define PX_INLINE
Definition: PxPreprocessor.h:324
3 Element vector class.
Definition: PxVec3.h:49