RavEngine
Loading...
Searching...
No Matches
PxVehicleSteeringParams.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
34#include "foundation/PxFoundation.h"
35
36#include "vehicle2/PxVehicleParams.h"
37
38#include "vehicle2/commands/PxVehicleCommandParams.h"
39
40#if !PX_DOXYGEN
41namespace physx
42{
43namespace vehicle2
44{
45#endif
46
47struct PxVehicleFrame;
48struct PxVehicleScale;
49
58{
60 const PxVehicleFrame& srcFrame, const PxVehicleFrame& trgFrame, const PxVehicleScale& srcScale, const PxVehicleScale& trgScale) const
61 {
62 PX_UNUSED(srcFrame);
63 PX_UNUSED(trgFrame);
64 PX_UNUSED(srcScale);
65 PX_UNUSED(trgScale);
66 return *this;
67 }
68
69 PX_FORCE_INLINE bool isValid(const PxVehicleAxleDescription& axleDesc) const
70 {
71 if (!axleDesc.isValid())
72 return false;
73 for (PxU32 i = 0; i < axleDesc.nbWheels; i++)
74 {
75 PX_CHECK_AND_RETURN_VAL(PxAbs(maxResponse*wheelResponseMultipliers[axleDesc.wheelIdsInAxleOrder[i]]) <= PxPi,
76 "PxVehicleSteerCommandResponseParams.maxResponse*PxVehicleSteerCommandResponseParams.wheelResponseMultipliers[i] must be in range [-Pi, Pi]", false);
77 }
78 return true;
79 }
80};
81
86{
87 PxU32 wheelIds[2];
88 PxReal wheelBase;
89 PxReal trackWidth;
90 PxReal strength;
91
92 PX_FORCE_INLINE bool isValid(const PxVehicleAxleDescription& axleDesc) const
93 {
94 PX_CHECK_AND_RETURN_VAL(0.0f == strength || wheelIds[0] < axleDesc.getNbWheels(), "PxVehicleAckermannParams.wheelIds[0] must be valid wheel", false);
95 PX_CHECK_AND_RETURN_VAL(0.0f == strength || wheelIds[1] < axleDesc.getNbWheels(), "PxVehicleAckermannParams.wheelIds[1] must be a valid wheel", false);
96 PX_CHECK_AND_RETURN_VAL(0.0f == strength || wheelIds[0] != wheelIds[1], "PxVehicleAckermannParams.wheelIds[0] and PxVehicleAckermannParams.wheelIds[1] must reference two different wheels", false);
97 PX_CHECK_AND_RETURN_VAL(0.0f == strength || wheelBase > 0.0f, "PxVehicleAckermannParams.wheelBase must be greater than zero", false);
98 PX_CHECK_AND_RETURN_VAL(0.0f == strength || trackWidth > 0.0f, "PxVehicleAckermannParams.trackWidth must be greater than zero", false);
99 PX_CHECK_AND_RETURN_VAL(strength >= 0.0f && strength <= 1.0f, "PxVehicleAckermannParams.strength must be in range [0,1]", false);
100 PX_UNUSED(axleDesc);
101 return true;
102 }
103
105 const PxVehicleFrame& srcFrame, const PxVehicleFrame& trgFrame, const PxVehicleScale& srcScale, const PxVehicleScale& trgScale) const
106 {
107 PX_UNUSED(srcFrame);
108 PX_UNUSED(trgFrame);
109 PxVehicleAckermannParams r = *this;
110 const PxReal scale = trgScale.scale / srcScale.scale;
111 r.wheelBase *= scale;
112 r.trackWidth *= scale;
113 return r;
114 }
115};
116
117#if !PX_DOXYGEN
118} // namespace vehicle2
119} // namespace physx
120#endif
121
#define PX_FORCE_INLINE
Definition PxPreprocessor.h:335
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 float PxAbs(float a)
abs returns the absolute value of its argument.
Definition PxMath.h:109
A description of a single axle that is to be affected by Ackermann steer correction.
Definition PxVehicleSteeringParams.h:86
PxReal wheelBase
wheelBase is the longitudinal distance between the axle that is affected by Ackermann correction and ...
Definition PxVehicleSteeringParams.h:88
PxU32 wheelIds[2]
wheelIds[0] is the id of the wheel that is negative along the lateral axis, wheelIds[1] is the wheel ...
Definition PxVehicleSteeringParams.h:87
PxReal strength
is the strength of the correction with 0 denoting no correction and 1 denoting perfect correction.
Definition PxVehicleSteeringParams.h:90
PxReal trackWidth
trackWidth is the width of the axle specified by wheelIds
Definition PxVehicleSteeringParams.h:89
Definition PxVehicleParams.h:53
PX_FORCE_INLINE PxU32 getNbWheels() const
Return the number of wheels on the vehicle.
Definition PxVehicleParams.h:115
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
A description of the per wheel response to an input command.
Definition PxVehicleCommandParams.h:177
PxReal wheelResponseMultipliers[PxVehicleLimits::eMAX_NB_WHEELS]
A description of the per wheel response multiplier to an input command.
Definition PxVehicleCommandParams.h:187
PxF32 maxResponse
The maximum response that occurs when the wheel response multiplier has value 1.0 and nonlinearRespon...
Definition PxVehicleCommandParams.h:192
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
Distribute a steer response to the wheels of a vehicle.
Definition PxVehicleSteeringParams.h:58