PxVehicleUtilTelemetry.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-2021 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 #ifndef PX_VEHICLE_UTILSTELEMETRY_H
31 #define PX_VEHICLE_UTILSTELEMETRY_H
32 
36 #include "vehicle/PxVehicleSDK.h"
38 #include "foundation/PxVec3.h"
39 
40 #if !PX_DOXYGEN
41 namespace physx
42 {
43 #endif
44 
45 #if PX_DEBUG_VEHICLE_ON
46 
47 class PxVehicleGraphDesc
48 {
49 
50  friend class PxVehicleGraph;
51 
52  PxVehicleGraphDesc();
53 
58  PxReal mPosX;
59 
64  PxReal mPosY;
65 
70  PxReal mSizeX;
71 
76  PxReal mSizeY;
77 
81  PxVec3 mBackgroundColor;
82 
86  PxReal mAlpha;
87 
88 private:
89 
90  bool isValid() const;
91 };
92 
93 struct PxVehicleGraphChannelDesc
94 {
95 public:
96 
97  friend class PxVehicleGraph;
98 
99  PxVehicleGraphChannelDesc();
100 
104  PxReal mMinY;
105 
109  PxReal mMaxY;
110 
115  PxReal mMidY;
116 
120  PxVec3 mColorLow;
121 
125  PxVec3 mColorHigh;
126 
130  char* mTitle;
131 
132 private:
133 
134  bool isValid() const;
135 };
136 
137 struct PxVehicleWheelGraphChannel
138 {
139  enum Enum
140  {
141  eJOUNCE=0,
142  eSUSPFORCE,
143  eTIRELOAD,
144  eNORMALIZED_TIRELOAD,
145  eWHEEL_OMEGA,
146  eTIRE_FRICTION,
147  eTIRE_LONG_SLIP,
148  eNORM_TIRE_LONG_FORCE,
149  eTIRE_LAT_SLIP,
150  eNORM_TIRE_LAT_FORCE,
151  eNORM_TIRE_ALIGNING_MOMENT,
152  eMAX_NB_WHEEL_CHANNELS
153  };
154 };
155 
156 struct PxVehicleDriveGraphChannel
157 {
158  enum Enum
159  {
160  eENGINE_REVS=0,
161  eENGINE_DRIVE_TORQUE,
162  eCLUTCH_SLIP,
163  eACCEL_CONTROL, //TANK_ACCEL
164  eBRAKE_CONTROL, //TANK_BRAKE_LEFT
165  eHANDBRAKE_CONTROL, //TANK_BRAKE_RIGHT
166  eSTEER_LEFT_CONTROL, //TANK_THRUST_LEFT
167  eSTEER_RIGHT_CONTROL, //TANK_THRUST_RIGHT
168  eGEAR_RATIO,
169  eMAX_NB_DRIVE_CHANNELS
170  };
171 };
172 
173 struct PxVehicleGraphType
174 {
175  enum Enum
176  {
177  eWHEEL=0,
178  eDRIVE
179  };
180 };
181 
182 
183 class PxVehicleGraph
184 {
185 public:
186 
187  friend class PxVehicleTelemetryData;
188  friend class PxVehicleUpdate;
189 
190  enum
191  {
192  eMAX_NB_SAMPLES=256
193  };
194 
195  enum
196  {
197  eMAX_NB_TITLE_CHARS=256
198  };
199 
200  enum
201  {
202  eMAX_NB_CHANNELS=12
203  };
204 
208  void setup(const PxVehicleGraphDesc& desc, const PxVehicleGraphType::Enum graphType);
209 
213  void clearRecordedChannelData();
214 
218  const PxVec3& getBackgroundColor() const {return mBackgroundColor;}
219 
223  PxReal getBackgroundAlpha() const {return mBackgroundAlpha;}
224 
233  void getBackgroundCoords(PxReal& xMin, PxReal& yMin, PxReal& xMax, PxReal& yMax) const {xMin = mBackgroundMinX;xMax = mBackgroundMaxX;yMin = mBackgroundMinY;yMax = mBackgroundMaxY;}
234 
242  void computeGraphChannel(const PxU32 channel, PxReal* xy, PxVec3* colors, char* title) const;
243 
247  PxF32 getLatestValue(const PxU32 channel) const ;
248 
255  void getRawData(const PxU32 channel, PxReal* values) const;
256 
257 private:
258 
259  //Min and max of each sample.
260  PxReal mChannelMinY[eMAX_NB_CHANNELS];
261  PxReal mChannelMaxY[eMAX_NB_CHANNELS];
262  //Discriminate between high and low values with different colors.
263  PxReal mChannelMidY[eMAX_NB_CHANNELS];
264  //Different colors for values than midY and less than midY.
265  PxVec3 mChannelColorLow[eMAX_NB_CHANNELS];
266  PxVec3 mChannelColorHigh[eMAX_NB_CHANNELS];
267  //Title of graph
268  char mChannelTitle[eMAX_NB_CHANNELS][eMAX_NB_TITLE_CHARS];
269  //Graph data.
270  PxReal mChannelSamples[eMAX_NB_CHANNELS][eMAX_NB_SAMPLES];
271 
272  //Background color,alpha,coords
273  PxVec3 mBackgroundColor;
274  PxReal mBackgroundAlpha;
275  PxReal mBackgroundMinX;
276  PxReal mBackgroundMaxX;
277  PxReal mBackgroundMinY;
278  PxReal mBackgroundMaxY;
279 
280  PxU32 mSampleTide;
281 
282  PxU32 mNbChannels;
283 
284  PxU32 mPad[2];
285 
286 
287  void setup
288  (const PxF32 graphSizeX, const PxF32 graphSizeY,
289  const PxF32 engineGraphPosX, const PxF32 engineGraphPosY,
290  const PxF32* const wheelGraphPosX, const PxF32* const wheelGraphPosY,
291  const PxVec3& backgroundColor, const PxVec3& lineColorHigh, const PxVec3& lineColorLow);
292 
293  void updateTimeSlice(const PxReal* const samples);
294 
295  void setChannel(PxVehicleGraphChannelDesc& desc, const PxU32 channel);
296 
297  void setupEngineGraph
298  (const PxF32 sizeX, const PxF32 sizeY, const PxF32 posX, const PxF32 posY,
299  const PxVec3& backgoundColor, const PxVec3& lineColorHigh, const PxVec3& lineColorLow);
300 
301  void setupWheelGraph
302  (const PxF32 sizeX, const PxF32 sizeY, const PxF32 posX, const PxF32 posY,
303  const PxVec3& backgoundColor, const PxVec3& lineColorHigh, const PxVec3& lineColorLow);
304 
305  PxVehicleGraph();
306  ~PxVehicleGraph();
307 };
308 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));
309 PX_COMPILE_TIME_ASSERT(0==(sizeof(PxVehicleGraph) & 15));
310 
311 class PxVehicleTelemetryData
312 {
313 public:
314 
315  friend class PxVehicleUpdate;
316 
321  static PxVehicleTelemetryData* allocate(const PxU32 nbWheels);
322 
327  void free();
328 
332  void setup
333  (const PxReal graphSizeX, const PxReal graphSizeY,
334  const PxReal engineGraphPosX, const PxReal engineGraphPosY,
335  const PxReal* const wheelGraphPosX, const PxReal* const wheelGraphPosY,
336  const PxVec3& backGroundColor, const PxVec3& lineColorHigh, const PxVec3& lineColorLow);
337 
341  void clear();
342 
346  const PxVehicleGraph& getEngineGraph() const {return *mEngineGraph;}
347 
351  PxU32 getNbWheelGraphs() const {return mNbActiveWheels;}
352 
356  const PxVehicleGraph& getWheelGraph(const PxU32 k) const {return mWheelGraphs[k];}
357 
361  const PxVec3* getTireforceAppPoints() const {return mTireforceAppPoints;}
362 
366  const PxVec3* getSuspforceAppPoints() const {return mSuspforceAppPoints;}
367 
368 private:
369 
375  PxVehicleGraph* mEngineGraph;
376 
382  PxVehicleGraph* mWheelGraphs;
383 
387  PxVec3* mTireforceAppPoints;
388 
392  PxVec3* mSuspforceAppPoints;
393 
397  PxU32 mNbActiveWheels;
398 
399  PxU32 mPad[3];
400 
401 private:
402 
403  PxVehicleTelemetryData(){}
404  ~PxVehicleTelemetryData(){}
405 };
406 
407 PX_COMPILE_TIME_ASSERT(0==(sizeof(PxVehicleTelemetryData) & 15));
408 
409 #endif //PX_DEBUG_VEHICLE_ON
410 
411 //#endif // PX_DEBUG_VEHICLE_ON
412 
413 #if !PX_DOXYGEN
414 } // namespace physx
415 #endif
416 
418 #endif //PX_VEHICLE_UTILSTELEMETRY_H
Definition: GuContactBuffer.h:37
float PxF32
Definition: PxSimpleTypes.h:76
float PxReal
Definition: PxSimpleTypes.h:78
uint32_t PxU32
Definition: PxSimpleTypes.h:71
#define PX_COMPILE_TIME_ASSERT(exp)
Definition: PxPreprocessor.h:434
uint32_t PxU32
Definition: Px.h:48
3 Element vector class.
Definition: PxVec3.h:49