CARLA
Loading...
Searching...
No Matches
TrafficLightBase.h
Go to the documentation of this file.
1// Copyright (c) 2026 Computer Vision Center (CVC) at the Universitat Autonoma
2// de Barcelona (UAB).
3//
4// This work is licensed under the terms of the MIT license.
5// For a copy, see <https://opensource.org/licenses/MIT>.
6
7#pragma once
8
10
13
14#include "TrafficLightBase.generated.h"
15
18
19UCLASS()
20class CARLA_API ATrafficLightBase : public ATrafficSignBase
21{
22
23 GENERATED_BODY()
24
25public:
26
27 ATrafficLightBase(const FObjectInitializer &ObjectInitializer);
28
29 UFUNCTION(Category = "Traffic Light", BlueprintCallable)
31
32 UFUNCTION(Category = "Traffic Light", BlueprintCallable)
34
35 UFUNCTION(Category = "Traffic Light", BlueprintCallable)
37
38 UFUNCTION(Category = "Traffic Light", BlueprintCallable)
40
41 UFUNCTION(Category = "Traffic Light", BlueprintCallable)
42 void SetGreenTime(float InGreenTime);
43
44 UFUNCTION(Category = "Traffic Light", BlueprintCallable)
45 float GetGreenTime() const;
46
47 UFUNCTION(Category = "Traffic Light", BlueprintCallable)
48 void SetYellowTime(float InYellowTime);
49
50 UFUNCTION(Category = "Traffic Light", BlueprintCallable)
51 float GetYellowTime() const;
52
53 UFUNCTION(Category = "Traffic Light", BlueprintCallable)
54 void SetRedTime(float InRedTime);
55
56 UFUNCTION(Category = "Traffic Light", BlueprintCallable)
57 float GetRedTime() const;
58
59 UFUNCTION(Category = "Traffic Light", BlueprintCallable)
60 float GetElapsedTime() const;
61
62 UFUNCTION(Category = "Traffic Light", BlueprintCallable)
63 void SetTimeIsFrozen(bool InTimeIsFrozen);
64
65 UFUNCTION(Category = "Traffic Light", BlueprintCallable)
66 bool GetTimeIsFrozen() const;
67
68 UFUNCTION(Category = "Traffic Light", BlueprintCallable)
69 void SetPoleIndex(int InPoleIndex);
70
71 UFUNCTION(Category = "Traffic Light", BlueprintCallable)
72 int GetPoleIndex() const;
73
74 UFUNCTION(Category = "Traffic Light", BlueprintCallable)
75 TArray<ATrafficLightBase *> GetGroupTrafficLights() const;
76
77 UFUNCTION(Category = "Traffic Light", BlueprintCallable)
78 void SetGroupTrafficLights(TArray<ATrafficLightBase *> InGroupTrafficLights);
79
80 // used from replayer
81 void SetElapsedTime(float InElapsedTime);
82
83 UFUNCTION(Category = "Traffic Light", BlueprintPure)
84 UTrafficLightComponent* GetTrafficLightComponent();
85
86 const UTrafficLightComponent* GetTrafficLightComponent() const;
87
88 // Compatibility old traffic light system with traffic light components
90
91 void AddTimeToRecorder();
92
93protected:
94
95 UFUNCTION(Category = "Traffic Light", BlueprintImplementableEvent)
97
98private:
99
100 UPROPERTY(Category = "Traffic Light", VisibleAnywhere)
102
103 UPROPERTY(Category = "Traffic Light", VisibleAnywhere)
104 int PoleIndex = 0;
105
106 UPROPERTY(Category = "Traffic Light", VisibleAnywhere)
108
109 UPROPERTY(Category = "Traffic Light", EditAnywhere)
110 TObjectPtr<UTrafficLightComponent> TrafficLightComponent = nullptr;
111};
Base class for CARLA wheeled vehicles.
TObjectPtr< UTrafficLightComponent > TrafficLightComponent
void SetGreenTime(float InGreenTime)
void SetRedTime(float InRedTime)
ATrafficLightBase(const FObjectInitializer &ObjectInitializer)
ETrafficLightState GetTrafficLightState() const
void SetTrafficLightState(ETrafficLightState State)
void SetPoleIndex(int InPoleIndex)
void OnTrafficLightStateChanged(ETrafficLightState TrafficLightState)
void LightChangedCompatibility(ETrafficLightState NewLightState)
float GetGreenTime() const
bool GetTimeIsFrozen() const
void SetYellowTime(float InYellowTime)
void NotifyWheeledVehicle(ACarlaWheeledVehicle *Vehicle)
TArray< TObjectPtr< AWheeledVehicleAIController > > Vehicles
float GetElapsedTime() const
float GetYellowTime() const
void SetElapsedTime(float InElapsedTime)
void UnNotifyWheeledVehicle(ACarlaWheeledVehicle *Vehicle)
void SetGroupTrafficLights(TArray< ATrafficLightBase * > InGroupTrafficLights)
TArray< TObjectPtr< ATrafficLightBase > > GroupTrafficLights
TArray< ATrafficLightBase * > GetGroupTrafficLights() const
void SetTimeIsFrozen(bool InTimeIsFrozen)
UTrafficLightComponent * GetTrafficLightComponent()
ATrafficSignBase(const FObjectInitializer &ObjectInitializer)
Wheeled vehicle controller with optional AI.