CARLA
CarlaWheeledVehicle.cpp
Go to the documentation of this file.
1 // Copyright (c) 2017 Computer Vision Center (CVC) at the Universitat Autonoma
2 // de Barcelona (UAB).
3 // Copyright (c) 2019 Intel Corporation
4 //
5 // This work is licensed under the terms of the MIT license.
6 // For a copy, see <https://opensource.org/licenses/MIT>.
7 
8 #include "Components/BoxComponent.h"
9 #include "Engine/CollisionProfile.h"
11 #include "Rendering/SkeletalMeshRenderData.h"
12 #include "UObject/UObjectGlobals.h"
13 #include "DrawDebugHelpers.h"
14 #include "Kismet/KismetSystemLibrary.h"
15 
16 #include "PhysXPublic.h"
17 #include "PhysXVehicleManager.h"
18 #include "TireConfig.h"
19 #include "VehicleWheel.h"
20 
21 #include "Carla.h"
22 #include "Carla/Game/CarlaHUD.h"
26 #include "Carla/Util/EmptyActor.h"
30 
31 // =============================================================================
32 // -- Constructor and destructor -----------------------------------------------
33 // =============================================================================
34 
35 ACarlaWheeledVehicle::ACarlaWheeledVehicle(const FObjectInitializer& ObjectInitializer) :
36  Super(ObjectInitializer)
37 {
38  VehicleBounds = CreateDefaultSubobject<UBoxComponent>(TEXT("VehicleBounds"));
39  VehicleBounds->SetupAttachment(RootComponent);
40  VehicleBounds->SetHiddenInGame(true);
41  VehicleBounds->SetCollisionProfileName(UCollisionProfile::NoCollision_ProfileName);
42 
43  VelocityControl = CreateDefaultSubobject<UVehicleVelocityControl>(TEXT("VelocityControl"));
44  VelocityControl->Deactivate();
45 
46  GetVehicleMovementComponent()->bReverseAsBrake = false;
47  BaseMovementComponent = CreateDefaultSubobject<UBaseCarlaMovementComponent>(TEXT("BaseMovementComponent"));
48 }
49 
51 
52 void ACarlaWheeledVehicle::SetWheelCollision(UWheeledVehicleMovementComponent4W *Vehicle4W,
54 
55  #ifdef WHEEL_SWEEP_ENABLED
56  const bool IsBike = IsTwoWheeledVehicle();
57 
58  if (IsBike)
59  return;
60 
61  const bool IsEqual = Vehicle4W->UseSweepWheelCollision == PhysicsControl.UseSweepWheelCollision;
62 
63  if (IsEqual)
64  return;
65 
66  Vehicle4W->UseSweepWheelCollision = PhysicsControl.UseSweepWheelCollision;
67 
68  #else
69 
70  if (PhysicsControl.UseSweepWheelCollision)
71  UE_LOG(LogCarla, Warning, TEXT("Error: Sweep for wheel collision is not available. \
72  Make sure you have installed the required patch.") );
73 
74  #endif
75 
76 }
77 
78 void ACarlaWheeledVehicle::SetWheelCollisionNW(UWheeledVehicleMovementComponentNW *VehicleNW,
80 
81  #ifdef WHEEL_SWEEP_ENABLED
82  const bool IsEqual = VehicleNW->UseSweepWheelCollision == PhysicsControl.UseSweepWheelCollision;
83 
84  if (IsEqual)
85  return;
86 
87  VehicleNW->UseSweepWheelCollision = PhysicsControl.UseSweepWheelCollision;
88 
89  #else
90 
91  if (PhysicsControl.UseSweepWheelCollision)
92  UE_LOG(LogCarla, Warning, TEXT("Error: Sweep for wheel collision is not available. \
93  Make sure you have installed the required patch.") );
94 
95  #endif
96 }
97 
99 {
100  Super::BeginPlay();
101 
103 
104  // Get constraint components and their initial transforms
105  FTransform ActorInverseTransform = GetActorTransform().Inverse();
106  ConstraintsComponents.Empty();
107  DoorComponentsTransform.Empty();
108  ConstraintDoor.Empty();
109  for (FName& ComponentName : ConstraintComponentNames)
110  {
111  UPhysicsConstraintComponent* ConstraintComponent =
112  Cast<UPhysicsConstraintComponent>(GetDefaultSubobjectByName(ComponentName));
113  if (ConstraintComponent)
114  {
115  UPrimitiveComponent* DoorComponent = Cast<UPrimitiveComponent>(
116  GetDefaultSubobjectByName(ConstraintComponent->ComponentName1.ComponentName));
117  if(DoorComponent)
118  {
119  UE_LOG(LogCarla, Warning, TEXT("Door name: %s"), *(DoorComponent->GetName()));
120  FTransform ComponentWorldTransform = DoorComponent->GetComponentTransform();
121  FTransform RelativeTransform = ComponentWorldTransform * ActorInverseTransform;
122  DoorComponentsTransform.Add(DoorComponent, RelativeTransform);
123  ConstraintDoor.Add(ConstraintComponent, DoorComponent);
124  ConstraintsComponents.Add(ConstraintComponent);
125  ConstraintComponent->TermComponentConstraint();
126  }
127  else
128  {
129  UE_LOG(LogCarla, Error, TEXT("Missing component for constraint: %s"), *(ConstraintComponent->GetName()));
130  }
131  }
132  }
134 
135  // get collision disable constraints (used to prevent doors from colliding with each other)
137  TArray<UPhysicsConstraintComponent*> Constraints;
138  GetComponents(Constraints);
139  for (UPhysicsConstraintComponent* Constraint : Constraints)
140  {
141  if (!ConstraintsComponents.Contains(Constraint))
142  {
143  UPrimitiveComponent* CollisionDisabledComponent1 = Cast<UPrimitiveComponent>(
144  GetDefaultSubobjectByName(Constraint->ComponentName1.ComponentName));
145  UPrimitiveComponent* CollisionDisabledComponent2 = Cast<UPrimitiveComponent>(
146  GetDefaultSubobjectByName(Constraint->ComponentName2.ComponentName));
147  if (CollisionDisabledComponent1)
148  {
149  CollisionDisableConstraints.Add(CollisionDisabledComponent1, Constraint);
150  }
151  if (CollisionDisabledComponent2)
152  {
153  CollisionDisableConstraints.Add(CollisionDisabledComponent2, Constraint);
154  }
155  }
156  }
157 
158  float FrictionScale = 3.5f;
159 
160  UWheeledVehicleMovementComponent* MovementComponent = GetVehicleMovementComponent();
161 
162  if (MovementComponent)
163  {
164  check(MovementComponent != nullptr);
165 
166  // Setup Tire Configs with default value. This is needed to avoid getting
167  // friction values of previously created TireConfigs for the same vehicle
168  // blueprint.
169  TArray<float> OriginalFrictions;
170  OriginalFrictions.Init(FrictionScale, MovementComponent->Wheels.Num());
171  SetWheelsFrictionScale(OriginalFrictions);
172 
173  // Check if it overlaps with a Friction trigger, if so, update the friction
174  // scale.
175  TArray<AActor *> OverlapActors;
176  GetOverlappingActors(OverlapActors, AFrictionTrigger::StaticClass());
177  for (const auto &Actor : OverlapActors)
178  {
179  AFrictionTrigger *FrictionTrigger = Cast<AFrictionTrigger>(Actor);
180  if (FrictionTrigger)
181  {
182  FrictionScale = FrictionTrigger->Friction;
183  }
184  }
185 
186  // Set the friction scale to Wheel CDO and update wheel setups
187  TArray<FWheelSetup> NewWheelSetups = MovementComponent->WheelSetups;
188  for (const auto &WheelSetup : NewWheelSetups)
189  {
190  UVehicleWheel *Wheel = WheelSetup.WheelClass.GetDefaultObject();
191  check(Wheel != nullptr);
192  }
193 
194  MovementComponent->WheelSetups = NewWheelSetups;
195 
197 
198  // Update physics in the Ackermann Controller
200  }
201 
203 }
204 
206 {
207  TRACE_CPUPROFILER_EVENT_SCOPE(ACarlaWheeledVehicle::IsInVehicleRange);
208 
209  return FoliageBoundingBox.IsInside(Location);
210 }
211 
213 {
214  const FTransform GlobalTransform = GetActorTransform();
215  const FVector Vec { DetectionSize, DetectionSize, DetectionSize };
216  FBox Box = FBox(-Vec, Vec);
217  const FTransform NonScaledTransform(GlobalTransform.GetRotation(), GlobalTransform.GetLocation(), {1.0f, 1.0f, 1.0f});
218  FoliageBoundingBox = Box.TransformBy(NonScaledTransform);
219 }
220 
221 const TArray<int32> ACarlaWheeledVehicle::GetFoliageInstancesCloseToVehicle(const UInstancedStaticMeshComponent* Component) const
222 {
223  TRACE_CPUPROFILER_EVENT_SCOPE(ACarlaWheeledVehicle::GetFoliageInstancesCloseToVehicle);
224  return Component->GetInstancesOverlappingBox(FoliageBoundingBox);
225 }
226 
228 {
229  TRACE_CPUPROFILER_EVENT_SCOPE(ACarlaWheeledVehicle::GetDetectionBox);
230  return FoliageBoundingBox;
231 }
232 
234 {
235  return DetectionSize;
236 }
237 
239 {
240  const FVector& Center = FoliageBoundingBox.GetCenter();
241  const FVector& Extent = FoliageBoundingBox.GetExtent();
242  const FQuat& Rotation = GetActorQuat();
243  DrawDebugBox(GetWorld(), Center, Extent, Rotation, FColor::Magenta, false, 0.0f, 0, 5.0f);
244 }
245 
247 {
248  ALargeMapManager* LargeMap = UCarlaStatics::GetLargeMapManager(GetWorld());
249  if (LargeMap)
250  {
251  FTransform GlobalTransform = LargeMap->LocalToGlobalTransform(GetActorTransform());
252  return VehicleBounds->CalcBounds(GlobalTransform);
253  }
254  return VehicleBounds->CalcBounds(GetActorTransform());
255 }
256 
258 {
260 
261  const FTransform& CompToWorldTransform = RootComponent->GetComponentTransform();
262  const FRotator Rotation = CompToWorldTransform.GetRotation().Rotator();
263  const FVector Translation = CompToWorldTransform.GetLocation();
264  const FVector Scale = CompToWorldTransform.GetScale3D();
265 
266  // Invert BB origin to local space
267  BoundingBox.Origin -= Translation;
268  BoundingBox.Origin = Rotation.UnrotateVector(BoundingBox.Origin);
269  BoundingBox.Origin /= Scale;
270 
271  // Prepare Box Collisions
272  FTransform Transform;
273  Transform.SetTranslation(BoundingBox.Origin);
274  VehicleBounds->SetRelativeTransform(Transform);
275  VehicleBounds->SetBoxExtent(BoundingBox.Extent);
276 }
277 
278 // =============================================================================
279 // -- Get functions ------------------------------------------------------------
280 // =============================================================================
281 
283 {
285 }
286 
288 {
289  return GetVehicleTransform().GetRotation().GetForwardVector();
290 }
291 
293 {
295 }
296 
298 {
299  return VehicleBounds->GetRelativeTransform();
300 }
301 
303 {
304  return VehicleBounds->GetScaledBoxExtent();
305 }
306 
308 {
309  const auto &Wheels = GetVehicleMovementComponent()->Wheels;
310  check(Wheels.Num() > 0);
311  const auto *FrontWheel = Wheels[0];
312  check(FrontWheel != nullptr);
313  return FrontWheel->SteerAngle;
314 }
315 
316 // =============================================================================
317 // -- Set functions ------------------------------------------------------------
318 // =============================================================================
319 
321 {
325  }
326 
328  InputControl.Control.bReverse = InputControl.Control.Gear < 0;
331 }
332 
334 {
336  Control.Throttle = Value;
337  ApplyVehicleControl(Control, EVehicleInputPriority::User);
338 }
339 
341 {
343  Control.Steer = Value;
344  ApplyVehicleControl(Control, EVehicleInputPriority::User);
345 }
346 
347 void ACarlaWheeledVehicle::SetBrakeInput(const float Value)
348 {
350  Control.Brake = Value;
351  ApplyVehicleControl(Control, EVehicleInputPriority::User);
352 }
353 
354 void ACarlaWheeledVehicle::SetReverse(const bool Value)
355 {
357  Control.bReverse = Value;
358  ApplyVehicleControl(Control, EVehicleInputPriority::User);
359 }
360 
362 {
364  Control.bHandBrake = Value;
365  ApplyVehicleControl(Control, EVehicleInputPriority::User);
366 }
367 
369 {
370 
371  UWheeledVehicleMovementComponent* Movement = GetVehicleMovement();
372  TArray<float> WheelsFrictionScale;
373  if (Movement)
374  {
375  check(Movement != nullptr);
376 
377  for (auto &Wheel : Movement->Wheels)
378  {
379  WheelsFrictionScale.Add(Wheel->TireConfig->GetFrictionScale());
380  }
381  }
382  return WheelsFrictionScale;
383 }
384 
385 void ACarlaWheeledVehicle::SetWheelsFrictionScale(TArray<float> &WheelsFrictionScale)
386 {
387 
388  UWheeledVehicleMovementComponent* Movement = GetVehicleMovement();
389  if (Movement)
390  {
391  check(Movement != nullptr);
392  check(Movement->Wheels.Num() == WheelsFrictionScale.Num());
393 
394  for (int32 i = 0; i < Movement->Wheels.Num(); ++i)
395  {
396  Movement->Wheels[i]->TireConfig->SetFrictionScale(WheelsFrictionScale[i]);
397  }
398  }
399 }
400 
402 {
404 
405  if (!bIsNWVehicle) {
406  UWheeledVehicleMovementComponent4W *Vehicle4W = Cast<UWheeledVehicleMovementComponent4W>(
407  GetVehicleMovement());
408  check(Vehicle4W != nullptr);
409 
410  // Engine Setup
411  PhysicsControl.TorqueCurve = Vehicle4W->EngineSetup.TorqueCurve.EditorCurveData;
412  PhysicsControl.MaxRPM = Vehicle4W->EngineSetup.MaxRPM;
413  PhysicsControl.MOI = Vehicle4W->EngineSetup.MOI;
414  PhysicsControl.DampingRateFullThrottle = Vehicle4W->EngineSetup.DampingRateFullThrottle;
415  PhysicsControl.DampingRateZeroThrottleClutchEngaged =
416  Vehicle4W->EngineSetup.DampingRateZeroThrottleClutchEngaged;
418  Vehicle4W->EngineSetup.DampingRateZeroThrottleClutchDisengaged;
419 
420  // Transmission Setup
421  PhysicsControl.bUseGearAutoBox = Vehicle4W->TransmissionSetup.bUseGearAutoBox;
422  PhysicsControl.GearSwitchTime = Vehicle4W->TransmissionSetup.GearSwitchTime;
423  PhysicsControl.ClutchStrength = Vehicle4W->TransmissionSetup.ClutchStrength;
424  PhysicsControl.FinalRatio = Vehicle4W->TransmissionSetup.FinalRatio;
425 
426  TArray<FGearPhysicsControl> ForwardGears;
427 
428  for (const auto &Gear : Vehicle4W->TransmissionSetup.ForwardGears)
429  {
430  FGearPhysicsControl GearPhysicsControl;
431 
432  GearPhysicsControl.Ratio = Gear.Ratio;
433  GearPhysicsControl.UpRatio = Gear.UpRatio;
434  GearPhysicsControl.DownRatio = Gear.DownRatio;
435 
436  ForwardGears.Add(GearPhysicsControl);
437  }
438 
439  PhysicsControl.ForwardGears = ForwardGears;
440 
441  // Vehicle Setup
442  PhysicsControl.Mass = Vehicle4W->Mass;
443  PhysicsControl.DragCoefficient = Vehicle4W->DragCoefficient;
444 
445  // Center of mass offset (Center of mass is always zero vector in local
446  // position)
447  UPrimitiveComponent *UpdatedPrimitive = Cast<UPrimitiveComponent>(Vehicle4W->UpdatedComponent);
448  check(UpdatedPrimitive != nullptr);
449 
450  PhysicsControl.CenterOfMass = UpdatedPrimitive->BodyInstance.COMNudge;
451 
452  // Transmission Setup
453  PhysicsControl.SteeringCurve = Vehicle4W->SteeringCurve.EditorCurveData;
454 
455  // Wheels Setup
456  TArray<FWheelPhysicsControl> Wheels;
457 
458  for (int32 i = 0; i < Vehicle4W->WheelSetups.Num(); ++i)
459  {
460  FWheelPhysicsControl PhysicsWheel;
461 
462  PxVehicleWheelData PWheelData = Vehicle4W->PVehicle->mWheelsSimData.getWheelData(i);
463  PhysicsWheel.DampingRate = Cm2ToM2(PWheelData.mDampingRate);
464  PhysicsWheel.MaxSteerAngle = FMath::RadiansToDegrees(PWheelData.mMaxSteer);
465  PhysicsWheel.Radius = PWheelData.mRadius;
466  PhysicsWheel.MaxBrakeTorque = Cm2ToM2(PWheelData.mMaxBrakeTorque);
467  PhysicsWheel.MaxHandBrakeTorque = Cm2ToM2(PWheelData.mMaxHandBrakeTorque);
468 
469  PxVehicleTireData PTireData = Vehicle4W->PVehicle->mWheelsSimData.getTireData(i);
470  PhysicsWheel.LatStiffMaxLoad = PTireData.mLatStiffX;
471  PhysicsWheel.LatStiffValue = PTireData.mLatStiffY;
472  PhysicsWheel.LongStiffValue = PTireData.mLongitudinalStiffnessPerUnitGravity;
473 
474  PhysicsWheel.TireFriction = Vehicle4W->Wheels[i]->TireConfig->GetFrictionScale();
475  PhysicsWheel.Position = Vehicle4W->Wheels[i]->Location;
476 
477  Wheels.Add(PhysicsWheel);
478  }
479 
480  PhysicsControl.Wheels = Wheels;
481 
482  } else {
483  UWheeledVehicleMovementComponentNW *VehicleNW = Cast<UWheeledVehicleMovementComponentNW>(
484  GetVehicleMovement());
485 
486  check(VehicleNW != nullptr);
487 
488  // Engine Setup
489  PhysicsControl.TorqueCurve = VehicleNW->EngineSetup.TorqueCurve.EditorCurveData;
490  PhysicsControl.MaxRPM = VehicleNW->EngineSetup.MaxRPM;
491  PhysicsControl.MOI = VehicleNW->EngineSetup.MOI;
492  PhysicsControl.DampingRateFullThrottle = VehicleNW->EngineSetup.DampingRateFullThrottle;
493  PhysicsControl.DampingRateZeroThrottleClutchEngaged =
494  VehicleNW->EngineSetup.DampingRateZeroThrottleClutchEngaged;
496  VehicleNW->EngineSetup.DampingRateZeroThrottleClutchDisengaged;
497 
498  // Transmission Setup
499  PhysicsControl.bUseGearAutoBox = VehicleNW->TransmissionSetup.bUseGearAutoBox;
500  PhysicsControl.GearSwitchTime = VehicleNW->TransmissionSetup.GearSwitchTime;
501  PhysicsControl.ClutchStrength = VehicleNW->TransmissionSetup.ClutchStrength;
502  PhysicsControl.FinalRatio = VehicleNW->TransmissionSetup.FinalRatio;
503 
504  TArray<FGearPhysicsControl> ForwardGears;
505 
506  for (const auto &Gear : VehicleNW->TransmissionSetup.ForwardGears)
507  {
508  FGearPhysicsControl GearPhysicsControl;
509 
510  GearPhysicsControl.Ratio = Gear.Ratio;
511  GearPhysicsControl.UpRatio = Gear.UpRatio;
512  GearPhysicsControl.DownRatio = Gear.DownRatio;
513 
514  ForwardGears.Add(GearPhysicsControl);
515  }
516 
517  PhysicsControl.ForwardGears = ForwardGears;
518 
519  // VehicleNW Setup
520  PhysicsControl.Mass = VehicleNW->Mass;
521  PhysicsControl.DragCoefficient = VehicleNW->DragCoefficient;
522 
523  // Center of mass offset (Center of mass is always zero vector in local
524  // position)
525  UPrimitiveComponent *UpdatedPrimitive = Cast<UPrimitiveComponent>(VehicleNW->UpdatedComponent);
526  check(UpdatedPrimitive != nullptr);
527 
528  PhysicsControl.CenterOfMass = UpdatedPrimitive->BodyInstance.COMNudge;
529 
530  // Transmission Setup
531  PhysicsControl.SteeringCurve = VehicleNW->SteeringCurve.EditorCurveData;
532 
533  // Wheels Setup
534  TArray<FWheelPhysicsControl> Wheels;
535 
536  for (int32 i = 0; i < VehicleNW->WheelSetups.Num(); ++i)
537  {
538  FWheelPhysicsControl PhysicsWheel;
539 
540  PxVehicleWheelData PWheelData = VehicleNW->PVehicle->mWheelsSimData.getWheelData(i);
541  PhysicsWheel.DampingRate = Cm2ToM2(PWheelData.mDampingRate);
542  PhysicsWheel.MaxSteerAngle = FMath::RadiansToDegrees(PWheelData.mMaxSteer);
543  PhysicsWheel.Radius = PWheelData.mRadius;
544  PhysicsWheel.MaxBrakeTorque = Cm2ToM2(PWheelData.mMaxBrakeTorque);
545  PhysicsWheel.MaxHandBrakeTorque = Cm2ToM2(PWheelData.mMaxHandBrakeTorque);
546 
547  PxVehicleTireData PTireData = VehicleNW->PVehicle->mWheelsSimData.getTireData(i);
548  PhysicsWheel.LatStiffMaxLoad = PTireData.mLatStiffX;
549  PhysicsWheel.LatStiffValue = PTireData.mLatStiffY;
550  PhysicsWheel.LongStiffValue = PTireData.mLongitudinalStiffnessPerUnitGravity;
551 
552  PhysicsWheel.TireFriction = VehicleNW->Wheels[i]->TireConfig->GetFrictionScale();
553  PhysicsWheel.Position = VehicleNW->Wheels[i]->Location;
554 
555  Wheels.Add(PhysicsWheel);
556  }
557 
558  PhysicsControl.Wheels = Wheels;
559 
560  }
561  return PhysicsControl;
562 }
563 
565 {
566  return InputControl.LightState;
567 }
568 
570 {
572 }
573 
575 {
577  if (!bIsNWVehicle) {
578  UWheeledVehicleMovementComponent4W *Vehicle4W = Cast<UWheeledVehicleMovementComponent4W>(
579  GetVehicleMovement());
580  check(Vehicle4W != nullptr);
581 
582 
583 
584  // Engine Setup
585  Vehicle4W->EngineSetup.TorqueCurve.EditorCurveData = PhysicsControl.TorqueCurve;
586  Vehicle4W->EngineSetup.MaxRPM = PhysicsControl.MaxRPM;
587 
588  Vehicle4W->EngineSetup.MOI = PhysicsControl.MOI;
589 
590  Vehicle4W->EngineSetup.DampingRateFullThrottle = PhysicsControl.DampingRateFullThrottle;
591  Vehicle4W->EngineSetup.DampingRateZeroThrottleClutchEngaged =
593  Vehicle4W->EngineSetup.DampingRateZeroThrottleClutchDisengaged =
595 
596  // Transmission Setup
597  Vehicle4W->TransmissionSetup.bUseGearAutoBox = PhysicsControl.bUseGearAutoBox;
598  Vehicle4W->TransmissionSetup.GearSwitchTime = PhysicsControl.GearSwitchTime;
599  Vehicle4W->TransmissionSetup.ClutchStrength = PhysicsControl.ClutchStrength;
600  Vehicle4W->TransmissionSetup.FinalRatio = PhysicsControl.FinalRatio;
601 
602  TArray<FVehicleGearData> ForwardGears;
603 
604  for (const auto &Gear : PhysicsControl.ForwardGears)
605  {
606  FVehicleGearData GearData;
607 
608  GearData.Ratio = Gear.Ratio;
609  GearData.UpRatio = Gear.UpRatio;
610  GearData.DownRatio = Gear.DownRatio;
611 
612  ForwardGears.Add(GearData);
613  }
614 
615  Vehicle4W->TransmissionSetup.ForwardGears = ForwardGears;
616 
617  // Vehicle Setup
618  Vehicle4W->Mass = PhysicsControl.Mass;
619  Vehicle4W->DragCoefficient = PhysicsControl.DragCoefficient;
620 
621  // Center of mass
622  UPrimitiveComponent *UpdatedPrimitive = Cast<UPrimitiveComponent>(Vehicle4W->UpdatedComponent);
623  check(UpdatedPrimitive != nullptr);
624 
625  UpdatedPrimitive->BodyInstance.COMNudge = PhysicsControl.CenterOfMass;
626 
627  // Transmission Setup
628  Vehicle4W->SteeringCurve.EditorCurveData = PhysicsControl.SteeringCurve;
629 
630  // Wheels Setup
631  const int PhysicsWheelsNum = PhysicsControl.Wheels.Num();
632  if (PhysicsWheelsNum != 4)
633  {
634  UE_LOG(LogCarla, Error, TEXT("Number of WheelPhysicsControl is not 4."));
635  return;
636  }
637 
638  // Change, if required, the collision mode for wheels
639  SetWheelCollision(Vehicle4W, PhysicsControl);
640 
641  TArray<FWheelSetup> NewWheelSetups = Vehicle4W->WheelSetups;
642 
643  for (int32 i = 0; i < PhysicsWheelsNum; ++i)
644  {
645  UVehicleWheel *Wheel = NewWheelSetups[i].WheelClass.GetDefaultObject();
646  check(Wheel != nullptr);
647 
648  // Assigning new tire config
649  Wheel->TireConfig = DuplicateObject<UTireConfig>(Wheel->TireConfig, nullptr);
650 
651  // Setting a new value to friction
652  Wheel->TireConfig->SetFrictionScale(PhysicsControl.Wheels[i].TireFriction);
653  }
654 
655  Vehicle4W->WheelSetups = NewWheelSetups;
656 
657  // Recreate Physics State for vehicle setup
658  GetWorld()->GetPhysicsScene()->GetPxScene()->lockWrite();
659  Vehicle4W->RecreatePhysicsState();
660  GetWorld()->GetPhysicsScene()->GetPxScene()->unlockWrite();
661 
662  for (int32 i = 0; i < PhysicsWheelsNum; ++i)
663  {
664  PxVehicleWheelData PWheelData = Vehicle4W->PVehicle->mWheelsSimData.getWheelData(i);
665 
666  PWheelData.mRadius = PhysicsControl.Wheels[i].Radius;
667  PWheelData.mMaxSteer = FMath::DegreesToRadians(PhysicsControl.Wheels[i].MaxSteerAngle);
668  PWheelData.mDampingRate = M2ToCm2(PhysicsControl.Wheels[i].DampingRate);
669  PWheelData.mMaxBrakeTorque = M2ToCm2(PhysicsControl.Wheels[i].MaxBrakeTorque);
670  PWheelData.mMaxHandBrakeTorque = M2ToCm2(PhysicsControl.Wheels[i].MaxHandBrakeTorque);
671  Vehicle4W->PVehicle->mWheelsSimData.setWheelData(i, PWheelData);
672 
673  PxVehicleTireData PTireData = Vehicle4W->PVehicle->mWheelsSimData.getTireData(i);
674  PTireData.mLatStiffX = PhysicsControl.Wheels[i].LatStiffMaxLoad;
675  PTireData.mLatStiffY = PhysicsControl.Wheels[i].LatStiffValue;
676  PTireData.mLongitudinalStiffnessPerUnitGravity = PhysicsControl.Wheels[i].LongStiffValue;
677  Vehicle4W->PVehicle->mWheelsSimData.setTireData(i, PTireData);
678  }
679 
681  } else {
682  UWheeledVehicleMovementComponentNW *VehicleNW = Cast<UWheeledVehicleMovementComponentNW>(
683  GetVehicleMovement());
684 
685  check(VehicleNW != nullptr);
686 
687  // Engine Setup
688  VehicleNW->EngineSetup.TorqueCurve.EditorCurveData = PhysicsControl.TorqueCurve;
689  VehicleNW->EngineSetup.MaxRPM = PhysicsControl.MaxRPM;
690 
691  VehicleNW->EngineSetup.MOI = PhysicsControl.MOI;
692 
693  VehicleNW->EngineSetup.DampingRateFullThrottle = PhysicsControl.DampingRateFullThrottle;
694  VehicleNW->EngineSetup.DampingRateZeroThrottleClutchEngaged =
696  VehicleNW->EngineSetup.DampingRateZeroThrottleClutchDisengaged =
698 
699  // Transmission Setup
700  VehicleNW->TransmissionSetup.bUseGearAutoBox = PhysicsControl.bUseGearAutoBox;
701  VehicleNW->TransmissionSetup.GearSwitchTime = PhysicsControl.GearSwitchTime;
702  VehicleNW->TransmissionSetup.ClutchStrength = PhysicsControl.ClutchStrength;
703  VehicleNW->TransmissionSetup.FinalRatio = PhysicsControl.FinalRatio;
704 
705  TArray<FVehicleNWGearData> ForwardGears;
706 
707  for (const auto &Gear : PhysicsControl.ForwardGears)
708  {
709  FVehicleNWGearData GearData;
710 
711  GearData.Ratio = Gear.Ratio;
712  GearData.UpRatio = Gear.UpRatio;
713  GearData.DownRatio = Gear.DownRatio;
714 
715  ForwardGears.Add(GearData);
716  }
717 
718  VehicleNW->TransmissionSetup.ForwardGears = ForwardGears;
719 
720  // VehicleNW Setup
721  VehicleNW->Mass = PhysicsControl.Mass;
722  VehicleNW->DragCoefficient = PhysicsControl.DragCoefficient;
723 
724  // Center of mass
725  UPrimitiveComponent *UpdatedPrimitive = Cast<UPrimitiveComponent>(VehicleNW->UpdatedComponent);
726  check(UpdatedPrimitive != nullptr);
727 
728  UpdatedPrimitive->BodyInstance.COMNudge = PhysicsControl.CenterOfMass;
729 
730  // Transmission Setup
731  VehicleNW->SteeringCurve.EditorCurveData = PhysicsControl.SteeringCurve;
732 
733  // Wheels Setup
734  const int PhysicsWheelsNum = PhysicsControl.Wheels.Num();
735 
736  // Change, if required, the collision mode for wheels
737  SetWheelCollisionNW(VehicleNW, PhysicsControl);
738 
739  TArray<FWheelSetup> NewWheelSetups = VehicleNW->WheelSetups;
740 
741  for (int32 i = 0; i < PhysicsWheelsNum; ++i)
742  {
743  UVehicleWheel *Wheel = NewWheelSetups[i].WheelClass.GetDefaultObject();
744  check(Wheel != nullptr);
745 
746  // Assigning new tire config
747  Wheel->TireConfig = DuplicateObject<UTireConfig>(Wheel->TireConfig, nullptr);
748 
749  // Setting a new value to friction
750  Wheel->TireConfig->SetFrictionScale(PhysicsControl.Wheels[i].TireFriction);
751  }
752 
753  VehicleNW->WheelSetups = NewWheelSetups;
754 
755  // Recreate Physics State for vehicle setup
756  GetWorld()->GetPhysicsScene()->GetPxScene()->lockWrite();
757  VehicleNW->RecreatePhysicsState();
758  GetWorld()->GetPhysicsScene()->GetPxScene()->unlockWrite();
759 
760  for (int32 i = 0; i < PhysicsWheelsNum; ++i)
761  {
762  PxVehicleWheelData PWheelData = VehicleNW->PVehicle->mWheelsSimData.getWheelData(i);
763 
764  PWheelData.mRadius = PhysicsControl.Wheels[i].Radius;
765  PWheelData.mMaxSteer = FMath::DegreesToRadians(PhysicsControl.Wheels[i].MaxSteerAngle);
766  PWheelData.mDampingRate = M2ToCm2(PhysicsControl.Wheels[i].DampingRate);
767  PWheelData.mMaxBrakeTorque = M2ToCm2(PhysicsControl.Wheels[i].MaxBrakeTorque);
768  PWheelData.mMaxHandBrakeTorque = M2ToCm2(PhysicsControl.Wheels[i].MaxHandBrakeTorque);
769  VehicleNW->PVehicle->mWheelsSimData.setWheelData(i, PWheelData);
770 
771  PxVehicleTireData PTireData = VehicleNW->PVehicle->mWheelsSimData.getTireData(i);
772  PTireData.mLatStiffX = PhysicsControl.Wheels[i].LatStiffMaxLoad;
773  PTireData.mLatStiffY = PhysicsControl.Wheels[i].LatStiffValue;
774  PTireData.mLongitudinalStiffnessPerUnitGravity = PhysicsControl.Wheels[i].LongStiffValue;
775  VehicleNW->PVehicle->mWheelsSimData.setTireData(i, PTireData);
776  }
777 
779 
780  }
781 
782  auto * Recorder = UCarlaStatics::GetRecorder(GetWorld());
783  if (Recorder && Recorder->IsEnabled())
784  {
785  Recorder->AddPhysicsControl(*this);
786  }
787 
788  // Update physics in the Ackermann Controller
790 
791 }
792 
794 {
795  VelocityControl->Activate(Velocity);
796 }
797 
799 {
800  VelocityControl->Deactivate();
801 }
802 
804 {
805  if (GetWorld()->GetFirstPlayerController())
806  {
807  ACarlaHUD* hud = Cast<ACarlaHUD>(GetWorld()->GetFirstPlayerController()->GetHUD());
808  if (hud) {
809 
810  // Set/Unset the car movement component in HUD to show the temetry
811  if (Enabled) {
812  hud->AddDebugVehicleForTelemetry(GetVehicleMovementComponent());
813  }
814  else{
815  if (hud->DebugVehicle == GetVehicleMovementComponent()) {
816  hud->AddDebugVehicleForTelemetry(nullptr);
817  GetVehicleMovementComponent()->StopTelemetry();
818  }
819  }
820 
821  }
822  else {
823  UE_LOG(LogCarla, Warning, TEXT("ACarlaWheeledVehicle::ShowDebugTelemetry:: Cannot find HUD for debug info"));
824  }
825  }
826 }
827 
829 {
830  if (LightState.Position != InputControl.LightState.Position ||
831  LightState.LowBeam != InputControl.LightState.LowBeam ||
832  LightState.HighBeam != InputControl.LightState.HighBeam ||
833  LightState.Brake != InputControl.LightState.Brake ||
834  LightState.RightBlinker != InputControl.LightState.RightBlinker ||
835  LightState.LeftBlinker != InputControl.LightState.LeftBlinker ||
836  LightState.Reverse != InputControl.LightState.Reverse ||
837  LightState.Fog != InputControl.LightState.Fog ||
838  LightState.Interior != InputControl.LightState.Interior ||
839  LightState.Special1 != InputControl.LightState.Special1 ||
840  LightState.Special2 != InputControl.LightState.Special2)
841  {
842  InputControl.LightState = LightState;
843  RefreshLightState(LightState);
844  }
845 }
846 
848 {
849  FailureState = InFailureState;
850 }
851 
853 {
855  {
856  BaseMovementComponent->DestroyComponent();
857  }
858  BaseMovementComponent = MovementComponent;
859 }
860 
862 
863  if (bPhysicsEnabled == false)
864  {
865  check((uint8)WheelLocation >= 0)
866  UVehicleAnimInstance *VehicleAnim = Cast<UVehicleAnimInstance>(GetMesh()->GetAnimInstance());
867  check(VehicleAnim != nullptr)
868  VehicleAnim->SetWheelRotYaw((uint8)WheelLocation, AngleInDeg);
869  }
870  else
871  {
872  UE_LOG(LogTemp, Warning, TEXT("Cannot set wheel steer direction. Physics are enabled."))
873  }
874 }
875 
877 
878  check((uint8)WheelLocation >= 0)
879  UVehicleAnimInstance *VehicleAnim = Cast<UVehicleAnimInstance>(GetMesh()->GetAnimInstance());
880  check(VehicleAnim != nullptr)
881  check(VehicleAnim->GetWheeledVehicleMovementComponent() != nullptr)
882 
883  if (bPhysicsEnabled == true)
884  {
885  return VehicleAnim->GetWheeledVehicleMovementComponent()->Wheels[(uint8)WheelLocation]->GetSteerAngle();
886  }
887  else
888  {
889  return VehicleAnim->GetWheelRotAngle((uint8)WheelLocation);
890  }
891 }
892 
894  if(!GetCarlaMovementComponent<UDefaultMovementComponent>())
895  {
896  return;
897  }
898 
899  UWheeledVehicleMovementComponent* Movement = GetVehicleMovement();
900  if (Movement)
901  {
902  check(Movement != nullptr);
903 
904  if(bPhysicsEnabled == enabled)
905  return;
906 
907  SetActorEnableCollision(true);
908  auto RootComponent = Cast<UPrimitiveComponent>(GetRootComponent());
909  RootComponent->SetSimulatePhysics(enabled);
910  RootComponent->SetCollisionEnabled(ECollisionEnabled::QueryAndPhysics);
911 
912  UVehicleAnimInstance *VehicleAnim = Cast<UVehicleAnimInstance>(GetMesh()->GetAnimInstance());
913  check(VehicleAnim != nullptr)
914 
915  GetWorld()->GetPhysicsScene()->GetPxScene()->lockWrite();
916  if (enabled)
917  {
918  Movement->RecreatePhysicsState();
919  VehicleAnim->ResetWheelCustomRotations();
920  }
921  else
922  {
923  Movement->DestroyPhysicsState();
924  }
925 
926  GetWorld()->GetPhysicsScene()->GetPxScene()->unlockWrite();
927 
928  bPhysicsEnabled = enabled;
929 
931  }
932 
933 }
934 
936 {
937  for (int i = 0; i < ConstraintsComponents.Num(); i++)
938  {
940  }
941  for (int i = 0; i < ConstraintsComponents.Num(); i++)
942  {
944  }
945 }
946 
948 {
950 }
951 
952 void ACarlaWheeledVehicle::EndPlay(const EEndPlayReason::Type EndPlayReason)
953 {
954  ShowDebugTelemetry(false);
955  Super::EndPlay(EndPlayReason);
957 }
958 
960  if (int(DoorIdx) >= ConstraintsComponents.Num() && DoorIdx != EVehicleDoor::All) {
961  UE_LOG(LogTemp, Warning, TEXT("This door is not configured for this car."));
962  return;
963  }
964 
965  if (DoorIdx == EVehicleDoor::All) {
966  for (int i = 0; i < ConstraintsComponents.Num(); i++)
967  {
969  }
970  return;
971  }
972 
973  OpenDoorPhys(DoorIdx);
974 }
975 
977  if (int(DoorIdx) >= ConstraintsComponents.Num() && DoorIdx != EVehicleDoor::All) {
978  UE_LOG(LogTemp, Warning, TEXT("This door is not configured for this car."));
979  return;
980  }
981 
982  if (DoorIdx == EVehicleDoor::All) {
983  for (int i = 0; i < ConstraintsComponents.Num(); i++)
984  {
986  }
987  return;
988  }
989 
990  CloseDoorPhys(DoorIdx);
991 }
992 
994 {
995  UPhysicsConstraintComponent* Constraint = ConstraintsComponents[static_cast<int>(DoorIdx)];
996  UPrimitiveComponent* DoorComponent = ConstraintDoor[Constraint];
997  DoorComponent->DetachFromComponent(
998  FDetachmentTransformRules(EDetachmentRule::KeepWorld, false));
999  FTransform DoorInitialTransform =
1000  DoorComponentsTransform[DoorComponent] * GetActorTransform();
1001  DoorComponent->SetWorldTransform(DoorInitialTransform);
1002  DoorComponent->SetSimulatePhysics(true);
1003  DoorComponent->SetCollisionProfileName(TEXT("BlockAll"));
1004  float AngleLimit = Constraint->ConstraintInstance.GetAngularSwing1Limit();
1005  FRotator AngularRotationOffset = Constraint->ConstraintInstance.AngularRotationOffset;
1006 
1007  if (Constraint->ConstraintInstance.AngularRotationOffset.Yaw < 0.0f)
1008  {
1009  AngleLimit = -AngleLimit;
1010  }
1011  Constraint->SetAngularOrientationTarget(FRotator(0, AngleLimit, 0));
1012  Constraint->SetAngularDriveParams(DoorOpenStrength, 1.0, 0.0);
1013 
1014  Constraint->InitComponentConstraint();
1015 
1016  UPhysicsConstraintComponent** CollisionDisable =
1017  CollisionDisableConstraints.Find(DoorComponent);
1018  if (CollisionDisable)
1019  {
1020  (*CollisionDisable)->InitComponentConstraint();
1021  }
1022 }
1023 
1025 {
1026  UPhysicsConstraintComponent* Constraint = ConstraintsComponents[static_cast<int>(DoorIdx)];
1027  UPrimitiveComponent* DoorComponent = ConstraintDoor[Constraint];
1028  FTransform DoorInitialTransform =
1029  DoorComponentsTransform[DoorComponent] * GetActorTransform();
1030  DoorComponent->SetSimulatePhysics(false);
1031  DoorComponent->SetCollisionProfileName(TEXT("NoCollision"));
1032  DoorComponent->SetWorldTransform(DoorInitialTransform);
1033  DoorComponent->AttachToComponent(
1034  GetMesh(), FAttachmentTransformRules(EAttachmentRule::KeepWorld, true));
1035 }
1036 
1038 {
1039  auto roll = GetVehicleTransform().Rotator().Roll;
1040 
1041  // The angular velocity reduction is applied in 4 stages, to improve its smoothness.
1042  // Case 4 starts the timer to set the rollover flag, so users are notified.
1043  switch (RolloverBehaviorTracker) {
1044  case 0: CheckRollover(roll, std::make_pair(130.0, 230.0)); break;
1045  case 1: CheckRollover(roll, std::make_pair(140.0, 220.0)); break;
1046  case 2: CheckRollover(roll, std::make_pair(150.0, 210.0)); break;
1047  case 3: CheckRollover(roll, std::make_pair(160.0, 200.0)); break;
1048  case 4:
1049  GetWorld()->GetTimerManager().SetTimer(TimerHandler, this, &ACarlaWheeledVehicle::SetRolloverFlag, RolloverFlagTime);
1051  break;
1052  case 5: break;
1053  default:
1055  }
1056 
1057  // In case the vehicle recovers, reset the rollover tracker
1058  if (RolloverBehaviorTracker > 0 && -30 < roll && roll < 30){
1061  }
1062 }
1063 
1064 void ACarlaWheeledVehicle::CheckRollover(const float roll, const std::pair<float, float> threshold_roll){
1065  if (threshold_roll.first < roll && roll < threshold_roll.second){
1066  auto RootComponent = Cast<UPrimitiveComponent>(GetRootComponent());
1067  auto angular_velocity = RootComponent->GetPhysicsAngularVelocityInDegrees();
1068  RootComponent->SetPhysicsAngularVelocity((1 - RolloverBehaviorForce) * angular_velocity);
1070  }
1071 }
1072 
1074  // Make sure the vehicle hasn't recovered since the timer started
1075  if (RolloverBehaviorTracker >= 4) {
1077  }
1078 }
1079 
1081  return FailureState;
1082 }
1083 
1085 {
1086  const UObject* World = GetWorld();
1087  TArray<AActor*> ActorsInLevel;
1088  UGameplayStatics::GetAllActorsOfClass(World, AActor::StaticClass(), ActorsInLevel);
1089  for (AActor* Actor : ActorsInLevel)
1090  {
1091  AVegetationManager* Manager = Cast<AVegetationManager>(Actor);
1092  if (!IsValid(Manager))
1093  continue;
1094  Manager->AddVehicle(this);
1095  return;
1096  }
1097 }
1098 
1100 {
1101  const UObject* World = GetWorld();
1102  TArray<AActor*> ActorsInLevel;
1103  UGameplayStatics::GetAllActorsOfClass(World, AActor::StaticClass(), ActorsInLevel);
1104  for (AActor* Actor : ActorsInLevel)
1105  {
1106  AVegetationManager* Manager = Cast<AVegetationManager>(Actor);
1107  if (!IsValid(Manager))
1108  continue;
1109  Manager->RemoveVehicle(this);
1110  return;
1111  }
1112 }
1113 
1115  UPhysicsConstraintComponent* Component)
1116 {
1117  return Component->ConstraintInstance.AngularRotationOffset;
1118 }
1119 
1121  UPhysicsConstraintComponent* Component, const FRotator &NewAngle)
1122 {
1123  Component->ConstraintInstance.AngularRotationOffset = NewAngle;
1124 }
void ApplyVehicleControl(const FVehicleControl &Control, EVehicleInputPriority Priority)
virtual void ProcessControl(FVehicleControl &Control)
void SetThrottleInput(float Value)
UBaseCarlaMovementComponent * BaseMovementComponent
FAckermannController AckermannController
FTransform GetVehicleBoundingBoxTransform() const
Transform of the vehicle&#39;s bounding box relative to the vehicle.
carla::rpc::VehicleFailureState GetFailureState() const
float GetVehicleForwardSpeed() const
Forward speed in cm/s. Might be negative if goes backwards.
float Ratio
Determines the amount of torque multiplication.
FVehiclePhysicsControl GetVehiclePhysicsControl() const
TArray< FName > ConstraintComponentNames
virtual FVector GetVelocity() const override
TArray< UPhysicsConstraintComponent * > ConstraintsComponents
FVehicleLightState LightState
const TArray< int32 > GetFoliageInstancesCloseToVehicle(const UInstancedStaticMeshComponent *Component) const
virtual void EndPlay(const EEndPlayReason::Type EndPlayReason)
void SetSimulatePhysics(bool enabled)
FBoxSphereBounds GetBoxSphereBounds() const
void OpenDoor(const EVehicleDoor DoorIdx)
FVector GetVehicleBoundingBoxExtent() const
Extent of the vehicle&#39;s bounding box.
float UpRatio
Value of engineRevs/maxEngineRevs that is high enough to gear up.
void ShowDebugTelemetry(bool Enabled)
float GetMaximumSteerAngle() const
Get the maximum angle at which the front wheel can steer.
TMap< UPhysicsConstraintComponent *, UPrimitiveComponent * > ConstraintDoor
void AddDebugVehicleForTelemetry(UWheeledVehicleMovementComponent *Veh)
Definition: CarlaHUD.h:55
static FBoundingBox GetVehicleBoundingBox(const ACarlaWheeledVehicle *Vehicle, uint8 InTagQueried=0xFF)
static bool IsValid(const ACarlaWheeledVehicle *Vehicle)
void CloseDoor(const EVehicleDoor DoorIdx)
ACarlaWheeledVehicle(const FObjectInitializer &ObjectInitializer)
void SetWheelSteerDirection(EVehicleWheelLocation WheelLocation, float AngleInDeg)
Set the rotation of the car wheels indicated by the user 0 = FL_VehicleWheel, 1 = FR_VehicleWheel...
bg::model::box< Point3D > Box
Definition: InMemoryMap.h:52
static FRotator GetPhysicsConstraintAngle(UPhysicsConstraintComponent *Component)
void UpdateVehiclePhysics(const ACarlaWheeledVehicle *Vehicle)
TArray< float > GetWheelsFrictionScale()
FVector GetVehicleOrientation() const
Orientation vector of the vehicle, pointing forward.
geom::Location Location
Definition: rpc/Location.h:14
void ApplyVehiclePhysicsControl(const FVehiclePhysicsControl &PhysicsControl)
carla::rpc::VehicleFailureState FailureState
void ActivateVelocityControl(const FVector &Velocity)
void SetWheelCollisionNW(UWheeledVehicleMovementComponentNW *VehicleNW, const FVehiclePhysicsControl &PhysicsControl)
carla::SharedPtr< cc::Actor > Actor
void UpdateVehicleState(const ACarlaWheeledVehicle *Vehicle)
void SetFailureState(const carla::rpc::VehicleFailureState &FailureState)
struct ACarlaWheeledVehicle::@1 InputControl
void SetSteeringInput(float Value)
virtual void BeginPlay() override
void SetHandbrakeInput(bool Value)
float GetWheelSteerAngle(EVehicleWheelLocation WheelLocation)
void RunLoop(FVehicleControl &Control)
FVehicleControl LastAppliedControl
void RefreshLightState(const FVehicleLightState &VehicleLightState)
void ApplyRolloverBehavior()
Rollovers tend to have too much angular velocity, resulting in the vehicle doing a full 360ยบ flip...
TMap< UPrimitiveComponent *, UPhysicsConstraintComponent * > CollisionDisableConstraints
void SetWheelCollision(UWheeledVehicleMovementComponent4W *Vehicle4W, const FVehiclePhysicsControl &PhysicsControl)
UBoxComponent * VehicleBounds
void AddVehicle(ACarlaWheeledVehicle *Vehicle)
EVehicleWheelLocation
geom::Rotation Rotation
Definition: rpc/Transform.h:14
FTransform LocalToGlobalTransform(const FTransform &InTransform) const
float DownRatio
Value of engineRevs/maxEngineRevs that is low enough to gear down.
void SetVehicleLightState(const FVehicleLightState &LightState)
TMap< UPrimitiveComponent *, FTransform > DoorComponentsTransform
bool IsInVehicleRange(const FVector &Location) const
int32 GetVehicleCurrentGear() const
Active gear of the vehicle.
static ALargeMapManager * GetLargeMapManager(const UObject *WorldContextObject)
Definition: CarlaStatics.h:100
UVehicleVelocityControl * VelocityControl
void SetBrakeInput(float Value)
void CloseDoorPhys(const EVehicleDoor DoorIdx)
virtual float GetVehicleForwardSpeed() const
void CheckRollover(const float roll, const std::pair< float, float > threshold_roll)
static void SetPhysicsConstraintAngle(UPhysicsConstraintComponent *Component, const FRotator &NewAngle)
FVehiclePhysicsControl LastPhysicsControl
FVector Origin
Origin of the bounding box relative to its owner.
void OpenDoorPhys(const EVehicleDoor DoorIdx)
EVehicleDoor
Type of door to open/close.
static void CreateDefaultMovementComponent(ACarlaWheeledVehicle *Vehicle)
void SetWheelsFrictionScale(TArray< float > &WheelsFrictionScale)
Class to draw on HUD.
Definition: CarlaHUD.h:40
FVector Extent
Radii extent of the bounding box.
UWheeledVehicleMovementComponent * DebugVehicle
Definition: CarlaHUD.h:54
geom::Transform Transform
Definition: rpc/Transform.h:16
void SetCarlaMovementComponent(UBaseCarlaMovementComponent *MoementComponent)
void RemoveVehicle(ACarlaWheeledVehicle *Vehicle)
FVehicleLightState GetVehicleLightState() const
FTransform GetVehicleTransform() const
Transform of the vehicle.
static ACarlaRecorder * GetRecorder(const UObject *WorldContextObject)
Definition: CarlaStatics.h:80