CARLA
CarSimManagerComponent.h
Go to the documentation of this file.
1 // Copyright (c) 2021 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 #pragma once
9 
12 
13 #ifdef WITH_CARSIM
14 #include "CarSimMovementComponent.h"
15 #endif
16 
17 #include "CarSimManagerComponent.generated.h"
18 
20 
21 UCLASS(Blueprintable, meta=(BlueprintSpawnableComponent) )
23 {
24  GENERATED_BODY()
25 
26  #ifdef WITH_CARSIM
27  AActor* OffsetActor;
28 
29  UCarSimMovementComponent * CarSimMovementComponent;
30  #endif
31 
32 public:
33 
34  static void CreateCarsimComponent(
35  ACarlaWheeledVehicle* Vehicle, FString Simfile);
36 
37  FString SimfilePath = "";
38 
39  virtual void BeginPlay() override;
40 
41  virtual void TickComponent(float DeltaTime, ELevelTick TickType, FActorComponentTickFunction* ThisTickFunction) override;
42 
43  void ProcessControl(FVehicleControl &Control) override;
44 
45  FVector GetVelocity() const override;
46 
47  virtual void EndPlay(const EEndPlayReason::Type EndPlayReason) override;
48 
49  void UseCarSimRoad(bool bEnabled);
50 
51  int32 GetVehicleCurrentGear() const override;
52 
53  float GetVehicleForwardSpeed() const override;
54 
55 private:
56 
57  // On car mesh hit, only works when carsim is enabled
58  UFUNCTION()
59  void OnCarSimHit(AActor *Actor,
60  AActor *OtherActor,
61  FVector NormalImpulse,
62  const FHitResult &Hit);
63 
64  // On car mesh overlap, only works when carsim is enabled
65  // (this event triggers when overlapping with static environment)
66  UFUNCTION()
67  void OnCarSimOverlap(UPrimitiveComponent* OverlappedComponent,
68  AActor* OtherActor,
69  UPrimitiveComponent* OtherComp,
70  int32 OtherBodyIndex,
71  bool bFromSweep,
72  const FHitResult & SweepResult);
73 
74  // On car mesh overlap end, only works when carsim is enabled
75  // (this event triggers when overlapping with static environment)
76  UFUNCTION()
77  void OnCarSimEndOverlap(UPrimitiveComponent* OverlappedComponent,
78  AActor* OtherActor,
79  UPrimitiveComponent* OtherComp,
80  int32 OtherBodyIndex);
81 };
float GetVehicleForwardSpeed() const
Forward speed in cm/s. Might be negative if goes backwards.
virtual FVector GetVelocity() const override
virtual void EndPlay(const EEndPlayReason::Type EndPlayReason)
carla::SharedPtr< cc::Actor > Actor
virtual void BeginPlay() override
int32 GetVehicleCurrentGear() const
Active gear of the vehicle.
Base class for CARLA wheeled vehicles.