PxVehicleUtilTelemetry.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2008-2015, NVIDIA CORPORATION. All rights reserved.
3  *
4  * NVIDIA CORPORATION and its licensors retain all intellectual property
5  * and proprietary rights in and to this software, related documentation
6  * and any modifications thereto. Any use, reproduction, disclosure or
7  * distribution of this software and related documentation without an express
8  * license agreement from NVIDIA CORPORATION is strictly prohibited.
9  */
10 // Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved.
11 // Copyright (c) 2001-2004 NovodeX AG. All rights reserved.
12 
13 #ifndef PX_VEHICLE_UTILSTELEMETRY_H
14 #define PX_VEHICLE_UTILSTELEMETRY_H
15 
19 #include "vehicle/PxVehicleSDK.h"
21 #include "foundation/PxVec3.h"
22 
23 #ifndef PX_DOXYGEN
24 namespace physx
25 {
26 #endif
27 
28 #if PX_DEBUG_VEHICLE_ON
29 
30 class PxVehicleGraphDesc
31 {
32 
33  friend class PxVehicleGraph;
34 
35  PxVehicleGraphDesc();
36 
41  PxReal mPosX;
42 
47  PxReal mPosY;
48 
53  PxReal mSizeX;
54 
59  PxReal mSizeY;
60 
64  PxVec3 mBackgroundColor;
65 
69  PxReal mAlpha;
70 
71 private:
72 
73  bool isValid() const;
74 };
75 
76 struct PxVehicleGraphChannelDesc
77 {
78 public:
79 
80  friend class PxVehicleGraph;
81 
82  PxVehicleGraphChannelDesc();
83 
87  PxReal mMinY;
88 
92  PxReal mMaxY;
93 
98  PxReal mMidY;
99 
103  PxVec3 mColorLow;
104 
108  PxVec3 mColorHigh;
109 
113  char* mTitle;
114 
115 private:
116 
117  bool isValid() const;
118 };
119 
120 struct PxVehicleWheelGraphChannel
121 {
122  enum Enum
123  {
124  eJOUNCE=0,
125  eSUSPFORCE,
126  eTIRELOAD,
127  eNORMALIZED_TIRELOAD,
128  eWHEEL_OMEGA,
129  eTIRE_FRICTION,
130  eTIRE_LONG_SLIP,
131  eNORM_TIRE_LONG_FORCE,
132  eTIRE_LAT_SLIP,
133  eNORM_TIRE_LAT_FORCE,
134  eNORM_TIRE_ALIGNING_MOMENT,
135  eMAX_NB_WHEEL_CHANNELS
136  };
137 };
138 
139 struct PxVehicleDriveGraphChannel
140 {
141  enum Enum
142  {
143  eENGINE_REVS=0,
144  eENGINE_DRIVE_TORQUE,
145  eCLUTCH_SLIP,
146  eACCEL_CONTROL, //TANK_ACCEL
147  eBRAKE_CONTROL, //TANK_BRAKE_LEFT
148  eHANDBRAKE_CONTROL, //TANK_BRAKE_RIGHT
149  eSTEER_LEFT_CONTROL, //TANK_THRUST_LEFT
150  eSTEER_RIGHT_CONTROL, //TANK_THRUST_RIGHT
151  eGEAR_RATIO,
152  eMAX_NB_DRIVE_CHANNELS
153  };
154 };
155 
156 struct PxVehicleGraphType
157 {
158  enum Enum
159  {
160  eWHEEL=0,
161  eDRIVE
162  };
163 };
164 
165 
166 class PxVehicleGraph
167 {
168 public:
169 
170  friend class PxVehicleTelemetryData;
171  friend class PxVehicleUpdate;
172 
173  enum
174  {
175  eMAX_NB_SAMPLES=256
176  };
177 
178  enum
179  {
180  eMAX_NB_TITLE_CHARS=256
181  };
182 
183  enum
184  {
185  eMAX_NB_CHANNELS=12
186  };
187 
191  void setup(const PxVehicleGraphDesc& desc, const PxVehicleGraphType::Enum graphType);
192 
196  void clearRecordedChannelData();
197 
201  const PxVec3& getBackgroundColor() const {return mBackgroundColor;}
202 
206  PxReal getBackgroundAlpha() const {return mBackgroundAlpha;}
207 
216  void getBackgroundCoords(PxReal& xMin, PxReal& yMin, PxReal& xMax, PxReal& yMax) const {xMin = mBackgroundMinX;xMax = mBackgroundMaxX;yMin = mBackgroundMinY;yMax = mBackgroundMaxY;}
217 
225  void computeGraphChannel(const PxU32 channel, PxReal* xy, PxVec3* colors, char* title) const;
226 
230  PxF32 getLatestValue(const PxU32 channel) const ;
231 
232 private:
233 
234  //Min and max of each sample.
235  PxReal mChannelMinY[eMAX_NB_CHANNELS];
236  PxReal mChannelMaxY[eMAX_NB_CHANNELS];
237  //Discriminate between high and low values with different colors.
238  PxReal mChannelMidY[eMAX_NB_CHANNELS];
239  //Different colors for values than midY and less than midY.
240  PxVec3 mChannelColorLow[eMAX_NB_CHANNELS];
241  PxVec3 mChannelColorHigh[eMAX_NB_CHANNELS];
242  //Title of graph
243  char mChannelTitle[eMAX_NB_CHANNELS][eMAX_NB_TITLE_CHARS];
244  //Graph data.
245  PxReal mChannelSamples[eMAX_NB_CHANNELS][eMAX_NB_SAMPLES];
246 
247  //Background color,alpha,coords
248  PxVec3 mBackgroundColor;
249  PxReal mBackgroundAlpha;
250  PxReal mBackgroundMinX;
251  PxReal mBackgroundMaxX;
252  PxReal mBackgroundMinY;
253  PxReal mBackgroundMaxY;
254 
255  PxU32 mSampleTide;
256 
257  PxU32 mNbChannels;
258 
259  PxU32 mPad[2];
260 
261 
262  void setup
263  (const PxF32 graphSizeX, const PxF32 graphSizeY,
264  const PxF32 engineGraphPosX, const PxF32 engineGraphPosY,
265  const PxF32* const wheelGraphPosX, const PxF32* const wheelGraphPosY,
266  const PxVec3& backgroundColor, const PxVec3& lineColorHigh, const PxVec3& lineColorLow);
267 
268  void updateTimeSlice(const PxReal* const samples);
269 
270  void setChannel(PxVehicleGraphChannelDesc& desc, const PxU32 channel);
271 
272  void setupEngineGraph
273  (const PxF32 sizeX, const PxF32 sizeY, const PxF32 posX, const PxF32 posY,
274  const PxVec3& backgoundColor, const PxVec3& lineColorHigh, const PxVec3& lineColorLow);
275 
276  void setupWheelGraph
277  (const PxF32 sizeX, const PxF32 sizeY, const PxF32 posX, const PxF32 posY,
278  const PxVec3& backgoundColor, const PxVec3& lineColorHigh, const PxVec3& lineColorLow);
279 
280  PxVehicleGraph();
281  ~PxVehicleGraph();
282 };
283 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));
284 PX_COMPILE_TIME_ASSERT(0==(sizeof(PxVehicleGraph) & 15));
285 
286 class PxVehicleTelemetryData
287 {
288 public:
289 
290  friend class PxVehicleUpdate;
291 
296  static PxVehicleTelemetryData* allocate(const PxU32 nbWheels);
297 
302  void free();
303 
307  void setup
308  (const PxReal graphSizeX, const PxReal graphSizeY,
309  const PxReal engineGraphPosX, const PxReal engineGraphPosY,
310  const PxReal* const wheelGraphPosX, const PxReal* const wheelGraphPosY,
311  const PxVec3& backGroundColor, const PxVec3& lineColorHigh, const PxVec3& lineColorLow);
312 
316  void clear();
317 
321  const PxVehicleGraph& getEngineGraph() const {return *mEngineGraph;}
322 
326  PxU32 getNbWheelGraphs() const {return mNbActiveWheels;}
327 
331  const PxVehicleGraph& getWheelGraph(const PxU32 k) const {return mWheelGraphs[k];}
332 
336  const PxVec3* getTireforceAppPoints() const {return mTireforceAppPoints;}
337 
341  const PxVec3* getSuspforceAppPoints() const {return mSuspforceAppPoints;}
342 
343 private:
344 
350  PxVehicleGraph* mEngineGraph;
351 
357  PxVehicleGraph* mWheelGraphs;
358 
362  PxVec3* mTireforceAppPoints;
363 
367  PxVec3* mSuspforceAppPoints;
368 
372  PxU32 mNbActiveWheels;
373 
374  PxU32 mPad[3];
375 
376 private:
377 
378  PxVehicleTelemetryData(){}
379  ~PxVehicleTelemetryData(){}
380 };
381 
382 PX_COMPILE_TIME_ASSERT(0==(sizeof(PxVehicleTelemetryData) & 15));
383 
384 #endif //PX_DEBUG_VEHICLE_ON
385 
386 //#endif // PX_DEBUG_VEHICLE_ON
387 
388 #ifndef PX_DOXYGEN
389 } // namespace physx
390 #endif
391 
393 #endif //PX_VEHICLE_UTILSTELEMETRY_H


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