CARLA
Loading...
Searching...
No Matches
Unreal/CarlaUnreal/Plugins/Carla/Source/Carla/Vehicle/WheelPhysicsControl.h
Go to the documentation of this file.
1// Copyright (c) 2026 Computer Vision Center (CVC) at the Universitat Autonoma
2// de Barcelona (UAB).
3//
4// This work is licensed under the terms of the MIT license.
5// For a copy, see <https://opensource.org/licenses/MIT>.
6
7#pragma once
8
9#include <util/ue-header-guard-begin.h>
10#include "ChaosVehicleWheel.h"
11#include <util/ue-header-guard-end.h>
12
13#include "WheelPhysicsControl.generated.h"
14
15USTRUCT(BlueprintType)
16struct CARLA_API FWheelPhysicsControl
17{
18 GENERATED_BODY()
19
21 AxleType(EAxleType::Undefined),
22 Offset(FVector(0.0f, 0.0f, 0.0f)),
23 WheelRadius(1.0f),
24 WheelWidth(1.0f),
25 WheelMass(1),
26 CorneringStiffness(1.0f),
27 FrictionForceMultiplier(1.0f),
28 SideSlipModifier(0.5f),
29 SlipThreshold(1.0f),
30 SkidThreshold(1.0f),
31 MaxSteerAngle(60.0f),
32 bAffectedBySteering(true),
33 bAffectedByBrake(true),
34 bAffectedByHandbrake(true),
35 bAffectedByEngine(true),
36 bABSEnabled(true),
37 bTractionControlEnabled(true),
38 MaxWheelspinRotation(1.0f),
39 ExternalTorqueCombineMethod(ETorqueCombineMethod::None),
40 LateralSlipGraph(FRichCurve()),
41 SuspensionAxis(FVector(0.0f, 0.0f, 1.0f)),
42 SuspensionForceOffset(1.0f),
43 SuspensionMaxRaise(1.0f),
44 SuspensionMaxDrop(1.0f),
45 SuspensionDampingRatio(0.5f),
46 WheelLoadRatio(0.5f),
47 SpringRate(1.0f),
48 SpringPreload(1.0f),
49 SuspensionSmoothing(5.0f),
50 RollbarScaling(0.0f),
51 SweepShape(ESweepShape::Spherecast),
52 SweepType(ESweepType::ComplexSweep),
53 MaxBrakeTorque(1.0f),
54 MaxHandBrakeTorque(1.0f),
55 WheelIndex(0),
56 Location(FVector(0.0f, 0.0f, 0.0f)),
57 OldLocation(FVector(0.0f, 0.0f, 0.0f)),
58 Velocity(FVector(0.0f, 0.0f, 0.0f))
59 {
60
61 }
62 /** If left undefined then the bAffectedByEngine value is used, if defined then bAffectedByEngine is ignored and the differential setup on the vehicle defines which wheels get power from the engine */
63 UPROPERTY(EditAnywhere, Category = Wheel)
64 EAxleType AxleType;
65
66 /**
67 * If BoneName is specified, offset the wheel from the bone's location.
68 * Otherwise this offsets the wheel from the vehicle's origin.
69 */
70 UPROPERTY(EditAnywhere, Category = Wheel)
71 FVector Offset;
72
73 /** Radius of the wheel */
74 UPROPERTY(EditAnywhere, Category = Wheel, meta = (ClampMin = "0.01", UIMin = "0.01"))
75 float WheelRadius;
76
77 /** Width of the wheel */
78 UPROPERTY(EditAnywhere, Category = Wheel, meta = (ClampMin = "0.01", UIMin = "0.01"))
79 float WheelWidth;
80
81 /** Mass of the wheel Kg */
82 UPROPERTY(EditAnywhere, Category = Wheel, meta = (ClampMin = "0.01", UIMin = "0.01"))
83 float WheelMass;
84
85 /** Tyre Cornering Ability */
86 UPROPERTY(EditAnywhere, Category = Wheel)
87 float CorneringStiffness;
88
89 /** Friction Force Multiplier */
90 UPROPERTY(EditAnywhere, Category = Wheel)
91 float FrictionForceMultiplier;
92
93 /** Wheel Lateral Skid Grip Loss, lower number less grip on skid */
94 UPROPERTY(EditAnywhere, Category = Wheel, meta = (ClampMin = "0.0", UIMin = "0.0", ClampMax = "1.0", UIMax = "1.0"))
95 float SideSlipModifier;
96
97 /** Wheel Longitudinal Slip Threshold */
98 UPROPERTY(EditAnywhere, Category = Wheel, meta = (ClampMin = "0.0", UIMin = "0.0"))
99 float SlipThreshold;
100
101 /** Wheel Lateral Skid Threshold */
102 UPROPERTY(EditAnywhere, Category = Wheel, meta = (ClampMin = "0.0", UIMin = "0.0"))
103 float SkidThreshold;
104
105 // steer angle in degrees for this wheel
106 UPROPERTY(EditAnywhere, Category = WheelsSetup)
107 float MaxSteerAngle;
108
109 /** Whether steering should affect this wheel */
110 UPROPERTY(EditAnywhere, Category = WheelsSetup)
111 bool bAffectedBySteering;
112
113 /** Whether brake should affect this wheel */
114 UPROPERTY(EditAnywhere, Category = Wheel)
115 bool bAffectedByBrake;
116
117 /** Whether handbrake should affect this wheel */
118 UPROPERTY(EditAnywhere, Category = Wheel)
119 bool bAffectedByHandbrake;
120
121 /** Whether engine should power this wheel */
122 UPROPERTY(EditAnywhere, Category = Wheel)
123 bool bAffectedByEngine;
124
125 /** Advanced Braking System Enabled */
126 UPROPERTY(EditAnywhere, Category = Wheel)
127 bool bABSEnabled;
128
129 /** Straight Line Traction Control Enabled */
130 UPROPERTY(EditAnywhere, Category = Wheel)
131 bool bTractionControlEnabled;
132
133 /** Max Wheelspin rotation rad/sec */
134 UPROPERTY(EditAnywhere, Category = Wheel)
135 float MaxWheelspinRotation;
136
137 /** Determines how the SetDriveTorque/SetBrakeTorque inputs are combined with the internal torques */
138 UPROPERTY(EditAnywhere, Category = Wheel)
139 ETorqueCombineMethod ExternalTorqueCombineMethod;
140
141 UPROPERTY(EditAnywhere, Category = Setup)
142 FRichCurve LateralSlipGraph;
143
144 /** Local body direction in which where suspension forces are applied (typically along -Z-axis) */
145 UPROPERTY(EditAnywhere, Category = Suspension)
146 FVector SuspensionAxis;
147
148 /** Vertical offset from where suspension forces are applied (along Z-axis) */
149 UPROPERTY(EditAnywhere, Category = Suspension)
150 FVector SuspensionForceOffset;
151
152 /** How far the wheel can go above the resting position */
153 UPROPERTY(EditAnywhere, Category = Suspension)
154 float SuspensionMaxRaise;
155
156 /** How far the wheel can drop below the resting position */
157 UPROPERTY(EditAnywhere, Category = Suspension)
158 float SuspensionMaxDrop;
159
160 /** Suspension damping, larger value causes the suspension to come to rest faster [range 0 to 1] */
161 UPROPERTY(EditAnywhere, Category = Suspension)
162 float SuspensionDampingRatio;
163
164 /**
165 * Amount wheel load effects wheel friction.
166 At 0 wheel friction is completely independent of the loading on the wheel (This is artificial as it always assumes even balance between all wheels)
167 At 1 wheel friction is based on the force pressing wheel into the ground. This is more realistic.
168 Lower value cures lift off over-steer, generally makes vehicle easier to handle under extreme motions.
169 */
170 UPROPERTY(EditAnywhere, Category = Suspension, meta = (ClampMin = "0.0", UIMin = "0.0", ClampMax = "1.0", UIMax = "1.0"))
171 float WheelLoadRatio;
172
173 /** Spring Force (N/m) */
174 UPROPERTY(EditAnywhere, Category = Suspension)
175 float SpringRate;
176
177 /** Spring Preload (N/m) */
178 UPROPERTY(EditAnywhere, Category = Suspension)
179 float SpringPreload;
180
181 /** Smooth suspension [0-off, 10-max] - Warning might cause momentary visual inter-penetration of the wheel against objects/terrain */
182 UPROPERTY(EditAnywhere, Category = Suspension, meta = (ClampMin = "0.0", UIMin = "0", ClampMax = "10.0", UIMax = "10"))
183 int SuspensionSmoothing;
184
185 /** Anti-roll effect */
186 UPROPERTY(EditAnywhere, Category = Suspension, meta = (ClampMin = "0.0", UIMin = "0", ClampMax = "1.0", UIMax = "1"))
187 float RollbarScaling;
188
189 /** Wheel suspension trace type, defaults to ray trace */
190 UPROPERTY(EditAnywhere, Category = Suspension)
191 ESweepShape SweepShape;
192
193 /** Whether wheel suspension considers simple, complex */
194 UPROPERTY(EditAnywhere, Category = Suspension)
195 ESweepType SweepType;
196
197 /** max brake torque for this wheel (Nm) */
198 UPROPERTY(EditAnywhere, Category = Brakes)
199 float MaxBrakeTorque;
200
201 /**
202 * Max handbrake brake torque for this wheel (Nm). A handbrake should have a stronger brake torque
203 * than the brake. This will be ignored for wheels that are not affected by the handbrake.
204 */
205 UPROPERTY(EditAnywhere, Category = Brakes)
206 float MaxHandBrakeTorque;
207
208 // Our index in the vehicle's (and setup's) wheels array
209 UPROPERTY(transient)
210 int32 WheelIndex;
211
212 // Worldspace location of this wheel
213 UPROPERTY(transient)
214 FVector Location;
215
216 // Worldspace location of this wheel last frame
217 UPROPERTY(transient)
218 FVector OldLocation;
219
220 // Current velocity of the wheel center (change in location over time)
221 UPROPERTY(Category = "Wheel Position", EditAnywhere, BlueprintReadWrite)
222 FVector Velocity;
223
224};