RavEngine
Loading...
Searching...
No Matches
PxVehicleUtilTelemetry.h
1// Redistribution and use in source and binary forms, with or without
2// modification, are permitted provided that the following conditions
3// are met:
4// * Redistributions of source code must retain the above copyright
5// notice, this list of conditions and the following disclaimer.
6// * Redistributions in binary form must reproduce the above copyright
7// notice, this list of conditions and the following disclaimer in the
8// documentation and/or other materials provided with the distribution.
9// * Neither the name of NVIDIA CORPORATION nor the names of its
10// contributors may be used to endorse or promote products derived
11// from this software without specific prior written permission.
12//
13// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
14// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
17// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
18// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
19// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
20// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
21// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
23// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24//
25// Copyright (c) 2008-2022 NVIDIA Corporation. All rights reserved.
26// Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved.
27// Copyright (c) 2001-2004 NovodeX AG. All rights reserved.
28
29#ifndef PX_VEHICLE_UTIL_TELEMETRY_H
30#define PX_VEHICLE_UTIL_TELEMETRY_H
31
32#include "vehicle/PxVehicleSDK.h"
33#include "foundation/PxSimpleTypes.h"
34#include "foundation/PxVec3.h"
35
36#if !PX_DOXYGEN
37namespace physx
38{
39#endif
40
41#if PX_DEBUG_VEHICLE_ON
42
43class PX_DEPRECATED PxVehicleGraphDesc
44{
45
46 friend class PxVehicleGraph;
47
48 PxVehicleGraphDesc();
49
54 PxReal mPosX;
55
60 PxReal mPosY;
61
66 PxReal mSizeX;
67
72 PxReal mSizeY;
73
77 PxVec3 mBackgroundColor;
78
82 PxReal mAlpha;
83
84private:
85
86 bool isValid() const;
87};
88
89struct PX_DEPRECATED PxVehicleGraphChannelDesc
90{
91public:
92
93 friend class PxVehicleGraph;
94
95 PxVehicleGraphChannelDesc();
96
100 PxReal mMinY;
101
105 PxReal mMaxY;
106
111 PxReal mMidY;
112
116 PxVec3 mColorLow;
117
121 PxVec3 mColorHigh;
122
126 char* mTitle;
127
128private:
129
130 bool isValid() const;
131};
132
133struct PX_DEPRECATED PxVehicleWheelGraphChannel
134{
135 enum Enum
136 {
137 eJOUNCE=0,
138 eSUSPFORCE,
139 eTIRELOAD,
140 eNORMALIZED_TIRELOAD,
141 eWHEEL_OMEGA,
142 eTIRE_FRICTION,
143 eTIRE_LONG_SLIP,
144 eNORM_TIRE_LONG_FORCE,
145 eTIRE_LAT_SLIP,
146 eNORM_TIRE_LAT_FORCE,
147 eNORM_TIRE_ALIGNING_MOMENT,
148 eMAX_NB_WHEEL_CHANNELS
149 };
150};
151
152struct PX_DEPRECATED PxVehicleDriveGraphChannel
153{
154 enum Enum
155 {
156 eENGINE_REVS=0,
157 eENGINE_DRIVE_TORQUE,
158 eCLUTCH_SLIP,
159 eACCEL_CONTROL, //TANK_ACCEL
160 eBRAKE_CONTROL, //TANK_BRAKE_LEFT
161 eHANDBRAKE_CONTROL, //TANK_BRAKE_RIGHT
162 eSTEER_LEFT_CONTROL, //TANK_THRUST_LEFT
163 eSTEER_RIGHT_CONTROL, //TANK_THRUST_RIGHT
164 eGEAR_RATIO,
165 eMAX_NB_DRIVE_CHANNELS
166 };
167};
168
169struct PX_DEPRECATED PxVehicleGraphType
170{
171 enum Enum
172 {
173 eWHEEL=0,
174 eDRIVE
175 };
176};
177
178
179class PX_DEPRECATED PxVehicleGraph
180{
181public:
182
183 friend class PxVehicleTelemetryData;
184 friend class PxVehicleUpdate;
185
186 enum
187 {
188 eMAX_NB_SAMPLES=256
189 };
190
191 enum
192 {
193 eMAX_NB_TITLE_CHARS=256
194 };
195
196 enum
197 {
198 eMAX_NB_CHANNELS=12
199 };
200
204 void setup(const PxVehicleGraphDesc& desc, const PxVehicleGraphType::Enum graphType);
205
209 void clearRecordedChannelData();
210
214 const PxVec3& getBackgroundColor() const {return mBackgroundColor;}
215
219 PxReal getBackgroundAlpha() const {return mBackgroundAlpha;}
220
229 void getBackgroundCoords(PxReal& xMin, PxReal& yMin, PxReal& xMax, PxReal& yMax) const {xMin = mBackgroundMinX;xMax = mBackgroundMaxX;yMin = mBackgroundMinY;yMax = mBackgroundMaxY;}
230
238 void computeGraphChannel(const PxU32 channel, PxReal* xy, PxVec3* colors, char* title) const;
239
243 PxF32 getLatestValue(const PxU32 channel) const ;
244
251 void getRawData(const PxU32 channel, PxReal* values) const;
252
253private:
254
255 //Min and max of each sample.
256 PxReal mChannelMinY[eMAX_NB_CHANNELS];
257 PxReal mChannelMaxY[eMAX_NB_CHANNELS];
258 //Discriminate between high and low values with different colors.
259 PxReal mChannelMidY[eMAX_NB_CHANNELS];
260 //Different colors for values than midY and less than midY.
261 PxVec3 mChannelColorLow[eMAX_NB_CHANNELS];
262 PxVec3 mChannelColorHigh[eMAX_NB_CHANNELS];
263 //Title of graph
264 char mChannelTitle[eMAX_NB_CHANNELS][eMAX_NB_TITLE_CHARS];
265 //Graph data.
266 PxReal mChannelSamples[eMAX_NB_CHANNELS][eMAX_NB_SAMPLES];
267
268 //Background color,alpha,coords
269 PxVec3 mBackgroundColor;
270 PxReal mBackgroundAlpha;
271 PxReal mBackgroundMinX;
272 PxReal mBackgroundMaxX;
273 PxReal mBackgroundMinY;
274 PxReal mBackgroundMaxY;
275
276 PxU32 mSampleTide;
277
278 PxU32 mNbChannels;
279
280 PxU32 mPad[2];
281
282
283 void setup
284 (const PxF32 graphSizeX, const PxF32 graphSizeY,
285 const PxF32 engineGraphPosX, const PxF32 engineGraphPosY,
286 const PxF32* const wheelGraphPosX, const PxF32* const wheelGraphPosY,
287 const PxVec3& backgroundColor, const PxVec3& lineColorHigh, const PxVec3& lineColorLow);
288
289 void updateTimeSlice(const PxReal* const samples);
290
291 void setChannel(PxVehicleGraphChannelDesc& desc, const PxU32 channel);
292
293 void setupEngineGraph
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 void setupWheelGraph
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 PxVehicleGraph();
302 ~PxVehicleGraph();
303};
304PX_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));
305PX_COMPILE_TIME_ASSERT(0==(sizeof(PxVehicleGraph) & 15));
306
307class PX_DEPRECATED PxVehicleTelemetryData
308{
309public:
310
311 friend class PxVehicleUpdate;
312
317 static PxVehicleTelemetryData* allocate(const PxU32 nbWheels);
318
323 void free();
324
328 void setup
329 (const PxReal graphSizeX, const PxReal graphSizeY,
330 const PxReal engineGraphPosX, const PxReal engineGraphPosY,
331 const PxReal* const wheelGraphPosX, const PxReal* const wheelGraphPosY,
332 const PxVec3& backGroundColor, const PxVec3& lineColorHigh, const PxVec3& lineColorLow);
333
337 void clear();
338
342 const PxVehicleGraph& getEngineGraph() const {return *mEngineGraph;}
343
347 PxU32 getNbWheelGraphs() const {return mNbActiveWheels;}
348
352 const PxVehicleGraph& getWheelGraph(const PxU32 k) const {return mWheelGraphs[k];}
353
357 const PxVec3* getTireforceAppPoints() const {return mTireforceAppPoints;}
358
362 const PxVec3* getSuspforceAppPoints() const {return mSuspforceAppPoints;}
363
364private:
365
371 PxVehicleGraph* mEngineGraph;
372
378 PxVehicleGraph* mWheelGraphs;
379
383 PxVec3* mTireforceAppPoints;
384
388 PxVec3* mSuspforceAppPoints;
389
393 PxU32 mNbActiveWheels;
394
395 PxU32 mPad[3];
396
397private:
398
399 PxVehicleTelemetryData(){}
400 ~PxVehicleTelemetryData(){}
401};
402
403PX_COMPILE_TIME_ASSERT(0==(sizeof(PxVehicleTelemetryData) & 15));
404
405#endif //PX_DEBUG_VEHICLE_ON
406
407//#endif // PX_DEBUG_VEHICLE_ON
408
409#if !PX_DOXYGEN
410} // namespace physx
411#endif
412
413#endif
#define PX_COMPILE_TIME_ASSERT(exp)
Definition PxPreprocessor.h:428
#define PX_DEPRECATED
Definition PxPreprocessor.h:418
Sorts an array of objects in ascending order, assuming that the predicate implements the < operator:
Definition PxBoxController.h:39