RavEngine
Loading...
Searching...
No Matches
PxVehicleCommandParams.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 "vehicle2/PxVehicleLimits.h"
37#include "vehicle2/PxVehicleParams.h"
38
39#if !PX_DOXYGEN
40namespace physx
41{
42namespace vehicle2
43{
44#endif
45
46
47
54{
55 enum Enum
56 {
57 eMAX_NB_SPEED_RESPONSES = 64
58 };
59
64
72};
73
80{
81public:
82
83 enum Enum
84 {
85 eMAX_NB_COMMAND_VALUES = 8
86 };
87
91 {
92 }
93
94 void clear()
95 {
98 }
99
105 bool addResponse(const PxVehicleCommandValueResponseTable& commandValueSpeedResponses)
106 {
107 const PxReal commandValue = commandValueSpeedResponses.commandValue;
108 const PxReal* speeds = commandValueSpeedResponses.speedResponses.xVals;
109 const PxReal* responses = commandValueSpeedResponses.speedResponses.yVals;
110 const PxU16 nb = PxU16(commandValueSpeedResponses.speedResponses.nbDataPairs);
111
112 PX_CHECK_AND_RETURN_VAL(commandValue >= 0.0f && commandValue <= 1.0f, "PxVehicleCommandAndResponseTable::commandValue must be in range (0,1)", false);
113
114 PX_CHECK_AND_RETURN_VAL(nbCommandValues < eMAX_NB_COMMAND_VALUES, "PxVehicleNonLinearCommandResponse::addResponse - exceeded maximum number of command responses", false);
115
116 PX_CHECK_AND_RETURN_VAL(((nbSpeedResponses + nb) <= PxVehicleCommandValueResponseTable::eMAX_NB_SPEED_RESPONSES), "PxVehicleNonLinearCommandResponse::addResponse - exceeded maximum number of command responses", false);
117
118 PX_CHECK_AND_RETURN_VAL((0 == nbCommandValues) || (commandValue > commandValues[nbCommandValues - 1]), "PxVehicleNonLinearCommandResponse::addResponse - command must be part of a a monotonically increasing series", false);
119
120 PX_CHECK_AND_RETURN_VAL(nb > 0, "PxVehicleNonLinearCommandResponse::addResponse - each command response must have at least 1 point", false);
121
122#if PX_CHECKED
123 for (PxU32 i = 1; i < nb; i++)
124 {
125 PX_CHECK_AND_RETURN_VAL(speeds[i] > speeds[i - 1], "PxVehicleNonLinearCommandResponse::addResponse - speeds array must be a monotonically increasing series", false);
126 PX_CHECK_AND_RETURN_VAL(responses[i] >= 0.0f && responses[i] <= 1.0f , "PxVehicleNonLinearCommandResponse::addResponse - response must be in range (0,1)", false);
127 }
128#endif
129
130 commandValues[nbCommandValues] = commandValue;
133 PxMemCopy(speedResponses + 2 * nbSpeedResponses, speeds, sizeof(PxReal)*nb);
134 PxMemCopy(speedResponses + 2 * nbSpeedResponses + nb, responses, sizeof(PxReal)*nb);
136 nbSpeedResponses += nb;
137 return true;
138 }
139
140public:
141
145 PxReal speedResponses[PxVehicleCommandValueResponseTable::eMAX_NB_SPEED_RESPONSES * 2];
146
151
155 PxU16 speedResponsesPerCommandValue[eMAX_NB_COMMAND_VALUES];
156
160 PxU16 nbSpeedRenponsesPerCommandValue[eMAX_NB_COMMAND_VALUES];
161
165 PxReal commandValues[eMAX_NB_COMMAND_VALUES];
166
171};
172
194
195
196
197#if !PX_DOXYGEN
198} // namespace vehicle2
199} // namespace physx
200#endif
201
Definition PxVehicleCommandParams.h:80
PxU16 nbSpeedRenponsesPerCommandValue[eMAX_NB_COMMAND_VALUES]
The ith command value has N speed responses with N = nbSpeedRenponsesPerCommandValue[i].
Definition PxVehicleCommandParams.h:160
PxReal commandValues[eMAX_NB_COMMAND_VALUES]
The command values.
Definition PxVehicleCommandParams.h:165
PxU16 nbCommandValues
The number of command values.
Definition PxVehicleCommandParams.h:170
PxU16 speedResponsesPerCommandValue[eMAX_NB_COMMAND_VALUES]
The table of speed responses for the ith command value begins at speedResponses[2*speedResponsesPerCo...
Definition PxVehicleCommandParams.h:155
bool addResponse(const PxVehicleCommandValueResponseTable &commandValueSpeedResponses)
Add a table of normalised response vs speed and associated it with a specified command value.
Definition PxVehicleCommandParams.h:105
PxReal speedResponses[PxVehicleCommandValueResponseTable::eMAX_NB_SPEED_RESPONSES *2]
A ragged array of speeds and normalized responses.
Definition PxVehicleCommandParams.h:145
PxU16 nbSpeedResponses
The number of speeds and normalized responses.
Definition PxVehicleCommandParams.h:150
Express a function as a sequence of points {(x, y)} that form a piecewise polynomial.
Definition PxVehicleParams.h:808
Sorts an array of objects in ascending order, assuming that the predicate implements the < operator:
Definition PxBoxController.h:39
PX_FORCE_INLINE void * PxMemCopy(void *dest, const void *src, PxU32 count)
Copies the bytes of one memory block to another. The memory blocks must not overlap.
Definition PxMemory.h:83
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
PxVehicleCommandNonLinearResponseParams nonlinearResponse
A nonlinear response to command value expressed as a lookup table of normalized response as a functio...
Definition PxVehicleCommandParams.h:182
Each command value may be associated with a table specifying a normalized response as a function of l...
Definition PxVehicleCommandParams.h:54
PxVehicleFixedSizeLookupTable< PxReal, eMAX_NB_SPEED_RESPONSES > speedResponses
A lookup table specifying the normalised response to the specified command value as a function of lon...
Definition PxVehicleCommandParams.h:71
PxReal commandValue
The command value associated with the table of speed responses.
Definition PxVehicleCommandParams.h:63