RavEngine
Loading...
Searching...
No Matches
PxVehicleSuspensionParams.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#pragma once
35#include "foundation/PxTransform.h"
36#include "foundation/PxFoundation.h"
37
38#include "common/PxCoreUtilityTypes.h"
39
40#include "vehicle2/PxVehicleParams.h"
41#include "vehicle2/PxVehicleFunctions.h"
42
43#if !PX_DOXYGEN
44namespace physx
45{
46namespace vehicle2
47{
48#endif
49
51{
58
64
72
78
79
81 const PxVehicleFrame& srcFrame, const PxVehicleFrame& trgFrame, const PxVehicleScale& srcScale, const PxVehicleScale& trgScale) const
82 {
84 r.suspensionAttachment= PxVehicleTransformFrameToFrame(srcFrame, trgFrame, srcScale, trgScale, suspensionAttachment);
85 r.suspensionTravelDir = PxVehicleTransformFrameToFrame(srcFrame, trgFrame, suspensionTravelDir);
86 r.suspensionTravelDist *= (trgScale.scale/srcScale.scale);
87 r.wheelAttachment = PxVehicleTransformFrameToFrame(srcFrame, trgFrame, srcScale, trgScale, wheelAttachment);
88 return r;
89 }
90
91 PX_FORCE_INLINE bool isValid() const
92 {
93 PX_CHECK_AND_RETURN_VAL(suspensionAttachment.isValid(), "PxVehicleSuspensionParams.suspensionAttachment must be a valid transform", false);
94 PX_CHECK_AND_RETURN_VAL(suspensionTravelDir.isFinite(), "PxVehicleSuspensionParams.suspensionTravelDir must be a valid vector", false);
95 PX_CHECK_AND_RETURN_VAL(suspensionTravelDir.isNormalized(), "PxVehicleSuspensionParams.suspensionTravelDir must be a unit vector", false);
96 PX_CHECK_AND_RETURN_VAL(suspensionTravelDist > 0.0f, "PxVehicleSuspensionParams.suspensionTravelDist must be greater than zero", false);
97 PX_CHECK_AND_RETURN_VAL(wheelAttachment.isValid(), "PxVehicleSuspensionParams.wheelAttachment must be a valid transform", false);
98 return true;
99 }
100};
101
103{
104 enum Enum
105 {
108 eMAX_NB
109 };
110};
111
113{
114 PxVehicleSuspensionJounceCalculationType::Enum suspensionJounceCalculationType;
115
128
130 const PxVehicleFrame& srcFrame, const PxVehicleFrame& trgFrame, const PxVehicleScale& srcScale, const PxVehicleScale& trgScale) const
131 {
132 PX_UNUSED(srcFrame);
133 PX_UNUSED(trgFrame);
134 PX_UNUSED(srcScale);
135 PX_UNUSED(trgScale);
136 return *this;
137 }
138
139 PX_FORCE_INLINE bool isValid() const
140 {
141 return true;
142 }
143};
144
155{
161
167
173
179
181 const PxVehicleFrame& srcFrame, const PxVehicleFrame& trgFrame, const PxVehicleScale& srcScale, const PxVehicleScale& trgScale) const
182 {
183 PX_UNUSED(srcFrame);
184 PX_UNUSED(trgFrame);
186
187 const PxReal scale = trgScale.scale / srcScale.scale;
188 for (PxU32 i = 0; i < r.suspForceAppPoint.nbDataPairs; i++)
189 {
190 r.suspForceAppPoint.yVals[i] = PxVehicleTransformFrameToFrame(srcFrame, trgFrame, suspForceAppPoint.yVals[i]);
191 r.suspForceAppPoint.yVals[i] *= scale;
192 }
193 for (PxU32 i = 0; i < r.tireForceAppPoint.nbDataPairs; i++)
194 {
195 r.tireForceAppPoint.yVals[i] = PxVehicleTransformFrameToFrame(srcFrame, trgFrame, tireForceAppPoint.yVals[i]);
196 r.tireForceAppPoint.yVals[i] *= scale;
197 }
198 return r;
199 }
200
201 PX_FORCE_INLINE bool isValid() const
202 {
203 PX_CHECK_AND_RETURN_VAL(wheelToeAngle.isValid(), "PxVehicleSuspensionComplianceParams.wheelToeAngle is invalid", false);
204 PX_CHECK_AND_RETURN_VAL(wheelCamberAngle.isValid(), "PxVehicleSuspensionComplianceParams.wheelCamberAngle is invalid", false);
205 PX_CHECK_AND_RETURN_VAL(suspForceAppPoint.isValid(), "PxVehicleSuspensionComplianceParams.wheelToeAngle is invalid", false);
206 PX_CHECK_AND_RETURN_VAL(tireForceAppPoint.isValid(), "PxVehicleSuspensionComplianceParams.wheelCamberAngle is invalid", false);
207
208 for (PxU32 i = 0; i < wheelToeAngle.nbDataPairs; i++)
209 {
210 PX_CHECK_AND_RETURN_VAL(wheelToeAngle.xVals[i] >= 0.0f && wheelToeAngle.xVals[i] <= 1.0f, "PxVehicleSuspensionComplianceParams.wheelToeAngle must be an array of points (x,y) with x in range [0, 1]", false);
211 PX_CHECK_AND_RETURN_VAL(wheelToeAngle.yVals[i] >= -PxPi && wheelToeAngle.yVals[i] <= PxPi, "PxVehicleSuspensionComplianceParams.wheelToeAngle must be an array of points (x,y) with y in range [-Pi, Pi]", false);
212 }
213 for (PxU32 i = 0; i < wheelCamberAngle.nbDataPairs; i++)
214 {
215 PX_CHECK_AND_RETURN_VAL(wheelCamberAngle.xVals[i] >= 0.0f && wheelCamberAngle.xVals[i] <= 1.0f, "PxVehicleSuspensionComplianceParams.wheelCamberAngle must be an array of points (x,y) with x in range [0, 1]", false);
216 PX_CHECK_AND_RETURN_VAL(wheelCamberAngle.yVals[i] >= -PxPi && wheelCamberAngle.yVals[i] <= PxPi, "PxVehicleSuspensionComplianceParams.wheelCamberAngle must be an array of points (x,y) with y in range [-Pi, Pi]", false);
217 }
218
219 for (PxU32 i = 0; i < suspForceAppPoint.nbDataPairs; i++)
220 {
221 PX_CHECK_AND_RETURN_VAL(suspForceAppPoint.xVals[i] >= 0.0f && suspForceAppPoint.xVals[i] <= 1.0f, "PxVehicleSuspensionComplianceParams.suspForceAppPoint[0] must be an array of points (x,y) with x in range [0, 1]", false);
222 }
223 for (PxU32 i = 0; i < tireForceAppPoint.nbDataPairs; i++)
224 {
225 PX_CHECK_AND_RETURN_VAL(tireForceAppPoint.xVals[i] >= 0.0f && tireForceAppPoint.xVals[i] <= 1.0f, "PxVehicleSuspensionComplianceParams.tireForceAppPoint[0] must be an array of points (x,y) with x in range [0, 1]", false);
226 }
227 return true;
228 }
229};
230
236{
243 PxReal stiffness;
244
251 PxReal damping;
252
260
262 const PxVehicleFrame& srcFrame, const PxVehicleFrame& trgFrame, const PxVehicleScale& srcScale, const PxVehicleScale& trgScale) const
263 {
264 PX_UNUSED(srcFrame);
265 PX_UNUSED(trgFrame);
266 PX_UNUSED(srcScale);
267 PX_UNUSED(trgScale);
268 return *this;
269 }
270
271 PX_FORCE_INLINE bool isValid() const
272 {
273 PX_CHECK_AND_RETURN_VAL(stiffness > 0.0f, "PxVehicleSuspensionForceParams.stiffness must be greater than zero", false);
274 PX_CHECK_AND_RETURN_VAL(damping >= 0.0f, "PxVehicleSuspensionForceParams.damping must be greater than or equal to zero", false);
275 PX_CHECK_AND_RETURN_VAL(sprungMass > 0.0f, "PxVehicleSuspensionForceParams.sprungMass must be greater than zero", false);
276 return true;
277 }
278};
279
286{
293 PxReal stiffness;
294
301 PxReal damping;
302
310
318
320 const PxVehicleFrame& srcFrame, const PxVehicleFrame& trgFrame, const PxVehicleScale& srcScale, const PxVehicleScale& trgScale) const
321 {
322 PX_UNUSED(srcFrame);
323 PX_UNUSED(trgFrame);
325 r.restDistance *= (trgScale.scale / srcScale.scale);
326 return *this;
327 }
328
329 PX_FORCE_INLINE bool isValid() const
330 {
331 PX_CHECK_AND_RETURN_VAL(stiffness > 0.0f, "PxVehicleSuspensionForceLegacyParams.stiffness must be greater than zero", false);
332 PX_CHECK_AND_RETURN_VAL(damping >= 0.0f, "PxVehicleSuspensionForceLegacyParams.damping must be greater than or equal to zero", false);
333 PX_CHECK_AND_RETURN_VAL(restDistance > 0.0f, "PxVehicleSuspensionForceLegacyParams.restDistance must be greater than zero", false);
334 PX_CHECK_AND_RETURN_VAL(sprungMass > 0.0f, "PxVehicleSuspensionForceLegacyParams.sprungMass must be greater than zero", false);
335 return true;
336 }
337
338};
339
347{
348 /*
349 \brief The anti-roll bar connects two wheels with indices wheel0 and wheel1
350 \note wheel0 and wheel1 may be chosen to have the effect of an anti-dive bar or to have the effect of an anti-roll bar.
351 */
352 PxU32 wheel0;
353
354 /*
355 \brief The anti-roll bar connects two wheels with indices wheel0 and wheel1
356 \note wheel0 and wheel1 may be chosen to have the effect of an anti-dive bar or to have the effect of an anti-roll bar.
357 */
358 PxU32 wheel1;
359
360 /*
361 \brief The linear stiffness of the anti-roll bar.
362 \note A positive stiffness will work to reduce the discrepancy in jounce between wheel0 and wheel1.
363 \note A negative stiffness will work to increase the discrepancy in jounce between wheel0 and wheel1.
364
365 <b>Unit:</b> mass / (time^2)
366 */
367 PxReal stiffness;
368
370 const PxVehicleFrame& srcFrame, const PxVehicleFrame& trgFrame, const PxVehicleScale& srcScale, const PxVehicleScale& trgScale) const
371 {
372 PX_UNUSED(srcFrame);
373 PX_UNUSED(trgFrame);
374 PX_UNUSED(srcScale);
375 PX_UNUSED(trgScale);
376 return *this;
377 }
378
379 PX_FORCE_INLINE bool isValid(const PxVehicleAxleDescription& axleDesc) const
380 {
381 if (!PxIsFinite(stiffness))
382 return false;
383 if (wheel0 == wheel1)
384 return false;
385
386 //Check that each wheel id is a valid wheel.
387 const PxU32 wheelIds[2] = { wheel0, wheel1 };
388 for (PxU32 k = 0; k < 2; k++)
389 {
390 const PxU32 wheelToFind = wheelIds[k];
391 bool foundWheelInAxleDescription = false;
392 for (PxU32 i = 0; i < axleDesc.nbWheels; i++)
393 {
394 const PxU32 wheel = axleDesc.wheelIdsInAxleOrder[i];
395 if (wheel == wheelToFind)
396 {
397 foundWheelInAxleDescription = true;
398 }
399 }
400 if (!foundWheelInAxleDescription)
401 return false;
402 }
403
404 return true;
405 }
406};
407
408
409#if !PX_DOXYGEN
410} // namespace vehicle2
411} // namespace physx
412#endif
413
class representing a rigid euclidean transform as a quaternion and a vector
Definition PxTransform.h:49
PX_CUDA_CALLABLE bool isValid() const
returns true if finite and q is a unit quaternion
Definition PxTransform.h:148
3 Element vector class.
Definition PxVec3.h:50
PX_CUDA_CALLABLE PX_INLINE bool isFinite() const
returns true if all 3 elems of the vector are finite (not NAN or INF, etc.)
Definition PxVec3.h:156
PX_CUDA_CALLABLE PX_FORCE_INLINE bool isNormalized() const
is normalized - used by API parameter validation
Definition PxVec3.h:164
Express a function as a sequence of points {(x, y)} that form a piecewise polynomial.
Definition PxVehicleParams.h:808
#define PX_FORCE_INLINE
Definition PxPreprocessor.h:335
#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
PX_CUDA_CALLABLE PX_FORCE_INLINE bool PxIsFinite(float f)
returns true if the passed number is a finite floating point number as opposed to INF,...
Definition PxMath.h:326
The purpose of the anti-roll bar is to generate a torque to apply to the vehicle's rigid body that wi...
Definition PxVehicleSuspensionParams.h:347
Definition PxVehicleParams.h:53
PxU32 wheelIdsInAxleOrder[PxVehicleLimits::eMAX_NB_WHEELS]
The list of all wheel ids on the vehicle.
Definition PxVehicleParams.h:149
PxU32 nbWheels
The number of wheels on the vehicle.
Definition PxVehicleParams.h:150
Definition PxVehicleParams.h:174
Definition PxVehicleParams.h:224
PxReal scale
The length scale used for the vehicle. For example, if 1.0 is considered meters, then 100....
Definition PxVehicleParams.h:225
Compliance describes how toe and camber angle and force application points are affected by suspension...
Definition PxVehicleSuspensionParams.h:155
PxVehicleFixedSizeLookupTable< PxVec3, 3 > suspForceAppPoint
Suspension forces are applied at an offset from the suspension frame. suspForceAppPoint specifies the...
Definition PxVehicleSuspensionParams.h:172
PxVehicleFixedSizeLookupTable< PxVec3, 3 > tireForceAppPoint
Tire forces are applied at an offset from the suspension frame. tireForceAppPoint specifies the (X,...
Definition PxVehicleSuspensionParams.h:178
PxVehicleFixedSizeLookupTable< PxReal, 3 > wheelCamberAngle
A graph of camber angle against jounce/suspensionTravelDist with the camber angle expressed in radian...
Definition PxVehicleSuspensionParams.h:166
PxVehicleFixedSizeLookupTable< PxReal, 3 > wheelToeAngle
A graph of toe angle against jounce/suspensionTravelDist with the toe angle expressed in radians.
Definition PxVehicleSuspensionParams.h:160
Suspension force is computed by converting suspenson state to suspension force under the assumption o...
Definition PxVehicleSuspensionParams.h:286
PxReal sprungMass
The mass supported by the suspension spring.
Definition PxVehicleSuspensionParams.h:317
PxReal stiffness
Spring strength of suspension.
Definition PxVehicleSuspensionParams.h:293
PxReal restDistance
The suspension compression that balances the gravitational force acting on the sprung mass.
Definition PxVehicleSuspensionParams.h:309
PxReal damping
Spring damper rate of suspension.
Definition PxVehicleSuspensionParams.h:301
Suspension force is computed by converting suspenson state to suspension force under the assumption o...
Definition PxVehicleSuspensionParams.h:236
PxReal stiffness
Spring strength of suspension.
Definition PxVehicleSuspensionParams.h:243
PxReal damping
Spring damper rate of suspension.
Definition PxVehicleSuspensionParams.h:251
PxReal sprungMass
Part of the vehicle mass that is supported by the suspension spring.
Definition PxVehicleSuspensionParams.h:259
Definition PxVehicleSuspensionParams.h:103
Enum
Definition PxVehicleSuspensionParams.h:105
@ eRAYCAST
The jounce is calculated using a raycast against the plane of the road geometry state.
Definition PxVehicleSuspensionParams.h:106
@ eSWEEP
The jounce is calculated by sweeping a cylinder against the plane of the road geometry state.
Definition PxVehicleSuspensionParams.h:107
Definition PxVehicleSuspensionParams.h:51
PxVec3 suspensionTravelDir
suspensionTravelDir specifies the direction of suspension travel.
Definition PxVehicleSuspensionParams.h:63
PxTransform wheelAttachment
wheelAttachment is the pose of the wheel in the suspension frame.
Definition PxVehicleSuspensionParams.h:77
PxReal suspensionTravelDist
suspensionTravelDist is the maximum distance that the suspenson can elongate along suspensionTravelDi...
Definition PxVehicleSuspensionParams.h:71
PxTransform suspensionAttachment
suspensionAttachment specifies the wheel pose at maximum compression.
Definition PxVehicleSuspensionParams.h:57
Definition PxVehicleSuspensionParams.h:113
bool limitSuspensionExpansionVelocity
Limit the suspension expansion dynamics.
Definition PxVehicleSuspensionParams.h:127