CARLA
Toggle main menu visibility
Loading...
Searching...
No Matches
Unreal
CarlaUnreal
Plugins
Carla
Source
Carla
Traffic
TrafficLightComponent.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 "CoreMinimal.h"
10
#include "
SignComponent.h
"
11
#include "
TrafficLightState.h
"
12
#include "
Carla/Vehicle/WheeledVehicleAIController.h
"
13
#include "TrafficLightComponent.generated.h"
14
15
class
ATrafficLightManager
;
16
class
ATrafficLightGroup
;
17
class
UTrafficLightController
;
18
19
// Delegate to define dispatcher
20
DECLARE_DYNAMIC_MULTICAST_DELEGATE
(FLightChangeDispatcher);
21
22
/// Class representing an OpenDRIVE Traffic Signal
23
UCLASS(Blueprintable, ClassGroup=(Custom), meta=(BlueprintSpawnableComponent) )
24
class
CARLA_API UTrafficLightComponent :
public
USignComponent
25
{
26
GENERATED_BODY()
27
28
public:
29
// Sets default values for this component's properties
30
UTrafficLightComponent();
31
32
UFUNCTION(Category =
"Traffic Light"
, BlueprintCallable)
33
void
SetLightState(
ETrafficLightState
NewState);
34
35
UFUNCTION(Category =
"Traffic Light"
, BlueprintCallable)
36
ETrafficLightState
GetLightState() const;
37
38
UFUNCTION(Category =
"Traffic Light"
, BlueprintCallable)
39
void
SetFrozenGroup(
bool
InFreeze);
40
41
UFUNCTION(Category =
"Traffic Light"
, BlueprintPure)
42
ATrafficLightGroup
* GetGroup();
43
44
const
ATrafficLightGroup
* GetGroup() const;
45
46
void
SetController(
UTrafficLightController
* Controller);
47
48
UFUNCTION(Category =
"Traffic Light"
, BlueprintPure)
49
UTrafficLightController
* GetController();
50
51
const
UTrafficLightController
* GetController() const;
52
53
virtual
void
InitializeSign(const
carla
::road::Map &Map) override;
54
55
/// Deregister from the controller so streamed-out lights (World Partition)
56
/// never leave dangling entries behind.
57
virtual
void
OnComponentDestroyed(
bool
bDestroyingHierarchy) override;
58
59
UPROPERTY(Category =
"Traffic Light"
, BlueprintAssignable)
60
FLightChangeDispatcher LightChangeDispatcher;
61
62
protected:
63
64
UFUNCTION(BlueprintCallable)
65
void
OnBeginOverlapTriggerBox(UPrimitiveComponent *OverlappedComp,
66
AActor
*OtherActor,
67
UPrimitiveComponent *OtherComp,
68
int32 OtherBodyIndex,
69
bool
bFromSweep,
70
const FHitResult &SweepResult);
71
72
UFUNCTION(BlueprintCallable)
73
void
OnEndOverlapTriggerBox(UPrimitiveComponent *OverlappedComp,
74
AActor
*OtherActor,
75
UPrimitiveComponent *OtherComp,
76
int32 OtherBodyIndex);
77
78
79
80
private:
81
82
friend
ATrafficLightManager
;
83
84
void
GenerateTrafficLightBox(
85
const FTransform BoxTransform,
86
const FVector BoxSize);
87
88
UPROPERTY(Category =
"Traffic Light"
, EditAnywhere)
89
ETrafficLightState
LightState;
90
91
// UPROPERTY(Category = "Traffic Light", VisibleAnywhere)
92
// ATrafficLightGroup *TrafficLightGroup = nullptr;
93
94
UPROPERTY(Category =
"Traffic Light"
, VisibleAnywhere)
95
UTrafficLightController
*TrafficLightController =
nullptr
;
96
97
// Vehicles that have entered the trigger box of the traffic light
98
UPROPERTY()
99
TArray<
AWheeledVehicleAIController
*> Vehicles;
100
101
};
SignComponent.h
DECLARE_DYNAMIC_MULTICAST_DELEGATE
DECLARE_DYNAMIC_MULTICAST_DELEGATE(FLightChangeDispatcher)
TrafficLightState.h
ETrafficLightState
ETrafficLightState
Definition
Unreal/CarlaUnreal/Plugins/Carla/Source/Carla/Traffic/TrafficLightState.h:13
WheeledVehicleAIController.h
AActor
ATrafficLightGroup
Class which implements the state changing of traffic lights.
Definition
TrafficLightGroup.h:21
ATrafficLightManager
Class In charge of creating and assigning traffic light groups, controllers and components.
Definition
TrafficLightManager.h:20
AWheeledVehicleAIController
Wheeled vehicle controller with optional AI.
Definition
WheeledVehicleAIController.h:27
UTrafficLightController
Maps a controller from OpenDrive.
Definition
TrafficLightController.h:37
carla
This file contains definitions of common data structures used in traffic manager.
Definition
SignComponent.h:21
Generated by
1.18.0