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 
199  // each actor gets an actor role name attribute (empty by default)
200  FActorVariation ActorRole;
201  ActorRole.Id = TEXT("role_name");
202  ActorRole.Type = EActorAttributeType::String;
203  ActorRole.RecommendedValues = { TEXT("default") };
204  ActorRole.bRestrictToRecommended = false;
205  Def.Variations.Emplace(ActorRole);
206 
207  // ROS2
208  FActorVariation Var;
209  Var.Id = TEXT("ros_name");
211  Var.RecommendedValues = { Def.Id };
212  Var.bRestrictToRecommended = false;
213  Def.Variations.Emplace(Var);
214 }
215 
217  FActorDefinition &Definition,
218  TArray<FString> &&RecommendedValues)
219 {
220  for (auto &&ActorVariation: Definition.Variations)
221  {
222  if (ActorVariation.Id == "role_name")
223  {
224  ActorVariation.RecommendedValues = RecommendedValues;
225  return;
226  }
227  }
228 }
229 
231 {
232  AddRecommendedValuesForActorRoleName(Definition, {TEXT("front"), TEXT("back"), TEXT("left"), TEXT(
233  "right"), TEXT("front_left"), TEXT("front_right"), TEXT("back_left"), TEXT("back_right")});
234 }
235 
237 {
238  FActorVariation Tick;
239 
240  Tick.Id = TEXT("sensor_tick");
242  Tick.RecommendedValues = { TEXT("0.0") };
243  Tick.bRestrictToRecommended = false;
244 
245  Def.Variations.Emplace(Tick);
246 }
247 
249 {
250  // Friction
251  FActorVariation Friction;
252  Friction.Id = FString("friction");
253  Friction.Type = EActorAttributeType::Float;
254  Friction.RecommendedValues = { TEXT("3.5f") };
255  Friction.bRestrictToRecommended = false;
256  Def.Variations.Emplace(Friction);
257 
258  // Extent
259  FString Extent("extent");
260  FString Coordinates[3] = {FString("x"), FString("y"), FString("z")};
261 
262  for (auto Coordinate : Coordinates)
263  {
264  FActorVariation ExtentCoordinate;
265 
266  ExtentCoordinate.Id = JoinStrings(TEXT("_"), Extent, Coordinate);
267  ExtentCoordinate.Type = EActorAttributeType::Float;
268  ExtentCoordinate.RecommendedValues = { TEXT("1.0f") };
269  ExtentCoordinate.bRestrictToRecommended = false;
270 
271  Def.Variations.Emplace(ExtentCoordinate);
272  }
273 }
274 
276  const FString &Category,
277  const FString &Type,
278  const FString &Id)
279 {
280  FActorDefinition Definition;
281  FillIdAndTags(Definition, Category, Type, Id);
282  return Definition;
283 }
284 
286  const FString &Type,
287  const FString &Id)
288 {
289  auto Definition = MakeGenericDefinition(TEXT("sensor"), Type, Id);
291  return Definition;
292 }
293 
295  const FString &Id,
296  const bool bEnableModifyingPostProcessEffects)
297 {
298  FActorDefinition Definition;
299  bool Success;
300  MakeCameraDefinition(Id, bEnableModifyingPostProcessEffects, Success, Definition);
301  check(Success);
302  return Definition;
303 }
304 
306  const FString &Id,
307  const bool bEnableModifyingPostProcessEffects,
308  bool &Success,
309  FActorDefinition &Definition)
310 {
311  FillIdAndTags(Definition, TEXT("sensor"), TEXT("camera"), Id);
313  AddVariationsForSensor(Definition);
314 
315  // FOV
316  FActorVariation FOV;
317  FOV.Id = TEXT("fov");
319  FOV.RecommendedValues = { TEXT("90.0") };
320  FOV.bRestrictToRecommended = false;
321 
322  // Resolution
323  FActorVariation ResX;
324  ResX.Id = TEXT("image_size_x");
326  ResX.RecommendedValues = { TEXT("800") };
327  ResX.bRestrictToRecommended = false;
328 
329  FActorVariation ResY;
330  ResY.Id = TEXT("image_size_y");
332  ResY.RecommendedValues = { TEXT("600") };
333  ResY.bRestrictToRecommended = false;
334 
335  // Lens parameters
336  FActorVariation LensCircleFalloff;
337  LensCircleFalloff.Id = TEXT("lens_circle_falloff");
338  LensCircleFalloff.Type = EActorAttributeType::Float;
339  LensCircleFalloff.RecommendedValues = { TEXT("5.0") };
340  LensCircleFalloff.bRestrictToRecommended = false;
341 
342  FActorVariation LensCircleMultiplier;
343  LensCircleMultiplier.Id = TEXT("lens_circle_multiplier");
344  LensCircleMultiplier.Type = EActorAttributeType::Float;
345  LensCircleMultiplier.RecommendedValues = { TEXT("0.0") };
346  LensCircleMultiplier.bRestrictToRecommended = false;
347 
348  FActorVariation LensK;
349  LensK.Id = TEXT("lens_k");
351  LensK.RecommendedValues = { TEXT("-1.0") };
352  LensK.bRestrictToRecommended = false;
353 
354  FActorVariation LensKcube;
355  LensKcube.Id = TEXT("lens_kcube");
356  LensKcube.Type = EActorAttributeType::Float;
357  LensKcube.RecommendedValues = { TEXT("0.0") };
358  LensKcube.bRestrictToRecommended = false;
359 
360  FActorVariation LensXSize;
361  LensXSize.Id = TEXT("lens_x_size");
362  LensXSize.Type = EActorAttributeType::Float;
363  LensXSize.RecommendedValues = { TEXT("0.08") };
364  LensXSize.bRestrictToRecommended = false;
365 
366  FActorVariation LensYSize;
367  LensYSize.Id = TEXT("lens_y_size");
368  LensYSize.Type = EActorAttributeType::Float;
369  LensYSize.RecommendedValues = { TEXT("0.08") };
370  LensYSize.bRestrictToRecommended = false;
371 
372  Definition.Variations.Append({
373  ResX,
374  ResY,
375  FOV,
376  LensCircleFalloff,
377  LensCircleMultiplier,
378  LensK,
379  LensKcube,
380  LensXSize,
381  LensYSize});
382 
383  if (bEnableModifyingPostProcessEffects)
384  {
385  FActorVariation PostProccess;
386  PostProccess.Id = TEXT("enable_postprocess_effects");
387  PostProccess.Type = EActorAttributeType::Bool;
388  PostProccess.RecommendedValues = { TEXT("true") };
389  PostProccess.bRestrictToRecommended = false;
390 
391  // Gamma
392  FActorVariation Gamma;
393  Gamma.Id = TEXT("gamma");
395  Gamma.RecommendedValues = { TEXT("2.2") };
396  Gamma.bRestrictToRecommended = false;
397 
398  // Motion Blur
399  FActorVariation MBIntesity;
400  MBIntesity.Id = TEXT("motion_blur_intensity");
401  MBIntesity.Type = EActorAttributeType::Float;
402  MBIntesity.RecommendedValues = { TEXT("0.45") };
403  MBIntesity.bRestrictToRecommended = false;
404 
405  FActorVariation MBMaxDistortion;
406  MBMaxDistortion.Id = TEXT("motion_blur_max_distortion");
407  MBMaxDistortion.Type = EActorAttributeType::Float;
408  MBMaxDistortion.RecommendedValues = { TEXT("0.35") };
409  MBMaxDistortion.bRestrictToRecommended = false;
410 
411  FActorVariation MBMinObjectScreenSize;
412  MBMinObjectScreenSize.Id = TEXT("motion_blur_min_object_screen_size");
413  MBMinObjectScreenSize.Type = EActorAttributeType::Float;
414  MBMinObjectScreenSize.RecommendedValues = { TEXT("0.1") };
415  MBMinObjectScreenSize.bRestrictToRecommended = false;
416 
417  // Lens Flare
418  FActorVariation LensFlareIntensity;
419  LensFlareIntensity.Id = TEXT("lens_flare_intensity");
420  LensFlareIntensity.Type = EActorAttributeType::Float;
421  LensFlareIntensity.RecommendedValues = { TEXT("0.1") };
422  LensFlareIntensity.bRestrictToRecommended = false;
423 
424  // Bloom
425  FActorVariation BloomIntensity;
426  BloomIntensity.Id = TEXT("bloom_intensity");
427  BloomIntensity.Type = EActorAttributeType::Float;
428  BloomIntensity.RecommendedValues = { TEXT("0.675") };
429  BloomIntensity.bRestrictToRecommended = false;
430 
431  // More info at:
432  // https://docs.unrealengine.com/en-US/Engine/Rendering/PostProcessEffects/AutomaticExposure/index.html
433  // https://docs.unrealengine.com/en-US/Engine/Rendering/PostProcessEffects/DepthOfField/CinematicDOFMethods/index.html
434  // https://docs.unrealengine.com/en-US/Engine/Rendering/PostProcessEffects/ColorGrading/index.html
435 
436  // Exposure
437  FActorVariation ExposureMode;
438  ExposureMode.Id = TEXT("exposure_mode");
439  ExposureMode.Type = EActorAttributeType::String;
440  ExposureMode.RecommendedValues = { TEXT("histogram"), TEXT("manual") };
441  ExposureMode.bRestrictToRecommended = true;
442 
443  // Logarithmic adjustment for the exposure. Only used if a tonemapper is
444  // specified.
445  // 0 : no adjustment
446  // -1 : 2x darker
447  // -2 : 4x darker
448  // 1 : 2x brighter
449  // 2 : 4x brighter.
450  FActorVariation ExposureCompensation;
451  ExposureCompensation.Id = TEXT("exposure_compensation");
452  ExposureCompensation.Type = EActorAttributeType::Float;
453  ExposureCompensation.RecommendedValues = { TEXT("0.0") };
454  ExposureCompensation.bRestrictToRecommended = false;
455 
456  // - Manual ------------------------------------------------
457 
458  // The formula used to compute the camera exposure scale is:
459  // Exposure = 1 / (1.2 * 2^(log2( NĀ²/t * 100/S )))
460 
461  // The camera shutter speed in seconds.
462  FActorVariation ShutterSpeed; // (1/t)
463  ShutterSpeed.Id = TEXT("shutter_speed");
464  ShutterSpeed.Type = EActorAttributeType::Float;
465  ShutterSpeed.RecommendedValues = { TEXT("200.0") };
466  ShutterSpeed.bRestrictToRecommended = false;
467 
468  // The camera sensor sensitivity.
469  FActorVariation ISO; // S
470  ISO.Id = TEXT("iso");
472  ISO.RecommendedValues = { TEXT("100.0") };
473  ISO.bRestrictToRecommended = false;
474 
475  // Defines the size of the opening for the camera lens.
476  // Using larger numbers will reduce the DOF effect.
477  FActorVariation Aperture; // N
478  Aperture.Id = TEXT("fstop");
479  Aperture.Type = EActorAttributeType::Float;
480  Aperture.RecommendedValues = { TEXT("1.4") };
481  Aperture.bRestrictToRecommended = false;
482 
483  // - Histogram ---------------------------------------------
484 
485  // The minimum brightness for auto exposure that limits the lower
486  // brightness the eye can adapt within
487  FActorVariation ExposureMinBright;
488  ExposureMinBright.Id = TEXT("exposure_min_bright");
489  ExposureMinBright.Type = EActorAttributeType::Float;
490  ExposureMinBright.RecommendedValues = { TEXT("10.0") };
491  ExposureMinBright.bRestrictToRecommended = false;
492 
493  // The maximum brightness for auto exposure that limits the upper
494  // brightness the eye can adapt within
495  FActorVariation ExposureMaxBright;
496  ExposureMaxBright.Id = TEXT("exposure_max_bright");
497  ExposureMaxBright.Type = EActorAttributeType::Float;
498  ExposureMaxBright.RecommendedValues = { TEXT("12.0") };
499  ExposureMaxBright.bRestrictToRecommended = false;
500 
501  // The speed at which the adaptation occurs from a dark environment
502  // to a bright environment.
503  FActorVariation ExposureSpeedUp;
504  ExposureSpeedUp.Id = TEXT("exposure_speed_up");
505  ExposureSpeedUp.Type = EActorAttributeType::Float;
506  ExposureSpeedUp.RecommendedValues = { TEXT("3.0") };
507  ExposureSpeedUp.bRestrictToRecommended = false;
508 
509  // The speed at which the adaptation occurs from a bright environment
510  // to a dark environment.
511  FActorVariation ExposureSpeedDown;
512  ExposureSpeedDown.Id = TEXT("exposure_speed_down");
513  ExposureSpeedDown.Type = EActorAttributeType::Float;
514  ExposureSpeedDown.RecommendedValues = { TEXT("1.0") };
515  ExposureSpeedDown.bRestrictToRecommended = false;
516 
517  // Calibration constant for 18% Albedo.
518  FActorVariation CalibrationConstant;
519  CalibrationConstant.Id = TEXT("calibration_constant");
520  CalibrationConstant.Type = EActorAttributeType::Float;
521  CalibrationConstant.RecommendedValues = { TEXT("16.0") };
522  CalibrationConstant.bRestrictToRecommended = false;
523 
524  // Distance in which the Depth of Field effect should be sharp,
525  // in unreal units (cm)
526  FActorVariation FocalDistance;
527  FocalDistance.Id = TEXT("focal_distance");
528  FocalDistance.Type = EActorAttributeType::Float;
529  FocalDistance.RecommendedValues = { TEXT("1000.0") };
530  FocalDistance.bRestrictToRecommended = false;
531 
532  // Depth blur km for 50%
533  FActorVariation DepthBlurAmount;
534  DepthBlurAmount.Id = TEXT("blur_amount");
535  DepthBlurAmount.Type = EActorAttributeType::Float;
536  DepthBlurAmount.RecommendedValues = { TEXT("1.0") };
537  DepthBlurAmount.bRestrictToRecommended = false;
538 
539  // Depth blur radius in pixels at 1920x
540  FActorVariation DepthBlurRadius;
541  DepthBlurRadius.Id = TEXT("blur_radius");
542  DepthBlurRadius.Type = EActorAttributeType::Float;
543  DepthBlurRadius.RecommendedValues = { TEXT("0.0") };
544  DepthBlurRadius.bRestrictToRecommended = false;
545 
546  // Defines the opening of the camera lens, Aperture is 1.0/fstop,
547  // typical lens go down to f/1.2 (large opening),
548  // larger numbers reduce the DOF effect
549  FActorVariation MaxAperture;
550  MaxAperture.Id = TEXT("min_fstop");
551  MaxAperture.Type = EActorAttributeType::Float;
552  MaxAperture.RecommendedValues = { TEXT("1.2") };
553  MaxAperture.bRestrictToRecommended = false;
554 
555  // Defines the number of blades of the diaphragm within the
556  // lens (between 4 and 16)
557  FActorVariation BladeCount;
558  BladeCount.Id = TEXT("blade_count");
559  BladeCount.Type = EActorAttributeType::Int;
560  BladeCount.RecommendedValues = { TEXT("5") };
561  BladeCount.bRestrictToRecommended = false;
562 
563  // - Tonemapper Settings -----------------------------------
564  // You can adjust these tonemapper controls to emulate other
565  // types of film stock for your project
566  FActorVariation FilmSlope;
567  FilmSlope.Id = TEXT("slope");
568  FilmSlope.Type = EActorAttributeType::Float;
569  FilmSlope.RecommendedValues = { TEXT("0.88") };
570  FilmSlope.bRestrictToRecommended = false;
571 
572  FActorVariation FilmToe;
573  FilmToe.Id = TEXT("toe");
575  FilmToe.RecommendedValues = { TEXT("0.55") };
576  FilmToe.bRestrictToRecommended = false;
577 
578  FActorVariation FilmShoulder;
579  FilmShoulder.Id = TEXT("shoulder");
580  FilmShoulder.Type = EActorAttributeType::Float;
581  FilmShoulder.RecommendedValues = { TEXT("0.26") };
582  FilmShoulder.bRestrictToRecommended = false;
583 
584  FActorVariation FilmBlackClip;
585  FilmBlackClip.Id = TEXT("black_clip");
586  FilmBlackClip.Type = EActorAttributeType::Float;
587  FilmBlackClip.RecommendedValues = { TEXT("0.0") };
588  FilmBlackClip.bRestrictToRecommended = false;
589 
590  FActorVariation FilmWhiteClip;
591  FilmWhiteClip.Id = TEXT("white_clip");
592  FilmWhiteClip.Type = EActorAttributeType::Float;
593  FilmWhiteClip.RecommendedValues = { TEXT("0.04") };
594  FilmWhiteClip.bRestrictToRecommended = false;
595 
596  // Color
597  FActorVariation Temperature;
598  Temperature.Id = TEXT("temp");
599  Temperature.Type = EActorAttributeType::Float;
600  Temperature.RecommendedValues = { TEXT("6500.0") };
601  Temperature.bRestrictToRecommended = false;
602 
603  FActorVariation Tint;
604  Tint.Id = TEXT("tint");
606  Tint.RecommendedValues = { TEXT("0.0") };
607  Tint.bRestrictToRecommended = false;
608 
609  FActorVariation ChromaticIntensity;
610  ChromaticIntensity.Id = TEXT("chromatic_aberration_intensity");
611  ChromaticIntensity.Type = EActorAttributeType::Float;
612  ChromaticIntensity.RecommendedValues = { TEXT("0.0") };
613  ChromaticIntensity.bRestrictToRecommended = false;
614 
615  FActorVariation ChromaticOffset;
616  ChromaticOffset.Id = TEXT("chromatic_aberration_offset");
617  ChromaticOffset.Type = EActorAttributeType::Float;
618  ChromaticOffset.RecommendedValues = { TEXT("0.0") };
619  ChromaticOffset.bRestrictToRecommended = false;
620 
621  Definition.Variations.Append({
622  ExposureMode,
623  ExposureCompensation,
624  ShutterSpeed,
625  ISO,
626  Aperture,
627  PostProccess,
628  Gamma,
629  MBIntesity,
630  MBMaxDistortion,
631  LensFlareIntensity,
632  BloomIntensity,
633  MBMinObjectScreenSize,
634  ExposureMinBright,
635  ExposureMaxBright,
636  ExposureSpeedUp,
637  ExposureSpeedDown,
638  CalibrationConstant,
639  FocalDistance,
640  MaxAperture,
641  BladeCount,
642  DepthBlurAmount,
643  DepthBlurRadius,
644  FilmSlope,
645  FilmToe,
646  FilmShoulder,
647  FilmBlackClip,
648  FilmWhiteClip,
649  Temperature,
650  Tint,
651  ChromaticIntensity,
652  ChromaticOffset});
653  }
654 
655  Success = CheckActorDefinition(Definition);
656 }
657 
659 {
660  FActorDefinition Definition;
661  bool Success;
662  MakeNormalsCameraDefinition(Success, Definition);
663  check(Success);
664  return Definition;
665 }
666 
668 {
669  FillIdAndTags(Definition, TEXT("sensor"), TEXT("camera"), TEXT("normals"));
671  AddVariationsForSensor(Definition);
672 
673  // FOV
674  FActorVariation FOV;
675  FOV.Id = TEXT("fov");
677  FOV.RecommendedValues = { TEXT("90.0") };
678  FOV.bRestrictToRecommended = false;
679 
680  // Resolution
681  FActorVariation ResX;
682  ResX.Id = TEXT("image_size_x");
684  ResX.RecommendedValues = { TEXT("800") };
685  ResX.bRestrictToRecommended = false;
686 
687  FActorVariation ResY;
688  ResY.Id = TEXT("image_size_y");
690  ResY.RecommendedValues = { TEXT("600") };
691  ResY.bRestrictToRecommended = false;
692 
693  // Lens parameters
694  FActorVariation LensCircleFalloff;
695  LensCircleFalloff.Id = TEXT("lens_circle_falloff");
696  LensCircleFalloff.Type = EActorAttributeType::Float;
697  LensCircleFalloff.RecommendedValues = { TEXT("5.0") };
698  LensCircleFalloff.bRestrictToRecommended = false;
699 
700  FActorVariation LensCircleMultiplier;
701  LensCircleMultiplier.Id = TEXT("lens_circle_multiplier");
702  LensCircleMultiplier.Type = EActorAttributeType::Float;
703  LensCircleMultiplier.RecommendedValues = { TEXT("0.0") };
704  LensCircleMultiplier.bRestrictToRecommended = false;
705 
706  FActorVariation LensK;
707  LensK.Id = TEXT("lens_k");
709  LensK.RecommendedValues = { TEXT("-1.0") };
710  LensK.bRestrictToRecommended = false;
711 
712  FActorVariation LensKcube;
713  LensKcube.Id = TEXT("lens_kcube");
714  LensKcube.Type = EActorAttributeType::Float;
715  LensKcube.RecommendedValues = { TEXT("0.0") };
716  LensKcube.bRestrictToRecommended = false;
717 
718  FActorVariation LensXSize;
719  LensXSize.Id = TEXT("lens_x_size");
720  LensXSize.Type = EActorAttributeType::Float;
721  LensXSize.RecommendedValues = { TEXT("0.08") };
722  LensXSize.bRestrictToRecommended = false;
723 
724  FActorVariation LensYSize;
725  LensYSize.Id = TEXT("lens_y_size");
726  LensYSize.Type = EActorAttributeType::Float;
727  LensYSize.RecommendedValues = { TEXT("0.08") };
728  LensYSize.bRestrictToRecommended = false;
729 
730  Definition.Variations.Append({
731  ResX,
732  ResY,
733  FOV,
734  LensCircleFalloff,
735  LensCircleMultiplier,
736  LensK,
737  LensKcube,
738  LensXSize,
739  LensYSize});
740 
741  Success = CheckActorDefinition(Definition);
742 }
743 
745 {
746  FActorDefinition Definition;
747  bool Success;
748  MakeIMUDefinition(Success, Definition);
749  check(Success);
750  return Definition;
751 }
752 
754  bool &Success,
755  FActorDefinition &Definition)
756 {
757  FillIdAndTags(Definition, TEXT("sensor"), TEXT("other"), TEXT("imu"));
758  AddVariationsForSensor(Definition);
759 
760  // - Noise seed --------------------------------
761  FActorVariation NoiseSeed;
762  NoiseSeed.Id = TEXT("noise_seed");
763  NoiseSeed.Type = EActorAttributeType::Int;
764  NoiseSeed.RecommendedValues = { TEXT("0") };
765  NoiseSeed.bRestrictToRecommended = false;
766 
767  // - Accelerometer Standard Deviation ----------
768  // X Component
769  FActorVariation StdDevAccelX;
770  StdDevAccelX.Id = TEXT("noise_accel_stddev_x");
771  StdDevAccelX.Type = EActorAttributeType::Float;
772  StdDevAccelX.RecommendedValues = { TEXT("0.0") };
773  StdDevAccelX.bRestrictToRecommended = false;
774  // Y Component
775  FActorVariation StdDevAccelY;
776  StdDevAccelY.Id = TEXT("noise_accel_stddev_y");
777  StdDevAccelY.Type = EActorAttributeType::Float;
778  StdDevAccelY.RecommendedValues = { TEXT("0.0") };
779  StdDevAccelY.bRestrictToRecommended = false;
780  // Z Component
781  FActorVariation StdDevAccelZ;
782  StdDevAccelZ.Id = TEXT("noise_accel_stddev_z");
783  StdDevAccelZ.Type = EActorAttributeType::Float;
784  StdDevAccelZ.RecommendedValues = { TEXT("0.0") };
785  StdDevAccelZ.bRestrictToRecommended = false;
786 
787  // - Gyroscope Standard Deviation --------------
788  // X Component
789  FActorVariation StdDevGyroX;
790  StdDevGyroX.Id = TEXT("noise_gyro_stddev_x");
791  StdDevGyroX.Type = EActorAttributeType::Float;
792  StdDevGyroX.RecommendedValues = { TEXT("0.0") };
793  StdDevGyroX.bRestrictToRecommended = false;
794  // Y Component
795  FActorVariation StdDevGyroY;
796  StdDevGyroY.Id = TEXT("noise_gyro_stddev_y");
797  StdDevGyroY.Type = EActorAttributeType::Float;
798  StdDevGyroY.RecommendedValues = { TEXT("0.0") };
799  StdDevGyroY.bRestrictToRecommended = false;
800  // Z Component
801  FActorVariation StdDevGyroZ;
802  StdDevGyroZ.Id = TEXT("noise_gyro_stddev_z");
803  StdDevGyroZ.Type = EActorAttributeType::Float;
804  StdDevGyroZ.RecommendedValues = { TEXT("0.0") };
805  StdDevGyroZ.bRestrictToRecommended = false;
806 
807  // - Gyroscope Bias ----------------------------
808  // X Component
809  FActorVariation BiasGyroX;
810  BiasGyroX.Id = TEXT("noise_gyro_bias_x");
811  BiasGyroX.Type = EActorAttributeType::Float;
812  BiasGyroX.RecommendedValues = { TEXT("0.0") };
813  BiasGyroX.bRestrictToRecommended = false;
814  // Y Component
815  FActorVariation BiasGyroY;
816  BiasGyroY.Id = TEXT("noise_gyro_bias_y");
817  BiasGyroY.Type = EActorAttributeType::Float;
818  BiasGyroY.RecommendedValues = { TEXT("0.0") };
819  BiasGyroY.bRestrictToRecommended = false;
820  // Z Component
821  FActorVariation BiasGyroZ;
822  BiasGyroZ.Id = TEXT("noise_gyro_bias_z");
823  BiasGyroZ.Type = EActorAttributeType::Float;
824  BiasGyroZ.RecommendedValues = { TEXT("0.0") };
825  BiasGyroZ.bRestrictToRecommended = false;
826 
827  Definition.Variations.Append({
828  NoiseSeed,
829  StdDevAccelX,
830  StdDevAccelY,
831  StdDevAccelZ,
832  StdDevGyroX,
833  StdDevGyroY,
834  StdDevGyroZ,
835  BiasGyroX,
836  BiasGyroY,
837  BiasGyroZ});
838 
839  Success = CheckActorDefinition(Definition);
840 }
841 
843 {
844  FActorDefinition Definition;
845  bool Success;
846  MakeRadarDefinition(Success, Definition);
847  check(Success);
848  return Definition;
849 }
850 
852  bool &Success,
853  FActorDefinition &Definition)
854 {
855  FillIdAndTags(Definition, TEXT("sensor"), TEXT("other"), TEXT("radar"));
856  AddVariationsForSensor(Definition);
857 
858  FActorVariation HorizontalFOV;
859  HorizontalFOV.Id = TEXT("horizontal_fov");
860  HorizontalFOV.Type = EActorAttributeType::Float;
861  HorizontalFOV.RecommendedValues = { TEXT("30") };
862  HorizontalFOV.bRestrictToRecommended = false;
863 
864  FActorVariation VerticalFOV;
865  VerticalFOV.Id = TEXT("vertical_fov");
866  VerticalFOV.Type = EActorAttributeType::Float;
867  VerticalFOV.RecommendedValues = { TEXT("30") };
868  VerticalFOV.bRestrictToRecommended = false;
869 
870  FActorVariation Range;
871  Range.Id = TEXT("range");
873  Range.RecommendedValues = { TEXT("100") };
874  Range.bRestrictToRecommended = false;
875 
876  FActorVariation PointsPerSecond;
877  PointsPerSecond.Id = TEXT("points_per_second");
878  PointsPerSecond.Type = EActorAttributeType::Int;
879  PointsPerSecond.RecommendedValues = { TEXT("1500") };
880  PointsPerSecond.bRestrictToRecommended = false;
881 
882  // Noise seed
883  FActorVariation NoiseSeed;
884  NoiseSeed.Id = TEXT("noise_seed");
885  NoiseSeed.Type = EActorAttributeType::Int;
886  NoiseSeed.RecommendedValues = { TEXT("0") };
887  NoiseSeed.bRestrictToRecommended = false;
888 
889  Definition.Variations.Append({
890  HorizontalFOV,
891  VerticalFOV,
892  Range,
893  PointsPerSecond,
894  NoiseSeed});
895 
896  Success = CheckActorDefinition(Definition);
897 }
898 
900  const FString &Id)
901 {
902  FActorDefinition Definition;
903  bool Success;
904  MakeLidarDefinition(Id, Success, Definition);
905  check(Success);
906  return Definition;
907 }
908 
910  const FString &Id,
911  bool &Success,
912  FActorDefinition &Definition)
913 {
914  FillIdAndTags(Definition, TEXT("sensor"), TEXT("lidar"), Id);
916  AddVariationsForSensor(Definition);
917  // Number of channels.
918  FActorVariation Channels;
919  Channels.Id = TEXT("channels");
920  Channels.Type = EActorAttributeType::Int;
921  Channels.RecommendedValues = { TEXT("32") };
922  // Range.
923  FActorVariation Range;
924  Range.Id = TEXT("range");
926  Range.RecommendedValues = { TEXT("10.0") }; // 10 meters
927  // Points per second.
928  FActorVariation PointsPerSecond;
929  PointsPerSecond.Id = TEXT("points_per_second");
930  PointsPerSecond.Type = EActorAttributeType::Int;
931  PointsPerSecond.RecommendedValues = { TEXT("56000") };
932  // Frequency.
933  FActorVariation Frequency;
934  Frequency.Id = TEXT("rotation_frequency");
935  Frequency.Type = EActorAttributeType::Float;
936  Frequency.RecommendedValues = { TEXT("10.0") };
937  // Upper FOV limit.
938  FActorVariation UpperFOV;
939  UpperFOV.Id = TEXT("upper_fov");
940  UpperFOV.Type = EActorAttributeType::Float;
941  UpperFOV.RecommendedValues = { TEXT("10.0") };
942  // Lower FOV limit.
943  FActorVariation LowerFOV;
944  LowerFOV.Id = TEXT("lower_fov");
945  LowerFOV.Type = EActorAttributeType::Float;
946  LowerFOV.RecommendedValues = { TEXT("-30.0") };
947  // Horizontal FOV.
948  FActorVariation HorizontalFOV;
949  HorizontalFOV.Id = TEXT("horizontal_fov");
950  HorizontalFOV.Type = EActorAttributeType::Float;
951  HorizontalFOV.RecommendedValues = { TEXT("360.0") };
952  // Atmospheric Attenuation Rate.
953  FActorVariation AtmospAttenRate;
954  AtmospAttenRate.Id = TEXT("atmosphere_attenuation_rate");
955  AtmospAttenRate.Type = EActorAttributeType::Float;
956  AtmospAttenRate.RecommendedValues = { TEXT("0.004") };
957  // Noise seed
958  FActorVariation NoiseSeed;
959  NoiseSeed.Id = TEXT("noise_seed");
960  NoiseSeed.Type = EActorAttributeType::Int;
961  NoiseSeed.RecommendedValues = { TEXT("0") };
962  NoiseSeed.bRestrictToRecommended = false;
963  // Dropoff General Rate
964  FActorVariation DropOffGenRate;
965  DropOffGenRate.Id = TEXT("dropoff_general_rate");
966  DropOffGenRate.Type = EActorAttributeType::Float;
967  DropOffGenRate.RecommendedValues = { TEXT("0.45") };
968  // Dropoff intensity limit.
969  FActorVariation DropOffIntensityLimit;
970  DropOffIntensityLimit.Id = TEXT("dropoff_intensity_limit");
971  DropOffIntensityLimit.Type = EActorAttributeType::Float;
972  DropOffIntensityLimit.RecommendedValues = { TEXT("0.8") };
973  // Dropoff at zero intensity.
974  FActorVariation DropOffAtZeroIntensity;
975  DropOffAtZeroIntensity.Id = TEXT("dropoff_zero_intensity");
976  DropOffAtZeroIntensity.Type = EActorAttributeType::Float;
977  DropOffAtZeroIntensity.RecommendedValues = { TEXT("0.4") };
978  // Noise in lidar cloud points.
979  FActorVariation StdDevLidar;
980  StdDevLidar.Id = TEXT("noise_stddev");
981  StdDevLidar.Type = EActorAttributeType::Float;
982  StdDevLidar.RecommendedValues = { TEXT("0.0") };
983 
984  if (Id == "ray_cast") {
985  Definition.Variations.Append({
986  Channels,
987  Range,
988  PointsPerSecond,
989  Frequency,
990  UpperFOV,
991  LowerFOV,
992  AtmospAttenRate,
993  NoiseSeed,
994  DropOffGenRate,
995  DropOffIntensityLimit,
996  DropOffAtZeroIntensity,
997  StdDevLidar,
998  HorizontalFOV});
999  }
1000  else if (Id == "ray_cast_semantic") {
1001  Definition.Variations.Append({
1002  Channels,
1003  Range,
1004  PointsPerSecond,
1005  Frequency,
1006  UpperFOV,
1007  LowerFOV,
1008  HorizontalFOV});
1009  }
1010  else {
1011  DEBUG_ASSERT(false);
1012  }
1013 
1014  Success = CheckActorDefinition(Definition);
1015 }
1016 
1018 {
1019  FActorDefinition Definition;
1020  bool Success;
1021  MakeGnssDefinition(Success, Definition);
1022  check(Success);
1023  return Definition;
1024 }
1025 
1027  bool &Success,
1028  FActorDefinition &Definition)
1029 {
1030  FillIdAndTags(Definition, TEXT("sensor"), TEXT("other"), TEXT("gnss"));
1031  AddVariationsForSensor(Definition);
1032 
1033  // - Noise seed --------------------------------
1034  FActorVariation NoiseSeed;
1035  NoiseSeed.Id = TEXT("noise_seed");
1036  NoiseSeed.Type = EActorAttributeType::Int;
1037  NoiseSeed.RecommendedValues = { TEXT("0") };
1038  NoiseSeed.bRestrictToRecommended = false;
1039 
1040  // - Latitude ----------------------------------
1041  FActorVariation StdDevLat;
1042  StdDevLat.Id = TEXT("noise_lat_stddev");
1043  StdDevLat.Type = EActorAttributeType::Float;
1044  StdDevLat.RecommendedValues = { TEXT("0.0") };
1045  StdDevLat.bRestrictToRecommended = false;
1046  FActorVariation BiasLat;
1047  BiasLat.Id = TEXT("noise_lat_bias");
1048  BiasLat.Type = EActorAttributeType::Float;
1049  BiasLat.RecommendedValues = { TEXT("0.0") };
1050  BiasLat.bRestrictToRecommended = false;
1051 
1052  // - Longitude ---------------------------------
1053  FActorVariation StdDevLong;
1054  StdDevLong.Id = TEXT("noise_lon_stddev");
1055  StdDevLong.Type = EActorAttributeType::Float;
1056  StdDevLong.RecommendedValues = { TEXT("0.0") };
1057  StdDevLong.bRestrictToRecommended = false;
1058  FActorVariation BiasLong;
1059  BiasLong.Id = TEXT("noise_lon_bias");
1060  BiasLong.Type = EActorAttributeType::Float;
1061  BiasLong.RecommendedValues = { TEXT("0.0") };
1062  BiasLong.bRestrictToRecommended = false;
1063 
1064  // - Altitude ----------------------------------
1065  FActorVariation StdDevAlt;
1066  StdDevAlt.Id = TEXT("noise_alt_stddev");
1067  StdDevAlt.Type = EActorAttributeType::Float;
1068  StdDevAlt.RecommendedValues = { TEXT("0.0") };
1069  StdDevAlt.bRestrictToRecommended = false;
1070  FActorVariation BiasAlt;
1071  BiasAlt.Id = TEXT("noise_alt_bias");
1072  BiasAlt.Type = EActorAttributeType::Float;
1073  BiasAlt.RecommendedValues = { TEXT("0.0") };
1074  BiasAlt.bRestrictToRecommended = false;
1075 
1076  Definition.Variations.Append({
1077  NoiseSeed,
1078  StdDevLat,
1079  BiasLat,
1080  StdDevLong,
1081  BiasLong,
1082  StdDevAlt,
1083  BiasAlt});
1084 
1085  Success = CheckActorDefinition(Definition);
1086 }
1087 
1089  const FVehicleParameters &Parameters,
1090  bool &Success,
1091  FActorDefinition &Definition)
1092 {
1093  /// @todo We need to validate here the params.
1094  FillIdAndTags(Definition, TEXT("vehicle"), Parameters.Make, Parameters.Model);
1096  {TEXT("autopilot"), TEXT("scenario"), TEXT("ego_vehicle")});
1097  Definition.Class = Parameters.Class;
1098 
1099  if (Parameters.RecommendedColors.Num() > 0)
1100  {
1101  FActorVariation Colors;
1102  Colors.Id = TEXT("color");
1104  Colors.bRestrictToRecommended = false;
1105  for (auto &Color : Parameters.RecommendedColors)
1106  {
1107  Colors.RecommendedValues.Emplace(ColorToFString(Color));
1108  }
1109  Definition.Variations.Emplace(Colors);
1110  }
1111 
1112  if (Parameters.SupportedDrivers.Num() > 0)
1113  {
1114  FActorVariation Drivers;
1115  Drivers.Id = TEXT("driver_id");
1116  Drivers.Type = EActorAttributeType::Int;
1117  Drivers.bRestrictToRecommended = true;
1118  for (auto &Id : Parameters.SupportedDrivers)
1119  {
1120  Drivers.RecommendedValues.Emplace(FString::FromInt(Id));
1121  }
1122  Definition.Variations.Emplace(Drivers);
1123  }
1124 
1125  FActorVariation StickyControl;
1126  StickyControl.Id = TEXT("sticky_control");
1127  StickyControl.Type = EActorAttributeType::Bool;
1128  StickyControl.bRestrictToRecommended = false;
1129  StickyControl.RecommendedValues.Emplace(TEXT("true"));
1130  Definition.Variations.Emplace(StickyControl);
1131 
1132  FActorVariation TerramechanicsAttribute;
1133  TerramechanicsAttribute.Id = TEXT("terramechanics");
1134  TerramechanicsAttribute.Type = EActorAttributeType::Bool;
1135  TerramechanicsAttribute.bRestrictToRecommended = false;
1136  TerramechanicsAttribute.RecommendedValues.Emplace(TEXT("false"));
1137  Definition.Variations.Emplace(TerramechanicsAttribute);
1138 
1139  Definition.Attributes.Emplace(FActorAttribute{
1140  TEXT("object_type"),
1142  Parameters.ObjectType});
1143 
1144  Definition.Attributes.Emplace(FActorAttribute{
1145  TEXT("base_type"),
1147  Parameters.BaseType});
1148  Success = CheckActorDefinition(Definition);
1149 
1150  Definition.Attributes.Emplace(FActorAttribute{
1151  TEXT("special_type"),
1153  Parameters.SpecialType});
1154  Success = CheckActorDefinition(Definition);
1155 
1156  Definition.Attributes.Emplace(FActorAttribute{
1157  TEXT("number_of_wheels"),
1159  FString::FromInt(Parameters.NumberOfWheels)});
1160  Success = CheckActorDefinition(Definition);
1161 
1162  Definition.Attributes.Emplace(FActorAttribute{
1163  TEXT("generation"),
1165  FString::FromInt(Parameters.Generation)});
1166  Success = CheckActorDefinition(Definition);
1167 
1168  Definition.Attributes.Emplace(FActorAttribute{
1169  TEXT("has_dynamic_doors"),
1171  Parameters.HasDynamicDoors ? TEXT("true") : TEXT("false")});
1172  Success = CheckActorDefinition(Definition);
1173 
1174  Definition.Attributes.Emplace(FActorAttribute{
1175  TEXT("has_lights"),
1177  Parameters.HasLights ? TEXT("true") : TEXT("false")});
1178  Success = CheckActorDefinition(Definition);
1179 }
1180 
1181 template <typename T, typename Functor>
1183  const TArray<T> &ParameterArray,
1184  TArray<FActorDefinition> &Definitions,
1185  Functor Maker)
1186 {
1187  for (auto &Item : ParameterArray)
1188  {
1189  FActorDefinition Definition;
1190  bool Success = false;
1191  Maker(Item, Success, Definition);
1192  if (Success)
1193  {
1194  Definitions.Emplace(std::move(Definition));
1195  }
1196  }
1197 }
1198 
1200  const TArray<FVehicleParameters> &ParameterArray,
1201  TArray<FActorDefinition> &Definitions)
1202 {
1203  FillActorDefinitionArray(ParameterArray, Definitions, &MakeVehicleDefinition);
1204 }
1205 
1207  const FPedestrianParameters &Parameters,
1208  bool &Success,
1209  FActorDefinition &Definition)
1210 {
1211  /// @todo We need to validate here the params.
1212  FillIdAndTags(Definition, TEXT("walker"), TEXT("pedestrian"), Parameters.Id);
1213  AddRecommendedValuesForActorRoleName(Definition, {TEXT("pedestrian")});
1214  Definition.Class = Parameters.Class;
1215 
1216  auto GetGender = [](EPedestrianGender Value) {
1217  switch (Value)
1218  {
1219  case EPedestrianGender::Female: return TEXT("female");
1220  case EPedestrianGender::Male: return TEXT("male");
1221  default: return TEXT("other");
1222  }
1223  };
1224 
1225  auto GetAge = [](EPedestrianAge Value) {
1226  switch (Value)
1227  {
1228  case EPedestrianAge::Child: return TEXT("child");
1229  case EPedestrianAge::Teenager: return TEXT("teenager");
1230  case EPedestrianAge::Elderly: return TEXT("elderly");
1231  default: return TEXT("adult");
1232  }
1233  };
1234 
1235  Definition.Attributes.Emplace(FActorAttribute{
1236  TEXT("gender"),
1238  GetGender(Parameters.Gender)});
1239 
1240  Definition.Attributes.Emplace(FActorAttribute{
1241  TEXT("generation"),
1243  FString::FromInt(Parameters.Generation)});
1244 
1245  Definition.Attributes.Emplace(FActorAttribute{
1246  TEXT("age"),
1248  GetAge(Parameters.Age)});
1249 
1250  if (Parameters.Speed.Num() > 0)
1251  {
1252  FActorVariation Speed;
1253  Speed.Id = TEXT("speed");
1255  for (auto &Value : Parameters.Speed)
1256  {
1257  Speed.RecommendedValues.Emplace(FString::SanitizeFloat(Value));
1258  }
1259  Speed.bRestrictToRecommended = false;
1260  Definition.Variations.Emplace(Speed);
1261  }
1262 
1263  FActorVariation IsInvincible;
1264  IsInvincible.Id = TEXT("is_invincible");
1265  IsInvincible.Type = EActorAttributeType::Bool;
1266  IsInvincible.RecommendedValues = { TEXT("true") };
1267  IsInvincible.bRestrictToRecommended = false;
1268  Definition.Variations.Emplace(IsInvincible);
1269 
1270  Success = CheckActorDefinition(Definition);
1271 }
1272 
1274  const TArray<FPedestrianParameters> &ParameterArray,
1275  TArray<FActorDefinition> &Definitions)
1276 {
1277  FillActorDefinitionArray(ParameterArray, Definitions, &MakePedestrianDefinition);
1278 }
1279 
1281  const TArray<FString> &ParameterArray,
1282  TArray<FActorDefinition> &Definitions)
1283 {
1284  FillActorDefinitionArray(ParameterArray, Definitions, &MakeTriggerDefinition);
1285 }
1286 
1288  const FString &Id,
1289  bool &Success,
1290  FActorDefinition &Definition)
1291 {
1292  FillIdAndTags(Definition, TEXT("static"), TEXT("trigger"), Id);
1293  AddVariationsForTrigger(Definition);
1294  Success = CheckActorDefinition(Definition);
1295  check(Success);
1296 }
1297 
1299  const FPropParameters &Parameters,
1300  bool &Success,
1301  FActorDefinition &Definition)
1302 {
1303  /// @todo We need to validate here the params.
1304  FillIdAndTags(Definition, TEXT("static"), TEXT("prop"), Parameters.Name);
1305  AddRecommendedValuesForActorRoleName(Definition, {TEXT("prop")});
1306 
1307  auto GetSize = [](EPropSize Value) {
1308  switch (Value)
1309  {
1310  case EPropSize::Tiny: return TEXT("tiny");
1311  case EPropSize::Small: return TEXT("small");
1312  case EPropSize::Medium: return TEXT("medium");
1313  case EPropSize::Big: return TEXT("big");
1314  case EPropSize::Huge: return TEXT("huge");
1315  default: return TEXT("unknown");
1316  }
1317  };
1318 
1319  Definition.Attributes.Emplace(FActorAttribute{
1320  TEXT("size"),
1322  GetSize(Parameters.Size)});
1323 
1324  Success = CheckActorDefinition(Definition);
1325 }
1326 
1328  const TArray<FPropParameters> &ParameterArray,
1329  TArray<FActorDefinition> &Definitions)
1330 {
1331  FillActorDefinitionArray(ParameterArray, Definitions, &MakePropDefinition);
1332 }
1333 
1335  const FString &Type,
1336  const FString &Id,
1337  FActorDefinition &Definition)
1338 {
1339  Definition = MakeGenericSensorDefinition(TEXT("other"), TEXT("obstacle"));
1340  AddVariationsForSensor(Definition);
1341  // Distance.
1342  FActorVariation distance;
1343  distance.Id = TEXT("distance");
1344  distance.Type = EActorAttributeType::Float;
1345  distance.RecommendedValues = { TEXT("5.0") };
1346  distance.bRestrictToRecommended = false;
1347  // HitRadius.
1348  FActorVariation hitradius;
1349  hitradius.Id = TEXT("hit_radius");
1350  hitradius.Type = EActorAttributeType::Float;
1351  hitradius.RecommendedValues = { TEXT("0.5") };
1352  hitradius.bRestrictToRecommended = false;
1353  // Only Dynamics
1354  FActorVariation onlydynamics;
1355  onlydynamics.Id = TEXT("only_dynamics");
1356  onlydynamics.Type = EActorAttributeType::Bool;
1357  onlydynamics.RecommendedValues = { TEXT("false") };
1358  onlydynamics.bRestrictToRecommended = false;
1359  // Debug Line Trace
1360  FActorVariation debuglinetrace;
1361  debuglinetrace.Id = TEXT("debug_linetrace");
1362  debuglinetrace.Type = EActorAttributeType::Bool;
1363  debuglinetrace.RecommendedValues = { TEXT("false") };
1364  debuglinetrace.bRestrictToRecommended = false;
1365 
1366  Definition.Variations.Append({
1367  distance,
1368  hitradius,
1369  onlydynamics,
1370  debuglinetrace
1371  });
1372 
1373 }
1374 /// ============================================================================
1375 /// -- Helpers to retrieve attribute values ------------------------------------
1376 /// ============================================================================
1377 
1379  const FActorAttribute &ActorAttribute,
1380  bool Default)
1381 {
1382  if (ActorAttribute.Type != EActorAttributeType::Bool)
1383  {
1384  UE_LOG(LogCarla, Error, TEXT("ActorAttribute '%s' is not a bool"), *ActorAttribute.Id);
1385  return Default;
1386  }
1387  return ActorAttribute.Value.ToBool();
1388 }
1389 
1391  const FActorAttribute &ActorAttribute,
1392  int32 Default)
1393 {
1394  if (ActorAttribute.Type != EActorAttributeType::Int)
1395  {
1396  UE_LOG(LogCarla, Error, TEXT("ActorAttribute '%s' is not an int"), *ActorAttribute.Id);
1397  return Default;
1398  }
1399  return FCString::Atoi(*ActorAttribute.Value);
1400 }
1401 
1403  const FActorAttribute &ActorAttribute,
1404  float Default)
1405 {
1406  if (ActorAttribute.Type != EActorAttributeType::Float)
1407  {
1408  UE_LOG(LogCarla, Error, TEXT("ActorAttribute '%s' is not a float"), *ActorAttribute.Id);
1409  return Default;
1410  }
1411  return FCString::Atof(*ActorAttribute.Value);
1412 }
1413 
1415  const FActorAttribute &ActorAttribute,
1416  const FString &Default)
1417 {
1418  if (ActorAttribute.Type != EActorAttributeType::String)
1419  {
1420  UE_LOG(LogCarla, Error, TEXT("ActorAttribute '%s' is not a string"), *ActorAttribute.Id);
1421  return Default;
1422  }
1423  return ActorAttribute.Value;
1424 }
1425 
1427  const FActorAttribute &ActorAttribute,
1428  const FColor &Default)
1429 {
1430  if (ActorAttribute.Type != EActorAttributeType::RGBColor)
1431  {
1432  UE_LOG(LogCarla, Error, TEXT("ActorAttribute '%s' is not a color"), *ActorAttribute.Id);
1433  return Default;
1434  }
1435  TArray<FString> Channels;
1436  ActorAttribute.Value.ParseIntoArray(Channels, TEXT(","), false);
1437  if (Channels.Num() != 3)
1438  {
1439  UE_LOG(LogCarla,
1440  Error,
1441  TEXT("ActorAttribute '%s': invalid color '%s'"),
1442  *ActorAttribute.Id,
1443  *ActorAttribute.Value);
1444  return Default;
1445  }
1446  TArray<uint8> Colors;
1447  for (auto &Str : Channels)
1448  {
1449  auto Val = FCString::Atoi(*Str);
1450  if ((Val < 0) || (Val > std::numeric_limits<uint8>::max()))
1451  {
1452  UE_LOG(LogCarla,
1453  Error,
1454  TEXT("ActorAttribute '%s': invalid color '%s'"),
1455  *ActorAttribute.Id,
1456  *ActorAttribute.Value);
1457  return Default;
1458  }
1459  Colors.Add(Val);
1460  }
1461  FColor Color;
1462  Color.R = Colors[0u];
1463  Color.G = Colors[1u];
1464  Color.B = Colors[2u];
1465  return Color;
1466 }
1467 
1469  const FString &Id,
1470  const TMap<FString, FActorAttribute> &Attributes,
1471  bool Default)
1472 {
1473  return Attributes.Contains(Id) ?
1474  ActorAttributeToBool(Attributes[Id], Default) :
1475  Default;
1476 }
1477 
1479  const FString &Id,
1480  const TMap<FString, FActorAttribute> &Attributes,
1481  int32 Default)
1482 {
1483  return Attributes.Contains(Id) ?
1484  ActorAttributeToInt(Attributes[Id], Default) :
1485  Default;
1486 }
1487 
1489  const FString &Id,
1490  const TMap<FString, FActorAttribute> &Attributes,
1491  float Default)
1492 {
1493  return Attributes.Contains(Id) ?
1494  ActorAttributeToFloat(Attributes[Id], Default) :
1495  Default;
1496 }
1497 
1499  const FString &Id,
1500  const TMap<FString, FActorAttribute> &Attributes,
1501  const FString &Default)
1502 {
1503  return Attributes.Contains(Id) ?
1504  ActorAttributeToString(Attributes[Id], Default) :
1505  Default;
1506 }
1507 
1509  const FString &Id,
1510  const TMap<FString, FActorAttribute> &Attributes,
1511  const FColor &Default)
1512 {
1513  return Attributes.Contains(Id) ?
1514  ActorAttributeToColor(Attributes[Id], Default) :
1515  Default;
1516 }
1517 
1518 /// ============================================================================
1519 /// -- Helpers to set Actors ---------------------------------------------------
1520 /// ============================================================================
1521 
1522 // Here we do different checks when we are in editor because we don't want the
1523 // editor crashing while people are testing new actor definitions.
1524 #if WITH_EDITOR
1525 # define CARLA_ABFL_CHECK_ACTOR(ActorPtr) \
1526  if ((ActorPtr == nullptr) || ActorPtr->IsPendingKill()) \
1527  { \
1528  UE_LOG(LogCarla, Error, TEXT("Cannot set empty actor!")); \
1529  return; \
1530  }
1531 #else
1532 # define CARLA_ABFL_CHECK_ACTOR(ActorPtr) \
1533  check((ActorPtr != nullptr) && !ActorPtr->IsPendingKill());
1534 #endif // WITH_EDITOR
1535 
1537  const FActorDescription &Description,
1538  ASceneCaptureSensor *Camera)
1539 {
1540  CARLA_ABFL_CHECK_ACTOR(Camera);
1541  Camera->SetImageSize(
1542  RetrieveActorAttributeToInt("image_size_x", Description.Variations, 800),
1543  RetrieveActorAttributeToInt("image_size_y", Description.Variations, 600));
1544  Camera->SetFOVAngle(
1545  RetrieveActorAttributeToFloat("fov", Description.Variations, 90.0f));
1546  if (Description.Variations.Contains("enable_postprocess_effects"))
1547  {
1549  ActorAttributeToBool(
1550  Description.Variations["enable_postprocess_effects"],
1551  true));
1552  Camera->SetTargetGamma(
1553  RetrieveActorAttributeToFloat("gamma", Description.Variations, 2.2f));
1554  Camera->SetMotionBlurIntensity(
1555  RetrieveActorAttributeToFloat("motion_blur_intensity", Description.Variations, 0.5f));
1557  RetrieveActorAttributeToFloat("motion_blur_max_distortion", Description.Variations, 5.0f));
1559  RetrieveActorAttributeToFloat("motion_blur_min_object_screen_size", Description.Variations, 0.5f));
1560  Camera->SetLensFlareIntensity(
1561  RetrieveActorAttributeToFloat("lens_flare_intensity", Description.Variations, 0.1f));
1562  Camera->SetBloomIntensity(
1563  RetrieveActorAttributeToFloat("bloom_intensity", Description.Variations, 0.675f));
1564  // Exposure, histogram mode by default
1565  if (RetrieveActorAttributeToString("exposure_mode", Description.Variations, "histogram") == "histogram")
1566  {
1567  Camera->SetExposureMethod(EAutoExposureMethod::AEM_Histogram);
1568  }
1569  else
1570  {
1571  Camera->SetExposureMethod(EAutoExposureMethod::AEM_Manual);
1572  }
1573  Camera->SetExposureCompensation(
1574  RetrieveActorAttributeToFloat("exposure_compensation", Description.Variations, 0.0f));
1575  Camera->SetShutterSpeed(
1576  RetrieveActorAttributeToFloat("shutter_speed", Description.Variations, 200.0f));
1577  Camera->SetISO(
1578  RetrieveActorAttributeToFloat("iso", Description.Variations, 100.0f));
1579  Camera->SetAperture(
1580  RetrieveActorAttributeToFloat("fstop", Description.Variations, 1.4f));
1581 
1582  Camera->SetExposureMinBrightness(
1583  RetrieveActorAttributeToFloat("exposure_min_bright", Description.Variations, 7.0f));
1584  Camera->SetExposureMaxBrightness(
1585  RetrieveActorAttributeToFloat("exposure_max_bright", Description.Variations, 9.0f));
1586  Camera->SetExposureSpeedUp(
1587  RetrieveActorAttributeToFloat("exposure_speed_up", Description.Variations, 3.0f));
1588  Camera->SetExposureSpeedDown(
1589  RetrieveActorAttributeToFloat("exposure_speed_down", Description.Variations, 1.0f));
1591  RetrieveActorAttributeToFloat("calibration_constant", Description.Variations, 16.0f));
1592 
1593  Camera->SetFocalDistance(
1594  RetrieveActorAttributeToFloat("focal_distance", Description.Variations, 1000.0f));
1595  Camera->SetDepthBlurAmount(
1596  RetrieveActorAttributeToFloat("blur_amount", Description.Variations, 1.0f));
1597  Camera->SetDepthBlurRadius(
1598  RetrieveActorAttributeToFloat("blur_radius", Description.Variations, 0.0f));
1599  Camera->SetDepthOfFieldMinFstop(
1600  RetrieveActorAttributeToFloat("min_fstop", Description.Variations, 1.2f));
1601  Camera->SetBladeCount(
1602  RetrieveActorAttributeToInt("blade_count", Description.Variations, 5));
1603 
1604  Camera->SetFilmSlope(
1605  RetrieveActorAttributeToFloat("slope", Description.Variations, 0.88f));
1606  Camera->SetFilmToe(
1607  RetrieveActorAttributeToFloat("toe", Description.Variations, 0.55f));
1608  Camera->SetFilmShoulder(
1609  RetrieveActorAttributeToFloat("shoulder", Description.Variations, 0.26f));
1610  Camera->SetFilmBlackClip(
1611  RetrieveActorAttributeToFloat("black_clip", Description.Variations, 0.0f));
1612  Camera->SetFilmWhiteClip(
1613  RetrieveActorAttributeToFloat("white_clip", Description.Variations, 0.04f));
1614 
1615  Camera->SetWhiteTemp(
1616  RetrieveActorAttributeToFloat("temp", Description.Variations, 6500.0f));
1617  Camera->SetWhiteTint(
1618  RetrieveActorAttributeToFloat("tint", Description.Variations, 0.0f));
1619 
1620  Camera->SetChromAberrIntensity(
1621  RetrieveActorAttributeToFloat("chromatic_aberration_intensity", Description.Variations, 0.0f));
1622  Camera->SetChromAberrOffset(
1623  RetrieveActorAttributeToFloat("chromatic_aberration_offset", Description.Variations, 0.0f));
1624  }
1625 }
1626 
1628  const FActorDescription &Description,
1629  AShaderBasedSensor *Camera)
1630 {
1631  CARLA_ABFL_CHECK_ACTOR(Camera);
1632  Camera->SetFloatShaderParameter(0, TEXT("CircleFalloff_NState"),
1633  RetrieveActorAttributeToFloat("lens_circle_falloff", Description.Variations, 5.0f));
1634  Camera->SetFloatShaderParameter(0, TEXT("CircleMultiplier_NState"),
1635  RetrieveActorAttributeToFloat("lens_circle_multiplier", Description.Variations, 0.0f));
1636  Camera->SetFloatShaderParameter(0, TEXT("K_NState"),
1637  RetrieveActorAttributeToFloat("lens_k", Description.Variations, -1.0f));
1638  Camera->SetFloatShaderParameter(0, TEXT("kcube"),
1639  RetrieveActorAttributeToFloat("lens_kcube", Description.Variations, 0.0f));
1640  Camera->SetFloatShaderParameter(0, TEXT("XSize_NState"),
1641  RetrieveActorAttributeToFloat("lens_x_size", Description.Variations, 0.08f));
1642  Camera->SetFloatShaderParameter(0, TEXT("YSize_NState"),
1643  RetrieveActorAttributeToFloat("lens_y_size", Description.Variations, 0.08f));
1644 }
1645 
1647  const FActorDescription &Description,
1648  FLidarDescription &Lidar)
1649 {
1650  constexpr float TO_CENTIMETERS = 1e2;
1651  Lidar.Channels =
1652  RetrieveActorAttributeToInt("channels", Description.Variations, Lidar.Channels);
1653  Lidar.Range =
1654  RetrieveActorAttributeToFloat("range", Description.Variations, 10.0f) * TO_CENTIMETERS;
1655  Lidar.PointsPerSecond =
1656  RetrieveActorAttributeToInt("points_per_second", Description.Variations, Lidar.PointsPerSecond);
1657  Lidar.RotationFrequency =
1658  RetrieveActorAttributeToFloat("rotation_frequency", Description.Variations, Lidar.RotationFrequency);
1659  Lidar.UpperFovLimit =
1660  RetrieveActorAttributeToFloat("upper_fov", Description.Variations, Lidar.UpperFovLimit);
1661  Lidar.LowerFovLimit =
1662  RetrieveActorAttributeToFloat("lower_fov", Description.Variations, Lidar.LowerFovLimit);
1663  Lidar.HorizontalFov =
1664  RetrieveActorAttributeToFloat("horizontal_fov", Description.Variations, Lidar.HorizontalFov);
1665  Lidar.AtmospAttenRate =
1666  RetrieveActorAttributeToFloat("atmosphere_attenuation_rate", Description.Variations, Lidar.AtmospAttenRate);
1667  Lidar.RandomSeed =
1668  RetrieveActorAttributeToInt("noise_seed", Description.Variations, Lidar.RandomSeed);
1669  Lidar.DropOffGenRate =
1670  RetrieveActorAttributeToFloat("dropoff_general_rate", Description.Variations, Lidar.DropOffGenRate);
1671  Lidar.DropOffIntensityLimit =
1672  RetrieveActorAttributeToFloat("dropoff_intensity_limit", Description.Variations, Lidar.DropOffIntensityLimit);
1673  Lidar.DropOffAtZeroIntensity =
1674  RetrieveActorAttributeToFloat("dropoff_zero_intensity", Description.Variations, Lidar.DropOffAtZeroIntensity);
1675  Lidar.NoiseStdDev =
1676  RetrieveActorAttributeToFloat("noise_stddev", Description.Variations, Lidar.NoiseStdDev);
1677 }
1678 
1680  const FActorDescription &Description,
1681  AGnssSensor *Gnss)
1682 {
1683  CARLA_ABFL_CHECK_ACTOR(Gnss);
1684  if (Description.Variations.Contains("noise_seed"))
1685  {
1686  Gnss->SetSeed(
1687  RetrieveActorAttributeToInt("noise_seed", Description.Variations, 0));
1688  }
1689  else
1690  {
1691  Gnss->SetSeed(Gnss->GetRandomEngine()->GenerateRandomSeed());
1692  }
1693 
1694  Gnss->SetLatitudeDeviation(
1695  RetrieveActorAttributeToFloat("noise_lat_stddev", Description.Variations, 0.0f));
1696  Gnss->SetLongitudeDeviation(
1697  RetrieveActorAttributeToFloat("noise_lon_stddev", Description.Variations, 0.0f));
1698  Gnss->SetAltitudeDeviation(
1699  RetrieveActorAttributeToFloat("noise_alt_stddev", Description.Variations, 0.0f));
1700  Gnss->SetLatitudeBias(
1701  RetrieveActorAttributeToFloat("noise_lat_bias", Description.Variations, 0.0f));
1702  Gnss->SetLongitudeBias(
1703  RetrieveActorAttributeToFloat("noise_lon_bias", Description.Variations, 0.0f));
1704  Gnss->SetAltitudeBias(
1705  RetrieveActorAttributeToFloat("noise_alt_bias", Description.Variations, 0.0f));
1706 }
1707 
1709  const FActorDescription &Description,
1711 {
1713  if (Description.Variations.Contains("noise_seed"))
1714  {
1715  IMU->SetSeed(
1716  RetrieveActorAttributeToInt("noise_seed", Description.Variations, 0));
1717  }
1718  else
1719  {
1720  IMU->SetSeed(IMU->GetRandomEngine()->GenerateRandomSeed());
1721  }
1722 
1724  RetrieveActorAttributeToFloat("noise_accel_stddev_x", Description.Variations, 0.0f),
1725  RetrieveActorAttributeToFloat("noise_accel_stddev_y", Description.Variations, 0.0f),
1726  RetrieveActorAttributeToFloat("noise_accel_stddev_z", Description.Variations, 0.0f)});
1727 
1729  RetrieveActorAttributeToFloat("noise_gyro_stddev_x", Description.Variations, 0.0f),
1730  RetrieveActorAttributeToFloat("noise_gyro_stddev_y", Description.Variations, 0.0f),
1731  RetrieveActorAttributeToFloat("noise_gyro_stddev_z", Description.Variations, 0.0f)});
1732 
1733  IMU->SetGyroscopeBias({
1734  RetrieveActorAttributeToFloat("noise_gyro_bias_x", Description.Variations, 0.0f),
1735  RetrieveActorAttributeToFloat("noise_gyro_bias_y", Description.Variations, 0.0f),
1736  RetrieveActorAttributeToFloat("noise_gyro_bias_z", Description.Variations, 0.0f)});
1737 }
1738 
1740  const FActorDescription &Description,
1741  ARadar *Radar)
1742 {
1743  CARLA_ABFL_CHECK_ACTOR(Radar);
1744  constexpr float TO_CENTIMETERS = 1e2;
1745 
1746  if (Description.Variations.Contains("noise_seed"))
1747  {
1748  Radar->SetSeed(
1749  RetrieveActorAttributeToInt("noise_seed", Description.Variations, 0));
1750  }
1751  else
1752  {
1753  Radar->SetSeed(Radar->GetRandomEngine()->GenerateRandomSeed());
1754  }
1755 
1756  Radar->SetHorizontalFOV(
1757  RetrieveActorAttributeToFloat("horizontal_fov", Description.Variations, 30.0f));
1758  Radar->SetVerticalFOV(
1759  RetrieveActorAttributeToFloat("vertical_fov", Description.Variations, 30.0f));
1760  Radar->SetRange(
1761  RetrieveActorAttributeToFloat("range", Description.Variations, 100.0f) * TO_CENTIMETERS);
1762  Radar->SetPointsPerSecond(
1763  RetrieveActorAttributeToInt("points_per_second", Description.Variations, 1500));
1764 }
1765 
1766 #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:44
void SetLatitudeBias(float Value)
Definition: GnssSensor.cpp:102
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 FActorDefinition MakeNormalsCameraDefinition()
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:87
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:54
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:97
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:107
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:112
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:92
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)
FString BaseType
(OPTIONAL) Use for a base classification of vehicles (car / truck / van / bycicle / motorcycle)...
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:92
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:87
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)
FString SpecialType
(OPTIONAL) Use for a more in-depth classification of vehicles (electric / emergency / taxi ...
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:49
FString GetDisplayId(const FString &Type, size_t Index, const FString &Item)
void SetPointsPerSecond(int NewPointsPerSecond)
Definition: Radar.cpp:59
bool IsValid(const EActorAttributeType Type)
void SetExposureCalibrationConstant(float Constant)
void SetMotionBlurMinObjectScreenSize(float ScreenSize)
static FColor ActorAttributeToColor(const FActorAttribute &ActorAttribute, const FColor &Default)