CARLA
ActorBlueprintFunctionLibrary.h
Go to the documentation of this file.
1 // Copyright (c) 2019 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 
15 #include "Carla/Sensor/Radar.h"
17 
18 #include "Kismet/BlueprintFunctionLibrary.h"
19 
20 #include "ActorBlueprintFunctionLibrary.generated.h"
21 
23 class AShaderBasedSensor;
24 struct FLidarDescription;
25 
26 UCLASS()
28 {
29  GENERATED_BODY()
30 
31 public:
32 
33  /// @}
34  /// ==========================================================================
35  /// @name Actor definition validators
36  /// ==========================================================================
37  /// @{
38 
39  /// Return whether the actor definition is valid. Prints all the errors found.
40  UFUNCTION(Category = "Carla Actor", BlueprintCallable)
41  static bool CheckActorDefinition(const FActorDefinition &ActorDefinitions);
42 
43  /// Return whether the list of actor definitions is valid. Prints all the
44  /// errors found.
45  UFUNCTION(Category = "Carla Actor", BlueprintCallable)
46  static bool CheckActorDefinitions(const TArray<FActorDefinition> &ActorDefinitions);
47 
48  /// @}
49  /// ==========================================================================
50  /// @name Helpers to create actor definitions
51  /// ==========================================================================
52  /// @{
53 
54  static FActorDefinition MakeGenericDefinition(
55  const FString &Category,
56  const FString &Type,
57  const FString &Id);
58 
59  static FActorDefinition MakeGenericSensorDefinition(
60  const FString &Type,
61  const FString &Id);
62 
63  static FActorDefinition MakeCameraDefinition(
64  const FString &Id,
65  bool bEnableModifyingPostProcessEffects = false);
66 
67  UFUNCTION(Category = "Carla Actor", BlueprintCallable)
68  static void MakeCameraDefinition(
69  const FString &Id,
70  bool bEnableModifyingPostProcessEffects,
71  bool &Success,
72  FActorDefinition &Definition);
73 
74  static FActorDefinition MakeNormalsCameraDefinition();
75 
76  UFUNCTION(Category = "Carla Actor", BlueprintCallable)
77  static void MakeNormalsCameraDefinition(
78  bool &Success,
79  FActorDefinition &Definition);
80 
81  static FActorDefinition MakeLidarDefinition(
82  const FString &Id);
83 
84  UFUNCTION(Category = "Carla Actor", BlueprintCallable)
85  static void MakeLidarDefinition(
86  const FString &Id,
87  bool &Success,
88  FActorDefinition &Definition);
89 
90  static FActorDefinition MakeGnssDefinition();
91 
92  UFUNCTION(Category = "Carla Actor", BlueprintCallable)
93  static void MakeGnssDefinition(
94  bool &Success,
95  FActorDefinition &Definition);
96 
97  static FActorDefinition MakeIMUDefinition();
98 
99  UFUNCTION(Category = "Carla Actor", BlueprintCallable)
100  static void MakeIMUDefinition(
101  bool &Success,
102  FActorDefinition &Definition);
103 
104  static FActorDefinition MakeRadarDefinition();
105 
106  UFUNCTION(Category = "Carla Actor", BlueprintCallable)
107  static void MakeRadarDefinition(
108  bool &Success,
109  FActorDefinition &Definition);
110 
111  UFUNCTION(Category = "Carla Actor", BlueprintCallable)
112  static void MakeVehicleDefinition(
113  const FVehicleParameters &Parameters,
114  bool &Success,
115  FActorDefinition &Definition);
116 
117  UFUNCTION(Category = "Carla Actor", BlueprintCallable)
118  static void MakeVehicleDefinitions(
119  const TArray<FVehicleParameters> &ParameterArray,
120  TArray<FActorDefinition> &Definitions);
121 
122  UFUNCTION(Category = "Carla Actor", BlueprintCallable)
123  static void MakePedestrianDefinition(
124  const FPedestrianParameters &Parameters,
125  bool &Success,
126  FActorDefinition &Definition);
127 
128  UFUNCTION(Category = "Carla Actor", BlueprintCallable)
129  static void MakePedestrianDefinitions(
130  const TArray<FPedestrianParameters> &ParameterArray,
131  TArray<FActorDefinition> &Definitions);
132 
133  UFUNCTION(Category = "Carla Actor", BlueprintCallable)
134  static void MakeTriggerDefinitions(
135  const TArray<FString> &ParameterArray,
136  TArray<FActorDefinition> &Definitions);
137 
138  UFUNCTION(Category = "Carla Actor", BlueprintCallable)
139  static void MakeTriggerDefinition(
140  const FString &Id,
141  bool &Success,
142  FActorDefinition &Definition);
143 
144  UFUNCTION(Category = "Carla Actor", BlueprintCallable)
145  static void MakePropDefinition(
146  const FPropParameters &Parameters,
147  bool &Success,
148  FActorDefinition &Definition);
149 
150  UFUNCTION(Category = "Carla Actor", BlueprintCallable)
151  static void MakePropDefinitions(
152  const TArray<FPropParameters> &ParameterArray,
153  TArray<FActorDefinition> &Definitions);
154 
155  UFUNCTION()
156  static void MakeObstacleDetectorDefinitions(
157  const FString &Type,
158  const FString &Id,
159  FActorDefinition &Definition);
160 
161  /// @}
162  /// ==========================================================================
163  /// @name Helpers to retrieve attribute values
164  /// ==========================================================================
165  /// @{
166 
167  UFUNCTION(Category = "Carla Actor", BlueprintCallable)
168  static bool ActorAttributeToBool(const FActorAttribute &ActorAttribute, bool Default);
169 
170  UFUNCTION(Category = "Carla Actor", BlueprintCallable)
171  static int32 ActorAttributeToInt(const FActorAttribute &ActorAttribute, int32 Default);
172 
173  UFUNCTION(Category = "Carla Actor", BlueprintCallable)
174  static float ActorAttributeToFloat(const FActorAttribute &ActorAttribute, float Default);
175 
176  UFUNCTION(Category = "Carla Actor", BlueprintCallable)
177  static FString ActorAttributeToString(const FActorAttribute &ActorAttribute, const FString &Default);
178 
179  UFUNCTION(Category = "Carla Actor", BlueprintCallable)
180  static FColor ActorAttributeToColor(const FActorAttribute &ActorAttribute, const FColor &Default);
181 
182  UFUNCTION(Category = "Carla Actor", BlueprintCallable)
183  static bool RetrieveActorAttributeToBool(
184  const FString &Id,
185  const TMap<FString, FActorAttribute> &Attributes,
186  bool Default);
187 
188  UFUNCTION(Category = "Carla Actor", BlueprintCallable)
189  static int32 RetrieveActorAttributeToInt(
190  const FString &Id,
191  const TMap<FString, FActorAttribute> &Attributes,
192  int32 Default);
193 
194  UFUNCTION(Category = "Carla Actor", BlueprintCallable)
195  static float RetrieveActorAttributeToFloat(
196  const FString &Id,
197  const TMap<FString, FActorAttribute> &Attributes,
198  float Default);
199 
200  UFUNCTION(Category = "Carla Actor", BlueprintCallable)
201  static FString RetrieveActorAttributeToString(
202  const FString &Id,
203  const TMap<FString, FActorAttribute> &Attributes,
204  const FString &Default);
205 
206  UFUNCTION(Category = "Carla Actor", BlueprintCallable)
207  static FColor RetrieveActorAttributeToColor(
208  const FString &Id,
209  const TMap<FString, FActorAttribute> &Attributes,
210  const FColor &Default);
211 
212  /// @}
213  /// ==========================================================================
214  /// @name Helpers to set Actors
215  /// ==========================================================================
216  /// @{
217 
218  UFUNCTION(Category = "Carla Actor", BlueprintCallable)
219  static void SetCamera(const FActorDescription &Description, ASceneCaptureSensor *Camera);
220  static void SetCamera(const FActorDescription &Description, AShaderBasedSensor *Camera);
221 
222  static void SetLidar(const FActorDescription &Description, FLidarDescription &Lidar);
223 
224  static void SetGnss(const FActorDescription &Description, AGnssSensor *Gnss);
225 
226  static void SetIMU(const FActorDescription &Description, AInertialMeasurementUnit *IMU);
227 
228  static void SetRadar(const FActorDescription &Description, ARadar *Radar);
229 };
A sensor that produces data by applying post-process materials (shaders) to a scene capture image...
A definition of a Carla Actor with all the variation and attributes.
A ray-cast based Radar sensor.
Definition: Radar.h:21
A description of a Carla Actor with all its variation.
Gnss sensor representation The actual position calculation is done one server side.
Definition: GnssSensor.h:23
Base class for sensors using a USceneCaptureComponent2D for rendering the scene.
An actor attribute, may be an intrinsic (non-modifiable) attribute of the actor or an user-defined ac...