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-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 #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 
249 private:
250 
251  //Min and max of each sample.
252  PxReal mChannelMinY[eMAX_NB_CHANNELS];
253  PxReal mChannelMaxY[eMAX_NB_CHANNELS];
254  //Discriminate between high and low values with different colors.
255  PxReal mChannelMidY[eMAX_NB_CHANNELS];
256  //Different colors for values than midY and less than midY.
257  PxVec3 mChannelColorLow[eMAX_NB_CHANNELS];
258  PxVec3 mChannelColorHigh[eMAX_NB_CHANNELS];
259  //Title of graph
260  char mChannelTitle[eMAX_NB_CHANNELS][eMAX_NB_TITLE_CHARS];
261  //Graph data.
262  PxReal mChannelSamples[eMAX_NB_CHANNELS][eMAX_NB_SAMPLES];
263 
264  //Background color,alpha,coords
265  PxVec3 mBackgroundColor;
266  PxReal mBackgroundAlpha;
267  PxReal mBackgroundMinX;
268  PxReal mBackgroundMaxX;
269  PxReal mBackgroundMinY;
270  PxReal mBackgroundMaxY;
271 
272  PxU32 mSampleTide;
273 
274  PxU32 mNbChannels;
275 
276  PxU32 mPad[2];
277 
278 
279  void setup
280  (const PxF32 graphSizeX, const PxF32 graphSizeY,
281  const PxF32 engineGraphPosX, const PxF32 engineGraphPosY,
282  const PxF32* const wheelGraphPosX, const PxF32* const wheelGraphPosY,
283  const PxVec3& backgroundColor, const PxVec3& lineColorHigh, const PxVec3& lineColorLow);
284 
285  void updateTimeSlice(const PxReal* const samples);
286 
287  void setChannel(PxVehicleGraphChannelDesc& desc, const PxU32 channel);
288 
289  void setupEngineGraph
290  (const PxF32 sizeX, const PxF32 sizeY, const PxF32 posX, const PxF32 posY,
291  const PxVec3& backgoundColor, const PxVec3& lineColorHigh, const PxVec3& lineColorLow);
292 
293  void setupWheelGraph
294  (const PxF32 sizeX, const PxF32 sizeY, const PxF32 posX, const PxF32 posY,
295  const PxVec3& backgoundColor, const PxVec3& lineColorHigh, const PxVec3& lineColorLow);
296 
297  PxVehicleGraph();
298  ~PxVehicleGraph();
299 };
300 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));
301 PX_COMPILE_TIME_ASSERT(0==(sizeof(PxVehicleGraph) & 15));
302 
303 class PxVehicleTelemetryData
304 {
305 public:
306 
307  friend class PxVehicleUpdate;
308 
313  static PxVehicleTelemetryData* allocate(const PxU32 nbWheels);
314 
319  void free();
320 
324  void setup
325  (const PxReal graphSizeX, const PxReal graphSizeY,
326  const PxReal engineGraphPosX, const PxReal engineGraphPosY,
327  const PxReal* const wheelGraphPosX, const PxReal* const wheelGraphPosY,
328  const PxVec3& backGroundColor, const PxVec3& lineColorHigh, const PxVec3& lineColorLow);
329 
333  void clear();
334 
338  const PxVehicleGraph& getEngineGraph() const {return *mEngineGraph;}
339 
343  PxU32 getNbWheelGraphs() const {return mNbActiveWheels;}
344 
348  const PxVehicleGraph& getWheelGraph(const PxU32 k) const {return mWheelGraphs[k];}
349 
353  const PxVec3* getTireforceAppPoints() const {return mTireforceAppPoints;}
354 
358  const PxVec3* getSuspforceAppPoints() const {return mSuspforceAppPoints;}
359 
360 private:
361 
367  PxVehicleGraph* mEngineGraph;
368 
374  PxVehicleGraph* mWheelGraphs;
375 
379  PxVec3* mTireforceAppPoints;
380 
384  PxVec3* mSuspforceAppPoints;
385 
389  PxU32 mNbActiveWheels;
390 
391  PxU32 mPad[3];
392 
393 private:
394 
395  PxVehicleTelemetryData(){}
396  ~PxVehicleTelemetryData(){}
397 };
398 
399 PX_COMPILE_TIME_ASSERT(0==(sizeof(PxVehicleTelemetryData) & 15));
400 
401 #endif //PX_DEBUG_VEHICLE_ON
402 
403 //#endif // PX_DEBUG_VEHICLE_ON
404 
405 #if !PX_DOXYGEN
406 } // namespace physx
407 #endif
408 
410 #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:447
uint32_t PxU32
Definition: Px.h:48
3 Element vector class.
Definition: PxVec3.h:49