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" 94 UFUNCTION(Category =
"CARLA Wheeled Vehicle", BlueprintCallable)
97 return LastAppliedControl;
101 UFUNCTION(Category =
"CARLA Wheeled Vehicle", BlueprintCallable)
104 return LastAppliedAckermannControl;
109 UFUNCTION(Category =
"CARLA Wheeled Vehicle", BlueprintCallable)
110 FTransform GetVehicleTransform()
const 112 return GetActorTransform();
116 UFUNCTION(Category =
"CARLA Wheeled Vehicle", BlueprintCallable)
117 float GetVehicleForwardSpeed()
const;
120 UFUNCTION(Category =
"CARLA Wheeled Vehicle", BlueprintCallable)
121 FVector GetVehicleOrientation()
const;
124 UFUNCTION(Category =
"CARLA Wheeled Vehicle", BlueprintCallable)
125 int32 GetVehicleCurrentGear()
const;
128 UFUNCTION(Category =
"CARLA Wheeled Vehicle", BlueprintCallable)
129 FTransform GetVehicleBoundingBoxTransform()
const;
132 UFUNCTION(Category =
"CARLA Wheeled Vehicle", BlueprintCallable)
133 FVector GetVehicleBoundingBoxExtent()
const;
136 UFUNCTION(Category =
"CARLA Wheeled Vehicle", BlueprintCallable)
137 UBoxComponent *GetVehicleBoundingBox()
const 139 return VehicleBounds;
143 UFUNCTION(Category =
"CARLA Wheeled Vehicle", BlueprintCallable)
144 float GetMaximumSteerAngle()
const;
159 UFUNCTION(Category =
"CARLA Wheeled Vehicle", BlueprintCallable)
165 UFUNCTION(Category =
"CARLA Wheeled Vehicle", BlueprintCallable)
168 UFUNCTION(Category =
"CARLA Wheeled Vehicle", BlueprintCallable)
170 return AckermannController.GetSettings();
173 UFUNCTION(Category =
"CARLA Wheeled Vehicle", BlueprintCallable)
174 void RestoreVehiclePhysicsControl();
176 UFUNCTION(Category =
"CARLA Wheeled Vehicle", BlueprintCallable)
182 return AckermannController.ApplySettings(AckermannControllerSettings);
185 UFUNCTION(Category =
"CARLA Wheeled Vehicle", BlueprintCallable)
186 void SetSimulatePhysics(
bool enabled);
188 void SetWheelCollision(UWheeledVehicleMovementComponent4W *Vehicle4W,
const FVehiclePhysicsControl &PhysicsControl);
190 void SetWheelCollisionNW(UWheeledVehicleMovementComponentNW *VehicleNW,
const FVehiclePhysicsControl &PhysicsControl);
196 UFUNCTION(BlueprintNativeEvent)
197 bool IsTwoWheeledVehicle();
209 UFUNCTION(Category =
"CARLA Wheeled Vehicle", BlueprintCallable)
212 if (bAckermannControlActive) {
213 AckermannController.Reset();
215 bAckermannControlActive =
false;
217 if (InputControl.Priority <= Priority)
219 InputControl.Control = Control;
220 InputControl.Priority = Priority;
224 UFUNCTION(Category =
"CARLA Wheeled Vehicle", BlueprintCallable)
227 bAckermannControlActive =
true;
228 LastAppliedAckermannControl = AckermannControl;
229 AckermannController.SetTargetPoint(AckermannControl);
234 return bAckermannControlActive;
237 UFUNCTION(Category =
"CARLA Wheeled Vehicle", BlueprintCallable)
238 void ActivateVelocityControl(
const FVector &Velocity);
240 UFUNCTION(Category =
"CARLA Wheeled Vehicle", BlueprintCallable)
241 void DeactivateVelocityControl();
243 UFUNCTION(Category =
"CARLA Wheeled Vehicle", BlueprintCallable)
244 void ShowDebugTelemetry(
bool Enabled);
247 void FlushVehicleControl();
256 UFUNCTION(Category =
"CARLA Wheeled Vehicle", BlueprintCallable)
257 void SetThrottleInput(
float Value);
259 UFUNCTION(Category =
"CARLA Wheeled Vehicle", BlueprintCallable)
260 void SetSteeringInput(
float Value);
262 UFUNCTION(Category =
"CARLA Wheeled Vehicle", BlueprintCallable)
263 void SetBrakeInput(
float Value);
265 UFUNCTION(Category =
"CARLA Wheeled Vehicle", BlueprintCallable)
266 void SetReverse(
bool Value);
268 UFUNCTION(Category =
"CARLA Wheeled Vehicle", BlueprintCallable)
271 SetReverse(!LastAppliedControl.bReverse);
274 UFUNCTION(Category =
"CARLA Wheeled Vehicle", BlueprintCallable)
275 void SetHandbrakeInput(
bool Value);
277 UFUNCTION(Category =
"CARLA Wheeled Vehicle", BlueprintCallable)
280 SetHandbrakeInput(
true);
283 UFUNCTION(Category =
"CARLA Wheeled Vehicle", BlueprintCallable)
284 void ReleaseHandbrake()
286 SetHandbrakeInput(
false);
289 TArray<float> GetWheelsFrictionScale();
291 void SetWheelsFrictionScale(TArray<float> &WheelsFrictionScale);
295 template<
typename T = UBaseCarlaMovementComponent>
298 return Cast<T>(BaseMovementComponent);
309 virtual void BeginPlay()
override;
310 virtual void EndPlay(
const EEndPlayReason::Type EndPlayReason);
312 UFUNCTION(BlueprintImplementableEvent)
315 UFUNCTION(BlueprintCallable, CallInEditor)
316 void AdjustVehicleBounds();
318 UPROPERTY(Category=
"Door Animation", EditAnywhere, BlueprintReadWrite)
319 TArray<FName> ConstraintComponentNames;
321 UPROPERTY(Category="Door Animation", EditAnywhere, BlueprintReadWrite)
322 float DoorOpenStrength = 100.0f;
324 UFUNCTION(BlueprintCallable, CallInEditor)
325 void ResetConstraints();
330 UPROPERTY(Category = "AI Controller", VisibleAnywhere)
333 UPROPERTY(Category = "CARLA Wheeled
Vehicle", EditAnywhere)
334 UVehicleVelocityControl* VelocityControl;
348 bool bAckermannControlActive =
false;
351 float RolloverBehaviorForce = 0.35;
352 int RolloverBehaviorTracker = 0;
353 float RolloverFlagTime = 5.0f;
358 UPROPERTY(Category =
"CARLA Wheeled Vehicle", EditDefaultsOnly)
359 float DetectionSize { 750.0f };
361 UPROPERTY(Category =
"CARLA Wheeled Vehicle", VisibleAnywhere, BlueprintReadOnly)
362 FBox FoliageBoundingBox;
364 UPROPERTY(Category = "CARLA Wheeled
Vehicle", EditAnywhere)
365 UBoxComponent *VehicleBounds;
368 FBox GetDetectionBox() const;
371 float GetDetectionSize() const;
374 void UpdateDetectionBox();
377 const TArray<int32> GetFoliageInstancesCloseToVehicle(const UInstancedStaticMeshComponent* Component) const;
379 UFUNCTION(BlueprintCallable)
380 void DrawFoliageBoundingBox() const;
383 FBoxSphereBounds GetBoxSphereBounds() const;
386 bool IsInVehicleRange(const FVector&
Location) const;
391 UFUNCTION(Category = "CARLA Wheeled
Vehicle", BlueprintCallable)
394 UFUNCTION(Category = "CARLA Wheeled
Vehicle", BlueprintCallable)
397 UFUNCTION(Category = "CARLA Wheeled
Vehicle", BlueprintCallable)
400 UFUNCTION(Category = "CARLA Wheeled
Vehicle", BlueprintCallable)
403 UFUNCTION(Category = "CARLA Wheeled
Vehicle", BlueprintCallable)
406 UFUNCTION(Category = "CARLA Wheeled
Vehicle", BlueprintCallable)
409 virtual FVector GetVelocity() const override;
412 UPROPERTY(Category="CARLA Wheeled
Vehicle", EditAnywhere)
413 float CarSimOriginOffset = 150.f;
416 UPROPERTY(Category="CARLA Wheeled
Vehicle", VisibleAnywhere)
417 bool bIsNWVehicle = false;
419 void SetRolloverFlag();
423 UFUNCTION(Category = "CARLA Wheeled
Vehicle", BlueprintCallable)
424 static FRotator GetPhysicsConstraintAngle(UPhysicsConstraintComponent* Component);
425 UFUNCTION(Category = "CARLA Wheeled
Vehicle", BlueprintCallable)
426 static
void SetPhysicsConstraintAngle(
427 UPhysicsConstraintComponent*Component, const FRotator &NewAngle);
431 UPROPERTY(Category="CARLA Wheeled
Vehicle", VisibleAnywhere)
432 bool bPhysicsEnabled = true;
435 UPROPERTY(Category="CARLA Wheeled
Vehicle", VisibleAnywhere, BlueprintReadOnly, meta = (AllowPrivateAccess = "true"))
438 UPROPERTY(Category="CARLA Wheeled
Vehicle", VisibleAnywhere, BlueprintReadOnly, meta = (AllowPrivateAccess = "true"))
439 TArray<UPhysicsConstraintComponent*> ConstraintsComponents;
441 UPROPERTY(Category="CARLA Wheeled
Vehicle", VisibleAnywhere, BlueprintReadOnly, meta = (AllowPrivateAccess = "true"))
445 UPROPERTY(Category="CARLA Wheeled
Vehicle", VisibleAnywhere, BlueprintReadOnly, meta = (AllowPrivateAccess = "true"))
448 UPROPERTY(Category="CARLA Wheeled
Vehicle", VisibleAnywhere, BlueprintReadOnly, meta = (AllowPrivateAccess = "true"))
453 UFUNCTION(Category = "CARLA Wheeled
Vehicle", BlueprintCallable)
454 void ApplyRolloverBehavior();
456 void CheckRollover(const
float roll, const
std::pair<
float,
float> threshold_roll);
458 void AddReferenceToManager();
459 void RemoveReferenceToManager();
462 FTimerHandle TimerHandler;
464 float SpeedAnim { 0.0f };
465 float RotationAnim { 0.0f };
467 UFUNCTION(Category =
"CARLA Wheeled Vehicle", BlueprintCallable)
468 float GetSpeedAnim()
const {
return SpeedAnim; }
470 UFUNCTION(Category =
"CARLA Wheeled Vehicle", BlueprintCallable)
471 void SetSpeedAnim(
float Speed) { SpeedAnim = Speed; }
473 UFUNCTION(Category =
"CARLA Wheeled Vehicle", BlueprintCallable)
474 float GetRotationAnim()
const {
return RotationAnim; }
476 UFUNCTION(Category =
"CARLA Wheeled Vehicle", BlueprintCallable)
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)