RavEngine
Loading...
Searching...
No Matches
PxVehicleTireComponents.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
30
34#include "vehicle2/PxVehicleParams.h"
35#include "vehicle2/PxVehicleComponent.h"
36
37#include "vehicle2/commands/PxVehicleCommandHelpers.h"
38#include "vehicle2/roadGeometry/PxVehicleRoadGeometryState.h"
39#include "vehicle2/suspension/PxVehicleSuspensionParams.h"
40#include "vehicle2/suspension/PxVehicleSuspensionStates.h"
41#include "vehicle2/wheel/PxVehicleWheelStates.h"
42#include "vehicle2/wheel/PxVehicleWheelParams.h"
43
44#include "PxVehicleTireFunctions.h"
45#include "PxVehicleTireParams.h"
46
47#include "common/PxProfileZone.h"
48
49#if !PX_DOXYGEN
50namespace physx
51{
52namespace vehicle2
53{
54#endif
55
57{
58public:
59
61 virtual ~PxVehicleTireComponent() {}
62
63 virtual void getDataForTireComponent(
64 const PxVehicleAxleDescription*& axleDescription,
65 PxVehicleArrayData<const PxReal>& steerResponseStates,
66 const PxVehicleRigidBodyState*& rigidBodyState,
83
84 virtual bool update(const PxReal dt, const PxVehicleSimulationContext& context)
85 {
86 PX_PROFILE_ZONE("PxVehicleTireComponent::update", 0);
87
88 const PxVehicleAxleDescription* axleDescription;
89 PxVehicleArrayData<const PxReal> steerResponseStates;
90 const PxVehicleRigidBodyState* rigidBodyState;
107
108 getDataForTireComponent(axleDescription, steerResponseStates,
109 rigidBodyState, actuationStates, wheelParams, suspensionParams, tireForceParams,
110 roadGeomStates, suspensionStates, suspensionComplianceStates, suspensionForces,
111 wheelRigidBody1DStates, tireGripStates, tireDirectionStates, tireSpeedStates,
112 tireSlipStates, tireCamberAngleStates, tireStickyStates, tireForces);
113
114 for (PxU32 i = 0; i < axleDescription->nbWheels; i++)
115 {
116 const PxU32 wheelId = axleDescription->wheelIdsInAxleOrder[i];
117
118 //Compute the tire slip directions
119 PxVehicleTireDirsUpdate(
120 suspensionParams[wheelId],
121 steerResponseStates[wheelId],
122 roadGeomStates[wheelId], suspensionComplianceStates[wheelId],
123 *rigidBodyState,
124 context.frame,
125 tireDirectionStates[wheelId]);
126
127 //Compute the rigid body speeds along the tire slip directions.
128 PxVehicleTireSlipSpeedsUpdate(
129 wheelParams[wheelId], suspensionParams[wheelId],
130 steerResponseStates[wheelId], suspensionStates[wheelId], tireDirectionStates[wheelId],
131 *rigidBodyState, roadGeomStates[i],
132 context.frame,
133 tireSpeedStates[wheelId]);
134
135 //Compute the tire slip angles.
136 PxVehicleTireSlipsUpdate(
137 wheelParams[wheelId], context.tireSlipParams,
138 actuationStates[wheelId], tireSpeedStates[wheelId],
139 wheelRigidBody1DStates[wheelId],
140 tireSlipStates[wheelId]);
141
142 //Update the camber angle
143 PxVehicleTireCamberAnglesUpdate(
144 suspensionParams[wheelId], steerResponseStates[wheelId], roadGeomStates[wheelId],
145 suspensionComplianceStates[wheelId], *rigidBodyState,
146 context.frame,
147 tireCamberAngleStates[wheelId]);
148
149 //Compute the friction
150 PxVehicleTireGripUpdate(
151 tireForceParams[wheelId], roadGeomStates[wheelId],
152 suspensionStates[wheelId], suspensionForces[wheelId],
153 tireSlipStates[wheelId], tireGripStates[wheelId]);
154
155 //Update the tire sticky state
156 //
157 //Note: this should be skipped if tires do not use the sticky feature
158 PxVehicleTireStickyStateUpdate(
159 *axleDescription,
160 wheelParams[wheelId],
161 context.tireStickyParams,
162 actuationStates, tireGripStates[wheelId],
163 tireSpeedStates[wheelId], wheelRigidBody1DStates[wheelId],
164 dt,
165 tireStickyStates[wheelId]);
166
167 //If sticky tire is active set the slip angle to zero.
168 //
169 //Note: this should be skipped if tires do not use the sticky feature
170 PxVehicleTireSlipsAccountingForStickyStatesUpdate(
171 tireStickyStates[wheelId],
172 tireSlipStates[wheelId]);
173
174 //Compute the tire forces
175 PxVehicleTireForcesUpdate(
176 wheelParams[wheelId], suspensionParams[wheelId],
177 tireForceParams[wheelId],
178 suspensionComplianceStates[wheelId],
179 tireGripStates[wheelId], tireDirectionStates[wheelId],
180 tireSlipStates[wheelId], tireCamberAngleStates[wheelId],
181 *rigidBodyState,
182 tireForces[wheelId]);
183 }
184
185 return true;
186 }
187};
188
193{
194public:
195
198
199 virtual void getDataForLegacyTireComponent(
200 const PxVehicleAxleDescription*& axleDescription,
201 PxVehicleArrayData<const PxReal>& steerResponseStates,
202 const PxVehicleRigidBodyState*& rigidBodyState,
219
220 virtual bool update(const PxReal dt, const PxVehicleSimulationContext& context)
221 {
222 PX_PROFILE_ZONE("PxVehicleLegacyTireComponent::update", 0);
223
224 const PxVehicleAxleDescription* axleDescription;
225 PxVehicleArrayData<const PxReal> steerResponseStates;
226 const PxVehicleRigidBodyState* rigidBodyState;
243
244 getDataForLegacyTireComponent(axleDescription, steerResponseStates,
245 rigidBodyState, actuationStates,
246 wheelParams, suspensionParams, tireForceParams,
247 roadGeomStates, suspensionStates, suspensionComplianceStates,
248 suspensionForces, wheelRigidBody1DStates,
249 tireGripStates, tireDirectionStates, tireSpeedStates, tireSlipStates,
250 tireCamberAngleStates, tireStickyStates, tireForces);
251
252 for (PxU32 i = 0; i < axleDescription->nbWheels; i++)
253 {
254 const PxU32 wheelId = axleDescription->wheelIdsInAxleOrder[i];
255
256 //Compute the tire slip directions
257 PxVehicleTireDirsLegacyUpdate(
258 suspensionParams[wheelId],
259 steerResponseStates[wheelId],
260 roadGeomStates[wheelId], *rigidBodyState,
261 context.frame,
262 tireDirectionStates[wheelId]);
263
264 //Compute the rigid body speeds along the tire slip directions.
265 PxVehicleTireSlipSpeedsUpdate(
266 wheelParams[wheelId], suspensionParams[wheelId],
267 steerResponseStates[wheelId], suspensionStates[wheelId], tireDirectionStates[wheelId],
268 *rigidBodyState, roadGeomStates[wheelId],
269 context.frame,
270 tireSpeedStates[wheelId]);
271
272 //Compute the tire slip angles.
273 PxVehicleTireSlipsLegacyUpdate(
274 wheelParams[wheelId], context.tireSlipParams,
275 actuationStates[wheelId], tireSpeedStates[wheelId],
276 wheelRigidBody1DStates[wheelId],
277 tireSlipStates[wheelId]);
278
279 //Update the camber angle
280 PxVehicleTireCamberAnglesUpdate(
281 suspensionParams[wheelId], steerResponseStates[wheelId], roadGeomStates[wheelId],
282 suspensionComplianceStates[wheelId], *rigidBodyState,
283 context.frame,
284 tireCamberAngleStates[wheelId]);
285
286 //Compute the friction
287 PxVehicleTireGripUpdate(
288 tireForceParams[wheelId], roadGeomStates[wheelId],
289 suspensionStates[wheelId], suspensionForces[wheelId],
290 tireSlipStates[wheelId], tireGripStates[wheelId]);
291
292 //Update the tire sticky state
293 //
294 //Note: this should be skipped if tires do not use the sticky feature
295 PxVehicleTireStickyStateUpdate(
296 *axleDescription,
297 wheelParams[wheelId],
298 context.tireStickyParams,
299 actuationStates, tireGripStates[wheelId],
300 tireSpeedStates[wheelId], wheelRigidBody1DStates[wheelId],
301 dt,
302 tireStickyStates[wheelId]);
303
304 //If sticky tire is active set the slip angle to zero.
305 //
306 //Note: this should be skipped if tires do not use the sticky feature
307 PxVehicleTireSlipsAccountingForStickyStatesUpdate(
308 tireStickyStates[wheelId],
309 tireSlipStates[wheelId]);
310
311 //Compute the tire forces
312 PxVehicleTireForcesUpdate(
313 wheelParams[wheelId], suspensionParams[wheelId],
314 tireForceParams[wheelId],
315 suspensionComplianceStates[wheelId],
316 tireGripStates[wheelId], tireDirectionStates[wheelId],
317 tireSlipStates[wheelId], tireCamberAngleStates[wheelId],
318 *rigidBodyState,
319 tireForces[wheelId]);
320 }
321
322 return true;
323 }
324};
325
326#if !PX_DOXYGEN
327} // namespace vehicle2
328} // namespace physx
329#endif
330
Definition base.h:1940
Definition PxVehicleComponent.h:45
Definition PxVehicleTireComponents.h:193
virtual bool update(const PxReal dt, const PxVehicleSimulationContext &context)
Update function for a vehicle component.
Definition PxVehicleTireComponents.h:220
Definition PxVehicleTireComponents.h:57
virtual bool update(const PxReal dt, const PxVehicleSimulationContext &context)
Update function for a vehicle component.
Definition PxVehicleTireComponents.h:84
#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
Helper struct to pass array type data to vehice components and functions.
Definition PxVehicleParams.h:249
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 PxVehicleRigidBodyStates.h:47
Definition PxVehicleParams.h:672