CARLA
Loading...
Searching...
No Matches
FrictionTrigger.h
Go to the documentation of this file.
1// Copyright (c) 2026 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
14
15UCLASS()
16class CARLA_API AFrictionTrigger : public AActor
17{
18 GENERATED_BODY()
19
20private:
21
22 void Init();
23
24 void UpdateWheelsFriction(AActor *OtherActor, TArray<float>& NewFriction);
25
26public:
27
28 AFrictionTrigger(const FObjectInitializer &ObjectInitializer);
29
30 UFUNCTION()
31 void OnTriggerBeginOverlap(
32 UPrimitiveComponent *OverlappedComp,
33 AActor *OtherActor,
34 UPrimitiveComponent *OtherComp,
35 int32 OtherBodyIndex,
36 bool bFromSweep,
37 const FHitResult &SweepResult);
38
39 UFUNCTION()
40 void OnTriggerEndOverlap(
41 UPrimitiveComponent *OverlappedComp,
42 AActor *OtherActor,
43 UPrimitiveComponent *OtherComp,
44 int32 OtherBodyIndex);
45
46 void SetEpisode(const UCarlaEpisode &InEpisode)
47 {
48 Episode = &InEpisode;
49 }
50
51 void SetBoxExtent(const FVector &Extent)
52 {
53 TriggerVolume->SetBoxExtent(Extent);
54 }
55
56 void SetFriction(float NewFriction)
57 {
58 Friction = NewFriction;
59 }
60
61protected:
62
63 virtual void BeginPlay() override;
64
65 virtual void EndPlay(EEndPlayReason::Type EndPlayReason) override;
66
67 virtual void Tick(float DeltaTime) override;
68
69 // Friction each vehicle had when it entered, restored when it leaves
70 TMap<TWeakObjectPtr<ACarlaWheeledVehicle>, TArray<float>> OldFrictionValues;
71
72public:
73
74 UPROPERTY(EditAnywhere)
75 float Friction = 0.0f;
76
77 UPROPERTY(EditAnywhere)
78 TObjectPtr<UBoxComponent> TriggerVolume;
79
80 UPROPERTY()
81 TObjectPtr<const UCarlaEpisode> Episode = nullptr;
82};
Base class for CARLA wheeled vehicles.
virtual void BeginPlay() override
virtual void EndPlay(const EEndPlayReason::Type EndPlayReason)
void SetBoxExtent(const FVector &Extent)
void SetEpisode(const UCarlaEpisode &InEpisode)
TMap< TWeakObjectPtr< ACarlaWheeledVehicle >, TArray< float > > OldFrictionValues
void SetFriction(float NewFriction)
A simulation episode.