PxArticulationReducedCoordinate.h

Go to the documentation of this file.
00001 // This code contains NVIDIA Confidential Information and is disclosed to you
00002 // under a form of NVIDIA software license agreement provided separately to you.
00003 //
00004 // Notice
00005 // NVIDIA Corporation and its licensors retain all intellectual property and
00006 // proprietary rights in and to this software and related documentation and
00007 // any modifications thereto. Any use, reproduction, disclosure, or
00008 // distribution of this software and related documentation without an express
00009 // license agreement from NVIDIA Corporation is strictly prohibited.
00010 //
00011 // ALL NVIDIA DESIGN SPECIFICATIONS, CODE ARE PROVIDED "AS IS.". NVIDIA MAKES
00012 // NO WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO
00013 // THE MATERIALS, AND EXPRESSLY DISCLAIMS ALL IMPLIED WARRANTIES OF NONINFRINGEMENT,
00014 // MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE.
00015 //
00016 // Information and code furnished is believed to be accurate and reliable.
00017 // However, NVIDIA Corporation assumes no responsibility for the consequences of use of such
00018 // information or for any infringement of patents or other rights of third parties that may
00019 // result from its use. No license is granted by implication or otherwise under any patent
00020 // or patent rights of NVIDIA Corporation. Details are subject to change without notice.
00021 // This code supersedes and replaces all information previously supplied.
00022 // NVIDIA Corporation products are not authorized for use as critical
00023 // components in life support devices or systems without express written approval of
00024 // NVIDIA Corporation.
00025 //
00026 // Copyright (c) 2008-2018 NVIDIA Corporation. All rights reserved.
00027 // Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved.
00028 // Copyright (c) 2001-2004 NovodeX AG. All rights reserved.  
00029 
00030 
00031 #ifndef PX_PHYSICS_NX_ARTICULATION_RC
00032 #define PX_PHYSICS_NX_ARTICULATION_RC
00033 
00036 #include "PxArticulationBase.h"
00037 #include "foundation/PxVec3.h"
00038 #include "foundation/PxTransform.h"
00039 
00040 #if !PX_DOXYGEN
00041 namespace physx
00042 {
00043 #endif
00044 
00045     namespace Cm
00046     {
00047         class SpatialVector;
00048     }
00049 
00050     class PxContactJoint;
00051 
00052     struct PxArticulationFlag
00053     {
00054         enum Enum
00055         {
00056             eFIX_BASE = (1 << 1)
00057         };
00058     };
00059 
00060     
00061     class PxJoint;
00062 
00063     typedef PxFlags<PxArticulationFlag::Enum, PxU8> PxArticulationFlags;
00064     PX_FLAGS_OPERATORS(PxArticulationFlag::Enum, PxU8)
00065 
00066     //PxKinematicJacobian is in world space 6x6 matrix
00067     class PxKinematicJacobian
00068     {
00069     public:
00070         //in each single column, top part is angular term and bottom is linear term
00071         PxReal j[6][6];//[column][row]
00072 
00073         PxU32   nbColumns;
00074     };
00075 
00076     class PxArticulationCache
00077     {
00078     public:
00079         enum Enum
00080         {
00081             eVELOCITY       = (1 << 0),     
00082             eACCELERATION   = (1 << 1),     
00083             ePOSITION       = (1 << 2),     
00084             eFORCE          = (1 << 3),     
00085             eROOT           = (1 << 4),     
00086             eALL            = (eVELOCITY | eACCELERATION | ePOSITION| eROOT)
00087         };
00088         PxArticulationCache() : coefficentMatrix(NULL), lambda(NULL)
00089         {}
00090 
00091         Cm::SpatialVector*      externalForces; // N total number of links
00092         PxKinematicJacobian*    jacobian; //this store jacobian matrix
00093         PxReal*                 massMatrix; //N X N (dof X dof)
00094         PxReal*                 jointVelocity; //N total Dofs
00095         PxReal*                 jointAcceleration; //N total Dofs
00096         PxReal*                 jointPosition; //N total Dofs
00097         PxReal*                 jointForce; //N total Dofs
00098 
00099         //application need to allocate those memory and assign them to the cache
00100         PxReal*                 coefficentMatrix; 
00101         PxReal*                 lambda;
00102         
00103         PxTransform             rootTransform;
00104         PxVec3                  rootLinVel;
00105         PxVec3                  rootAngVel;
00106 
00107         //These three members won't be set to zero when zeroCache get called 
00108         void*                   scratchMemory;      //this is used for internal calculation
00109         void*                   scratchAllocator;
00110         PxU32                   version; //cache version. If the articulation configulation change, the cache is invalid
00111 
00112         
00113     };
00114 
00115     typedef PxFlags<PxArticulationCache::Enum, PxU8> PxArticulationCacheFlags;
00116     PX_FLAGS_OPERATORS(PxArticulationCache::Enum, PxU8)
00117 
00118 
00119     
00130 #if PX_VC
00131 #pragma warning(push)
00132 #pragma warning(disable : 4435)
00133 #endif
00134 
00135     class PxArticulationReducedCoordinate : public PxArticulationBase
00136     {
00137     public:
00138 
00139         virtual     void                            release() = 0;
00140 
00141 
00149         virtual     void                            setArticulationFlags(PxArticulationFlags flags) = 0;
00150 
00154         virtual     PxArticulationFlags             getArticulationFlags() const = 0;
00155 
00159         virtual         PxU32                       getDofs() const = 0;
00160 
00166         virtual     PxArticulationCache*            createCache() const = 0;
00167 
00168         virtual     PxU32                           getCacheDataSize() const = 0;
00169 
00175         virtual     void                            zeroCache(PxArticulationCache& cache) = 0;
00176 
00177     
00187         virtual     void                            applyCache(PxArticulationCache& cache, const PxArticulationCacheFlags flag, bool autowake = true) = 0;
00188 
00197         virtual     void                        copyInternalStateToCache(PxArticulationCache& cache, const PxArticulationCacheFlags flag) const = 0;
00198     
00199 
00207         virtual     void                        releaseCache(PxArticulationCache& cache) const = 0;
00208     
00209 
00215         virtual     void                        packJointData(const PxReal* maximum, PxReal* reduced) const = 0;
00216 
00222         virtual     void                        unpackJointData(const PxReal* reduced, PxReal* maximum) const = 0;
00223 
00227         virtual     void                        commonInit() const = 0;
00228 
00229 
00238         virtual     void                        computeGeneralizedGravityForce(PxArticulationCache& cache) const = 0;
00239 
00248         virtual     void                        computeCoriolisAndCentrifugalForce(PxArticulationCache& cache) const = 0;
00249 
00258         virtual     void                        computeGeneralizedExternalForce(PxArticulationCache& cache) const = 0;
00267         virtual     void                        computeJointAcceleration(PxArticulationCache& cache) const = 0;
00268 
00269 
00279         virtual     void                        computeJointForce(PxArticulationCache& cache) const = 0;
00280 
00288         virtual     void                        computeKinematicJacobian(const PxU32 linkID, PxArticulationCache& cache) const = 0;
00289 
00290 
00296         virtual     void                        computeCoefficentMatrix(PxArticulationCache& cache) const = 0;
00297 
00298         
00307         virtual     bool                        computeLambda(PxArticulationCache& cache, PxArticulationCache& initialState, const PxReal* const jointTorque, const PxU32 maxIter) const = 0;
00308         
00315         virtual     void                        computeGeneralizedMassMatrix(PxArticulationCache& cache) const = 0;
00316     
00323         virtual     void                        addLoopJoint(PxJoint* joint) = 0;
00324 
00331         virtual     void                        removeLoopJoint(PxJoint* joint) = 0;
00332 
00338         virtual     PxU32                       getNbLoopJoints() const = 0;
00339 
00353         virtual     PxU32                       getLoopJoints(PxJoint** userBuffer, PxU32 bufferSize, PxU32 startIndex = 0) const = 0;
00354 
00360         virtual     PxU32                       getCoefficentMatrixSize() const = 0;
00361 
00369         virtual     void                        teleportRootLink(const PxTransform& pose, bool autowake) = 0;
00370 
00371     protected:
00372         PX_INLINE                   PxArticulationReducedCoordinate(PxType concreteType, PxBaseFlags baseFlags) : PxArticulationBase(concreteType, baseFlags) {}
00373         PX_INLINE                   PxArticulationReducedCoordinate(PxBaseFlags baseFlags) : PxArticulationBase(baseFlags) {}
00374         virtual                     ~PxArticulationReducedCoordinate() {}
00375     };
00376 
00377 #if PX_VC
00378 #pragma warning(pop)
00379 #endif
00380 
00381 #if !PX_DOXYGEN
00382 } // namespace physx
00383 #endif
00384 
00385 
00387 #endif


Copyright © 2008-2018 NVIDIA Corporation, 2701 San Tomas Expressway, Santa Clara, CA 95050 U.S.A. All rights reserved. www.nvidia.com