CARLA
ActorBlueprintFunctionLibrary.cpp
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 #include "Carla.h"
9 
13 #include "Carla/Util/ScopedStack.h"
14 
15 #include <algorithm>
16 #include <limits>
17 #include <stack>
18 
19 /// Checks validity of FActorDefinition.
21 {
22 public:
23 
24  /// Iterate all actor definitions and their properties and display messages on
25  /// error.
26  bool AreValid(const TArray<FActorDefinition> &ActorDefinitions)
27  {
28  return AreValid(TEXT("Actor Definition"), ActorDefinitions);
29  }
30 
31  /// Validate @a ActorDefinition and display messages on error.
32  bool SingleIsValid(const FActorDefinition &Definition)
33  {
34  auto ScopeText = FString::Printf(TEXT("[Actor Definition : %s]"), *Definition.Id);
35  auto Scope = Stack.PushScope(ScopeText);
36  return IsValid(Definition);
37  }
38 
39 private:
40 
41  /// If @a Predicate is false, print an error message. If possible the message
42  /// is printed to the editor window.
43  template <typename T, typename ... ARGS>
44  bool OnScreenAssert(bool Predicate, const T &Format, ARGS && ... Args) const
45  {
46  if (!Predicate)
47  {
48  FString Message;
49  for (auto &String : Stack)
50  {
51  Message += String;
52  }
53  Message += TEXT(" ");
54  Message += FString::Printf(Format, std::forward<ARGS>(Args) ...);
55 
56  UE_LOG(LogCarla, Error, TEXT("%s"), *Message);
57 #if WITH_EDITOR
58  if (GEngine)
59  {
60  GEngine->AddOnScreenDebugMessage(42, 15.0f, FColor::Red, Message);
61  }
62 #endif // WITH_EDITOR
63  }
64  return Predicate;
65  }
66 
67  template <typename T>
68  FString GetDisplayId(const FString &Type, size_t Index, const T &Item)
69  {
70  return FString::Printf(TEXT("[%s %d : %s]"), *Type, Index, *Item.Id);
71  }
72 
73  FString GetDisplayId(const FString &Type, size_t Index, const FString &Item)
74  {
75  return FString::Printf(TEXT("[%s %d : %s]"), *Type, Index, *Item);
76  }
77 
78  /// Applies @a Validator to each item in @a Array. Pushes a new context to the
79  /// stack for each item.
80  template <typename T, typename F>
81  bool ForEach(const FString &Type, const TArray<T> &Array, F Validator)
82  {
83  bool Result = true;
84  auto Counter = 0u;
85  for (const auto &Item : Array)
86  {
87  auto Scope = Stack.PushScope(GetDisplayId(Type, Counter, Item));
88  Result &= Validator(Item);
89  ++Counter;
90  }
91  return Result;
92  }
93 
94  /// Applies @a IsValid to each item in @a Array. Pushes a new context to the
95  /// stack for each item.
96  template <typename T>
97  bool AreValid(const FString &Type, const TArray<T> &Array)
98  {
99  return ForEach(Type, Array, [this](const auto &Item) { return IsValid(Item); });
100  }
101 
102  bool IsIdValid(const FString &Id)
103  {
104  /// @todo Do more checks.
105  return OnScreenAssert((!Id.IsEmpty() && Id != TEXT(".")), TEXT("Id cannot be empty"));
106  }
107 
108  bool AreTagsValid(const FString &Tags)
109  {
110  /// @todo Do more checks.
111  return OnScreenAssert(!Tags.IsEmpty(), TEXT("Tags cannot be empty"));
112  }
113 
114  bool IsValid(const EActorAttributeType Type)
115  {
116  /// @todo Do more checks.
117  return OnScreenAssert(Type < EActorAttributeType::SIZE, TEXT("Invalid type"));
118  }
119 
120  bool ValueIsValid(const EActorAttributeType Type, const FString &Value)
121  {
122  /// @todo Do more checks.
123  return true;
124  }
125 
126  bool IsValid(const FActorVariation &Variation)
127  {
128  return
129  IsIdValid(Variation.Id) &&
130  IsValid(Variation.Type) &&
131  OnScreenAssert(Variation.RecommendedValues.Num() > 0, TEXT("Recommended values cannot be empty")) &&
132  ForEach(TEXT("Recommended Value"), Variation.RecommendedValues, [&](auto &Value) {
133  return ValueIsValid(Variation.Type, Value);
134  });
135  }
136 
137  bool IsValid(const FActorAttribute &Attribute)
138  {
139  return
140  IsIdValid(Attribute.Id) &&
141  IsValid(Attribute.Type) &&
142  ValueIsValid(Attribute.Type, Attribute.Value);
143  }
144 
145  bool IsValid(const FActorDefinition &ActorDefinition)
146  {
147  /// @todo Validate Class and make sure IDs are not repeated.
148  return
149  IsIdValid(ActorDefinition.Id) &&
150  AreTagsValid(ActorDefinition.Tags) &&
151  AreValid(TEXT("Variation"), ActorDefinition.Variations) &&
152  AreValid(TEXT("Attribute"), ActorDefinition.Attributes);
153  }
154 
156 };
157 
158 template <typename ... ARGS>
159 static FString JoinStrings(const FString &Separator, ARGS && ... Args)
160 {
161  return FString::Join(TArray<FString>{std::forward<ARGS>(Args) ...}, *Separator);
162 }
163 
164 static FString ColorToFString(const FColor &Color)
165 {
166  return JoinStrings(
167  TEXT(","),
168  FString::FromInt(Color.R),
169  FString::FromInt(Color.G),
170  FString::FromInt(Color.B));
171 }
172 
173 /// ============================================================================
174 /// -- Actor definition validators ---------------------------------------------
175 /// ============================================================================
176 
178 {
179  FActorDefinitionValidator Validator;
180  return Validator.SingleIsValid(ActorDefinition);
181 }
182 
183 bool UActorBlueprintFunctionLibrary::CheckActorDefinitions(const TArray<FActorDefinition> &ActorDefinitions)
184 {
185  FActorDefinitionValidator Validator;
186  return Validator.AreValid(ActorDefinitions);
187 }
188 
189 /// ============================================================================
190 /// -- Helpers to create actor definitions -------------------------------------
191 /// ============================================================================
192 
193 template <typename ... TStrs>
194 static void FillIdAndTags(FActorDefinition &Def, TStrs && ... Strings)
195 {
196  Def.Id = JoinStrings(TEXT("."), std::forward<TStrs>(Strings) ...).ToLower();
197  Def.Tags = JoinStrings(TEXT(","), std::forward<TStrs>(Strings) ...).ToLower();
198  // each actor gets an actor role name attribute (empty by default)
199  FActorVariation ActorRole;
200  ActorRole.Id = TEXT("role_name");
201  ActorRole.Type = EActorAttributeType::String;
202  ActorRole.RecommendedValues = { TEXT("default") };
203  ActorRole.bRestrictToRecommended = false;
204  Def.Variations.Emplace(ActorRole);
205 }
206 
208  FActorDefinition &Definition,
209  TArray<FString> &&RecommendedValues)
210 {
211  for (auto &&ActorVariation: Definition.Variations)
212  {
213  if (ActorVariation.Id == "role_name")
214  {
215  ActorVariation.RecommendedValues = RecommendedValues;
216  return;
217  }
218  }
219 }
220 
222 {
223  AddRecommendedValuesForActorRoleName(Definition, {TEXT("front"), TEXT("back"), TEXT("left"), TEXT(
224  "right"), TEXT("front_left"), TEXT("front_right"), TEXT("back_left"), TEXT("back_right")});
225 }
226 
228 {
229  FActorVariation Tick;
230 
231  Tick.Id = TEXT("sensor_tick");
233  Tick.RecommendedValues = { TEXT("0.0") };
234  Tick.bRestrictToRecommended = false;
235 
236  Def.Variations.Emplace(Tick);
237 }
238 
240 {
241  // Friction
242  FActorVariation Friction;
243  Friction.Id = FString("friction");
244  Friction.Type = EActorAttributeType::Float;
245  Friction.RecommendedValues = { TEXT("3.5f") };
246  Friction.bRestrictToRecommended = false;
247  Def.Variations.Emplace(Friction);
248 
249  // Extent
250  FString Extent("extent");
251  FString Coordinates[3] = {FString("x"), FString("y"), FString("z")};
252 
253  for (auto Coordinate : Coordinates)
254  {
255  FActorVariation ExtentCoordinate;
256 
257  ExtentCoordinate.Id = JoinStrings(TEXT("_"), Extent, Coordinate);
258  ExtentCoordinate.Type = EActorAttributeType::Float;
259  ExtentCoordinate.RecommendedValues = { TEXT("1.0f") };
260  ExtentCoordinate.bRestrictToRecommended = false;
261 
262  Def.Variations.Emplace(ExtentCoordinate);
263  }
264 }
265 
267  const FString &Category,
268  const FString &Type,
269  const FString &Id)
270 {
271  FActorDefinition Definition;
272  FillIdAndTags(Definition, Category, Type, Id);
273  return Definition;
274 }
275 
277  const FString &Type,
278  const FString &Id)
279 {
280  auto Definition = MakeGenericDefinition(TEXT("sensor"), Type, Id);
282  return Definition;
283 }
284 
286  const FString &Id,
287  const bool bEnableModifyingPostProcessEffects)
288 {
289  FActorDefinition Definition;
290  bool Success;
291  MakeCameraDefinition(Id, bEnableModifyingPostProcessEffects, Success, Definition);
292  check(Success);
293  return Definition;
294 }
295 
297  const FString &Id,
298  const bool bEnableModifyingPostProcessEffects,
299  bool &Success,
300  FActorDefinition &Definition)
301 {
302  FillIdAndTags(Definition, TEXT("sensor"), TEXT("camera"), Id);
304  AddVariationsForSensor(Definition);
305 
306  // FOV
307  FActorVariation FOV;
308  FOV.Id = TEXT("fov");
310  FOV.RecommendedValues = { TEXT("90.0") };
311  FOV.bRestrictToRecommended = false;
312 
313  // Resolution
314  FActorVariation ResX;
315  ResX.Id = TEXT("image_size_x");
317  ResX.RecommendedValues = { TEXT("800") };
318  ResX.bRestrictToRecommended = false;
319 
320  FActorVariation ResY;
321  ResY.Id = TEXT("image_size_y");
323  ResY.RecommendedValues = { TEXT("600") };
324  ResY.bRestrictToRecommended = false;
325 
326  // Lens parameters
327  FActorVariation LensCircleFalloff;
328  LensCircleFalloff.Id = TEXT("lens_circle_falloff");
329  LensCircleFalloff.Type = EActorAttributeType::Float;
330  LensCircleFalloff.RecommendedValues = { TEXT("5.0") };
331  LensCircleFalloff.bRestrictToRecommended = false;
332 
333  FActorVariation LensCircleMultiplier;
334  LensCircleMultiplier.Id = TEXT("lens_circle_multiplier");
335  LensCircleMultiplier.Type = EActorAttributeType::Float;
336  LensCircleMultiplier.RecommendedValues = { TEXT("0.0") };
337  LensCircleMultiplier.bRestrictToRecommended = false;
338 
339  FActorVariation LensK;
340  LensK.Id = TEXT("lens_k");
342  LensK.RecommendedValues = { TEXT("-1.0") };
343  LensK.bRestrictToRecommended = false;
344 
345  FActorVariation LensKcube;
346  LensKcube.Id = TEXT("lens_kcube");
347  LensKcube.Type = EActorAttributeType::Float;
348  LensKcube.RecommendedValues = { TEXT("0.0") };
349  LensKcube.bRestrictToRecommended = false;
350 
351  FActorVariation LensXSize;
352  LensXSize.Id = TEXT("lens_x_size");
353  LensXSize.Type = EActorAttributeType::Float;
354  LensXSize.RecommendedValues = { TEXT("0.08") };
355  LensXSize.bRestrictToRecommended = false;
356 
357  FActorVariation LensYSize;
358  LensYSize.Id = TEXT("lens_y_size");
359  LensYSize.Type = EActorAttributeType::Float;
360  LensYSize.RecommendedValues = { TEXT("0.08") };
361  LensYSize.bRestrictToRecommended = false;
362 
363  Definition.Variations.Append({
364  ResX,
365  ResY,
366  FOV,
367  LensCircleFalloff,
368  LensCircleMultiplier,
369  LensK,
370  LensKcube,
371  LensXSize,
372  LensYSize});
373 
374  if (bEnableModifyingPostProcessEffects)
375  {
376  FActorVariation PostProccess;
377  PostProccess.Id = TEXT("enable_postprocess_effects");
378  PostProccess.Type = EActorAttributeType::Bool;
379  PostProccess.RecommendedValues = { TEXT("true") };
380  PostProccess.bRestrictToRecommended = false;
381 
382  // Gamma
383  FActorVariation Gamma;
384  Gamma.Id = TEXT("gamma");
386  Gamma.RecommendedValues = { TEXT("2.2") };
387  Gamma.bRestrictToRecommended = false;
388 
389  // Motion Blur
390  FActorVariation MBIntesity;
391  MBIntesity.Id = TEXT("motion_blur_intensity");
392  MBIntesity.Type = EActorAttributeType::Float;
393  MBIntesity.RecommendedValues = { TEXT("0.45") };
394  MBIntesity.bRestrictToRecommended = false;
395 
396  FActorVariation MBMaxDistortion;
397  MBMaxDistortion.Id = TEXT("motion_blur_max_distortion");
398  MBMaxDistortion.Type = EActorAttributeType::Float;
399  MBMaxDistortion.RecommendedValues = { TEXT("0.35") };
400  MBMaxDistortion.bRestrictToRecommended = false;
401 
402  FActorVariation MBMinObjectScreenSize;
403  MBMinObjectScreenSize.Id = TEXT("motion_blur_min_object_screen_size");
404  MBMinObjectScreenSize.Type = EActorAttributeType::Float;
405  MBMinObjectScreenSize.RecommendedValues = { TEXT("0.1") };
406  MBMinObjectScreenSize.bRestrictToRecommended = false;
407 
408  // Lens Flare
409  FActorVariation LensFlareIntensity;
410  LensFlareIntensity.Id = TEXT("lens_flare_intensity");
411  LensFlareIntensity.Type = EActorAttributeType::Float;
412  LensFlareIntensity.RecommendedValues = { TEXT("0.1") };
413  LensFlareIntensity.bRestrictToRecommended = false;
414 
415  // Bloom
416  FActorVariation BloomIntensity;
417  BloomIntensity.Id = TEXT("bloom_intensity");
418  BloomIntensity.Type = EActorAttributeType::Float;
419  BloomIntensity.RecommendedValues = { TEXT("0.675") };
420  BloomIntensity.bRestrictToRecommended = false;
421 
422  // More info at:
423  // https://docs.unrealengine.com/en-US/Engine/Rendering/PostProcessEffects/AutomaticExposure/index.html
424  // https://docs.unrealengine.com/en-US/Engine/Rendering/PostProcessEffects/DepthOfField/CinematicDOFMethods/index.html
425  // https://docs.unrealengine.com/en-US/Engine/Rendering/PostProcessEffects/ColorGrading/index.html
426 
427  // Exposure
428  FActorVariation ExposureMode;
429  ExposureMode.Id = TEXT("exposure_mode");
430  ExposureMode.Type = EActorAttributeType::String;
431  ExposureMode.RecommendedValues = { TEXT("histogram"), TEXT("manual") };
432  ExposureMode.bRestrictToRecommended = true;
433 
434  // Logarithmic adjustment for the exposure. Only used if a tonemapper is
435  // specified.
436  // 0 : no adjustment
437  // -1 : 2x darker
438  // -2 : 4x darker
439  // 1 : 2x brighter
440  // 2 : 4x brighter.
441  FActorVariation ExposureCompensation;
442  ExposureCompensation.Id = TEXT("exposure_compensation");
443  ExposureCompensation.Type = EActorAttributeType::Float;
444  ExposureCompensation.RecommendedValues = { TEXT("0.0") };
445  ExposureCompensation.bRestrictToRecommended = false;
446 
447  // - Manual ------------------------------------------------
448 
449  // The formula used to compute the camera exposure scale is:
450  // Exposure = 1 / (1.2 * 2^(log2( NĀ²/t * 100/S )))
451 
452  // The camera shutter speed in seconds.
453  FActorVariation ShutterSpeed; // (1/t)
454  ShutterSpeed.Id = TEXT("shutter_speed");
455  ShutterSpeed.Type = EActorAttributeType::Float;
456  ShutterSpeed.RecommendedValues = { TEXT("200.0") };
457  ShutterSpeed.bRestrictToRecommended = false;
458 
459  // The camera sensor sensitivity.
460  FActorVariation ISO; // S
461  ISO.Id = TEXT("iso");
463  ISO.RecommendedValues = { TEXT("100.0") };
464  ISO.bRestrictToRecommended = false;
465 
466  // Defines the size of the opening for the camera lens.
467  // Using larger numbers will reduce the DOF effect.
468  FActorVariation Aperture; // N
469  Aperture.Id = TEXT("fstop");
470  Aperture.Type = EActorAttributeType::Float;
471  Aperture.RecommendedValues = { TEXT("1.4") };
472  Aperture.bRestrictToRecommended = false;
473 
474  // - Histogram ---------------------------------------------
475 
476  // The minimum brightness for auto exposure that limits the lower
477  // brightness the eye can adapt within
478  FActorVariation ExposureMinBright;
479  ExposureMinBright.Id = TEXT("exposure_min_bright");
480  ExposureMinBright.Type = EActorAttributeType::Float;
481  ExposureMinBright.RecommendedValues = { TEXT("7.0") };
482  ExposureMinBright.bRestrictToRecommended = false;
483 
484  // The maximum brightness for auto exposure that limits the upper
485  // brightness the eye can adapt within
486  FActorVariation ExposureMaxBright;
487  ExposureMaxBright.Id = TEXT("exposure_max_bright");
488  ExposureMaxBright.Type = EActorAttributeType::Float;
489  ExposureMaxBright.RecommendedValues = { TEXT("9.0") };
490  ExposureMaxBright.bRestrictToRecommended = false;
491 
492  // The speed at which the adaptation occurs from a dark environment
493  // to a bright environment.
494  FActorVariation ExposureSpeedUp;
495  ExposureSpeedUp.Id = TEXT("exposure_speed_up");
496  ExposureSpeedUp.Type = EActorAttributeType::Float;
497  ExposureSpeedUp.RecommendedValues = { TEXT("3.0") };
498  ExposureSpeedUp.bRestrictToRecommended = false;
499 
500  // The speed at which the adaptation occurs from a bright environment
501  // to a dark environment.
502  FActorVariation ExposureSpeedDown;
503  ExposureSpeedDown.Id = TEXT("exposure_speed_down");
504  ExposureSpeedDown.Type = EActorAttributeType::Float;
505  ExposureSpeedDown.RecommendedValues = { TEXT("1.0") };
506  ExposureSpeedDown.bRestrictToRecommended = false;
507 
508  // Calibration constant for 18% Albedo.
509  FActorVariation CalibrationConstant;
510  CalibrationConstant.Id = TEXT("calibration_constant");
511  CalibrationConstant.Type = EActorAttributeType::Float;
512  CalibrationConstant.RecommendedValues = { TEXT("16.0") };
513  CalibrationConstant.bRestrictToRecommended = false;
514 
515  // Distance in which the Depth of Field effect should be sharp,
516  // in unreal units (cm)
517  FActorVariation FocalDistance;
518  FocalDistance.Id = TEXT("focal_distance");
519  FocalDistance.Type = EActorAttributeType::Float;
520  FocalDistance.RecommendedValues = { TEXT("1000.0") };
521  FocalDistance.bRestrictToRecommended = false;
522 
523  // Depth blur km for 50%
524  FActorVariation DepthBlurAmount;
525  DepthBlurAmount.Id = TEXT("blur_amount");
526  DepthBlurAmount.Type = EActorAttributeType::Float;
527  DepthBlurAmount.RecommendedValues = { TEXT("1.0") };
528  DepthBlurAmount.bRestrictToRecommended = false;
529 
530  // Depth blur radius in pixels at 1920x
531  FActorVariation DepthBlurRadius;
532  DepthBlurRadius.Id = TEXT("blur_radius");
533  DepthBlurRadius.Type = EActorAttributeType::Float;
534  DepthBlurRadius.RecommendedValues = { TEXT("0.0") };
535  DepthBlurRadius.bRestrictToRecommended = false;
536 
537  // Defines the opening of the camera lens, Aperture is 1.0/fstop,
538  // typical lens go down to f/1.2 (large opening),
539  // larger numbers reduce the DOF effect
540  FActorVariation MaxAperture;
541  MaxAperture.Id = TEXT("min_fstop");
542  MaxAperture.Type = EActorAttributeType::Float;
543  MaxAperture.RecommendedValues = { TEXT("1.2") };
544  MaxAperture.bRestrictToRecommended = false;
545 
546  // Defines the number of blades of the diaphragm within the
547  // lens (between 4 and 16)
548  FActorVariation BladeCount;
549  BladeCount.Id = TEXT("blade_count");
550  BladeCount.Type = EActorAttributeType::Int;
551  BladeCount.RecommendedValues = { TEXT("5") };
552  BladeCount.bRestrictToRecommended = false;
553 
554  // - Tonemapper Settings -----------------------------------
555  // You can adjust these tonemapper controls to emulate other
556  // types of film stock for your project
557  FActorVariation FilmSlope;
558  FilmSlope.Id = TEXT("slope");
559  FilmSlope.Type = EActorAttributeType::Float;
560  FilmSlope.RecommendedValues = { TEXT("0.88") };
561  FilmSlope.bRestrictToRecommended = false;
562 
563  FActorVariation FilmToe;
564  FilmToe.Id = TEXT("toe");
566  FilmToe.RecommendedValues = { TEXT("0.55") };
567  FilmToe.bRestrictToRecommended = false;
568 
569  FActorVariation FilmShoulder;
570  FilmShoulder.Id = TEXT("shoulder");
571  FilmShoulder.Type = EActorAttributeType::Float;
572  FilmShoulder.RecommendedValues = { TEXT("0.26") };
573  FilmShoulder.bRestrictToRecommended = false;
574 
575  FActorVariation FilmBlackClip;
576  FilmBlackClip.Id = TEXT("black_clip");
577  FilmBlackClip.Type = EActorAttributeType::Float;
578  FilmBlackClip.RecommendedValues = { TEXT("0.0") };
579  FilmBlackClip.bRestrictToRecommended = false;
580 
581  FActorVariation FilmWhiteClip;
582  FilmWhiteClip.Id = TEXT("white_clip");
583  FilmWhiteClip.Type = EActorAttributeType::Float;
584  FilmWhiteClip.RecommendedValues = { TEXT("0.04") };
585  FilmWhiteClip.bRestrictToRecommended = false;
586 
587  // Color
588  FActorVariation Temperature;
589  Temperature.Id = TEXT("temp");
590  Temperature.Type = EActorAttributeType::Float;
591  Temperature.RecommendedValues = { TEXT("6500.0") };
592  Temperature.bRestrictToRecommended = false;
593 
594  FActorVariation Tint;
595  Tint.Id = TEXT("tint");
597  Tint.RecommendedValues = { TEXT("0.0") };
598  Tint.bRestrictToRecommended = false;
599 
600  FActorVariation ChromaticIntensity;
601  ChromaticIntensity.Id = TEXT("chromatic_aberration_intensity");
602  ChromaticIntensity.Type = EActorAttributeType::Float;
603  ChromaticIntensity.RecommendedValues = { TEXT("0.0") };
604  ChromaticIntensity.bRestrictToRecommended = false;
605 
606  FActorVariation ChromaticOffset;
607  ChromaticOffset.Id = TEXT("chromatic_aberration_offset");
608  ChromaticOffset.Type = EActorAttributeType::Float;
609  ChromaticOffset.RecommendedValues = { TEXT("0.0") };
610  ChromaticOffset.bRestrictToRecommended = false;
611 
612  Definition.Variations.Append({
613  ExposureMode,
614  ExposureCompensation,
615  ShutterSpeed,
616  ISO,
617  Aperture,
618  PostProccess,
619  Gamma,
620  MBIntesity,
621  MBMaxDistortion,
622  LensFlareIntensity,
623  BloomIntensity,
624  MBMinObjectScreenSize,
625  ExposureMinBright,
626  ExposureMaxBright,
627  ExposureSpeedUp,
628  ExposureSpeedDown,
629  CalibrationConstant,
630  FocalDistance,
631  MaxAperture,
632  BladeCount,
633  DepthBlurAmount,
634  DepthBlurRadius,
635  FilmSlope,
636  FilmToe,
637  FilmShoulder,
638  FilmBlackClip,
639  FilmWhiteClip,
640  Temperature,
641  Tint,
642  ChromaticIntensity,
643  ChromaticOffset});
644  }
645 
646  Success = CheckActorDefinition(Definition);
647 }
648 
650 {
651  FActorDefinition Definition;
652  bool Success;
653  MakeIMUDefinition(Success, Definition);
654  check(Success);
655  return Definition;
656 }
657 
659  bool &Success,
660  FActorDefinition &Definition)
661 {
662  FillIdAndTags(Definition, TEXT("sensor"), TEXT("other"), TEXT("imu"));
663  AddVariationsForSensor(Definition);
664 
665  // - Noise seed --------------------------------
666  FActorVariation NoiseSeed;
667  NoiseSeed.Id = TEXT("noise_seed");
668  NoiseSeed.Type = EActorAttributeType::Int;
669  NoiseSeed.RecommendedValues = { TEXT("0") };
670  NoiseSeed.bRestrictToRecommended = false;
671 
672  // - Accelerometer Standard Deviation ----------
673  // X Component
674  FActorVariation StdDevAccelX;
675  StdDevAccelX.Id = TEXT("noise_accel_stddev_x");
676  StdDevAccelX.Type = EActorAttributeType::Float;
677  StdDevAccelX.RecommendedValues = { TEXT("0.0") };
678  StdDevAccelX.bRestrictToRecommended = false;
679  // Y Component
680  FActorVariation StdDevAccelY;
681  StdDevAccelY.Id = TEXT("noise_accel_stddev_y");
682  StdDevAccelY.Type = EActorAttributeType::Float;
683  StdDevAccelY.RecommendedValues = { TEXT("0.0") };
684  StdDevAccelY.bRestrictToRecommended = false;
685  // Z Component
686  FActorVariation StdDevAccelZ;
687  StdDevAccelZ.Id = TEXT("noise_accel_stddev_z");
688  StdDevAccelZ.Type = EActorAttributeType::Float;
689  StdDevAccelZ.RecommendedValues = { TEXT("0.0") };
690  StdDevAccelZ.bRestrictToRecommended = false;
691 
692  // - Gyroscope Standard Deviation --------------
693  // X Component
694  FActorVariation StdDevGyroX;
695  StdDevGyroX.Id = TEXT("noise_gyro_stddev_x");
696  StdDevGyroX.Type = EActorAttributeType::Float;
697  StdDevGyroX.RecommendedValues = { TEXT("0.0") };
698  StdDevGyroX.bRestrictToRecommended = false;
699  // Y Component
700  FActorVariation StdDevGyroY;
701  StdDevGyroY.Id = TEXT("noise_gyro_stddev_y");
702  StdDevGyroY.Type = EActorAttributeType::Float;
703  StdDevGyroY.RecommendedValues = { TEXT("0.0") };
704  StdDevGyroY.bRestrictToRecommended = false;
705  // Z Component
706  FActorVariation StdDevGyroZ;
707  StdDevGyroZ.Id = TEXT("noise_gyro_stddev_z");
708  StdDevGyroZ.Type = EActorAttributeType::Float;
709  StdDevGyroZ.RecommendedValues = { TEXT("0.0") };
710  StdDevGyroZ.bRestrictToRecommended = false;
711 
712  // - Gyroscope Bias ----------------------------
713  // X Component
714  FActorVariation BiasGyroX;
715  BiasGyroX.Id = TEXT("noise_gyro_bias_x");
716  BiasGyroX.Type = EActorAttributeType::Float;
717  BiasGyroX.RecommendedValues = { TEXT("0.0") };
718  BiasGyroX.bRestrictToRecommended = false;
719  // Y Component
720  FActorVariation BiasGyroY;
721  BiasGyroY.Id = TEXT("noise_gyro_bias_y");
722  BiasGyroY.Type = EActorAttributeType::Float;
723  BiasGyroY.RecommendedValues = { TEXT("0.0") };
724  BiasGyroY.bRestrictToRecommended = false;
725  // Z Component
726  FActorVariation BiasGyroZ;
727  BiasGyroZ.Id = TEXT("noise_gyro_bias_z");
728  BiasGyroZ.Type = EActorAttributeType::Float;
729  BiasGyroZ.RecommendedValues = { TEXT("0.0") };
730  BiasGyroZ.bRestrictToRecommended = false;
731 
732  Definition.Variations.Append({
733  NoiseSeed,
734  StdDevAccelX,
735  StdDevAccelY,
736  StdDevAccelZ,
737  StdDevGyroX,
738  StdDevGyroY,
739  StdDevGyroZ,
740  BiasGyroX,
741  BiasGyroY,
742  BiasGyroZ});
743 
744  Success = CheckActorDefinition(Definition);
745 }
746 
748 {
749  FActorDefinition Definition;
750  bool Success;
751  MakeRadarDefinition(Success, Definition);
752  check(Success);
753  return Definition;
754 }
755 
757  bool &Success,
758  FActorDefinition &Definition)
759 {
760  FillIdAndTags(Definition, TEXT("sensor"), TEXT("other"), TEXT("radar"));
761  AddVariationsForSensor(Definition);
762 
763  FActorVariation HorizontalFOV;
764  HorizontalFOV.Id = TEXT("horizontal_fov");
765  HorizontalFOV.Type = EActorAttributeType::Float;
766  HorizontalFOV.RecommendedValues = { TEXT("30") };
767  HorizontalFOV.bRestrictToRecommended = false;
768 
769  FActorVariation VerticalFOV;
770  VerticalFOV.Id = TEXT("vertical_fov");
771  VerticalFOV.Type = EActorAttributeType::Float;
772  VerticalFOV.RecommendedValues = { TEXT("30") };
773  VerticalFOV.bRestrictToRecommended = false;
774 
775  FActorVariation Range;
776  Range.Id = TEXT("range");
778  Range.RecommendedValues = { TEXT("100") };
779  Range.bRestrictToRecommended = false;
780 
781  FActorVariation PointsPerSecond;
782  PointsPerSecond.Id = TEXT("points_per_second");
783  PointsPerSecond.Type = EActorAttributeType::Int;
784  PointsPerSecond.RecommendedValues = { TEXT("1500") };
785  PointsPerSecond.bRestrictToRecommended = false;
786 
787  // Noise seed
788  FActorVariation NoiseSeed;
789  NoiseSeed.Id = TEXT("noise_seed");
790  NoiseSeed.Type = EActorAttributeType::Int;
791  NoiseSeed.RecommendedValues = { TEXT("0") };
792  NoiseSeed.bRestrictToRecommended = false;
793 
794  Definition.Variations.Append({
795  HorizontalFOV,
796  VerticalFOV,
797  Range,
798  PointsPerSecond,
799  NoiseSeed});
800 
801  Success = CheckActorDefinition(Definition);
802 }
803 
805  const FString &Id)
806 {
807  FActorDefinition Definition;
808  bool Success;
809  MakeLidarDefinition(Id, Success, Definition);
810  check(Success);
811  return Definition;
812 }
813 
815  const FString &Id,
816  bool &Success,
817  FActorDefinition &Definition)
818 {
819  FillIdAndTags(Definition, TEXT("sensor"), TEXT("lidar"), Id);
821  AddVariationsForSensor(Definition);
822  // Number of channels.
823  FActorVariation Channels;
824  Channels.Id = TEXT("channels");
825  Channels.Type = EActorAttributeType::Int;
826  Channels.RecommendedValues = { TEXT("32") };
827  // Range.
828  FActorVariation Range;
829  Range.Id = TEXT("range");
831  Range.RecommendedValues = { TEXT("10.0") }; // 10 meters
832  // Points per second.
833  FActorVariation PointsPerSecond;
834  PointsPerSecond.Id = TEXT("points_per_second");
835  PointsPerSecond.Type = EActorAttributeType::Int;
836  PointsPerSecond.RecommendedValues = { TEXT("56000") };
837  // Frequency.
838  FActorVariation Frequency;
839  Frequency.Id = TEXT("rotation_frequency");
840  Frequency.Type = EActorAttributeType::Float;
841  Frequency.RecommendedValues = { TEXT("10.0") };
842  // Upper FOV limit.
843  FActorVariation UpperFOV;
844  UpperFOV.Id = TEXT("upper_fov");
845  UpperFOV.Type = EActorAttributeType::Float;
846  UpperFOV.RecommendedValues = { TEXT("10.0") };
847  // Lower FOV limit.
848  FActorVariation LowerFOV;
849  LowerFOV.Id = TEXT("lower_fov");
850  LowerFOV.Type = EActorAttributeType::Float;
851  LowerFOV.RecommendedValues = { TEXT("-30.0") };
852  // Horizontal FOV.
853  FActorVariation HorizontalFOV;
854  HorizontalFOV.Id = TEXT("horizontal_fov");
855  HorizontalFOV.Type = EActorAttributeType::Float;
856  HorizontalFOV.RecommendedValues = { TEXT("360.0") };
857  // Atmospheric Attenuation Rate.
858  FActorVariation AtmospAttenRate;
859  AtmospAttenRate.Id = TEXT("atmosphere_attenuation_rate");
860  AtmospAttenRate.Type = EActorAttributeType::Float;
861  AtmospAttenRate.RecommendedValues = { TEXT("0.004") };
862  // Noise seed
863  FActorVariation NoiseSeed;
864  NoiseSeed.Id = TEXT("noise_seed");
865  NoiseSeed.Type = EActorAttributeType::Int;
866  NoiseSeed.RecommendedValues = { TEXT("0") };
867  NoiseSeed.bRestrictToRecommended = false;
868  // Dropoff General Rate
869  FActorVariation DropOffGenRate;
870  DropOffGenRate.Id = TEXT("dropoff_general_rate");
871  DropOffGenRate.Type = EActorAttributeType::Float;
872  DropOffGenRate.RecommendedValues = { TEXT("0.45") };
873  // Dropoff intensity limit.
874  FActorVariation DropOffIntensityLimit;
875  DropOffIntensityLimit.Id = TEXT("dropoff_intensity_limit");
876  DropOffIntensityLimit.Type = EActorAttributeType::Float;
877  DropOffIntensityLimit.RecommendedValues = { TEXT("0.8") };
878  // Dropoff at zero intensity.
879  FActorVariation DropOffAtZeroIntensity;
880  DropOffAtZeroIntensity.Id = TEXT("dropoff_zero_intensity");
881  DropOffAtZeroIntensity.Type = EActorAttributeType::Float;
882  DropOffAtZeroIntensity.RecommendedValues = { TEXT("0.4") };
883  // Noise in lidar cloud points.
884  FActorVariation StdDevLidar;
885  StdDevLidar.Id = TEXT("noise_stddev");
886  StdDevLidar.Type = EActorAttributeType::Float;
887  StdDevLidar.RecommendedValues = { TEXT("0.0") };
888 
889  if (Id == "ray_cast") {
890  Definition.Variations.Append({
891  Channels,
892  Range,
893  PointsPerSecond,
894  Frequency,
895  UpperFOV,
896  LowerFOV,
897  AtmospAttenRate,
898  NoiseSeed,
899  DropOffGenRate,
900  DropOffIntensityLimit,
901  DropOffAtZeroIntensity,
902  StdDevLidar,
903  HorizontalFOV});
904  }
905  else if (Id == "ray_cast_semantic") {
906  Definition.Variations.Append({
907  Channels,
908  Range,
909  PointsPerSecond,
910  Frequency,
911  UpperFOV,
912  LowerFOV,
913  HorizontalFOV});
914  }
915  else {
916  DEBUG_ASSERT(false);
917  }
918 
919  Success = CheckActorDefinition(Definition);
920 }
921 
923 {
924  FActorDefinition Definition;
925  bool Success;
926  MakeGnssDefinition(Success, Definition);
927  check(Success);
928  return Definition;
929 }
930 
932  bool &Success,
933  FActorDefinition &Definition)
934 {
935  FillIdAndTags(Definition, TEXT("sensor"), TEXT("other"), TEXT("gnss"));
936  AddVariationsForSensor(Definition);
937 
938  // - Noise seed --------------------------------
939  FActorVariation NoiseSeed;
940  NoiseSeed.Id = TEXT("noise_seed");
941  NoiseSeed.Type = EActorAttributeType::Int;
942  NoiseSeed.RecommendedValues = { TEXT("0") };
943  NoiseSeed.bRestrictToRecommended = false;
944 
945  // - Latitude ----------------------------------
946  FActorVariation StdDevLat;
947  StdDevLat.Id = TEXT("noise_lat_stddev");
948  StdDevLat.Type = EActorAttributeType::Float;
949  StdDevLat.RecommendedValues = { TEXT("0.0") };
950  StdDevLat.bRestrictToRecommended = false;
951  FActorVariation BiasLat;
952  BiasLat.Id = TEXT("noise_lat_bias");
954  BiasLat.RecommendedValues = { TEXT("0.0") };
955  BiasLat.bRestrictToRecommended = false;
956 
957  // - Longitude ---------------------------------
958  FActorVariation StdDevLong;
959  StdDevLong.Id = TEXT("noise_lon_stddev");
960  StdDevLong.Type = EActorAttributeType::Float;
961  StdDevLong.RecommendedValues = { TEXT("0.0") };
962  StdDevLong.bRestrictToRecommended = false;
963  FActorVariation BiasLong;
964  BiasLong.Id = TEXT("noise_lon_bias");
965  BiasLong.Type = EActorAttributeType::Float;
966  BiasLong.RecommendedValues = { TEXT("0.0") };
967  BiasLong.bRestrictToRecommended = false;
968 
969  // - Altitude ----------------------------------
970  FActorVariation StdDevAlt;
971  StdDevAlt.Id = TEXT("noise_alt_stddev");
972  StdDevAlt.Type = EActorAttributeType::Float;
973  StdDevAlt.RecommendedValues = { TEXT("0.0") };
974  StdDevAlt.bRestrictToRecommended = false;
975  FActorVariation BiasAlt;
976  BiasAlt.Id = TEXT("noise_alt_bias");
978  BiasAlt.RecommendedValues = { TEXT("0.0") };
979  BiasAlt.bRestrictToRecommended = false;
980 
981  Definition.Variations.Append({
982  NoiseSeed,
983  StdDevLat,
984  BiasLat,
985  StdDevLong,
986  BiasLong,
987  StdDevAlt,
988  BiasAlt});
989 
990  Success = CheckActorDefinition(Definition);
991 }
992 
994  const FVehicleParameters &Parameters,
995  bool &Success,
996  FActorDefinition &Definition)
997 {
998  /// @todo We need to validate here the params.
999  FillIdAndTags(Definition, TEXT("vehicle"), Parameters.Make, Parameters.Model);
1001  {TEXT("autopilot"), TEXT("scenario"), TEXT("ego_vehicle")});
1002  Definition.Class = Parameters.Class;
1003 
1004  if (Parameters.RecommendedColors.Num() > 0)
1005  {
1006  FActorVariation Colors;
1007  Colors.Id = TEXT("color");
1009  Colors.bRestrictToRecommended = false;
1010  for (auto &Color : Parameters.RecommendedColors)
1011  {
1012  Colors.RecommendedValues.Emplace(ColorToFString(Color));
1013  }
1014  Definition.Variations.Emplace(Colors);
1015  }
1016 
1017  if (Parameters.SupportedDrivers.Num() > 0)
1018  {
1019  FActorVariation Drivers;
1020  Drivers.Id = TEXT("driver_id");
1021  Drivers.Type = EActorAttributeType::Int;
1022  Drivers.bRestrictToRecommended = true;
1023  for (auto &Id : Parameters.SupportedDrivers)
1024  {
1025  Drivers.RecommendedValues.Emplace(FString::FromInt(Id));
1026  }
1027  Definition.Variations.Emplace(Drivers);
1028  }
1029 
1030  FActorVariation StickyControl;
1031  StickyControl.Id = TEXT("sticky_control");
1032  StickyControl.Type = EActorAttributeType::Bool;
1033  StickyControl.bRestrictToRecommended = false;
1034  StickyControl.RecommendedValues.Emplace(TEXT("true"));
1035  Definition.Variations.Emplace(StickyControl);
1036 
1037  Definition.Attributes.Emplace(FActorAttribute{
1038  TEXT("object_type"),
1040  Parameters.ObjectType});
1041 
1042  Definition.Attributes.Emplace(FActorAttribute{
1043  TEXT("number_of_wheels"),
1045  FString::FromInt(Parameters.NumberOfWheels)});
1046  Success = CheckActorDefinition(Definition);
1047 }
1048 
1049 template <typename T, typename Functor>
1051  const TArray<T> &ParameterArray,
1052  TArray<FActorDefinition> &Definitions,
1053  Functor Maker)
1054 {
1055  for (auto &Item : ParameterArray)
1056  {
1057  FActorDefinition Definition;
1058  bool Success = false;
1059  Maker(Item, Success, Definition);
1060  if (Success)
1061  {
1062  Definitions.Emplace(std::move(Definition));
1063  }
1064  }
1065 }
1066 
1068  const TArray<FVehicleParameters> &ParameterArray,
1069  TArray<FActorDefinition> &Definitions)
1070 {
1071  FillActorDefinitionArray(ParameterArray, Definitions, &MakeVehicleDefinition);
1072 }
1073 
1075  const FPedestrianParameters &Parameters,
1076  bool &Success,
1077  FActorDefinition &Definition)
1078 {
1079  /// @todo We need to validate here the params.
1080  FillIdAndTags(Definition, TEXT("walker"), TEXT("pedestrian"), Parameters.Id);
1081  AddRecommendedValuesForActorRoleName(Definition, {TEXT("pedestrian")});
1082  Definition.Class = Parameters.Class;
1083 
1084  auto GetGender = [](EPedestrianGender Value) {
1085  switch (Value)
1086  {
1087  case EPedestrianGender::Female: return TEXT("female");
1088  case EPedestrianGender::Male: return TEXT("male");
1089  default: return TEXT("other");
1090  }
1091  };
1092 
1093  auto GetAge = [](EPedestrianAge Value) {
1094  switch (Value)
1095  {
1096  case EPedestrianAge::Child: return TEXT("child");
1097  case EPedestrianAge::Teenager: return TEXT("teenager");
1098  case EPedestrianAge::Elderly: return TEXT("elderly");
1099  default: return TEXT("adult");
1100  }
1101  };
1102 
1103  Definition.Attributes.Emplace(FActorAttribute{
1104  TEXT("gender"),
1106  GetGender(Parameters.Gender)});
1107 
1108  Definition.Attributes.Emplace(FActorAttribute{
1109  TEXT("age"),
1111  GetAge(Parameters.Age)});
1112 
1113  if (Parameters.Speed.Num() > 0)
1114  {
1115  FActorVariation Speed;
1116  Speed.Id = TEXT("speed");
1118  for (auto &Value : Parameters.Speed)
1119  {
1120  Speed.RecommendedValues.Emplace(FString::SanitizeFloat(Value));
1121  }
1122  Speed.bRestrictToRecommended = false;
1123  Definition.Variations.Emplace(Speed);
1124  }
1125 
1126  FActorVariation IsInvincible;
1127  IsInvincible.Id = TEXT("is_invincible");
1128  IsInvincible.Type = EActorAttributeType::Bool;
1129  IsInvincible.RecommendedValues = { TEXT("true") };
1130  IsInvincible.bRestrictToRecommended = false;
1131  Definition.Variations.Emplace(IsInvincible);
1132 
1133  Success = CheckActorDefinition(Definition);
1134 }
1135 
1137  const TArray<FPedestrianParameters> &ParameterArray,
1138  TArray<FActorDefinition> &Definitions)
1139 {
1140  FillActorDefinitionArray(ParameterArray, Definitions, &MakePedestrianDefinition);
1141 }
1142 
1144  const TArray<FString> &ParameterArray,
1145  TArray<FActorDefinition> &Definitions)
1146 {
1147  FillActorDefinitionArray(ParameterArray, Definitions, &MakeTriggerDefinition);
1148 }
1149 
1151  const FString &Id,
1152  bool &Success,
1153  FActorDefinition &Definition)
1154 {
1155  FillIdAndTags(Definition, TEXT("static"), TEXT("trigger"), Id);
1156  AddVariationsForTrigger(Definition);
1157  Success = CheckActorDefinition(Definition);
1158  check(Success);
1159 }
1160 
1162  const FPropParameters &Parameters,
1163  bool &Success,
1164  FActorDefinition &Definition)
1165 {
1166  /// @todo We need to validate here the params.
1167  FillIdAndTags(Definition, TEXT("static"), TEXT("prop"), Parameters.Name);
1168  AddRecommendedValuesForActorRoleName(Definition, {TEXT("prop")});
1169 
1170  auto GetSize = [](EPropSize Value) {
1171  switch (Value)
1172  {
1173  case EPropSize::Tiny: return TEXT("tiny");
1174  case EPropSize::Small: return TEXT("small");
1175  case EPropSize::Medium: return TEXT("medium");
1176  case EPropSize::Big: return TEXT("big");
1177  case EPropSize::Huge: return TEXT("huge");
1178  default: return TEXT("unknown");
1179  }
1180  };
1181 
1182  Definition.Attributes.Emplace(FActorAttribute{
1183  TEXT("size"),
1185  GetSize(Parameters.Size)});
1186 
1187  Success = CheckActorDefinition(Definition);
1188 }
1189 
1191  const TArray<FPropParameters> &ParameterArray,
1192  TArray<FActorDefinition> &Definitions)
1193 {
1194  FillActorDefinitionArray(ParameterArray, Definitions, &MakePropDefinition);
1195 }
1196 
1198  const FString &Type,
1199  const FString &Id,
1200  FActorDefinition &Definition)
1201 {
1202  Definition = MakeGenericSensorDefinition(TEXT("other"), TEXT("obstacle"));
1203  AddVariationsForSensor(Definition);
1204  // Distance.
1205  FActorVariation distance;
1206  distance.Id = TEXT("distance");
1207  distance.Type = EActorAttributeType::Float;
1208  distance.RecommendedValues = { TEXT("5.0") };
1209  distance.bRestrictToRecommended = false;
1210  // HitRadius.
1211  FActorVariation hitradius;
1212  hitradius.Id = TEXT("hit_radius");
1213  hitradius.Type = EActorAttributeType::Float;
1214  hitradius.RecommendedValues = { TEXT("0.5") };
1215  hitradius.bRestrictToRecommended = false;
1216  // Only Dynamics
1217  FActorVariation onlydynamics;
1218  onlydynamics.Id = TEXT("only_dynamics");
1219  onlydynamics.Type = EActorAttributeType::Bool;
1220  onlydynamics.RecommendedValues = { TEXT("false") };
1221  onlydynamics.bRestrictToRecommended = false;
1222  // Debug Line Trace
1223  FActorVariation debuglinetrace;
1224  debuglinetrace.Id = TEXT("debug_linetrace");
1225  debuglinetrace.Type = EActorAttributeType::Bool;
1226  debuglinetrace.RecommendedValues = { TEXT("false") };
1227  debuglinetrace.bRestrictToRecommended = false;
1228 
1229  Definition.Variations.Append({
1230  distance,
1231  hitradius,
1232  onlydynamics,
1233  debuglinetrace
1234  });
1235 
1236 }
1237 /// ============================================================================
1238 /// -- Helpers to retrieve attribute values ------------------------------------
1239 /// ============================================================================
1240 
1242  const FActorAttribute &ActorAttribute,
1243  bool Default)
1244 {
1245  if (ActorAttribute.Type != EActorAttributeType::Bool)
1246  {
1247  UE_LOG(LogCarla, Error, TEXT("ActorAttribute '%s' is not a bool"), *ActorAttribute.Id);
1248  return Default;
1249  }
1250  return ActorAttribute.Value.ToBool();
1251 }
1252 
1254  const FActorAttribute &ActorAttribute,
1255  int32 Default)
1256 {
1257  if (ActorAttribute.Type != EActorAttributeType::Int)
1258  {
1259  UE_LOG(LogCarla, Error, TEXT("ActorAttribute '%s' is not an int"), *ActorAttribute.Id);
1260  return Default;
1261  }
1262  return FCString::Atoi(*ActorAttribute.Value);
1263 }
1264 
1266  const FActorAttribute &ActorAttribute,
1267  float Default)
1268 {
1269  if (ActorAttribute.Type != EActorAttributeType::Float)
1270  {
1271  UE_LOG(LogCarla, Error, TEXT("ActorAttribute '%s' is not a float"), *ActorAttribute.Id);
1272  return Default;
1273  }
1274  return FCString::Atof(*ActorAttribute.Value);
1275 }
1276 
1278  const FActorAttribute &ActorAttribute,
1279  const FString &Default)
1280 {
1281  if (ActorAttribute.Type != EActorAttributeType::String)
1282  {
1283  UE_LOG(LogCarla, Error, TEXT("ActorAttribute '%s' is not a string"), *ActorAttribute.Id);
1284  return Default;
1285  }
1286  return ActorAttribute.Value;
1287 }
1288 
1290  const FActorAttribute &ActorAttribute,
1291  const FColor &Default)
1292 {
1293  if (ActorAttribute.Type != EActorAttributeType::RGBColor)
1294  {
1295  UE_LOG(LogCarla, Error, TEXT("ActorAttribute '%s' is not a color"), *ActorAttribute.Id);
1296  return Default;
1297  }
1298  TArray<FString> Channels;
1299  ActorAttribute.Value.ParseIntoArray(Channels, TEXT(","), false);
1300  if (Channels.Num() != 3)
1301  {
1302  UE_LOG(LogCarla,
1303  Error,
1304  TEXT("ActorAttribute '%s': invalid color '%s'"),
1305  *ActorAttribute.Id,
1306  *ActorAttribute.Value);
1307  return Default;
1308  }
1309  TArray<uint8> Colors;
1310  for (auto &Str : Channels)
1311  {
1312  auto Val = FCString::Atoi(*Str);
1313  if ((Val < 0) || (Val > std::numeric_limits<uint8>::max()))
1314  {
1315  UE_LOG(LogCarla,
1316  Error,
1317  TEXT("ActorAttribute '%s': invalid color '%s'"),
1318  *ActorAttribute.Id,
1319  *ActorAttribute.Value);
1320  return Default;
1321  }
1322  Colors.Add(Val);
1323  }
1324  FColor Color;
1325  Color.R = Colors[0u];
1326  Color.G = Colors[1u];
1327  Color.B = Colors[2u];
1328  return Color;
1329 }
1330 
1332  const FString &Id,
1333  const TMap<FString, FActorAttribute> &Attributes,
1334  bool Default)
1335 {
1336  return Attributes.Contains(Id) ?
1337  ActorAttributeToBool(Attributes[Id], Default) :
1338  Default;
1339 }
1340 
1342  const FString &Id,
1343  const TMap<FString, FActorAttribute> &Attributes,
1344  int32 Default)
1345 {
1346  return Attributes.Contains(Id) ?
1347  ActorAttributeToInt(Attributes[Id], Default) :
1348  Default;
1349 }
1350 
1352  const FString &Id,
1353  const TMap<FString, FActorAttribute> &Attributes,
1354  float Default)
1355 {
1356  return Attributes.Contains(Id) ?
1357  ActorAttributeToFloat(Attributes[Id], Default) :
1358  Default;
1359 }
1360 
1362  const FString &Id,
1363  const TMap<FString, FActorAttribute> &Attributes,
1364  const FString &Default)
1365 {
1366  return Attributes.Contains(Id) ?
1367  ActorAttributeToString(Attributes[Id], Default) :
1368  Default;
1369 }
1370 
1372  const FString &Id,
1373  const TMap<FString, FActorAttribute> &Attributes,
1374  const FColor &Default)
1375 {
1376  return Attributes.Contains(Id) ?
1377  ActorAttributeToColor(Attributes[Id], Default) :
1378  Default;
1379 }
1380 
1381 /// ============================================================================
1382 /// -- Helpers to set Actors ---------------------------------------------------
1383 /// ============================================================================
1384 
1385 // Here we do different checks when we are in editor because we don't want the
1386 // editor crashing while people are testing new actor definitions.
1387 #if WITH_EDITOR
1388 # define CARLA_ABFL_CHECK_ACTOR(ActorPtr) \
1389  if ((ActorPtr == nullptr) || ActorPtr->IsPendingKill()) \
1390  { \
1391  UE_LOG(LogCarla, Error, TEXT("Cannot set empty actor!")); \
1392  return; \
1393  }
1394 #else
1395 # define CARLA_ABFL_CHECK_ACTOR(ActorPtr) \
1396  check((ActorPtr != nullptr) && !ActorPtr->IsPendingKill());
1397 #endif // WITH_EDITOR
1398 
1400  const FActorDescription &Description,
1401  ASceneCaptureSensor *Camera)
1402 {
1403  CARLA_ABFL_CHECK_ACTOR(Camera);
1404  Camera->SetImageSize(
1405  RetrieveActorAttributeToInt("image_size_x", Description.Variations, 800),
1406  RetrieveActorAttributeToInt("image_size_y", Description.Variations, 600));
1407  Camera->SetFOVAngle(
1408  RetrieveActorAttributeToFloat("fov", Description.Variations, 90.0f));
1409  if (Description.Variations.Contains("enable_postprocess_effects"))
1410  {
1412  ActorAttributeToBool(
1413  Description.Variations["enable_postprocess_effects"],
1414  true));
1415  Camera->SetTargetGamma(
1416  RetrieveActorAttributeToFloat("gamma", Description.Variations, 2.2f));
1417  Camera->SetMotionBlurIntensity(
1418  RetrieveActorAttributeToFloat("motion_blur_intensity", Description.Variations, 0.5f));
1420  RetrieveActorAttributeToFloat("motion_blur_max_distortion", Description.Variations, 5.0f));
1422  RetrieveActorAttributeToFloat("motion_blur_min_object_screen_size", Description.Variations, 0.5f));
1423  Camera->SetLensFlareIntensity(
1424  RetrieveActorAttributeToFloat("lens_flare_intensity", Description.Variations, 0.1f));
1425  Camera->SetBloomIntensity(
1426  RetrieveActorAttributeToFloat("bloom_intensity", Description.Variations, 0.675f));
1427  // Exposure, histogram mode by default
1428  if (RetrieveActorAttributeToString("exposure_mode", Description.Variations, "histogram") == "histogram")
1429  {
1430  Camera->SetExposureMethod(EAutoExposureMethod::AEM_Histogram);
1431  }
1432  else
1433  {
1434  Camera->SetExposureMethod(EAutoExposureMethod::AEM_Manual);
1435  }
1436  Camera->SetExposureCompensation(
1437  RetrieveActorAttributeToFloat("exposure_compensation", Description.Variations, 0.0f));
1438  Camera->SetShutterSpeed(
1439  RetrieveActorAttributeToFloat("shutter_speed", Description.Variations, 200.0f));
1440  Camera->SetISO(
1441  RetrieveActorAttributeToFloat("iso", Description.Variations, 100.0f));
1442  Camera->SetAperture(
1443  RetrieveActorAttributeToFloat("fstop", Description.Variations, 1.4f));
1444 
1445  Camera->SetExposureMinBrightness(
1446  RetrieveActorAttributeToFloat("exposure_min_bright", Description.Variations, 7.0f));
1447  Camera->SetExposureMaxBrightness(
1448  RetrieveActorAttributeToFloat("exposure_max_bright", Description.Variations, 9.0f));
1449  Camera->SetExposureSpeedUp(
1450  RetrieveActorAttributeToFloat("exposure_speed_up", Description.Variations, 3.0f));
1451  Camera->SetExposureSpeedDown(
1452  RetrieveActorAttributeToFloat("exposure_speed_down", Description.Variations, 1.0f));
1454  RetrieveActorAttributeToFloat("calibration_constant", Description.Variations, 16.0f));
1455 
1456  Camera->SetFocalDistance(
1457  RetrieveActorAttributeToFloat("focal_distance", Description.Variations, 1000.0f));
1458  Camera->SetDepthBlurAmount(
1459  RetrieveActorAttributeToFloat("blur_amount", Description.Variations, 1.0f));
1460  Camera->SetDepthBlurRadius(
1461  RetrieveActorAttributeToFloat("blur_radius", Description.Variations, 0.0f));
1462  Camera->SetDepthOfFieldMinFstop(
1463  RetrieveActorAttributeToFloat("min_fstop", Description.Variations, 1.2f));
1464  Camera->SetBladeCount(
1465  RetrieveActorAttributeToInt("blade_count", Description.Variations, 5));
1466 
1467  Camera->SetFilmSlope(
1468  RetrieveActorAttributeToFloat("slope", Description.Variations, 0.88f));
1469  Camera->SetFilmToe(
1470  RetrieveActorAttributeToFloat("toe", Description.Variations, 0.55f));
1471  Camera->SetFilmShoulder(
1472  RetrieveActorAttributeToFloat("shoulder", Description.Variations, 0.26f));
1473  Camera->SetFilmBlackClip(
1474  RetrieveActorAttributeToFloat("black_clip", Description.Variations, 0.0f));
1475  Camera->SetFilmWhiteClip(
1476  RetrieveActorAttributeToFloat("white_clip", Description.Variations, 0.04f));
1477 
1478  Camera->SetWhiteTemp(
1479  RetrieveActorAttributeToFloat("temp", Description.Variations, 6500.0f));
1480  Camera->SetWhiteTint(
1481  RetrieveActorAttributeToFloat("tint", Description.Variations, 0.0f));
1482 
1483  Camera->SetChromAberrIntensity(
1484  RetrieveActorAttributeToFloat("chromatic_aberration_intensity", Description.Variations, 0.0f));
1485  Camera->SetChromAberrOffset(
1486  RetrieveActorAttributeToFloat("chromatic_aberration_offset", Description.Variations, 0.0f));
1487  }
1488 }
1489 
1491  const FActorDescription &Description,
1492  AShaderBasedSensor *Camera)
1493 {
1494  CARLA_ABFL_CHECK_ACTOR(Camera);
1495  Camera->SetFloatShaderParameter(0, TEXT("CircleFalloff_NState"),
1496  RetrieveActorAttributeToFloat("lens_circle_falloff", Description.Variations, 5.0f));
1497  Camera->SetFloatShaderParameter(0, TEXT("CircleMultiplier_NState"),
1498  RetrieveActorAttributeToFloat("lens_circle_multiplier", Description.Variations, 0.0f));
1499  Camera->SetFloatShaderParameter(0, TEXT("K_NState"),
1500  RetrieveActorAttributeToFloat("lens_k", Description.Variations, -1.0f));
1501  Camera->SetFloatShaderParameter(0, TEXT("kcube"),
1502  RetrieveActorAttributeToFloat("lens_kcube", Description.Variations, 0.0f));
1503  Camera->SetFloatShaderParameter(0, TEXT("XSize_NState"),
1504  RetrieveActorAttributeToFloat("lens_x_size", Description.Variations, 0.08f));
1505  Camera->SetFloatShaderParameter(0, TEXT("YSize_NState"),
1506  RetrieveActorAttributeToFloat("lens_y_size", Description.Variations, 0.08f));
1507 }
1508 
1510  const FActorDescription &Description,
1511  FLidarDescription &Lidar)
1512 {
1513  constexpr float TO_CENTIMETERS = 1e2;
1514  Lidar.Channels =
1515  RetrieveActorAttributeToInt("channels", Description.Variations, Lidar.Channels);
1516  Lidar.Range =
1517  RetrieveActorAttributeToFloat("range", Description.Variations, 10.0f) * TO_CENTIMETERS;
1518  Lidar.PointsPerSecond =
1519  RetrieveActorAttributeToInt("points_per_second", Description.Variations, Lidar.PointsPerSecond);
1520  Lidar.RotationFrequency =
1521  RetrieveActorAttributeToFloat("rotation_frequency", Description.Variations, Lidar.RotationFrequency);
1522  Lidar.UpperFovLimit =
1523  RetrieveActorAttributeToFloat("upper_fov", Description.Variations, Lidar.UpperFovLimit);
1524  Lidar.LowerFovLimit =
1525  RetrieveActorAttributeToFloat("lower_fov", Description.Variations, Lidar.LowerFovLimit);
1526  Lidar.HorizontalFov =
1527  RetrieveActorAttributeToFloat("horizontal_fov", Description.Variations, Lidar.HorizontalFov);
1528  Lidar.AtmospAttenRate =
1529  RetrieveActorAttributeToFloat("atmosphere_attenuation_rate", Description.Variations, Lidar.AtmospAttenRate);
1530  Lidar.RandomSeed =
1531  RetrieveActorAttributeToInt("noise_seed", Description.Variations, Lidar.RandomSeed);
1532  Lidar.DropOffGenRate =
1533  RetrieveActorAttributeToFloat("dropoff_general_rate", Description.Variations, Lidar.DropOffGenRate);
1534  Lidar.DropOffIntensityLimit =
1535  RetrieveActorAttributeToFloat("dropoff_intensity_limit", Description.Variations, Lidar.DropOffIntensityLimit);
1536  Lidar.DropOffAtZeroIntensity =
1537  RetrieveActorAttributeToFloat("dropoff_zero_intensity", Description.Variations, Lidar.DropOffAtZeroIntensity);
1538  Lidar.NoiseStdDev =
1539  RetrieveActorAttributeToFloat("noise_stddev", Description.Variations, Lidar.NoiseStdDev);
1540 }
1541 
1543  const FActorDescription &Description,
1544  AGnssSensor *Gnss)
1545 {
1546  CARLA_ABFL_CHECK_ACTOR(Gnss);
1547  if (Description.Variations.Contains("noise_seed"))
1548  {
1549  Gnss->SetSeed(
1550  RetrieveActorAttributeToInt("noise_seed", Description.Variations, 0));
1551  }
1552  else
1553  {
1554  Gnss->SetSeed(Gnss->GetRandomEngine()->GenerateRandomSeed());
1555  }
1556 
1557  Gnss->SetLatitudeDeviation(
1558  RetrieveActorAttributeToFloat("noise_lat_stddev", Description.Variations, 0.0f));
1559  Gnss->SetLongitudeDeviation(
1560  RetrieveActorAttributeToFloat("noise_lon_stddev", Description.Variations, 0.0f));
1561  Gnss->SetAltitudeDeviation(
1562  RetrieveActorAttributeToFloat("noise_alt_stddev", Description.Variations, 0.0f));
1563  Gnss->SetLatitudeBias(
1564  RetrieveActorAttributeToFloat("noise_lat_bias", Description.Variations, 0.0f));
1565  Gnss->SetLongitudeBias(
1566  RetrieveActorAttributeToFloat("noise_lon_bias", Description.Variations, 0.0f));
1567  Gnss->SetAltitudeBias(
1568  RetrieveActorAttributeToFloat("noise_alt_bias", Description.Variations, 0.0f));
1569 }
1570 
1572  const FActorDescription &Description,
1574 {
1576  if (Description.Variations.Contains("noise_seed"))
1577  {
1578  IMU->SetSeed(
1579  RetrieveActorAttributeToInt("noise_seed", Description.Variations, 0));
1580  }
1581  else
1582  {
1583  IMU->SetSeed(IMU->GetRandomEngine()->GenerateRandomSeed());
1584  }
1585 
1587  RetrieveActorAttributeToFloat("noise_accel_stddev_x", Description.Variations, 0.0f),
1588  RetrieveActorAttributeToFloat("noise_accel_stddev_y", Description.Variations, 0.0f),
1589  RetrieveActorAttributeToFloat("noise_accel_stddev_z", Description.Variations, 0.0f)});
1590 
1592  RetrieveActorAttributeToFloat("noise_gyro_stddev_x", Description.Variations, 0.0f),
1593  RetrieveActorAttributeToFloat("noise_gyro_stddev_y", Description.Variations, 0.0f),
1594  RetrieveActorAttributeToFloat("noise_gyro_stddev_z", Description.Variations, 0.0f)});
1595 
1596  IMU->SetGyroscopeBias({
1597  RetrieveActorAttributeToFloat("noise_gyro_bias_x", Description.Variations, 0.0f),
1598  RetrieveActorAttributeToFloat("noise_gyro_bias_y", Description.Variations, 0.0f),
1599  RetrieveActorAttributeToFloat("noise_gyro_bias_z", Description.Variations, 0.0f)});
1600 }
1601 
1603  const FActorDescription &Description,
1604  ARadar *Radar)
1605 {
1606  CARLA_ABFL_CHECK_ACTOR(Radar);
1607  constexpr float TO_CENTIMETERS = 1e2;
1608 
1609  if (Description.Variations.Contains("noise_seed"))
1610  {
1611  Radar->SetSeed(
1612  RetrieveActorAttributeToInt("noise_seed", Description.Variations, 0));
1613  }
1614  else
1615  {
1616  Radar->SetSeed(Radar->GetRandomEngine()->GenerateRandomSeed());
1617  }
1618 
1619  Radar->SetHorizontalFOV(
1620  RetrieveActorAttributeToFloat("horizontal_fov", Description.Variations, 30.0f));
1621  Radar->SetVerticalFOV(
1622  RetrieveActorAttributeToFloat("vertical_fov", Description.Variations, 30.0f));
1623  Radar->SetRange(
1624  RetrieveActorAttributeToFloat("range", Description.Variations, 100.0f) * TO_CENTIMETERS);
1625  Radar->SetPointsPerSecond(
1626  RetrieveActorAttributeToInt("points_per_second", Description.Variations, 1500));
1627 }
1628 
1629 #undef CARLA_ABFL_CHECK_ACTOR
float DropOffGenRate
General drop off rate.
void SetFilmToe(float Toe)
void SetFilmWhiteClip(float WhiteClip)
void SetHorizontalFOV(float NewHorizontalFOV)
Definition: Radar.cpp:41
void SetLatitudeBias(float Value)
Definition: GnssSensor.cpp:67
void SetMotionBlurIntensity(float Intensity)
static FActorDefinition MakeLidarDefinition(const FString &Id)
void SetExposureMethod(EAutoExposureMethod Method)
static void AddRecommendedValuesForActorRoleName(FActorDefinition &Definition, TArray< FString > &&RecommendedValues)
bool IsValid(const FActorVariation &Variation)
static void FillActorDefinitionArray(const TArray< T > &ParameterArray, TArray< FActorDefinition > &Definitions, Functor Maker)
TSubclassOf< ACharacter > Class
float DropOffIntensityLimit
General drop off rate.
void SetLensFlareIntensity(float Intensity)
EPedestrianGender
bool AreValid(const TArray< FActorDefinition > &ActorDefinitions)
Iterate all actor definitions and their properties and display messages on error. ...
EPropSize
void SetChromAberrIntensity(float Intensity)
bool ForEach(const FString &Type, const TArray< T > &Array, F Validator)
Applies Validator to each item in Array.
void SetWhiteTint(float Tint)
void SetFOVAngle(float FOVAngle)
sensor::data::Color Color
FString ObjectType
(OPTIONAL) Use for custom classification of vehicles.
void SetChromAberrOffset(float ChromAberrOffset)
static int32 ActorAttributeToInt(const FActorAttribute &ActorAttribute, int32 Default)
static const FString SIZE
bool IsValid(const FActorDefinition &ActorDefinition)
static bool ActorAttributeToBool(const FActorAttribute &ActorAttribute, bool Default)
============================================================================ ā€“ Helpers to retrieve a...
TArray< int32 > SupportedDrivers
List of IDs of the drivers (pedestrians) supported by this vehicle, leave empty if no driver is suppo...
EActorAttributeType
List of valid types for actor attributes.
static float ActorAttributeToFloat(const FActorAttribute &ActorAttribute, float Default)
void SetSeed(int32 InSeed)
Definition: Sensor.cpp:47
static void AddRecommendedValuesForSensorRoleNames(FActorDefinition &Definition)
float Range
Measure distance in centimeters.
void SetFloatShaderParameter(uint8_t ShaderIndex, const FName &ParameterName, float Value)
EPedestrianAge
void SetRange(float NewRange)
Definition: Radar.cpp:51
FString GetDisplayId(const FString &Type, size_t Index, const T &Item)
static void MakeObstacleDetectorDefinitions(const FString &Type, const FString &Id, FActorDefinition &Definition)
void SetFilmSlope(float Slope)
A sensor that produces data by applying post-process materials (shaders) to a scene capture image...
static bool CheckActorDefinitions(const TArray< FActorDefinition > &ActorDefinitions)
Return whether the list of actor definitions is valid.
void SetFocalDistance(float Distance)
bool SingleIsValid(const FActorDefinition &Definition)
Validate ActorDefinition and display messages on error.
static FString ActorAttributeToString(const FActorAttribute &ActorAttribute, const FString &Default)
static void MakePropDefinitions(const TArray< FPropParameters > &ParameterArray, TArray< FActorDefinition > &Definitions)
void SetBladeCount(int Count)
static float RetrieveActorAttributeToFloat(const FString &Id, const TMap< FString, FActorAttribute > &Attributes, float Default)
auto PushScope(V &&Value)
Push this scope into the stack.
Definition: ScopedStack.h:21
float LowerFovLimit
Lower laser angle, counts from horizontal, negative values means under horizontal line...
A definition of a Carla Actor with all the variation and attributes.
A ray-cast based Radar sensor.
Definition: Radar.h:21
bool IsValid(const FActorAttribute &Attribute)
bool OnScreenAssert(bool Predicate, const T &Format, ARGS &&... Args) const
If Predicate is false, print an error message.
static void MakeTriggerDefinitions(const TArray< FString > &ParameterArray, TArray< FActorDefinition > &Definitions)
#define CARLA_ABFL_CHECK_ACTOR(ActorPtr)
============================================================================ ā€“ Helpers to set Actors...
void SetAltitudeDeviation(float Value)
Definition: GnssSensor.cpp:62
static void SetRadar(const FActorDescription &Description, ARadar *Radar)
static void SetIMU(const FActorDescription &Description, AInertialMeasurementUnit *IMU)
#define DEBUG_ASSERT(predicate)
Definition: Debug.h:66
static FColor RetrieveActorAttributeToColor(const FString &Id, const TMap< FString, FActorAttribute > &Attributes, const FColor &Default)
static bool CheckActorDefinition(const FActorDefinition &ActorDefinitions)
Return whether the actor definition is valid. Prints all the errors found.
void SetLongitudeBias(float Value)
Definition: GnssSensor.cpp:72
TMap< FString, FActorAttribute > Variations
User selected variations of the actor.
static FString ColorToFString(const FColor &Color)
static void MakeTriggerDefinition(const FString &Id, bool &Success, FActorDefinition &Definition)
void SetAltitudeBias(float Value)
Definition: GnssSensor.cpp:77
void SetDepthBlurRadius(float Radius)
static void SetCamera(const FActorDescription &Description, ASceneCaptureSensor *Camera)
MessageTmpl< 2u > Message
A TCP message containing a maximum of 2 buffers.
Definition: Message.h:91
static void SetGnss(const FActorDescription &Description, AGnssSensor *Gnss)
static void AddVariationsForTrigger(FActorDefinition &Def)
EPedestrianGender Gender
TArray< FColor > RecommendedColors
static int32 RetrieveActorAttributeToInt(const FString &Id, const TMap< FString, FActorAttribute > &Attributes, int32 Default)
static void MakeVehicleDefinition(const FVehicleParameters &Parameters, bool &Success, FActorDefinition &Definition)
float RotationFrequency
Lidar rotation frequency.
static FActorDefinition MakeGenericSensorDefinition(const FString &Type, const FString &Id)
bool AreValid(const FString &Type, const TArray< T > &Array)
Applies IsValid to each item in Array.
static void SetLidar(const FActorDescription &Description, FLidarDescription &Lidar)
bool ValueIsValid(const EActorAttributeType Type, const FString &Value)
TArray< FActorVariation > Variations
Variations represent variables the user can modify to generate variations of the actor.
A description of a Carla Actor with all its variation.
void SetExposureMinBrightness(float Brightness)
void SetMotionBlurMaxDistortion(float MaxDistortion)
Gnss sensor representation The actual position calculation is done one server side.
Definition: GnssSensor.h:23
void SetGyroscopeBias(const FVector &Vec)
Checks validity of FActorDefinition.
float AtmospAttenRate
Attenuation Rate in the atmosphere in m^-1.
void EnablePostProcessingEffects(bool Enable=true)
uint32 Channels
Number of lasers.
static FString JoinStrings(const FString &Separator, ARGS &&... Args)
float DropOffAtZeroIntensity
General drop off rate.
float UpperFovLimit
Upper laser angle, counts from horizontal, positive values means above horizontal line...
static void MakeVehicleDefinitions(const TArray< FVehicleParameters > &ParameterArray, TArray< FActorDefinition > &Definitions)
static FActorDefinition MakeGenericDefinition(const FString &Category, const FString &Type, const FString &Id)
Base class for sensors using a USceneCaptureComponent2D for rendering the scene.
void SetFilmShoulder(float Shoulder)
void SetBloomIntensity(float Intensity)
void SetGyroscopeStandardDeviation(const FVector &Vec)
void SetExposureSpeedDown(float Speed)
void SetLongitudeDeviation(float Value)
Definition: GnssSensor.cpp:57
void SetWhiteTemp(float Temp)
float HorizontalFov
Horizontal field of view.
static void AddVariationsForSensor(FActorDefinition &Def)
FString Id
Display ID that identifies the actor.
void SetLatitudeDeviation(float Value)
Definition: GnssSensor.cpp:52
void SetImageSize(uint32 Width, uint32 Height)
void SetExposureMaxBrightness(float Brightness)
static void MakePropDefinition(const FPropParameters &Parameters, bool &Success, FActorDefinition &Definition)
int RandomSeed
Random seed for the noise/dropoff used by this sensor.
TSubclassOf< ACarlaWheeledVehicle > Class
static bool RetrieveActorAttributeToBool(const FString &Id, const TMap< FString, FActorAttribute > &Attributes, bool Default)
TSubclassOf< AActor > Class
Class of the actor to be spawned (Optional).
void SetAccelerationStandardDeviation(const FVector &Vec)
void SetExposureCompensation(float Compensation)
void SetExposureSpeedUp(float Speed)
void SetDepthBlurAmount(float Amount)
void SetFilmBlackClip(float BlackClip)
TArray< FActorAttribute > Attributes
Attributes represent non-modifiable properties of the actor that might help the user identifying and ...
static void MakePedestrianDefinition(const FPedestrianParameters &Parameters, bool &Success, FActorDefinition &Definition)
uint32 PointsPerSecond
Points generated by all lasers per second.
static FString RetrieveActorAttributeToString(const FString &Id, const TMap< FString, FActorAttribute > &Attributes, const FString &Default)
void SetTargetGamma(float InTargetGamma)
static FActorDefinition MakeCameraDefinition(const FString &Id, bool bEnableModifyingPostProcessEffects=false)
static void FillIdAndTags(FActorDefinition &Def, TStrs &&... Strings)
============================================================================ ā€“ Helpers to create act...
void SetAperture(float Aperture)
An actor attribute, may be an intrinsic (non-modifiable) attribute of the actor or an user-defined ac...
void SetDepthOfFieldMinFstop(float MinFstop)
static void MakePedestrianDefinitions(const TArray< FPedestrianParameters > &ParameterArray, TArray< FActorDefinition > &Definitions)
void SetShutterSpeed(float Speed)
static int32 GenerateRandomSeed()
Generate a non-deterministic random seed.
static auto GetSize(const RangeT &Range)
void SetVerticalFOV(float NewVerticalFOV)
Definition: Radar.cpp:46
FString GetDisplayId(const FString &Type, size_t Index, const FString &Item)
void SetPointsPerSecond(int NewPointsPerSecond)
Definition: Radar.cpp:56
bool IsValid(const EActorAttributeType Type)
void SetExposureCalibrationConstant(float Constant)
void SetMotionBlurMinObjectScreenSize(float ScreenSize)
static FColor ActorAttributeToColor(const FActorAttribute &ActorAttribute, const FColor &Default)