CARLA
 
载入中...
搜索中...
未找到
TrafficLightComponent.h
浏览该文件的文档.
1// Copyright (c) 2020 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"
13#include "TrafficLightComponent.generated.h"
14
18
19// Delegate to define dispatcher
20DECLARE_DYNAMIC_MULTICAST_DELEGATE(FLightChangeDispatcher);
21
22/// Class representing an OpenDRIVE Traffic Signal
23UCLASS(Blueprintable, ClassGroup=(Custom), meta=(BlueprintSpawnableComponent) )
24class CARLA_API UTrafficLightComponent : public USignComponent
25{
26 GENERATED_BODY()
27
28public:
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
55protected:
56
57 UFUNCTION(BlueprintCallable)
58 void OnBeginOverlapTriggerBox(UPrimitiveComponent *OverlappedComp,
59 AActor *OtherActor,
60 UPrimitiveComponent *OtherComp,
61 int32 OtherBodyIndex,
62 bool bFromSweep,
63 const FHitResult &SweepResult);
64
65 UFUNCTION(BlueprintCallable)
66 void OnEndOverlapTriggerBox(UPrimitiveComponent *OverlappedComp,
67 AActor *OtherActor,
68 UPrimitiveComponent *OtherComp,
69 int32 OtherBodyIndex);
70
71
72
73private:
74
76
77 void GenerateTrafficLightBox(
78 const FTransform BoxTransform,
79 const FVector BoxSize);
80
81 UPROPERTY(Category = "Traffic Light", EditAnywhere)
82 ETrafficLightState LightState;
83
84 UPROPERTY(Category = "Traffic Light", BlueprintAssignable)
85 FLightChangeDispatcher LightChangeDispatcher;
86
87 // UPROPERTY(Category = "Traffic Light", VisibleAnywhere)
88 // ATrafficLightGroup *TrafficLightGroup = nullptr;
89
90 UPROPERTY(Category = "Traffic Light", VisibleAnywhere)
91 UTrafficLightController *TrafficLightController = nullptr;
92
93 // Vehicles that have entered the trigger box of the traffic light
94 UPROPERTY()
95 TArray<AWheeledVehicleAIController*> Vehicles;
96
97};
DECLARE_DYNAMIC_MULTICAST_DELEGATE(FLightChangeDispatcher)
Class which implements the state changing of traffic lights
Class In charge of creating and assigning traffic light groups, controllers and components.
Wheeled vehicle controller with optional AI.
Maps a controller from OpenDrive.
This file contains definitions of common data structures used in traffic manager.
Definition Carla.cpp:133