CARLA
FrictionTrigger.h
Go to the documentation of this file.
1 // Copyright (c) 2019 Computer Vision Center (CVC) at the Universitat Autonoma
2 // de Barcelona (UAB). This work is licensed under the terms of the MIT license.
3 // For a copy, see <https://opensource.org/licenses/MIT>.
4 
5 #pragma once
6 
7 #include "GameFramework/Actor.h"
8 #include "Components/BoxComponent.h"
10 
11 #include "FrictionTrigger.generated.h"
12 
13 UCLASS()
14 class CARLA_API AFrictionTrigger : public AActor
15 {
16  GENERATED_BODY()
17 
18 private:
19 
20  void Init();
21 
22  void UpdateWheelsFriction(AActor *OtherActor, TArray<float>& NewFriction);
23 
24 public:
25 
26  AFrictionTrigger(const FObjectInitializer &ObjectInitializer);
27 
28  UFUNCTION()
29  void OnTriggerBeginOverlap(
30  UPrimitiveComponent *OverlappedComp,
31  AActor *OtherActor,
32  UPrimitiveComponent *OtherComp,
33  int32 OtherBodyIndex,
34  bool bFromSweep,
35  const FHitResult &SweepResult);
36 
37  UFUNCTION()
38  void OnTriggerEndOverlap(
39  UPrimitiveComponent *OverlappedComp,
40  AActor *OtherActor,
41  UPrimitiveComponent *OtherComp,
42  int32 OtherBodyIndex);
43 
44  void SetEpisode(const UCarlaEpisode &InEpisode)
45  {
46  Episode = &InEpisode;
47  }
48 
49  void SetBoxExtent(const FVector &Extent)
50  {
51  TriggerVolume->SetBoxExtent(Extent);
52  }
53 
54  void SetFriction(float NewFriction)
55  {
56  Friction = NewFriction;
57  }
58 
59 protected:
60 
61  virtual void BeginPlay() override;
62 
63  virtual void EndPlay(EEndPlayReason::Type EndPlayReason) override;
64 
65  virtual void Tick(float DeltaTime) override;
66 
67  // Save old frictions
68  TArray<float> OldFrictionValues;
69 
70 public:
71 
72  UPROPERTY(EditAnywhere)
73  float Friction = 0.0f;
74 
75  UPROPERTY(EditAnywhere)
76  UBoxComponent *TriggerVolume;
77 
78  const UCarlaEpisode *Episode = nullptr;
79 };
void SetFriction(float NewFriction)
TArray< float > OldFrictionValues
A simulation episode.
Definition: CarlaEpisode.h:34
void SetBoxExtent(const FVector &Extent)
void SetEpisode(const UCarlaEpisode &InEpisode)