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(BlueprintCallable, Category = "Carla Light")
55  void SetLightIntensity(float Intensity);
56 
57  UFUNCTION(BlueprintPure, Category = "Carla Light")
58  float GetLightIntensity() const;
59 
60  UFUNCTION(BlueprintCallable, Category = "Carla Light")
61  void SetLightColor(FLinearColor Color);
62 
63  UFUNCTION(BlueprintPure, Category = "Carla Light")
64  FLinearColor GetLightColor() const;
65 
66  UFUNCTION(BlueprintCallable, Category = "Carla Light")
67  void SetLightOn(bool bOn);
68 
69  UFUNCTION(BlueprintPure, Category = "Carla Light")
70  bool GetLightOn() const;
71 
72  UFUNCTION(BlueprintCallable, Category = "Carla Light")
73  void SetLightType(ELightType Type);
74 
75  UFUNCTION(BlueprintPure, Category = "Carla Light")
76  ELightType GetLightType() const;
77 
78  carla::rpc::LightState GetLightState();
79 
80  void SetLightState(carla::rpc::LightState LightState);
81 
82  FVector GetLocation() const;
83 
84  UFUNCTION(BlueprintPure, Category = "Carla Light")
85  int GetId() const;
86 
87  UFUNCTION(BlueprintCallable, Category = "Carla Light")
88  void SetId(int InId);
89 
90 protected:
91 
92  UPROPERTY(EditAnywhere, Category = "Carla Light")
93  ELightType LightType = ELightType::Street;
94 
95  UPROPERTY(EditAnywhere, Category = "Carla Light")
96  float LightIntensity;
97 
98  UPROPERTY(EditAnywhere, Category = "Carla Light")
99  FLinearColor LightColor;
100 
101  UPROPERTY(EditAnywhere, Category = "Carla Light")
102  bool bLightOn;
103 
104  UPROPERTY(EditAnywhere, Category = "Carla Light")
105  int Id = -1;
106 
107  private:
108 
109  void RecordLightChange() const;
110 
111  bool bRegistered = false;
112 };
#define CARLA_ENUM_FROM_RPC(e)
Definition: CarlaLight.h:19
sensor::data::Color Color
ELightType
Definition: CarlaLight.h:22