CARLA
CarlaLight.h
Go to the documentation of this file.
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 
10 #include <carla/rpc/LightState.h>
12 
13 #include "CoreMinimal.h"
14 #include "Components/ActorComponent.h"
15 #include "CarlaLight.generated.h"
16 
17 
18 
19 #define CARLA_ENUM_FROM_RPC(e) static_cast<uint8>(carla::rpc::LightState::LightGroup:: e)
20 
21 UENUM(BlueprintType)
22 enum class ELightType : uint8
23 {
24  Null = 0, // Workarround for UE4.24 issue with enums
25  Vehicle = CARLA_ENUM_FROM_RPC(Vehicle) UMETA(DisplayName = "Vehicle"),
26  Street = CARLA_ENUM_FROM_RPC(Street) UMETA(DisplayName = "Street"),
27  Building = CARLA_ENUM_FROM_RPC(Building) UMETA(DisplayName = "Building"),
28  Other = CARLA_ENUM_FROM_RPC(Other) UMETA(DisplayName = "Other"),
29 };
30 
31 #undef CARLA_ENUM_FROM_RPC
32 
33 // Class representing a light in the scene
34 UCLASS(Blueprintable, BlueprintType, ClassGroup=(Custom), meta=(BlueprintSpawnableComponent))
35 class CARLA_API UCarlaLight : public UActorComponent
36 {
37  GENERATED_BODY()
38 
39 public:
40  UCarlaLight();
41 
42  void BeginPlay() override;
43 
44  void EndPlay(const EEndPlayReason::Type EndPlayReason) override;
45 
46  void OnComponentDestroyed(bool bDestroyingHierarchy) override;
47 
48  UFUNCTION(BlueprintCallable, Category = "Carla Light")
49  void RegisterLight();
50 
51  UFUNCTION(BlueprintImplementableEvent, BlueprintCallable, Category = "Carla Light")
52  void UpdateLights();
53 
54  UFUNCTION(BlueprintImplementableEvent, BlueprintCallable, Category = "Carla Light")
55  void RegisterLightWithWeather();
56 
57  UFUNCTION(BlueprintCallable, Category = "Carla Light")
58  void SetLightIntensity(float Intensity);
59 
60  UFUNCTION(BlueprintPure, Category = "Carla Light")
61  float GetLightIntensity() const;
62 
63  UFUNCTION(BlueprintCallable, Category = "Carla Light")
64  void SetLightColor(FLinearColor Color);
65 
66  UFUNCTION(BlueprintPure, Category = "Carla Light")
67  FLinearColor GetLightColor() const;
68 
69  UFUNCTION(BlueprintCallable, Category = "Carla Light")
70  void SetLightOn(bool bOn);
71 
72  UFUNCTION(BlueprintPure, Category = "Carla Light")
73  bool GetLightOn() const;
74 
75  UFUNCTION(BlueprintCallable, Category = "Carla Light")
76  void SetLightType(ELightType Type);
77 
78  UFUNCTION(BlueprintPure, Category = "Carla Light")
79  ELightType GetLightType() const;
80 
81  carla::rpc::LightState GetLightState();
82 
83  void SetLightState(carla::rpc::LightState LightState);
84 
85  FVector GetLocation() const;
86 
87  UFUNCTION(BlueprintPure, Category = "Carla Light")
88  int GetId() const;
89 
90  UFUNCTION(BlueprintCallable, Category = "Carla Light")
91  void SetId(int InId);
92 
93 protected:
94 
95  UPROPERTY(EditAnywhere, Category = "Carla Light")
96  ELightType LightType = ELightType::Street;
97 
98  UPROPERTY(EditAnywhere, Category = "Carla Light")
99  float LightIntensity;
100 
101  UPROPERTY(EditAnywhere, Category = "Carla Light")
102  FLinearColor LightColor;
103 
104  UPROPERTY(EditAnywhere, Category = "Carla Light")
105  bool bLightOn;
106 
107  UPROPERTY(EditAnywhere, Category = "Carla Light")
108  int Id = -1;
109 
110  private:
111 
112  void RecordLightChange() const;
113 
114  bool bRegistered = false;
115 };
#define CARLA_ENUM_FROM_RPC(e)
Definition: CarlaLight.h:19
sensor::data::Color Color
ELightType
Definition: CarlaLight.h:22