CARLA
Toggle main menu visibility
Loading...
Searching...
No Matches
Unreal
CarlaUnreal
Plugins
Carla
Source
Carla
Traffic
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
9
#include "
Traffic/TrafficSignBase.h
"
10
11
#include "
Traffic/TrafficLightState.h
"
12
#include "
Traffic/TrafficLightComponent.h
"
13
14
#include "TrafficLightBase.generated.h"
15
16
class
ACarlaWheeledVehicle
;
17
class
AWheeledVehicleAIController
;
18
19
UCLASS()
20
class CARLA_API
ATrafficLightBase
: public
ATrafficSignBase
21
{
22
23
GENERATED_BODY()
24
25
public
:
26
27
ATrafficLightBase
(
const
FObjectInitializer &ObjectInitializer);
28
29
UFUNCTION(Category =
"Traffic Light"
, BlueprintCallable)
30
ETrafficLightState
GetTrafficLightState
()
const
;
31
32
UFUNCTION(Category =
"Traffic Light"
, BlueprintCallable)
33
void
SetTrafficLightState
(
ETrafficLightState
State
);
34
35
UFUNCTION(Category =
"Traffic Light"
, BlueprintCallable)
36
void
NotifyWheeledVehicle
(
ACarlaWheeledVehicle
*
Vehicle
);
37
38
UFUNCTION(Category =
"Traffic Light"
, BlueprintCallable)
39
void
UnNotifyWheeledVehicle
(
ACarlaWheeledVehicle
*
Vehicle
);
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
89
void
LightChangedCompatibility
(
ETrafficLightState
NewLightState);
90
91
void
AddTimeToRecorder
();
92
93
protected
:
94
95
UFUNCTION(Category =
"Traffic Light"
, BlueprintImplementableEvent)
96
void
OnTrafficLightStateChanged
(
ETrafficLightState
TrafficLightState);
97
98
private:
99
100
UPROPERTY(Category =
"Traffic Light"
, VisibleAnywhere)
101
TArray<TObjectPtr<
AWheeledVehicleAIController
>>
Vehicles
;
102
103
UPROPERTY(Category =
"Traffic Light"
, VisibleAnywhere)
104
int
PoleIndex
= 0;
105
106
UPROPERTY(Category =
"Traffic Light"
, VisibleAnywhere)
107
TArray<TObjectPtr<
ATrafficLightBase
>>
GroupTrafficLights
;
108
109
UPROPERTY(Category =
"Traffic Light"
, EditAnywhere)
110
TObjectPtr<UTrafficLightComponent>
TrafficLightComponent
=
nullptr
;
111
};
CarlaRecorderPacketId::State
@ State
Definition
CarlaRecorder.h:58
TrafficLightComponent.h
TrafficSignBase.h
TrafficLightState.h
ETrafficLightState
ETrafficLightState
Definition
Unreal/CarlaUnreal/Plugins/Carla/Source/Carla/Traffic/TrafficLightState.h:13
Vehicle
@ Vehicle
Definition
Unreal/CarlaUnreal/Plugins/Carla/Source/Carla/Util/EnvironmentObject.h:21
ACarlaWheeledVehicle
Base class for CARLA wheeled vehicles.
Definition
CarlaWheeledVehicle.h:85
ATrafficLightBase::AddTimeToRecorder
void AddTimeToRecorder()
Definition
TrafficLightBase.cpp:267
ATrafficLightBase::TrafficLightComponent
TObjectPtr< UTrafficLightComponent > TrafficLightComponent
Definition
TrafficLightBase.h:110
ATrafficLightBase::SetGreenTime
void SetGreenTime(float InGreenTime)
Definition
TrafficLightBase.cpp:100
ATrafficLightBase::PoleIndex
int PoleIndex
Definition
TrafficLightBase.h:104
ATrafficLightBase::SetRedTime
void SetRedTime(float InRedTime)
Definition
TrafficLightBase.cpp:152
ATrafficLightBase::ATrafficLightBase
ATrafficLightBase(const FObjectInitializer &ObjectInitializer)
Definition
TrafficLightBase.cpp:40
ATrafficLightBase::GetTrafficLightState
ETrafficLightState GetTrafficLightState() const
Definition
TrafficLightBase.cpp:52
ATrafficLightBase::SetTrafficLightState
void SetTrafficLightState(ETrafficLightState State)
Definition
TrafficLightBase.cpp:64
ATrafficLightBase::SetPoleIndex
void SetPoleIndex(int InPoleIndex)
Definition
TrafficLightBase.cpp:221
ATrafficLightBase::OnTrafficLightStateChanged
void OnTrafficLightStateChanged(ETrafficLightState TrafficLightState)
ATrafficLightBase::LightChangedCompatibility
void LightChangedCompatibility(ETrafficLightState NewLightState)
Definition
TrafficLightBase.cpp:276
ATrafficLightBase::GetPoleIndex
int GetPoleIndex() const
Definition
TrafficLightBase.cpp:226
ATrafficLightBase::GetGreenTime
float GetGreenTime() const
Definition
TrafficLightBase.cpp:112
ATrafficLightBase::GetTimeIsFrozen
bool GetTimeIsFrozen() const
Definition
TrafficLightBase.cpp:210
ATrafficLightBase::SetYellowTime
void SetYellowTime(float InYellowTime)
Definition
TrafficLightBase.cpp:126
ATrafficLightBase::NotifyWheeledVehicle
void NotifyWheeledVehicle(ACarlaWheeledVehicle *Vehicle)
Definition
TrafficLightBase.cpp:73
ATrafficLightBase::Vehicles
TArray< TObjectPtr< AWheeledVehicleAIController > > Vehicles
Definition
TrafficLightBase.h:101
ATrafficLightBase::GetElapsedTime
float GetElapsedTime() const
Definition
TrafficLightBase.cpp:178
ATrafficLightBase::GetYellowTime
float GetYellowTime() const
Definition
TrafficLightBase.cpp:138
ATrafficLightBase::SetElapsedTime
void SetElapsedTime(float InElapsedTime)
Definition
TrafficLightBase.cpp:192
ATrafficLightBase::GetRedTime
float GetRedTime() const
Definition
TrafficLightBase.cpp:164
ATrafficLightBase::UnNotifyWheeledVehicle
void UnNotifyWheeledVehicle(ACarlaWheeledVehicle *Vehicle)
Definition
TrafficLightBase.cpp:87
ATrafficLightBase::SetGroupTrafficLights
void SetGroupTrafficLights(TArray< ATrafficLightBase * > InGroupTrafficLights)
Definition
TrafficLightBase.cpp:253
ATrafficLightBase::GroupTrafficLights
TArray< TObjectPtr< ATrafficLightBase > > GroupTrafficLights
Definition
TrafficLightBase.h:107
ATrafficLightBase::GetGroupTrafficLights
TArray< ATrafficLightBase * > GetGroupTrafficLights() const
Definition
TrafficLightBase.cpp:231
ATrafficLightBase::SetTimeIsFrozen
void SetTimeIsFrozen(bool InTimeIsFrozen)
Definition
TrafficLightBase.cpp:202
ATrafficLightBase::GetTrafficLightComponent
UTrafficLightComponent * GetTrafficLightComponent()
Definition
TrafficLightBase.cpp:258
ATrafficSignBase::ATrafficSignBase
ATrafficSignBase(const FObjectInitializer &ObjectInitializer)
Definition
TrafficSignBase.cpp:11
AWheeledVehicleAIController
Wheeled vehicle controller with optional AI.
Definition
WheeledVehicleAIController.h:27
Generated by
1.18.0