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// 委托定义调度程序:declare_dynamic_multicast_delegate
20DECLARE_DYNAMIC_MULTICAST_DELEGATE(FLightChangeDispatcher);
21
22/// 表示 OpenDRIVE 交通信号灯的类
23UCLASS(Blueprintable, ClassGroup=(Custom), meta=(BlueprintSpawnableComponent) )
24class CARLA_API UTrafficLightComponent : public USignComponent
25{
26 GENERATED_BODY()
27
28public:
29 // 设置此组件属性的默认值
30 UTrafficLightComponent();
31
32 // 通过 UFUNCTION宏 来注册函数到蓝图中;
33 // BlueprintCallable 表示这个函数可以被蓝图调用;
34 // 这个成员函数由其蓝图的子类实现,你不应该尝试在C++中给出函数的实现,这会导致链接错误。
35 // 设置交通灯的状态
36 UFUNCTION(Category = "Traffic Light", BlueprintCallable)
37 void SetLightState(ETrafficLightState NewState);
38
39 // 获得交通灯的状态
40 UFUNCTION(Category = "Traffic Light", BlueprintCallable)
41 ETrafficLightState GetLightState() const;
42
43 // 修改冻结的交通信号灯
44 UFUNCTION(Category = "Traffic Light", BlueprintCallable)
45 void SetFrozenGroup(bool InFreeze);
46
47 // 获得交通灯组(列表)
48 UFUNCTION(Category = "Traffic Light", BlueprintPure)
49 ATrafficLightGroup* GetGroup();
50
51 const ATrafficLightGroup* GetGroup() const;
52
53 void SetController(UTrafficLightController* Controller);
54
55 UFUNCTION(Category = "Traffic Light", BlueprintPure)
56 UTrafficLightController* GetController();
57
58 const UTrafficLightController* GetController() const;
59
60 virtual void InitializeSign(const carla::road::Map &Map) override;
61
62protected:
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
80private:
81
83
84 void GenerateTrafficLightBox(
85 const FTransform BoxTransform,
86 const FVector BoxSize);
87
88 // 借助 UPROPERTY 宏 将一个 UObject 类的子类的成员变量注册到蓝图中(让蓝图能够调用这个C++类中的函数)
89 // 可以传递更多参数来控制 UPROPERTY 宏的行为
90 UPROPERTY(Category = "Traffic Light", EditAnywhere)
92
93 UPROPERTY(Category = "Traffic Light", BlueprintAssignable)
94 FLightChangeDispatcher LightChangeDispatcher;
95
96 // UPROPERTY(Category = "Traffic Light", VisibleAnywhere)
97 // ATrafficLightGroup *TrafficLightGroup = nullptr;
98
99 UPROPERTY(Category = "Traffic Light", VisibleAnywhere)
100 UTrafficLightController *TrafficLightController = nullptr;
101
102 // 进入交通信号灯触发框的车辆
103 UPROPERTY()
104 TArray<AWheeledVehicleAIController*> Vehicles;
105
106};
FVehicleLightState LightState
Definition ActorData.h:131
sode override
Definition ActorData.h:280
DECLARE_DYNAMIC_MULTICAST_DELEGATE(FLightChangeDispatcher)
如果你的类继承自UObject,你的类名上方需要加入 UCLASS() 宏 实现交通信号灯状态改变的类
负责创建和分配交通灯组、控制器和组件的类。
带可选 AI 的轮式车辆控制器。
地图类的前向声明,用于在LaneInvasionSensor类中可能的引用。
从 OpenDrive 映射一个控制器。控制相关交通信号灯并包含其循环
CARLA模拟器的主命名空间。
Definition Carla.cpp:139