RavEngine
Loading...
Searching...
No Matches
PxVehicleDrivetrainParams.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
35#include "foundation/PxFoundation.h"
36#include "common/PxCoreUtilityTypes.h"
37
38#include "vehicle2/PxVehicleParams.h"
39
40#include "vehicle2/commands/PxVehicleCommandParams.h"
41
42#if !PX_DOXYGEN
43namespace physx
44{
45namespace vehicle2
46{
47#endif
48
57{
59 const PxVehicleFrame& srcFrame, const PxVehicleFrame& trgFrame, const PxVehicleScale& srcScale, const PxVehicleScale& trgScale) const
60 {
61 PX_UNUSED(srcFrame);
62 PX_UNUSED(trgFrame);
64 const PxReal scale = trgScale.scale/srcScale.scale;
65 r.maxResponse *= (scale*scale); //Max response is a torque!
66 return r;
67 }
68
69 PX_FORCE_INLINE bool isValid(const PxVehicleAxleDescription& axleDesc) const
70 {
71 PX_CHECK_AND_RETURN_VAL(PxIsFinite(maxResponse), "PxVehicleDirectDriveThrottleCommandResponseParams.maxResponse must be a finite value", false);
72 for (PxU32 i = 0; i < axleDesc.nbWheels; i++)
73 {
74 PX_CHECK_AND_RETURN_VAL(PxIsFinite(wheelResponseMultipliers[axleDesc.wheelIdsInAxleOrder[i]]), "PxVehicleDirectDriveThrottleCommandResponseParams.wheelResponseMultipliers[i] must be a finite value", false);
75 }
76 return true;
77 }
78};
79
84{
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 const PxReal scale = trgScale.scale/srcScale.scale;
111 r.maxResponse *= (scale*scale);
112 return r;
113 }
114
115 PX_FORCE_INLINE bool isValid() const
116 {
117 PX_CHECK_AND_RETURN_VAL(maxResponse >= 0.0f, "PxVehicleClutchCommandResponseParams.maxResponse must be greater than or equal to zero", false);
118 return true;
119 }
120};
121
127{
128 enum Enum
129 {
130 eESTIMATE = 0,
131 eBEST_POSSIBLE
132 };
133};
134
141{
142public:
143
158 PxVehicleClutchAccuracyMode::Enum accuracyMode;
159
172
173 PX_FORCE_INLINE PxVehicleClutchParams transformAndScale(
174 const PxVehicleFrame& srcFrame, const PxVehicleFrame& trgFrame, const PxVehicleScale& srcScale, const PxVehicleScale& trgScale) const
175 {
176 PX_UNUSED(srcFrame);
177 PX_UNUSED(trgFrame);
178 PX_UNUSED(srcScale);
179 PX_UNUSED(trgScale);
180 return *this;
181 }
182
183 PX_FORCE_INLINE bool isValid() const
184 {
185 PX_CHECK_AND_RETURN_VAL((PxVehicleClutchAccuracyMode::eBEST_POSSIBLE == accuracyMode) || ((PxVehicleClutchAccuracyMode::eESTIMATE == accuracyMode) && (estimateIterations > 0)), "PxVehicleClutchParams.estimateIterations must be greater than zero if PxVehicleClutchAccuracyMode::eESTIMATE is selected", false);
186 return true;
187 }
188};
189
190
192{
196 enum
197 {
198 eMAX_NB_ENGINE_TORQUE_CURVE_ENTRIES = 8
199 };
200
207
214 PxReal moi;
215
225
232 PxReal idleOmega;
233
240 PxReal maxOmega;
241
257
273
289
290 PX_FORCE_INLINE PxVehicleEngineParams transformAndScale(
291 const PxVehicleFrame& srcFrame, const PxVehicleFrame& trgFrame, const PxVehicleScale& srcScale, const PxVehicleScale& trgScale) const
292 {
293 PX_UNUSED(srcFrame);
294 PX_UNUSED(trgFrame);
295 PxVehicleEngineParams r = *this;
296 const PxReal scale = trgScale.scale/srcScale.scale;
297 r.moi *= (scale*scale);
298 r.peakTorque *= (scale*scale);
299 r.dampingRateFullThrottle *= (scale*scale);
301 r.dampingRateZeroThrottleClutchEngaged *= (scale*scale);
302 return r;
303 }
304
305 PX_FORCE_INLINE bool isValid() const
306 {
307 PX_CHECK_AND_RETURN_VAL(moi > 0.0f, "PxVehicleEngineParams.moi must be greater than zero", false);
308 PX_CHECK_AND_RETURN_VAL(peakTorque >= 0.0f, "PxVehicleEngineParams.peakTorque must be greater than or equal to zero", false);
309 PX_CHECK_AND_RETURN_VAL(torqueCurve.isValid(), "PxVehicleEngineParams.torqueCurve is invalid", false);
310 PX_CHECK_AND_RETURN_VAL(maxOmega >= 0.0f, "PxVehicleEngineParams.maxOmega must be greater than or equal to zero", false);
311 PX_CHECK_AND_RETURN_VAL(idleOmega >= 0.0f, "PxVehicleEngineParams.idleOmega must be greater or equal to zero", false);
312 PX_CHECK_AND_RETURN_VAL(dampingRateFullThrottle >= 0.0f, "PxVehicleEngineParams.dampingRateFullThrottle must be greater than or equal to zero", false);
313 PX_CHECK_AND_RETURN_VAL(dampingRateZeroThrottleClutchEngaged >= 0.0f, "PxVehicleEngineParams.dampingRateZeroThrottleClutchEngaged must be greater than or equal to zero", false);
314 PX_CHECK_AND_RETURN_VAL(dampingRateZeroThrottleClutchDisengaged >= 0.0f, "PxVehicleEngineParams.dampingRateZeroThrottleClutchDisengaged must be greater than or equal to zero", false)
315 return true;
316 }
317};
318
320{
321public:
322
327
331 enum Enum
332 {
333 eMAX_NB_GEARS = 32
334 };
335
342 PxReal ratios[eMAX_NB_GEARS];
343
350
356 PxU32 nbRatios;
357
365
366 PX_FORCE_INLINE PxVehicleGearboxParams transformAndScale(
367 const PxVehicleFrame& srcFrame, const PxVehicleFrame& trgFrame, const PxVehicleScale& srcScale, const PxVehicleScale& trgScale) const
368 {
369 PX_UNUSED(srcFrame);
370 PX_UNUSED(trgFrame);
371 PX_UNUSED(srcScale);
372 PX_UNUSED(trgScale);
373 return *this;
374 }
375
376 PX_FORCE_INLINE bool isValid() const
377 {
378 PX_CHECK_AND_RETURN_VAL(finalRatio > 0, "PxVehicleGearboxParams.finalRatio must be greater than zero", false);
379 PX_CHECK_AND_RETURN_VAL(nbRatios >= 1, "PxVehicleGearboxParams.nbRatios must be greater than zero", false);
380 PX_CHECK_AND_RETURN_VAL(nbRatios <= eMAX_NB_GEARS, "PxVehicleGearboxParams.nbRatios must be less than or equal to eMAX_NB_GEARS", false);
381 PX_CHECK_AND_RETURN_VAL(neutralGear < nbRatios, "PxVehicleGearboxParams.neutralGear must be less than PxVehicleGearboxParams.nbRatios", false);
382 PX_CHECK_AND_RETURN_VAL(switchTime >= 0.0f, "PxVehicleGearboxParams.switchTime must be greater than or equal to zero", false);
383 for(PxU32 i = 0; i < neutralGear; i++)
384 {
385 PX_CHECK_AND_RETURN_VAL(ratios[i] < 0.0f, "Reverse gear ratios must be less than zero", false);
386 }
387 {
388 PX_CHECK_AND_RETURN_VAL(ratios[neutralGear] == 0.0f, "Neutral gear ratio must be equal to zero", false);
389 }
390 for (PxU32 i = neutralGear + 1; i < nbRatios; i++)
391 {
392 PX_CHECK_AND_RETURN_VAL(ratios[i] > 0.0f, "Forward gear ratios must be greater than zero", false);
393 }
394 for (PxU32 i = neutralGear + 2; i < nbRatios; i++)
395 {
396 PX_CHECK_AND_RETURN_VAL(ratios[i] < ratios[i - 1], "Forward gear ratios must be a descending sequence of gear ratios", false);
397 }
398 return true;
399 }
400};
401
402
404{
405public:
406
415 PxReal upRatios[PxVehicleGearboxParams::eMAX_NB_GEARS];
416
425 PxReal downRatios[PxVehicleGearboxParams::eMAX_NB_GEARS];
426
437 PxReal latency;
438
439 PX_FORCE_INLINE PxVehicleAutoboxParams transformAndScale(
440 const PxVehicleFrame& srcFrame, const PxVehicleFrame& trgFrame, const PxVehicleScale& srcScale, const PxVehicleScale& trgScale) const
441 {
442 PX_UNUSED(srcFrame);
443 PX_UNUSED(trgFrame);
444 PX_UNUSED(srcScale);
445 PX_UNUSED(trgScale);
446 return *this;
447 }
448
449 PX_FORCE_INLINE bool isValid(const PxVehicleGearboxParams& gearboxParams) const
450 {
451 if (!gearboxParams.isValid())
452 return false;
453
454 for (PxU32 i = gearboxParams.neutralGear + 1; i < gearboxParams.nbRatios-1; i++)
455 {
456 PX_CHECK_AND_RETURN_VAL(upRatios[i] >= 0.0f, "PxVehicleAutoboxParams.upRatios must be greater than or equal to zero", false);
457 }
458 for (PxU32 i = gearboxParams.neutralGear + 2; i < gearboxParams.nbRatios; i++)
459 {
460 PX_CHECK_AND_RETURN_VAL(downRatios[i] >= 0.0f, "PxVehicleAutoboxParams.downRatios must be greater than or equal to zero", false);
461 }
462 PX_CHECK_AND_RETURN_VAL(latency >= 0.0f, "PxVehicleAutoboxParams.latency must be greater than or equal to zero", false);
463 return true;
464 }
465};
466
471{
472public:
473
474 enum Enum
475 {
476 eDIFF_TYPE_LS_4WD, //limited slip differential for car with 4 driven wheels
477 eDIFF_TYPE_LS_FRONTWD, //limited slip differential for car with front-wheel drive
478 eDIFF_TYPE_LS_REARWD, //limited slip differential for car with rear-wheel drive
479 eMAX_NB_DIFF_TYPES
480 };
481
491 PxU32 frontWheelIds[2];
492
493
503 PxU32 rearWheelIds[2];
504
513
522
531
541
550 PxReal frontBias;
551
560 PxReal rearBias;
561
567 Enum type;
568
570 const PxVehicleFrame& srcFrame, const PxVehicleFrame& trgFrame, const PxVehicleScale& srcScale, const PxVehicleScale& trgScale) const
571 {
572 PX_UNUSED(srcFrame);
573 PX_UNUSED(trgFrame);
574 PX_UNUSED(srcScale);
575 PX_UNUSED(trgScale);
576 return *this;
577 }
578
579 PX_FORCE_INLINE bool isValid(const PxVehicleAxleDescription& axleDesc) const
580 {
581 PX_UNUSED(axleDesc);
582 PX_CHECK_AND_RETURN_VAL((axleDesc.getAxle(frontWheelIds[0]) != 0xffffffff) && (axleDesc.getAxle(frontWheelIds[0])== axleDesc.getAxle(frontWheelIds[1])), "frontWheelIds[0] and frontWheelIds[1] must reference wheels on the same axle", false);
583 PX_CHECK_AND_RETURN_VAL((axleDesc.getAxle(rearWheelIds[0]) != 0xffffffff) && (axleDesc.getAxle(rearWheelIds[0]) == axleDesc.getAxle(rearWheelIds[1])), "rearWheelIds[0] and rearWheelIds[1] must reference wheels on the same axle", false);
584 PX_CHECK_AND_RETURN_VAL(frontRearSplit <= 1.0f && frontRearSplit >= 0.0f, "PxVehicleLegacyFourWheelDriveDifferentialParams.frontRearSplit must be in range [0,1]", false);
585 PX_CHECK_AND_RETURN_VAL(frontNegPosSplit <= 1.0f && frontNegPosSplit >= 0.0f, "PxVehicleLegacyFourWheelDriveDifferentialParams.frontNegPosSplit must be in range [0,1]", false);
586 PX_CHECK_AND_RETURN_VAL(rearNegPosSplit <= 1.0f && rearNegPosSplit >= 0.0f, "PxVehicleLegacyFourWheelDriveDifferentialParams.rearNegPosSplit must be in range [0,1]", false);
587 PX_CHECK_AND_RETURN_VAL(centerBias >= 1.0f, "PxVehicleLegacyFourWheelDriveDifferentialParams.centerBias must be greater than or equal to 1.0f", false);
588 PX_CHECK_AND_RETURN_VAL(frontBias >= 1.0f, "PxVehicleLegacyFourWheelDriveDifferentialParams.frontBias must be greater than or equal to 1.0f", false);
589 PX_CHECK_AND_RETURN_VAL(rearBias >= 1.0f, "PxVehicleLegacyFourWheelDriveDifferentialParams.rearBias must be greater than or equal to 1.0f", false);
590 PX_CHECK_AND_RETURN_VAL(type < PxVehicleFourWheelDriveDifferentialLegacyParams::eMAX_NB_DIFF_TYPES, "PxVehicleLegacyFourWheelDriveDifferentialParams.type has illegal value", false);
591 return true;
592 }
593};
594
600{
610 PxReal torqueRatios[PxVehicleLimits::eMAX_NB_WHEELS];
611
620 PxReal aveWheelSpeedRatios[PxVehicleLimits::eMAX_NB_WHEELS];
621
622
623 PX_FORCE_INLINE void setToDefault()
624 {
626 }
627
629 const PxVehicleFrame& srcFrame, const PxVehicleFrame& trgFrame, const PxVehicleScale& srcScale, const PxVehicleScale& trgScale) const
630 {
631 PX_UNUSED(srcFrame);
632 PX_UNUSED(trgFrame);
633 PX_UNUSED(srcScale);
634 PX_UNUSED(trgScale);
635 return *this;
636 }
637
638 PX_FORCE_INLINE bool isValid(const PxVehicleAxleDescription& axleDesc) const
639 {
640 if (!axleDesc.isValid())
641 return false;
642 PxReal aveWheelSpeedSum = 0.0f;
643 PxReal torqueRatioSum = 0.0f;
644 for (PxU32 i = 0; i < axleDesc.nbWheels; i++)
645 {
646 const PxU32 wheelId = axleDesc.wheelIdsInAxleOrder[i];
647 PX_CHECK_AND_RETURN_VAL(PxAbs(torqueRatios[wheelId]) <= 1.0f, "PxVehicleMultiWheelDriveDifferentialParams.torqueRatios[i] must be in range [-1, 1] for all wheels connected to the differential", false);
648 PX_CHECK_AND_RETURN_VAL(aveWheelSpeedRatios[wheelId] >= 0.0f && aveWheelSpeedRatios[wheelId] <= 1.0f, "PxVehicleMultiWheelDriveDifferentialParams.aveWheelSpeedRatios[i] must be in range [0, 1] for all wheels connected to the differential", false);
649 aveWheelSpeedSum += aveWheelSpeedRatios[wheelId];
650 torqueRatioSum += PxAbs(torqueRatios[wheelId]);
651 }
652 PX_CHECK_AND_RETURN_VAL(aveWheelSpeedSum >= 0.99f && aveWheelSpeedSum <= 1.01f, "Sum of PxVehicleMultiWheelDriveDifferentialParams.aveWheelSpeedRatios[i] must be 1.0.", false);
653 PX_CHECK_AND_RETURN_VAL(torqueRatioSum >= 0.99f && torqueRatioSum <= 1.01f, "Sum of PxVehicleMultiWheelDriveDifferentialParams.torqueRatios[i] must be 1.0.", false);
654 PX_UNUSED(aveWheelSpeedSum);
655 PX_UNUSED(torqueRatioSum);
656 return true;
657 }
658};
659
663#define PX_VEHICLE_FOUR_WHEEL_DIFFERENTIAL_MAXIMUM_STRENGTH PX_MAX_F32
664
672{
679 PxU32 frontWheelIds[2];
680
687 PxU32 rearWheelIds[2];
688
700 PxReal frontBias;
701
709
721 PxReal rearBias;
722
730
744
752
760 PxReal rate;
761
762
763 PX_FORCE_INLINE void setToDefault()
764 {
765 PxVehicleMultiWheelDriveDifferentialParams::setToDefault();
766 frontBias = 0.0f;
767 rearBias = 0.0f;
768 centerBias = 0.0f;
769 }
770
771 PX_FORCE_INLINE bool isValid(const PxVehicleAxleDescription& axleDesc) const
772 {
773 if (!PxVehicleMultiWheelDriveDifferentialParams::isValid(axleDesc))
774 return false;
775
776 PX_CHECK_AND_RETURN_VAL((0.0f == centerBias) ||
777 (centerBias > 1.0f &&
778 frontWheelIds[0] < axleDesc.nbWheels && frontWheelIds[1] < axleDesc.nbWheels &&
779 rearWheelIds[0] < axleDesc.nbWheels && rearWheelIds[1] < axleDesc.nbWheels),
780 "PxVehicleFourWheelDriveDifferentialParams:: centreBias is enabled but the frontWheelIds and rearWheelIds are not configured correctly.", false);
781 PX_CHECK_AND_RETURN_VAL((0.0f == centerBias) ||
782 (centerBias > 1.0f &&
783 frontWheelIds[0] != frontWheelIds[1] && frontWheelIds[0] != rearWheelIds[0] && frontWheelIds[0] != rearWheelIds[1] &&
784 frontWheelIds[1] != rearWheelIds[0] && frontWheelIds[1] != rearWheelIds[1] &&
785 rearWheelIds[0] != rearWheelIds[1]),
786 "PxVehicleFourWheelDriveDifferentialParams:: centreBias is enabled but the frontWheelIds and rearWheelIds are not configured correctly.", false);
787 PX_CHECK_AND_RETURN_VAL((0.0f == centerBias) ||
788 (centerBias > 1.0f &&
789 torqueRatios[frontWheelIds[0]] != 0.0f && torqueRatios[frontWheelIds[1]] != 0.0f && torqueRatios[rearWheelIds[0]] != 0.0f && torqueRatios[rearWheelIds[1]] != 0.0f),
790 "PxVehicleFourWheelDriveDifferentialParams:: centreBias is enabled but the front and rear wheels are not connected.", false);
791
792 PX_CHECK_AND_RETURN_VAL((0.0f == rearBias) ||
793 (rearBias > 1.0f && rearWheelIds[0] < axleDesc.nbWheels && rearWheelIds[1] < axleDesc.nbWheels),
794 "PxVehicleFourWheelDriveDifferentialParams:: rearBias is enabled but the rearWheelIds are not configured correctly.", false);
795 PX_CHECK_AND_RETURN_VAL((0.0f == rearBias) ||
796 (rearBias > 1.0f && rearWheelIds[0] != rearWheelIds[1]),
797 "PxVehicleFourWheelDriveDifferentialParams:: rearBias is enabled but the rearWheelIds are not configured correctly.", false);
798 PX_CHECK_AND_RETURN_VAL((0.0f == centerBias) ||
799 (rearBias > 1.0f && torqueRatios[rearWheelIds[0]] != 0.0f && torqueRatios[rearWheelIds[1]] != 0.0f),
800 "PxVehicleFourWheelDriveDifferentialParams:: rearBias is enabled but the rear wheels are not connected.", false);
801
802 PX_CHECK_AND_RETURN_VAL((0.0f == frontBias) ||
803 (frontBias > 1.0f && frontWheelIds[0] < axleDesc.nbWheels && frontWheelIds[1] < axleDesc.nbWheels),
804 "PxVehicleFourWheelDriveDifferentialParams:: frontBias is enabled but the frontWheelIds are not configured correctly.", false);
805 PX_CHECK_AND_RETURN_VAL((0.0f == frontBias) ||
806 (frontBias > 1.0f && frontWheelIds[0] != frontWheelIds[1]),
807 "PxVehicleFourWheelDriveDifferentialParams:: frontBias is enabled but the frontWheelIds are not configured correctly.", false);
808 PX_CHECK_AND_RETURN_VAL((0.0f == frontBias) ||
809 (frontBias > 1.0f && torqueRatios[frontWheelIds[0]] != 0.0f && frontWheelIds[frontWheelIds[1]]),
810 "PxVehicleFourWheelDriveDifferentialParams:: frontBias is enabled but the front wheels are not connected.", false);
811
812 PX_CHECK_AND_RETURN_VAL(((0.0f == frontBias) && (0.0f == rearBias) && (0.0f == centerBias)) || (rate >= 0.0f),
813 "PxVehicleFourWheelDriveDifferentialParams:: strength must be greater than or equal to zero", false);
814
815 PX_CHECK_AND_RETURN_VAL((0.0f == frontBias) || ((1.0f == frontTarget && 1.0f == rearTarget) || (frontTarget > 1.0f && frontTarget < frontBias)),
816 "PxVehicleFourWheelDriveDifferentialParams: frontBias is enabled but frontTarget not in range (1.0f, frontBias)", false);
817 PX_CHECK_AND_RETURN_VAL((0.0f == rearBias) || ((1.0f == rearTarget && 1.0f == rearBias) || (rearTarget > 1.0f && rearTarget < rearBias)),
818 "PxVehicleFourWheelDriveDifferentialParams: rearBias is enabled but rearTarget not in range (1.0f, rearBias)", false);
819 PX_CHECK_AND_RETURN_VAL((0.0f == centerBias) || ((1.0f == centerTarget && 1.0f == centerBias) || (centerTarget > 1.0f && centerTarget < centerBias)),
820 "PxVehicleFourWheelDriveDifferentialParams: centerBias is enabled but centerTarget not in range (1.0f, centerBias)", false);
821
822 return true;
823 }
824
825 PX_FORCE_INLINE PxVehicleFourWheelDriveDifferentialParams transformAndScale(
826 const PxVehicleFrame& srcFrame, const PxVehicleFrame& trgFrame, const PxVehicleScale& srcScale, const PxVehicleScale& trgScale) const
827 {
828 PX_UNUSED(srcFrame);
829 PX_UNUSED(trgFrame);
830 PX_UNUSED(srcScale);
831 PX_UNUSED(trgScale);
832 PxVehicleFourWheelDriveDifferentialParams r = *this;
833 static_cast<PxVehicleMultiWheelDriveDifferentialParams&>(r) = PxVehicleMultiWheelDriveDifferentialParams::transformAndScale(srcFrame, trgFrame, srcScale, trgScale);
834 return r;
835 }
836};
837
853{
854 PX_FORCE_INLINE void setToDefault()
855 {
856 PxVehicleMultiWheelDriveDifferentialParams::setToDefault();
857 nbTracks = 0;
858 nbWheelsInTracks = 0;
859 }
860
867 void addTankTrack(const PxU32 nbWheelsInTrackToAdd, const PxU32* const wheelIdsInTrackToAdd, const PxU32 thrustControllerIndex)
868 {
869 PX_ASSERT((nbWheelsInTracks + nbWheelsInTrackToAdd) < PxVehicleLimits::eMAX_NB_WHEELS);
870 PX_ASSERT(nbTracks < PxVehicleLimits::eMAX_NB_WHEELS);
871 PX_ASSERT(thrustControllerIndex < 2);
872 nbWheelsPerTrack[nbTracks] = nbWheelsInTrackToAdd;
873 thrustIdPerTrack[nbTracks] = thrustControllerIndex;
874 trackToWheelIds[nbTracks] = nbWheelsInTracks;
875 for (PxU32 i = 0; i < nbWheelsInTrackToAdd; i++)
876 {
877 wheelIdsInTrackOrder[nbWheelsInTracks + i] = wheelIdsInTrackToAdd[i];
878 }
879 nbWheelsInTracks += nbWheelsInTrackToAdd;
880 nbTracks++;
881 }
882
889 {
890 return nbTracks;
891 }
892
899 PX_FORCE_INLINE PxU32 getNbWheelsInTrack(const PxU32 i) const
900 {
901 return nbWheelsPerTrack[i];
902 }
903
909 PX_FORCE_INLINE const PxU32* getWheelsInTrack(const PxU32 i) const
910 {
911 return (wheelIdsInTrackOrder + trackToWheelIds[i]);
912 }
913
921 PX_FORCE_INLINE PxU32 getWheelInTrack(const PxU32 j, const PxU32 i) const
922 {
923 return wheelIdsInTrackOrder[trackToWheelIds[i] + j];
924 }
925
931 PX_FORCE_INLINE PxU32 getThrustControllerIndex(const PxU32 i) const
932 {
933 return thrustIdPerTrack[i];
934 }
935
937 const PxVehicleFrame& srcFrame, const PxVehicleFrame& trgFrame, const PxVehicleScale& srcScale, const PxVehicleScale& trgScale) const
938 {
939 PX_UNUSED(srcFrame);
940 PX_UNUSED(trgFrame);
941 PX_UNUSED(srcScale);
942 PX_UNUSED(trgScale);
944 static_cast<PxVehicleMultiWheelDriveDifferentialParams&>(r) = PxVehicleMultiWheelDriveDifferentialParams::transformAndScale(srcFrame, trgFrame, srcScale, trgScale);
945 return r;
946 }
947
948 PX_FORCE_INLINE bool isValid(const PxVehicleAxleDescription& axleDesc) const
949 {
950 if (!PxVehicleMultiWheelDriveDifferentialParams::isValid(axleDesc))
951 return false;
952
953 PX_CHECK_AND_RETURN_VAL(nbTracks <= PxVehicleLimits::eMAX_NB_WHEELS, "PxVehicleTankDriveDifferentialParams.nbTracks must not exceed PxVehicleLimits::eMAX_NB_WHEELS", false);
954 PX_CHECK_AND_RETURN_VAL(nbWheelsInTracks <= PxVehicleLimits::eMAX_NB_WHEELS, "PxVehicleTankDriveDifferentialParams.nbWheelsInTracks must not exceed PxVehicleLimits::eMAX_NB_WHEELS", false);
955 for (PxU32 i = 0; i < nbTracks; i++)
956 {
957 PX_CHECK_AND_RETURN_VAL(thrustIdPerTrack[i] < 2, "PxVehicleTankDriveDifferentialParams.thrustId must be less than 2", false);
958 PX_CHECK_AND_RETURN_VAL(getNbWheelsInTrack(i) >= 2, "PxVehicleTankDriveDifferentialParams.nbWheelsPerTrack must be greater than or equal to 2", false);
959 }
960
961 for (PxU32 i = 0; i < axleDesc.nbWheels; i++)
962 {
963 const PxU32 wheelId = axleDesc.wheelIdsInAxleOrder[i];
964 PxU32 count = 0;
965 for (PxU32 j = 0; j < nbWheelsInTracks; j++)
966 {
967 if (wheelIdsInTrackOrder[j] == wheelId)
968 count++;
969 }
970 PX_CHECK_AND_RETURN_VAL(count <= 1, "PxVehicleTankDriveDifferentialParams - a wheel cannot be in more than one tank track", false);
971 }
972 return true;
973 }
974
975 PxU32 nbTracks;
976 PxU32 thrustIdPerTrack[PxVehicleLimits::eMAX_NB_WHEELS];
977 PxU32 nbWheelsPerTrack[PxVehicleLimits::eMAX_NB_WHEELS];
978 PxU32 trackToWheelIds[PxVehicleLimits::eMAX_NB_WHEELS];
979
980 PxU32 wheelIdsInTrackOrder[PxVehicleLimits::eMAX_NB_WHEELS];
982};
983
984
985#if !PX_DOXYGEN
986} // namespace vehicle2
987} // namespace physx
988#endif
989
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 float PxAbs(float a)
abs returns the absolute value of its argument.
Definition PxMath.h:109
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
PX_FORCE_INLINE void * PxMemZero(void *dest, PxU32 count)
Sets the bytes of the provided buffer to zero.
Definition PxMemory.h:53
Definition PxVehicleDrivetrainParams.h:404
PxReal latency
Set the latency time of the autobox.
Definition PxVehicleDrivetrainParams.h:437
Definition PxVehicleParams.h:53
PxU32 wheelIdsInAxleOrder[PxVehicleLimits::eMAX_NB_WHEELS]
The list of all wheel ids on the vehicle.
Definition PxVehicleParams.h:149
PX_FORCE_INLINE PxU32 getAxle(const PxU32 wheelId) const
Return the axle of a specified wheel.
Definition PxVehicleParams.h:125
PxU32 nbWheels
The number of wheels on the vehicle.
Definition PxVehicleParams.h:150
Choose between a potentially more expensive but more accurate solution to the clutch model or a poten...
Definition PxVehicleDrivetrainParams.h:127
Specifies the maximum clutch strength that occurs when the clutch pedal is fully disengaged and the c...
Definition PxVehicleDrivetrainParams.h:84
PxReal maxResponse
Strength of clutch.
Definition PxVehicleDrivetrainParams.h:102
The clutch connects two plates together. One plate rotates with the speed of the engine....
Definition PxVehicleDrivetrainParams.h:141
PxVehicleClutchAccuracyMode::Enum accuracyMode
The engine and wheel rotation speeds that are coupled through the clutch can be updated by choosing o...
Definition PxVehicleDrivetrainParams.h:158
PxU32 estimateIterations
Tune the mathematical accuracy and computational cost of the computed estimate to the wheel and engin...
Definition PxVehicleDrivetrainParams.h:171
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
Distribute a throttle response to the wheels of a direct drive vehicle.
Definition PxVehicleDrivetrainParams.h:57
Definition PxVehicleDrivetrainParams.h:192
PxReal peakTorque
Maximum torque available to apply to the engine when the accelerator pedal is at maximum.
Definition PxVehicleDrivetrainParams.h:224
PxReal dampingRateFullThrottle
Damping rate of engine when full throttle is applied.
Definition PxVehicleDrivetrainParams.h:256
PxReal moi
Moment of inertia of the engine around the axis of rotation.
Definition PxVehicleDrivetrainParams.h:214
PxVehicleFixedSizeLookupTable< PxReal, eMAX_NB_ENGINE_TORQUE_CURVE_ENTRIES > torqueCurve
Graph of normalized torque (torque/peakTorque) against normalized engine speed ( engineRotationSpeed ...
Definition PxVehicleDrivetrainParams.h:206
PxReal idleOmega
Minimum rotation speed of the engine.
Definition PxVehicleDrivetrainParams.h:232
PxReal dampingRateZeroThrottleClutchDisengaged
Damping rate of engine when no throttle is applied and with disengaged clutch.
Definition PxVehicleDrivetrainParams.h:288
PxReal maxOmega
Maximum rotation speed of the engine.
Definition PxVehicleDrivetrainParams.h:240
PxReal dampingRateZeroThrottleClutchEngaged
Damping rate of engine when no throttle is applied and with engaged clutch.
Definition PxVehicleDrivetrainParams.h:272
Enum type
Type of differential.
Definition PxVehicleDrivetrainParams.h:567
PxReal rearBias
Maximum allowed ratio of rear-left and rear-right wheel rotation speeds. The differential will divert...
Definition PxVehicleDrivetrainParams.h:560
PxReal centerBias
Maximum allowed ratio of average front wheel rotation speed and rear wheel rotation speeds....
Definition PxVehicleDrivetrainParams.h:540
PxReal frontRearSplit
Ratio of torque split between front and rear wheels (>0.5 means more front, <0.5 means more to rear).
Definition PxVehicleDrivetrainParams.h:512
PxReal frontNegPosSplit
Ratio of torque split between front-negative and front-positive wheels (>0.5 means more to frontWheel...
Definition PxVehicleDrivetrainParams.h:521
PxReal frontBias
Maximum allowed ratio of front-left and front-right wheel rotation speeds. The differential will dive...
Definition PxVehicleDrivetrainParams.h:550
PxReal rearNegPosSplit
Ratio of torque split between rear-negative wheel and rear-positive wheels (>0.5 means more to rearWh...
Definition PxVehicleDrivetrainParams.h:530
PxVehicleFourWheelDriveDifferentialParams specifies the wheels that are to receive drive torque from ...
Definition PxVehicleDrivetrainParams.h:672
PxReal centerBias
The parameter centerBias specifies the maximum angular speed ratio of the sum of the two front wheels...
Definition PxVehicleDrivetrainParams.h:743
PxReal frontBias
The parameter frontBias specifies the maximum angular speed ratio of the two front wheels specified b...
Definition PxVehicleDrivetrainParams.h:700
PxReal rearBias
The parameter rearBias specifies the maximum angular speed ratio of the two rear wheels specified by ...
Definition PxVehicleDrivetrainParams.h:721
PxReal rate
The parameter rate specifies how quickly the ratio of rotational speeds approaches the target rotatio...
Definition PxVehicleDrivetrainParams.h:760
PxReal frontTarget
The parameter frontTarget specifies the target rotational speed ratio of the two front wheels in the ...
Definition PxVehicleDrivetrainParams.h:708
PxReal rearTarget
The parameter rearTarget specifies the target rotational speed ratio of the two rear wheels in the ev...
Definition PxVehicleDrivetrainParams.h:729
PxReal centerTarget
The parameter centerTarget specifies the target rotational speed ratio of the sum of the two front wh...
Definition PxVehicleDrivetrainParams.h:751
Definition PxVehicleParams.h:174
Definition PxVehicleDrivetrainParams.h:320
PxU32 neutralGear
The gear that denotes neutral gear.
Definition PxVehicleDrivetrainParams.h:326
PxU32 nbRatios
Number of gears (including reverse and neutral).
Definition PxVehicleDrivetrainParams.h:356
Enum
Maximum supported number of gears, including reverse and neutral.
Definition PxVehicleDrivetrainParams.h:332
PxReal finalRatio
Gear ratio applied is ratios[currentGear]*finalRatio.
Definition PxVehicleDrivetrainParams.h:349
PxReal switchTime
Time it takes to switch gear.
Definition PxVehicleDrivetrainParams.h:364
PxVehicleMultiWheelDriveDifferentialParams specifies the wheels that are to receive drive torque from...
Definition PxVehicleDrivetrainParams.h:600
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
A description of a tank differential.
Definition PxVehicleDrivetrainParams.h:853
void addTankTrack(const PxU32 nbWheelsInTrackToAdd, const PxU32 *const wheelIdsInTrackToAdd, const PxU32 thrustControllerIndex)
Add a tank track by specifying the number of wheels along the track track and an array of wheel ids s...
Definition PxVehicleDrivetrainParams.h:867
PX_FORCE_INLINE PxU32 getWheelInTrack(const PxU32 j, const PxU32 i) const
Return the wheel id of the jth wheel in the ith track.
Definition PxVehicleDrivetrainParams.h:921
PxU32 nbWheelsInTracks
The number of wheels in all tracks.
Definition PxVehicleDrivetrainParams.h:981
PX_FORCE_INLINE PxU32 getThrustControllerIndex(const PxU32 i) const
Return the index of the thrust controller that will control a specified track.
Definition PxVehicleDrivetrainParams.h:931
PxU32 nbTracks
The number of tracks.
Definition PxVehicleDrivetrainParams.h:975
PX_FORCE_INLINE const PxU32 * getWheelsInTrack(const PxU32 i) const
Return the array of all wheels in the ith track.
Definition PxVehicleDrivetrainParams.h:909
PX_FORCE_INLINE PxU32 getNbTracks() const
Return the number of tracks.
Definition PxVehicleDrivetrainParams.h:888
PX_FORCE_INLINE PxU32 getNbWheelsInTrack(const PxU32 i) const
Return the number of wheels in the ith track.
Definition PxVehicleDrivetrainParams.h:899