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-2018 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 << 1)
57  };
58  };
59 
60 
61  class PxJoint;
62 
64  PX_FLAGS_OPERATORS(PxArticulationFlag::Enum, PxU8)
65 
66  //PxKinematicJacobian is in world space 6x6 matrix
68  {
69  public:
70  //in each single column, top part is angular term and bottom is linear term
71  PxReal j[6][6];//[column][row]
72 
74  };
75 
77  {
78 
84  };
85 
87  {
88  public:
89  enum Enum
90  {
91  eVELOCITY = (1 << 0),
92  eACCELERATION = (1 << 1),
93  ePOSITION = (1 << 2),
94  eFORCE = (1 << 3),
95  eROOT = (1 << 4),
96  eALL = (eVELOCITY | eACCELERATION | ePOSITION| eROOT)
97  };
98  PxArticulationCache() : coefficentMatrix(NULL), lambda(NULL)
99  {}
100 
101  Cm::SpatialVector* externalForces; // N total number of links
102  PxKinematicJacobian* jacobian; //this store jacobian matrix
103  PxReal* massMatrix; //N X N (dof X dof)
104  PxReal* jointVelocity; //N total Dofs
105  PxReal* jointAcceleration; //N total Dofs
106  PxReal* jointPosition; //N total Dofs
107  PxReal* jointForce; //N total Dofs
108 
109  //application need to allocate those memory and assign them to the cache
112 
113  //root link data
115 
116  //These three members won't be set to zero when zeroCache get called
117  void* scratchMemory; //this is used for internal calculation
119  PxU32 version; //cache version. If the articulation configulation change, the cache is invalid
120 
121 
122  };
123 
125  PX_FLAGS_OPERATORS(PxArticulationCache::Enum, PxU8)
126 
127 
128 
139 #if PX_VC
140 #pragma warning(push)
141 #pragma warning(disable : 4435)
142 #endif
143 
145  {
146  public:
147 
148  virtual void release() = 0;
149 
150 
157  virtual void setArticulationFlags(PxArticulationFlags flags) = 0;
158 
166  virtual void setArticulationFlag(PxArticulationFlag::Enum flag, bool value) = 0;
167 
171  virtual PxArticulationFlags getArticulationFlags() const = 0;
172 
176  virtual PxU32 getDofs() const = 0;
177 
183  virtual PxArticulationCache* createCache() const = 0;
184 
190  virtual PxU32 getCacheDataSize() const = 0;
191 
197  virtual void zeroCache(PxArticulationCache& cache) = 0;
198 
199 
209  virtual void applyCache(PxArticulationCache& cache, const PxArticulationCacheFlags flag, bool autowake = true) = 0;
210 
219  virtual void copyInternalStateToCache(PxArticulationCache& cache, const PxArticulationCacheFlags flag) const = 0;
220 
221 
229  virtual void releaseCache(PxArticulationCache& cache) const = 0;
230 
231 
237  virtual void packJointData(const PxReal* maximum, PxReal* reduced) const = 0;
238 
244  virtual void unpackJointData(const PxReal* reduced, PxReal* maximum) const = 0;
245 
249  virtual void commonInit() const = 0;
250 
251 
260  virtual void computeGeneralizedGravityForce(PxArticulationCache& cache) const = 0;
261 
270  virtual void computeCoriolisAndCentrifugalForce(PxArticulationCache& cache) const = 0;
271 
280  virtual void computeGeneralizedExternalForce(PxArticulationCache& cache) const = 0;
289  virtual void computeJointAcceleration(PxArticulationCache& cache) const = 0;
290 
291 
301  virtual void computeJointForce(PxArticulationCache& cache) const = 0;
302 
310  virtual void computeKinematicJacobian(const PxU32 linkID, PxArticulationCache& cache) const = 0;
311 
312 
318  virtual void computeCoefficentMatrix(PxArticulationCache& cache) const = 0;
319 
320 
329  virtual bool computeLambda(PxArticulationCache& cache, PxArticulationCache& initialState, const PxReal* const jointTorque, const PxU32 maxIter) const = 0;
330 
337  virtual void computeGeneralizedMassMatrix(PxArticulationCache& cache) const = 0;
338 
345  virtual void addLoopJoint(PxJoint* joint) = 0;
346 
353  virtual void removeLoopJoint(PxJoint* joint) = 0;
354 
360  virtual PxU32 getNbLoopJoints() const = 0;
361 
375  virtual PxU32 getLoopJoints(PxJoint** userBuffer, PxU32 bufferSize, PxU32 startIndex = 0) const = 0;
376 
382  virtual PxU32 getCoefficentMatrixSize() const = 0;
383 
391  virtual void teleportRootLink(const PxTransform& pose, bool autowake) = 0;
392 
393  protected:
394  PX_INLINE PxArticulationReducedCoordinate(PxType concreteType, PxBaseFlags baseFlags) : PxArticulationBase(concreteType, baseFlags) {}
397  };
398 
399 #if PX_VC
400 #pragma warning(pop)
401 #endif
402 
403 #if !PX_DOXYGEN
404 } // namespace physx
405 #endif
406 
407 
409 #endif
Definition: GuContactBuffer.h:37
PxU32 nbColumns
Definition: PxArticulationReducedCoordinate.h:73
PxU32 version
Definition: PxArticulationReducedCoordinate.h:119
PxFlags< PxArticulationCache::Enum, PxU8 > PxArticulationCacheFlags
Definition: PxArticulationReducedCoordinate.h:124
PxReal * jointVelocity
Definition: PxArticulationReducedCoordinate.h:104
float PxReal
Definition: PxSimpleTypes.h:78
Definition: PxArticulationReducedCoordinate.h:67
PX_INLINE PxArticulationReducedCoordinate(PxType concreteType, PxBaseFlags baseFlags)
Definition: PxArticulationReducedCoordinate.h:394
PxTransform transform
Definition: PxArticulationReducedCoordinate.h:79
Definition: PxArticulationReducedCoordinate.h:52
PxFlags< PxArticulationFlag::Enum, PxU8 > PxArticulationFlags
Definition: PxArticulationReducedCoordinate.h:61
PxU16 PxType
Definition: PxBase.h:49
Definition: PxArticulationReducedCoordinate.h:86
PxKinematicJacobian * jacobian
Definition: PxArticulationReducedCoordinate.h:102
PxVec3 linAcel
Definition: PxArticulationReducedCoordinate.h:82
PxReal * jointAcceleration
Definition: PxArticulationReducedCoordinate.h:105
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
a tree structure of bodies connected by joints that is treated as a unit by the dynamics solver ...
Definition: PxArticulationReducedCoordinate.h:144
PxU16 flags
a set of Px1DConstraintFlags
Definition: PxConstraintDesc.h:110
virtual ~PxArticulationReducedCoordinate()
Definition: PxArticulationReducedCoordinate.h:396
PxReal * coefficentMatrix
Definition: PxArticulationReducedCoordinate.h:110
PxReal * lambda
Definition: PxArticulationReducedCoordinate.h:111
uint8_t PxU8
Definition: PxSimpleTypes.h:75
class representing a rigid euclidean transform as a quaternion and a vector
Definition: PxTransform.h:48
PxReal * jointPosition
Definition: PxArticulationReducedCoordinate.h:106
PxReal * jointForce
Definition: PxArticulationReducedCoordinate.h:107
Cm::SpatialVector * externalForces
Definition: PxArticulationReducedCoordinate.h:101
Enum
Definition: PxArticulationReducedCoordinate.h:89
void * scratchMemory
Definition: PxArticulationReducedCoordinate.h:117
PX_INLINE PxArticulationReducedCoordinate(PxBaseFlags baseFlags)
Definition: PxArticulationReducedCoordinate.h:395
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:57
PxArticulationRootLinkData rootLinkData
Definition: PxArticulationReducedCoordinate.h:114
PxVec3 angVel
Definition: PxArticulationReducedCoordinate.h:81
Container for bitfield flag variables associated with a specific enum type.
Definition: PxFlags.h:73
void * scratchAllocator
Definition: PxArticulationReducedCoordinate.h:118
PxArticulationCache()
Definition: PxArticulationReducedCoordinate.h:98
Definition: PxArticulationReducedCoordinate.h:76
uint32_t PxU32
Definition: Px.h:48
Enum
Definition: PxArticulationReducedCoordinate.h:54
PxReal * massMatrix
Definition: PxArticulationReducedCoordinate.h:103
PxVec3 linVel
Definition: PxArticulationReducedCoordinate.h:80
#define PX_INLINE
Definition: PxPreprocessor.h:349
PxVec3 angAcel
Definition: PxArticulationReducedCoordinate.h:83
3 Element vector class.
Definition: PxVec3.h:49