CARLA
Loading...
Searching...
No Matches
LibCarla/source/carla/rpc/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
10#include "carla/geom/Vector3D.h"
11#include "carla/geom/Location.h"
12#include "carla/MsgPack.h"
13
14
15namespace carla {
16 namespace rpc {
17
19
20 uint8_t axle_type = 0; // @TODO INTRODUCE ENUM
22 float wheel_radius = 30.0f;
23 float wheel_width = 30.0f;
24 float wheel_mass = 30.0f;
25 float cornering_stiffness = 1000.0f;
27 float side_slip_modifier = 1.0f;
28 float slip_threshold = 20.0f;
29 float skid_threshold = 20.0f;
30 float max_steer_angle = 70.0f;
32 bool affected_by_brake = true;
34 bool affected_by_engine = true;
35 bool abs_enabled = false;
38 uint8_t external_torque_combine_method = 0; // @TODO INTRODUCE ENUM
39 std::vector<geom::Vector2D> lateral_slip_graph = {};
42 float suspension_max_raise = 10.0f;
43 float suspension_max_drop = 10.0f;
45 float wheel_load_ratio = 0.5f;
46 float spring_rate = 250.0f;
47 float spring_preload = 50.0f;
49 float rollbar_scaling = 0.15f;
50 uint8_t sweep_shape = 0; // @TODO INTRODUCE ENUM
51 uint8_t sweep_type = 0; // @TODO INTRODUCE ENUM
52 float max_brake_torque = 1500.0f;
53 float max_hand_brake_torque = 3000.0f;
54 int32_t wheel_index = -1;
58
59 inline bool operator==(const WheelPhysicsControl& rhs) const {
60 const bool cmp[] =
61 {
62 axle_type == rhs.axle_type,
63 offset == rhs.offset,
97 location == rhs.location,
99 velocity == rhs.velocity
100 };
101 return std::all_of(std::begin(cmp), std::end(cmp), [](bool b) noexcept { return b; });
102 }
103
104 inline bool operator!=(const WheelPhysicsControl& rhs) const {
105 return !(*this == rhs);
106 }
107
108#ifdef LIBCARLA_INCLUDED_FROM_UE4
109
111 const FWheelPhysicsControl& Wheel)
112 {
113 WheelPhysicsControl Out = { };
114 Out.axle_type = (uint8_t)Wheel.AxleType;
116 Wheel.Offset.X,
117 Wheel.Offset.Y,
118 Wheel.Offset.Z);
119 Out.wheel_radius = Wheel.WheelRadius;
120 Out.wheel_width = Wheel.WheelWidth;
121 Out.wheel_mass = Wheel.WheelMass;
125 Out.slip_threshold = Wheel.SlipThreshold;
126 Out.skid_threshold = Wheel.SkidThreshold;
127 Out.max_steer_angle = Wheel.MaxSteerAngle;
132 Out.abs_enabled = Wheel.bABSEnabled;
136 Out.lateral_slip_graph.reserve(Wheel.LateralSlipGraph.GetNumKeys());
137 for (auto& e : Wheel.LateralSlipGraph.GetConstRefOfKeys())
138 Out.lateral_slip_graph.push_back({ e.Time, e.Value });
140 Wheel.SuspensionAxis.X,
141 Wheel.SuspensionAxis.Y,
142 Wheel.SuspensionAxis.Z);
144 Wheel.SuspensionForceOffset.X,
145 Wheel.SuspensionForceOffset.Y,
146 Wheel.SuspensionForceOffset.Z);
151 Out.spring_rate = Wheel.SpringRate;
152 Out.spring_preload = Wheel.SpringPreload;
155 Out.sweep_shape = (uint8_t)Wheel.SweepShape;
156 Out.sweep_type = (uint8_t)Wheel.SweepType;
159 Out.wheel_index = Wheel.WheelIndex;
160 Out.location = Wheel.Location;
161 Out.old_location = Wheel.OldLocation;
162 Out.velocity = Wheel.Velocity;
163 return Out;
164 }
165
166 operator FWheelPhysicsControl() const {
168 Wheel.AxleType = (EAxleType)axle_type;
169 Wheel.Offset = FVector(offset.x, offset.y, offset.z);
171 Wheel.WheelWidth = wheel_width;
172 Wheel.WheelMass = wheel_mass;
183 Wheel.bABSEnabled = abs_enabled;
187 for (auto [x, y] : lateral_slip_graph)
188 Wheel.LateralSlipGraph.AddKey(x, y);
189 Wheel.SuspensionAxis = FVector(
193 Wheel.SuspensionForceOffset = FVector(
201 Wheel.SpringRate = spring_rate;
205 Wheel.SweepShape = (ESweepShape)sweep_shape;
206 Wheel.SweepType = (ESweepType)sweep_type;
209 Wheel.WheelIndex = wheel_index;
210 Wheel.Location = location;
212 Wheel.Velocity = velocity;
213 return Wheel;
214 }
215#endif
216
217 MSGPACK_DEFINE_ARRAY(
218 axle_type,
219 offset,
253 location,
255 velocity)
256 };
257
258 }
259}
This file contains definitions of common data structures used in traffic manager.
ETorqueCombineMethod ExternalTorqueCombineMethod
Determines how the SetDriveTorque/SetBrakeTorque inputs are combined with the internal torques.
float SuspensionMaxRaise
How far the wheel can go above the resting position.
int SuspensionSmoothing
Smooth suspension [0-off, 10-max] - Warning might cause momentary visual inter-penetration of the whe...
ESweepShape SweepShape
Wheel suspension trace type, defaults to ray trace.
FVector SuspensionForceOffset
Vertical offset from where suspension forces are applied (along Z-axis).
float MaxHandBrakeTorque
Max handbrake brake torque for this wheel (Nm).
FVector Offset
If BoneName is specified, offset the wheel from the bone's location.
float SideSlipModifier
Wheel Lateral Skid Grip Loss, lower number less grip on skid.
float SuspensionMaxDrop
How far the wheel can drop below the resting position.
FVector SuspensionAxis
Local body direction in which where suspension forces are applied (typically along -Z-axis).
EAxleType AxleType
If left undefined then the bAffectedByEngine value is used, if defined then bAffectedByEngine is igno...
float SuspensionDampingRatio
Suspension damping, larger value causes the suspension to come to rest faster [range 0 to 1].
ESweepType SweepType
Whether wheel suspension considers simple, complex.
static WheelPhysicsControl FromFWheelPhysicsControl(const FWheelPhysicsControl &Wheel)
bool operator!=(const WheelPhysicsControl &rhs) const
bool operator==(const WheelPhysicsControl &rhs) const