9 #include "WheeledVehicle.h" 20 #include "WheeledVehicleMovementComponent4W.h" 22 #include "VehicleAnimInstance.h" 23 #include "PhysicsEngine/PhysicsConstraintComponent.h" 27 #include "FoliageInstancedStaticMeshComponent.h" 28 #include "CoreMinimal.h" 32 #include "CarSimMovementComponent.h" 39 #include "CarlaWheeledVehicle.generated.h" 92 UFUNCTION(Category =
"CARLA Wheeled Vehicle", BlueprintCallable)
95 return LastAppliedControl;
99 UFUNCTION(Category =
"CARLA Wheeled Vehicle", BlueprintCallable)
102 return LastAppliedAckermannControl;
107 UFUNCTION(Category =
"CARLA Wheeled Vehicle", BlueprintCallable)
108 FTransform GetVehicleTransform()
const 110 return GetActorTransform();
114 UFUNCTION(Category =
"CARLA Wheeled Vehicle", BlueprintCallable)
115 float GetVehicleForwardSpeed()
const;
118 UFUNCTION(Category =
"CARLA Wheeled Vehicle", BlueprintCallable)
119 FVector GetVehicleOrientation()
const;
122 UFUNCTION(Category =
"CARLA Wheeled Vehicle", BlueprintCallable)
123 int32 GetVehicleCurrentGear()
const;
126 UFUNCTION(Category =
"CARLA Wheeled Vehicle", BlueprintCallable)
127 FTransform GetVehicleBoundingBoxTransform()
const;
130 UFUNCTION(Category =
"CARLA Wheeled Vehicle", BlueprintCallable)
131 FVector GetVehicleBoundingBoxExtent()
const;
134 UFUNCTION(Category =
"CARLA Wheeled Vehicle", BlueprintCallable)
135 UBoxComponent *GetVehicleBoundingBox()
const 137 return VehicleBounds;
141 UFUNCTION(Category =
"CARLA Wheeled Vehicle", BlueprintCallable)
142 float GetMaximumSteerAngle()
const;
157 UFUNCTION(Category =
"CARLA Wheeled Vehicle", BlueprintCallable)
163 UFUNCTION(Category =
"CARLA Wheeled Vehicle", BlueprintCallable)
166 UFUNCTION(Category =
"CARLA Wheeled Vehicle", BlueprintCallable)
168 return AckermannController.GetSettings();
171 UFUNCTION(Category =
"CARLA Wheeled Vehicle", BlueprintCallable)
172 void RestoreVehiclePhysicsControl();
174 UFUNCTION(Category =
"CARLA Wheeled Vehicle", BlueprintCallable)
180 return AckermannController.ApplySettings(AckermannControllerSettings);
183 UFUNCTION(Category =
"CARLA Wheeled Vehicle", BlueprintCallable)
184 void SetSimulatePhysics(
bool enabled);
186 void SetWheelCollision(UWheeledVehicleMovementComponent4W *Vehicle4W,
const FVehiclePhysicsControl &PhysicsControl);
188 void SetWheelCollisionNW(UWheeledVehicleMovementComponentNW *VehicleNW,
const FVehiclePhysicsControl &PhysicsControl);
194 UFUNCTION(BlueprintNativeEvent)
195 bool IsTwoWheeledVehicle();
207 UFUNCTION(Category =
"CARLA Wheeled Vehicle", BlueprintCallable)
210 if (bAckermannControlActive) {
211 AckermannController.Reset();
213 bAckermannControlActive =
false;
215 if (InputControl.Priority <= Priority)
217 InputControl.Control = Control;
218 InputControl.Priority = Priority;
222 UFUNCTION(Category =
"CARLA Wheeled Vehicle", BlueprintCallable)
225 bAckermannControlActive =
true;
226 LastAppliedAckermannControl = AckermannControl;
227 AckermannController.SetTargetPoint(AckermannControl);
232 return bAckermannControlActive;
235 UFUNCTION(Category =
"CARLA Wheeled Vehicle", BlueprintCallable)
236 void ActivateVelocityControl(
const FVector &Velocity);
238 UFUNCTION(Category =
"CARLA Wheeled Vehicle", BlueprintCallable)
239 void DeactivateVelocityControl();
241 UFUNCTION(Category =
"CARLA Wheeled Vehicle", BlueprintCallable)
242 void ShowDebugTelemetry(
bool Enabled);
245 void FlushVehicleControl();
254 UFUNCTION(Category =
"CARLA Wheeled Vehicle", BlueprintCallable)
255 void SetThrottleInput(
float Value);
257 UFUNCTION(Category =
"CARLA Wheeled Vehicle", BlueprintCallable)
258 void SetSteeringInput(
float Value);
260 UFUNCTION(Category =
"CARLA Wheeled Vehicle", BlueprintCallable)
261 void SetBrakeInput(
float Value);
263 UFUNCTION(Category =
"CARLA Wheeled Vehicle", BlueprintCallable)
264 void SetReverse(
bool Value);
266 UFUNCTION(Category =
"CARLA Wheeled Vehicle", BlueprintCallable)
269 SetReverse(!LastAppliedControl.bReverse);
272 UFUNCTION(Category =
"CARLA Wheeled Vehicle", BlueprintCallable)
273 void SetHandbrakeInput(
bool Value);
275 UFUNCTION(Category =
"CARLA Wheeled Vehicle", BlueprintCallable)
278 SetHandbrakeInput(
true);
281 UFUNCTION(Category =
"CARLA Wheeled Vehicle", BlueprintCallable)
282 void ReleaseHandbrake()
284 SetHandbrakeInput(
false);
287 TArray<float> GetWheelsFrictionScale();
289 void SetWheelsFrictionScale(TArray<float> &WheelsFrictionScale);
293 template<
typename T = UBaseCarlaMovementComponent>
296 return Cast<T>(BaseMovementComponent);
307 virtual void BeginPlay()
override;
308 virtual void EndPlay(
const EEndPlayReason::Type EndPlayReason);
310 UFUNCTION(BlueprintImplementableEvent)
313 UFUNCTION(BlueprintCallable, CallInEditor)
314 void AdjustVehicleBounds();
316 UPROPERTY(Category=
"Door Animation", EditAnywhere, BlueprintReadWrite)
317 TArray<FName> ConstraintComponentNames;
319 UPROPERTY(Category="Door Animation", EditAnywhere, BlueprintReadWrite)
320 float DoorOpenStrength = 100.0f;
322 UFUNCTION(BlueprintCallable, CallInEditor)
323 void ResetConstraints();
328 UPROPERTY(Category = "AI Controller", VisibleAnywhere)
331 UPROPERTY(Category = "CARLA Wheeled
Vehicle", EditAnywhere)
332 UVehicleVelocityControl* VelocityControl;
346 bool bAckermannControlActive =
false;
349 float RolloverBehaviorForce = 0.35;
350 int RolloverBehaviorTracker = 0;
351 float RolloverFlagTime = 5.0f;
356 UPROPERTY(Category =
"CARLA Wheeled Vehicle", EditDefaultsOnly)
357 float DetectionSize { 750.0f };
359 UPROPERTY(Category =
"CARLA Wheeled Vehicle", VisibleAnywhere, BlueprintReadOnly)
360 FBox FoliageBoundingBox;
362 UPROPERTY(Category = "CARLA Wheeled
Vehicle", EditAnywhere)
363 UBoxComponent *VehicleBounds;
366 FBox GetDetectionBox() const;
369 float GetDetectionSize() const;
372 void UpdateDetectionBox();
375 const TArray<int32> GetFoliageInstancesCloseToVehicle(const UInstancedStaticMeshComponent* Component) const;
377 UFUNCTION(BlueprintCallable)
378 void DrawFoliageBoundingBox() const;
381 FBoxSphereBounds GetBoxSphereBounds() const;
384 bool IsInVehicleRange(const FVector&
Location) const;
389 UFUNCTION(Category = "CARLA Wheeled
Vehicle", BlueprintCallable)
392 UFUNCTION(Category = "CARLA Wheeled
Vehicle", BlueprintCallable)
395 UFUNCTION(Category = "CARLA Wheeled
Vehicle", BlueprintCallable)
398 UFUNCTION(Category = "CARLA Wheeled
Vehicle", BlueprintCallable)
401 UFUNCTION(Category = "CARLA Wheeled
Vehicle", BlueprintCallable)
404 UFUNCTION(Category = "CARLA Wheeled
Vehicle", BlueprintCallable)
407 virtual FVector GetVelocity() const override;
410 UPROPERTY(Category="CARLA Wheeled
Vehicle", EditAnywhere)
411 float CarSimOriginOffset = 150.f;
414 UPROPERTY(Category="CARLA Wheeled
Vehicle", VisibleAnywhere)
415 bool bIsNWVehicle = false;
417 void SetRolloverFlag();
423 UPROPERTY(Category="CARLA Wheeled
Vehicle", VisibleAnywhere)
424 bool bPhysicsEnabled = true;
427 UPROPERTY(Category="CARLA Wheeled
Vehicle", VisibleAnywhere, BlueprintReadOnly, meta = (AllowPrivateAccess = "true"))
430 UPROPERTY(Category="CARLA Wheeled
Vehicle", VisibleAnywhere, BlueprintReadOnly, meta = (AllowPrivateAccess = "true"))
431 TArray<UPhysicsConstraintComponent*> ConstraintsComponents;
433 UPROPERTY(Category="CARLA Wheeled
Vehicle", VisibleAnywhere, BlueprintReadOnly, meta = (AllowPrivateAccess = "true"))
437 UPROPERTY(Category="CARLA Wheeled
Vehicle", VisibleAnywhere, BlueprintReadOnly, meta = (AllowPrivateAccess = "true"))
440 UPROPERTY(Category="CARLA Wheeled
Vehicle", VisibleAnywhere, BlueprintReadOnly, meta = (AllowPrivateAccess = "true"))
445 UFUNCTION(Category = "CARLA Wheeled
Vehicle", BlueprintCallable)
446 void ApplyRolloverBehavior();
448 void CheckRollover(const
float roll, const
std::pair<
float,
float> threshold_roll);
450 void AddReferenceToManager();
451 void RemoveReferenceToManager();
454 FTimerHandle TimerHandler;
FVehicleAckermannControl LastAppliedAckermannControl
FAckermannController AckermannController
void SetAIVehicleState(ECarlaWheeledVehicleState InState)
T * GetCarlaMovementComponent() const
FVehicleLightState LightState
bool IsAckermannControlActive() const
ECarlaWheeledVehicleState
State of a ACarlaWheeledVehicle, to be displayed in editor for debugging purposes.
This file contains definitions of common data structures used in traffic manager. ...
virtual bool IsTwoWheeledVehicle_Implementation()
FVehicleControl LastAppliedControl
FVehiclePhysicsControl LastPhysicsControl
EVehicleDoor
Type of door to open/close.
Base class for CARLA wheeled vehicles.
void ApplyAckermannControllerSettings(const FAckermannControllerSettings &AckermannControllerSettings)