9 #include "CoreMinimal.h" 13 #include "Containers/Map.h" 15 #include "TrafficLightController.generated.h" 21 USTRUCT(BlueprintType)
26 UPROPERTY(EditAnywhere, BlueprintReadWrite)
29 UPROPERTY(EditAnywhere, BlueprintReadWrite)
44 UFUNCTION(Category =
"Traffic Controller", BlueprintCallable)
45 void SetStates(TArray<FTrafficLightStage> States);
47 UFUNCTION(Category =
"Traffic Controller", BlueprintPure)
48 const FTrafficLightStage &GetCurrentState()
const;
51 UFUNCTION(Category =
"Traffic Controller", BlueprintCallable)
55 UFUNCTION(Category =
"Traffic Controller", BlueprintCallable)
56 bool AdvanceTimeAndCycleFinished(
float DeltaTime);
58 UFUNCTION(Category =
"Traffic Controller", BlueprintCallable)
61 UFUNCTION(Category =
"Traffic Controller", BlueprintPure)
62 const TArray<UTrafficLightComponent *> &GetTrafficLights();
64 UFUNCTION(Category =
"Traffic Controller", BlueprintCallable)
65 void EmptyTrafficLights();
67 UFUNCTION(Category =
"Traffic Controller", BlueprintPure)
68 const FString &GetControllerId()
const;
70 UFUNCTION(Category =
"Traffic Controller", BlueprintCallable)
71 void SetControllerId(
const FString &Id);
73 UFUNCTION(Category =
"Traffic Controller", BlueprintCallable)
74 void AddTrafficLight(UTrafficLightComponent *
TrafficLight);
76 UFUNCTION(Category =
"Traffic Controller", BlueprintCallable)
77 void RemoveTrafficLight(UTrafficLightComponent * TrafficLight);
79 void AddCarlaActorTrafficLight(
FCarlaActor* CarlaActor);
81 void RemoveCarlaActorTrafficLight(
FCarlaActor* CarlaActor);
83 UFUNCTION(Category =
"Traffic Controller", BlueprintCallable)
84 bool IsCycleFinished()
const;
86 UFUNCTION(Category =
"Traffic Controller", BlueprintCallable)
89 UFUNCTION(Category =
"Traffic Controller", BlueprintCallable)
90 int GetSequence()
const;
92 UFUNCTION(Category =
"Traffic Controller", BlueprintCallable)
93 void SetSequence(
int InSequence);
95 UFUNCTION(Category =
"Traffic Controller", BlueprintCallable)
98 UFUNCTION(Category =
"Traffic Controller", BlueprintCallable)
99 void SetYellowTime(
float NewTime);
101 UFUNCTION(Category =
"Traffic Controller", BlueprintCallable)
102 void SetRedTime(
float NewTime);
104 UFUNCTION(Category =
"Traffic Controller", BlueprintCallable)
105 void SetGreenTime(
float NewTime);
107 UFUNCTION(Category =
"Traffic Controller", BlueprintCallable)
108 float GetGreenTime()
const;
110 UFUNCTION(Category =
"Traffic Controller", BlueprintCallable)
111 float GetYellowTime()
const;
113 UFUNCTION(Category =
"Traffic Controller", BlueprintCallable)
114 float GetRedTime()
const;
116 UFUNCTION(Category =
"Traffic Controller", BlueprintCallable)
117 float GetElapsedTime()
const;
119 UFUNCTION(Category =
"Traffic Controller", BlueprintCallable)
120 void SetElapsedTime(
float InElapsedTime);
130 return CurrentLightState;
134 CurrentLightState = NewState;
143 UPROPERTY(Category =
"Traffic Controller", EditAnywhere)
144 FString ControllerId = "";
146 UPROPERTY(Category = "Traffic Controller", EditAnywhere)
147 int CurrentState = 0;
150 UPROPERTY(Category = "Traffic Controller", EditAnywhere)
151 TArray<FTrafficLightStage> LightStates = {
152 {10, ETrafficLightState::Green},
153 { 3, ETrafficLightState::Yellow},
154 { 2, ETrafficLightState::Red}
157 UPROPERTY(Category =
"Traffic Controller", EditAnywhere)
158 TArray<UTrafficLightComponent *> TrafficLights;
162 UPROPERTY(Category = "Traffic Controller", VisibleAnywhere)
166 UPROPERTY(Category = "Traffic Controller", EditAnywhere)
170 float ElapsedTime = 0;
Class which implements the state changing of traffic lights.
Defines a stage of a semaphor with a State and the time this state lasts.
void SetCurrentLightState(ETrafficLightState NewState)
ETrafficLightState GetCurrentLightState() const
Maps a controller from OpenDrive.
A view over an actor and its properties.