PxVehicleUtilTelemetry.h

Go to the documentation of this file.
00001 //
00002 // Redistribution and use in source and binary forms, with or without
00003 // modification, are permitted provided that the following conditions
00004 // are met:
00005 //  * Redistributions of source code must retain the above copyright
00006 //    notice, this list of conditions and the following disclaimer.
00007 //  * Redistributions in binary form must reproduce the above copyright
00008 //    notice, this list of conditions and the following disclaimer in the
00009 //    documentation and/or other materials provided with the distribution.
00010 //  * Neither the name of NVIDIA CORPORATION nor the names of its
00011 //    contributors may be used to endorse or promote products derived
00012 //    from this software without specific prior written permission.
00013 //
00014 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY
00015 // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
00016 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
00017 // PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR
00018 // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
00019 // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
00020 // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
00021 // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
00022 // OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
00023 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
00024 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
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 #ifndef PX_VEHICLE_UTILSTELEMETRY_H
00031 #define PX_VEHICLE_UTILSTELEMETRY_H
00032 
00036 #include "vehicle/PxVehicleSDK.h"
00037 #include "foundation/PxSimpleTypes.h"
00038 #include "foundation/PxVec3.h"
00039 
00040 #if !PX_DOXYGEN
00041 namespace physx
00042 {
00043 #endif
00044 
00045 #if PX_DEBUG_VEHICLE_ON
00046 
00047 class PxVehicleGraphDesc
00048 {
00049 
00050     friend class PxVehicleGraph;
00051 
00052     PxVehicleGraphDesc();
00053 
00058     PxReal mPosX;
00059 
00064     PxReal mPosY;
00065 
00070     PxReal mSizeX;
00071 
00076     PxReal mSizeY;
00077 
00081     PxVec3 mBackgroundColor;
00082 
00086     PxReal mAlpha;
00087 
00088 private:
00089 
00090     bool isValid() const;
00091 };
00092 
00093 struct PxVehicleGraphChannelDesc
00094 {
00095 public:
00096 
00097     friend class PxVehicleGraph;
00098 
00099     PxVehicleGraphChannelDesc();
00100 
00104     PxReal mMinY;
00105 
00109     PxReal mMaxY;
00110 
00115     PxReal mMidY;
00116 
00120     PxVec3 mColorLow;
00121 
00125     PxVec3 mColorHigh;
00126 
00130     char* mTitle;
00131 
00132 private:
00133 
00134     bool isValid() const;
00135 };
00136 
00137 struct PxVehicleWheelGraphChannel
00138 {
00139     enum Enum
00140     {
00141         eJOUNCE=0,
00142         eSUSPFORCE,
00143         eTIRELOAD,
00144         eNORMALIZED_TIRELOAD,
00145         eWHEEL_OMEGA, 
00146         eTIRE_FRICTION,
00147         eTIRE_LONG_SLIP,
00148         eNORM_TIRE_LONG_FORCE,
00149         eTIRE_LAT_SLIP,
00150         eNORM_TIRE_LAT_FORCE,
00151         eNORM_TIRE_ALIGNING_MOMENT,
00152         eMAX_NB_WHEEL_CHANNELS
00153     };
00154 };
00155 
00156 struct PxVehicleDriveGraphChannel
00157 {
00158     enum Enum
00159     {
00160         eENGINE_REVS=0,
00161         eENGINE_DRIVE_TORQUE,
00162         eCLUTCH_SLIP,
00163         eACCEL_CONTROL,                 //TANK_ACCEL
00164         eBRAKE_CONTROL,                 //TANK_BRAKE_LEFT
00165         eHANDBRAKE_CONTROL,             //TANK_BRAKE_RIGHT
00166         eSTEER_LEFT_CONTROL,            //TANK_THRUST_LEFT
00167         eSTEER_RIGHT_CONTROL,           //TANK_THRUST_RIGHT
00168         eGEAR_RATIO,
00169         eMAX_NB_DRIVE_CHANNELS
00170     };
00171 };
00172 
00173 struct PxVehicleGraphType
00174 {
00175     enum Enum
00176     {
00177         eWHEEL=0,
00178         eDRIVE
00179     };
00180 };
00181 
00182 
00183 class PxVehicleGraph
00184 {
00185 public:
00186 
00187     friend class PxVehicleTelemetryData;
00188     friend class PxVehicleUpdate;
00189 
00190     enum
00191     {
00192         eMAX_NB_SAMPLES=256
00193     };
00194 
00195     enum
00196     {
00197         eMAX_NB_TITLE_CHARS=256
00198     };
00199 
00200     enum
00201     {
00202         eMAX_NB_CHANNELS=12
00203     };
00204 
00208     void setup(const PxVehicleGraphDesc& desc, const PxVehicleGraphType::Enum graphType);
00209 
00213     void clearRecordedChannelData();
00214 
00218     const PxVec3& getBackgroundColor() const {return mBackgroundColor;}
00219 
00223     PxReal getBackgroundAlpha() const {return mBackgroundAlpha;}
00224 
00233     void getBackgroundCoords(PxReal& xMin, PxReal& yMin, PxReal& xMax, PxReal& yMax) const {xMin = mBackgroundMinX;xMax = mBackgroundMaxX;yMin = mBackgroundMinY;yMax = mBackgroundMaxY;}
00234 
00242     void computeGraphChannel(const PxU32 channel, PxReal* xy, PxVec3* colors, char* title) const;
00243 
00247     PxF32 getLatestValue(const PxU32 channel) const ;
00248 
00249 private:
00250 
00251     //Min and max of each sample.
00252     PxReal mChannelMinY[eMAX_NB_CHANNELS];
00253     PxReal mChannelMaxY[eMAX_NB_CHANNELS];
00254     //Discriminate between high and low values with different colors.
00255     PxReal mChannelMidY[eMAX_NB_CHANNELS];
00256     //Different colors for values than midY and less than midY.
00257     PxVec3 mChannelColorLow[eMAX_NB_CHANNELS];
00258     PxVec3 mChannelColorHigh[eMAX_NB_CHANNELS];
00259     //Title of graph
00260     char mChannelTitle[eMAX_NB_CHANNELS][eMAX_NB_TITLE_CHARS];
00261     //Graph data.
00262     PxReal mChannelSamples[eMAX_NB_CHANNELS][eMAX_NB_SAMPLES];
00263 
00264     //Background color,alpha,coords
00265     PxVec3 mBackgroundColor;
00266     PxReal mBackgroundAlpha;
00267     PxReal mBackgroundMinX;
00268     PxReal mBackgroundMaxX;
00269     PxReal mBackgroundMinY;
00270     PxReal mBackgroundMaxY;
00271 
00272     PxU32 mSampleTide;
00273 
00274     PxU32 mNbChannels;
00275 
00276     PxU32 mPad[2];
00277 
00278 
00279     void setup
00280         (const PxF32 graphSizeX, const PxF32 graphSizeY,
00281         const PxF32 engineGraphPosX, const PxF32 engineGraphPosY,
00282         const PxF32* const wheelGraphPosX, const PxF32* const wheelGraphPosY,
00283         const PxVec3& backgroundColor, const PxVec3& lineColorHigh, const PxVec3& lineColorLow);
00284 
00285     void updateTimeSlice(const PxReal* const samples);
00286 
00287     void setChannel(PxVehicleGraphChannelDesc& desc, const PxU32 channel);
00288 
00289     void setupEngineGraph
00290         (const PxF32 sizeX, const PxF32 sizeY, const PxF32 posX, const PxF32 posY, 
00291         const PxVec3& backgoundColor, const PxVec3& lineColorHigh, const PxVec3& lineColorLow);
00292 
00293     void setupWheelGraph
00294         (const PxF32 sizeX, const PxF32 sizeY, const PxF32 posX, const PxF32 posY, 
00295         const PxVec3& backgoundColor, const PxVec3& lineColorHigh, const PxVec3& lineColorLow);
00296 
00297     PxVehicleGraph();
00298     ~PxVehicleGraph();
00299 };
00300 PX_COMPILE_TIME_ASSERT(PxU32(PxVehicleGraph::eMAX_NB_CHANNELS) >= PxU32(PxVehicleWheelGraphChannel::eMAX_NB_WHEEL_CHANNELS) && PxU32(PxVehicleGraph::eMAX_NB_CHANNELS) >= PxU32(PxVehicleDriveGraphChannel::eMAX_NB_DRIVE_CHANNELS));
00301 PX_COMPILE_TIME_ASSERT(0==(sizeof(PxVehicleGraph) & 15));
00302 
00303 class PxVehicleTelemetryData
00304 {
00305 public:
00306 
00307     friend class PxVehicleUpdate;
00308 
00313     static PxVehicleTelemetryData* allocate(const PxU32 nbWheels);
00314 
00319     void free();
00320 
00324     void setup
00325         (const PxReal graphSizeX, const PxReal graphSizeY,
00326          const PxReal engineGraphPosX, const PxReal engineGraphPosY,
00327          const PxReal* const wheelGraphPosX, const PxReal* const wheelGraphPosY,
00328          const PxVec3& backGroundColor, const PxVec3& lineColorHigh, const PxVec3& lineColorLow);
00329 
00333     void clear();
00334 
00338     const PxVehicleGraph& getEngineGraph() const {return *mEngineGraph;}
00339 
00343     PxU32 getNbWheelGraphs() const {return mNbActiveWheels;}
00344 
00348     const PxVehicleGraph& getWheelGraph(const PxU32 k) const {return mWheelGraphs[k];}
00349 
00353     const PxVec3* getTireforceAppPoints() const {return mTireforceAppPoints;}
00354 
00358     const PxVec3* getSuspforceAppPoints() const {return mSuspforceAppPoints;}
00359 
00360 private:
00361 
00367     PxVehicleGraph* mEngineGraph;
00368 
00374     PxVehicleGraph* mWheelGraphs;
00375 
00379     PxVec3* mTireforceAppPoints;
00380 
00384     PxVec3* mSuspforceAppPoints;
00385 
00389     PxU32 mNbActiveWheels;
00390 
00391     PxU32 mPad[3];
00392 
00393 private:
00394 
00395     PxVehicleTelemetryData(){}
00396     ~PxVehicleTelemetryData(){}
00397 };
00398 
00399 PX_COMPILE_TIME_ASSERT(0==(sizeof(PxVehicleTelemetryData) & 15));
00400 
00401 #endif //PX_DEBUG_VEHICLE_ON
00402 
00403 //#endif // PX_DEBUG_VEHICLE_ON
00404 
00405 #if !PX_DOXYGEN
00406 } // namespace physx
00407 #endif
00408 
00410 #endif //PX_VEHICLE_UTILSTELEMETRY_H


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