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.4") };
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("10.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("12.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  MakeNormalsCameraDefinition(Success, Definition);
654  check(Success);
655  return Definition;
656 }
657 
659 {
660  FillIdAndTags(Definition, TEXT("sensor"), TEXT("camera"), TEXT("normals"));
662  AddVariationsForSensor(Definition);
663 
664  // FOV
665  FActorVariation FOV;
666  FOV.Id = TEXT("fov");
668  FOV.RecommendedValues = { TEXT("90.0") };
669  FOV.bRestrictToRecommended = false;
670 
671  // Resolution
672  FActorVariation ResX;
673  ResX.Id = TEXT("image_size_x");
675  ResX.RecommendedValues = { TEXT("800") };
676  ResX.bRestrictToRecommended = false;
677 
678  FActorVariation ResY;
679  ResY.Id = TEXT("image_size_y");
681  ResY.RecommendedValues = { TEXT("600") };
682  ResY.bRestrictToRecommended = false;
683 
684  // Lens parameters
685  FActorVariation LensCircleFalloff;
686  LensCircleFalloff.Id = TEXT("lens_circle_falloff");
687  LensCircleFalloff.Type = EActorAttributeType::Float;
688  LensCircleFalloff.RecommendedValues = { TEXT("5.0") };
689  LensCircleFalloff.bRestrictToRecommended = false;
690 
691  FActorVariation LensCircleMultiplier;
692  LensCircleMultiplier.Id = TEXT("lens_circle_multiplier");
693  LensCircleMultiplier.Type = EActorAttributeType::Float;
694  LensCircleMultiplier.RecommendedValues = { TEXT("0.0") };
695  LensCircleMultiplier.bRestrictToRecommended = false;
696 
697  FActorVariation LensK;
698  LensK.Id = TEXT("lens_k");
700  LensK.RecommendedValues = { TEXT("-1.0") };
701  LensK.bRestrictToRecommended = false;
702 
703  FActorVariation LensKcube;
704  LensKcube.Id = TEXT("lens_kcube");
705  LensKcube.Type = EActorAttributeType::Float;
706  LensKcube.RecommendedValues = { TEXT("0.0") };
707  LensKcube.bRestrictToRecommended = false;
708 
709  FActorVariation LensXSize;
710  LensXSize.Id = TEXT("lens_x_size");
711  LensXSize.Type = EActorAttributeType::Float;
712  LensXSize.RecommendedValues = { TEXT("0.08") };
713  LensXSize.bRestrictToRecommended = false;
714 
715  FActorVariation LensYSize;
716  LensYSize.Id = TEXT("lens_y_size");
717  LensYSize.Type = EActorAttributeType::Float;
718  LensYSize.RecommendedValues = { TEXT("0.08") };
719  LensYSize.bRestrictToRecommended = false;
720 
721  Definition.Variations.Append({
722  ResX,
723  ResY,
724  FOV,
725  LensCircleFalloff,
726  LensCircleMultiplier,
727  LensK,
728  LensKcube,
729  LensXSize,
730  LensYSize});
731 
732  Success = CheckActorDefinition(Definition);
733 }
734 
736 {
737  FActorDefinition Definition;
738  bool Success;
739  MakeIMUDefinition(Success, Definition);
740  check(Success);
741  return Definition;
742 }
743 
745  bool &Success,
746  FActorDefinition &Definition)
747 {
748  FillIdAndTags(Definition, TEXT("sensor"), TEXT("other"), TEXT("imu"));
749  AddVariationsForSensor(Definition);
750 
751  // - Noise seed --------------------------------
752  FActorVariation NoiseSeed;
753  NoiseSeed.Id = TEXT("noise_seed");
754  NoiseSeed.Type = EActorAttributeType::Int;
755  NoiseSeed.RecommendedValues = { TEXT("0") };
756  NoiseSeed.bRestrictToRecommended = false;
757 
758  // - Accelerometer Standard Deviation ----------
759  // X Component
760  FActorVariation StdDevAccelX;
761  StdDevAccelX.Id = TEXT("noise_accel_stddev_x");
762  StdDevAccelX.Type = EActorAttributeType::Float;
763  StdDevAccelX.RecommendedValues = { TEXT("0.0") };
764  StdDevAccelX.bRestrictToRecommended = false;
765  // Y Component
766  FActorVariation StdDevAccelY;
767  StdDevAccelY.Id = TEXT("noise_accel_stddev_y");
768  StdDevAccelY.Type = EActorAttributeType::Float;
769  StdDevAccelY.RecommendedValues = { TEXT("0.0") };
770  StdDevAccelY.bRestrictToRecommended = false;
771  // Z Component
772  FActorVariation StdDevAccelZ;
773  StdDevAccelZ.Id = TEXT("noise_accel_stddev_z");
774  StdDevAccelZ.Type = EActorAttributeType::Float;
775  StdDevAccelZ.RecommendedValues = { TEXT("0.0") };
776  StdDevAccelZ.bRestrictToRecommended = false;
777 
778  // - Gyroscope Standard Deviation --------------
779  // X Component
780  FActorVariation StdDevGyroX;
781  StdDevGyroX.Id = TEXT("noise_gyro_stddev_x");
782  StdDevGyroX.Type = EActorAttributeType::Float;
783  StdDevGyroX.RecommendedValues = { TEXT("0.0") };
784  StdDevGyroX.bRestrictToRecommended = false;
785  // Y Component
786  FActorVariation StdDevGyroY;
787  StdDevGyroY.Id = TEXT("noise_gyro_stddev_y");
788  StdDevGyroY.Type = EActorAttributeType::Float;
789  StdDevGyroY.RecommendedValues = { TEXT("0.0") };
790  StdDevGyroY.bRestrictToRecommended = false;
791  // Z Component
792  FActorVariation StdDevGyroZ;
793  StdDevGyroZ.Id = TEXT("noise_gyro_stddev_z");
794  StdDevGyroZ.Type = EActorAttributeType::Float;
795  StdDevGyroZ.RecommendedValues = { TEXT("0.0") };
796  StdDevGyroZ.bRestrictToRecommended = false;
797 
798  // - Gyroscope Bias ----------------------------
799  // X Component
800  FActorVariation BiasGyroX;
801  BiasGyroX.Id = TEXT("noise_gyro_bias_x");
802  BiasGyroX.Type = EActorAttributeType::Float;
803  BiasGyroX.RecommendedValues = { TEXT("0.0") };
804  BiasGyroX.bRestrictToRecommended = false;
805  // Y Component
806  FActorVariation BiasGyroY;
807  BiasGyroY.Id = TEXT("noise_gyro_bias_y");
808  BiasGyroY.Type = EActorAttributeType::Float;
809  BiasGyroY.RecommendedValues = { TEXT("0.0") };
810  BiasGyroY.bRestrictToRecommended = false;
811  // Z Component
812  FActorVariation BiasGyroZ;
813  BiasGyroZ.Id = TEXT("noise_gyro_bias_z");
814  BiasGyroZ.Type = EActorAttributeType::Float;
815  BiasGyroZ.RecommendedValues = { TEXT("0.0") };
816  BiasGyroZ.bRestrictToRecommended = false;
817 
818  Definition.Variations.Append({
819  NoiseSeed,
820  StdDevAccelX,
821  StdDevAccelY,
822  StdDevAccelZ,
823  StdDevGyroX,
824  StdDevGyroY,
825  StdDevGyroZ,
826  BiasGyroX,
827  BiasGyroY,
828  BiasGyroZ});
829 
830  Success = CheckActorDefinition(Definition);
831 }
832 
834 {
835  FActorDefinition Definition;
836  bool Success;
837  MakeRadarDefinition(Success, Definition);
838  check(Success);
839  return Definition;
840 }
841 
843  bool &Success,
844  FActorDefinition &Definition)
845 {
846  FillIdAndTags(Definition, TEXT("sensor"), TEXT("other"), TEXT("radar"));
847  AddVariationsForSensor(Definition);
848 
849  FActorVariation HorizontalFOV;
850  HorizontalFOV.Id = TEXT("horizontal_fov");
851  HorizontalFOV.Type = EActorAttributeType::Float;
852  HorizontalFOV.RecommendedValues = { TEXT("30") };
853  HorizontalFOV.bRestrictToRecommended = false;
854 
855  FActorVariation VerticalFOV;
856  VerticalFOV.Id = TEXT("vertical_fov");
857  VerticalFOV.Type = EActorAttributeType::Float;
858  VerticalFOV.RecommendedValues = { TEXT("30") };
859  VerticalFOV.bRestrictToRecommended = false;
860 
861  FActorVariation Range;
862  Range.Id = TEXT("range");
864  Range.RecommendedValues = { TEXT("100") };
865  Range.bRestrictToRecommended = false;
866 
867  FActorVariation PointsPerSecond;
868  PointsPerSecond.Id = TEXT("points_per_second");
869  PointsPerSecond.Type = EActorAttributeType::Int;
870  PointsPerSecond.RecommendedValues = { TEXT("1500") };
871  PointsPerSecond.bRestrictToRecommended = false;
872 
873  // Noise seed
874  FActorVariation NoiseSeed;
875  NoiseSeed.Id = TEXT("noise_seed");
876  NoiseSeed.Type = EActorAttributeType::Int;
877  NoiseSeed.RecommendedValues = { TEXT("0") };
878  NoiseSeed.bRestrictToRecommended = false;
879 
880  Definition.Variations.Append({
881  HorizontalFOV,
882  VerticalFOV,
883  Range,
884  PointsPerSecond,
885  NoiseSeed});
886 
887  Success = CheckActorDefinition(Definition);
888 }
889 
891  const FString &Id)
892 {
893  FActorDefinition Definition;
894  bool Success;
895  MakeLidarDefinition(Id, Success, Definition);
896  check(Success);
897  return Definition;
898 }
899 
901  const FString &Id,
902  bool &Success,
903  FActorDefinition &Definition)
904 {
905  FillIdAndTags(Definition, TEXT("sensor"), TEXT("lidar"), Id);
907  AddVariationsForSensor(Definition);
908  // Number of channels.
909  FActorVariation Channels;
910  Channels.Id = TEXT("channels");
911  Channels.Type = EActorAttributeType::Int;
912  Channels.RecommendedValues = { TEXT("32") };
913  // Range.
914  FActorVariation Range;
915  Range.Id = TEXT("range");
917  Range.RecommendedValues = { TEXT("10.0") }; // 10 meters
918  // Points per second.
919  FActorVariation PointsPerSecond;
920  PointsPerSecond.Id = TEXT("points_per_second");
921  PointsPerSecond.Type = EActorAttributeType::Int;
922  PointsPerSecond.RecommendedValues = { TEXT("56000") };
923  // Frequency.
924  FActorVariation Frequency;
925  Frequency.Id = TEXT("rotation_frequency");
926  Frequency.Type = EActorAttributeType::Float;
927  Frequency.RecommendedValues = { TEXT("10.0") };
928  // Upper FOV limit.
929  FActorVariation UpperFOV;
930  UpperFOV.Id = TEXT("upper_fov");
931  UpperFOV.Type = EActorAttributeType::Float;
932  UpperFOV.RecommendedValues = { TEXT("10.0") };
933  // Lower FOV limit.
934  FActorVariation LowerFOV;
935  LowerFOV.Id = TEXT("lower_fov");
936  LowerFOV.Type = EActorAttributeType::Float;
937  LowerFOV.RecommendedValues = { TEXT("-30.0") };
938  // Horizontal FOV.
939  FActorVariation HorizontalFOV;
940  HorizontalFOV.Id = TEXT("horizontal_fov");
941  HorizontalFOV.Type = EActorAttributeType::Float;
942  HorizontalFOV.RecommendedValues = { TEXT("360.0") };
943  // Atmospheric Attenuation Rate.
944  FActorVariation AtmospAttenRate;
945  AtmospAttenRate.Id = TEXT("atmosphere_attenuation_rate");
946  AtmospAttenRate.Type = EActorAttributeType::Float;
947  AtmospAttenRate.RecommendedValues = { TEXT("0.004") };
948  // Noise seed
949  FActorVariation NoiseSeed;
950  NoiseSeed.Id = TEXT("noise_seed");
951  NoiseSeed.Type = EActorAttributeType::Int;
952  NoiseSeed.RecommendedValues = { TEXT("0") };
953  NoiseSeed.bRestrictToRecommended = false;
954  // Dropoff General Rate
955  FActorVariation DropOffGenRate;
956  DropOffGenRate.Id = TEXT("dropoff_general_rate");
957  DropOffGenRate.Type = EActorAttributeType::Float;
958  DropOffGenRate.RecommendedValues = { TEXT("0.45") };
959  // Dropoff intensity limit.
960  FActorVariation DropOffIntensityLimit;
961  DropOffIntensityLimit.Id = TEXT("dropoff_intensity_limit");
962  DropOffIntensityLimit.Type = EActorAttributeType::Float;
963  DropOffIntensityLimit.RecommendedValues = { TEXT("0.8") };
964  // Dropoff at zero intensity.
965  FActorVariation DropOffAtZeroIntensity;
966  DropOffAtZeroIntensity.Id = TEXT("dropoff_zero_intensity");
967  DropOffAtZeroIntensity.Type = EActorAttributeType::Float;
968  DropOffAtZeroIntensity.RecommendedValues = { TEXT("0.4") };
969  // Noise in lidar cloud points.
970  FActorVariation StdDevLidar;
971  StdDevLidar.Id = TEXT("noise_stddev");
972  StdDevLidar.Type = EActorAttributeType::Float;
973  StdDevLidar.RecommendedValues = { TEXT("0.0") };
974 
975  if (Id == "ray_cast") {
976  Definition.Variations.Append({
977  Channels,
978  Range,
979  PointsPerSecond,
980  Frequency,
981  UpperFOV,
982  LowerFOV,
983  AtmospAttenRate,
984  NoiseSeed,
985  DropOffGenRate,
986  DropOffIntensityLimit,
987  DropOffAtZeroIntensity,
988  StdDevLidar,
989  HorizontalFOV});
990  }
991  else if (Id == "ray_cast_semantic") {
992  Definition.Variations.Append({
993  Channels,
994  Range,
995  PointsPerSecond,
996  Frequency,
997  UpperFOV,
998  LowerFOV,
999  HorizontalFOV});
1000  }
1001  else {
1002  DEBUG_ASSERT(false);
1003  }
1004 
1005  Success = CheckActorDefinition(Definition);
1006 }
1007 
1009 {
1010  FActorDefinition Definition;
1011  bool Success;
1012  MakeGnssDefinition(Success, Definition);
1013  check(Success);
1014  return Definition;
1015 }
1016 
1018  bool &Success,
1019  FActorDefinition &Definition)
1020 {
1021  FillIdAndTags(Definition, TEXT("sensor"), TEXT("other"), TEXT("gnss"));
1022  AddVariationsForSensor(Definition);
1023 
1024  // - Noise seed --------------------------------
1025  FActorVariation NoiseSeed;
1026  NoiseSeed.Id = TEXT("noise_seed");
1027  NoiseSeed.Type = EActorAttributeType::Int;
1028  NoiseSeed.RecommendedValues = { TEXT("0") };
1029  NoiseSeed.bRestrictToRecommended = false;
1030 
1031  // - Latitude ----------------------------------
1032  FActorVariation StdDevLat;
1033  StdDevLat.Id = TEXT("noise_lat_stddev");
1034  StdDevLat.Type = EActorAttributeType::Float;
1035  StdDevLat.RecommendedValues = { TEXT("0.0") };
1036  StdDevLat.bRestrictToRecommended = false;
1037  FActorVariation BiasLat;
1038  BiasLat.Id = TEXT("noise_lat_bias");
1039  BiasLat.Type = EActorAttributeType::Float;
1040  BiasLat.RecommendedValues = { TEXT("0.0") };
1041  BiasLat.bRestrictToRecommended = false;
1042 
1043  // - Longitude ---------------------------------
1044  FActorVariation StdDevLong;
1045  StdDevLong.Id = TEXT("noise_lon_stddev");
1046  StdDevLong.Type = EActorAttributeType::Float;
1047  StdDevLong.RecommendedValues = { TEXT("0.0") };
1048  StdDevLong.bRestrictToRecommended = false;
1049  FActorVariation BiasLong;
1050  BiasLong.Id = TEXT("noise_lon_bias");
1051  BiasLong.Type = EActorAttributeType::Float;
1052  BiasLong.RecommendedValues = { TEXT("0.0") };
1053  BiasLong.bRestrictToRecommended = false;
1054 
1055  // - Altitude ----------------------------------
1056  FActorVariation StdDevAlt;
1057  StdDevAlt.Id = TEXT("noise_alt_stddev");
1058  StdDevAlt.Type = EActorAttributeType::Float;
1059  StdDevAlt.RecommendedValues = { TEXT("0.0") };
1060  StdDevAlt.bRestrictToRecommended = false;
1061  FActorVariation BiasAlt;
1062  BiasAlt.Id = TEXT("noise_alt_bias");
1063  BiasAlt.Type = EActorAttributeType::Float;
1064  BiasAlt.RecommendedValues = { TEXT("0.0") };
1065  BiasAlt.bRestrictToRecommended = false;
1066 
1067  Definition.Variations.Append({
1068  NoiseSeed,
1069  StdDevLat,
1070  BiasLat,
1071  StdDevLong,
1072  BiasLong,
1073  StdDevAlt,
1074  BiasAlt});
1075 
1076  Success = CheckActorDefinition(Definition);
1077 }
1078 
1080  const FVehicleParameters &Parameters,
1081  bool &Success,
1082  FActorDefinition &Definition)
1083 {
1084  /// @todo We need to validate here the params.
1085  FillIdAndTags(Definition, TEXT("vehicle"), Parameters.Make, Parameters.Model);
1087  {TEXT("autopilot"), TEXT("scenario"), TEXT("ego_vehicle")});
1088  Definition.Class = Parameters.Class;
1089 
1090  if (Parameters.RecommendedColors.Num() > 0)
1091  {
1092  FActorVariation Colors;
1093  Colors.Id = TEXT("color");
1095  Colors.bRestrictToRecommended = false;
1096  for (auto &Color : Parameters.RecommendedColors)
1097  {
1098  Colors.RecommendedValues.Emplace(ColorToFString(Color));
1099  }
1100  Definition.Variations.Emplace(Colors);
1101  }
1102 
1103  if (Parameters.SupportedDrivers.Num() > 0)
1104  {
1105  FActorVariation Drivers;
1106  Drivers.Id = TEXT("driver_id");
1107  Drivers.Type = EActorAttributeType::Int;
1108  Drivers.bRestrictToRecommended = true;
1109  for (auto &Id : Parameters.SupportedDrivers)
1110  {
1111  Drivers.RecommendedValues.Emplace(FString::FromInt(Id));
1112  }
1113  Definition.Variations.Emplace(Drivers);
1114  }
1115 
1116  FActorVariation StickyControl;
1117  StickyControl.Id = TEXT("sticky_control");
1118  StickyControl.Type = EActorAttributeType::Bool;
1119  StickyControl.bRestrictToRecommended = false;
1120  StickyControl.RecommendedValues.Emplace(TEXT("true"));
1121  Definition.Variations.Emplace(StickyControl);
1122 
1123  Definition.Attributes.Emplace(FActorAttribute{
1124  TEXT("object_type"),
1126  Parameters.ObjectType});
1127 
1128  Definition.Attributes.Emplace(FActorAttribute{
1129  TEXT("base_type"),
1131  Parameters.BaseType});
1132  Success = CheckActorDefinition(Definition);
1133 
1134  Definition.Attributes.Emplace(FActorAttribute{
1135  TEXT("special_type"),
1137  Parameters.SpecialType});
1138  Success = CheckActorDefinition(Definition);
1139 
1140  Definition.Attributes.Emplace(FActorAttribute{
1141  TEXT("number_of_wheels"),
1143  FString::FromInt(Parameters.NumberOfWheels)});
1144  Success = CheckActorDefinition(Definition);
1145 
1146  Definition.Attributes.Emplace(FActorAttribute{
1147  TEXT("generation"),
1149  FString::FromInt(Parameters.Generation)});
1150  Success = CheckActorDefinition(Definition);
1151 
1152  Definition.Attributes.Emplace(FActorAttribute{
1153  TEXT("has_dynamic_doors"),
1155  Parameters.HasDynamicDoors ? TEXT("true") : TEXT("false")});
1156  Success = CheckActorDefinition(Definition);
1157 
1158  Definition.Attributes.Emplace(FActorAttribute{
1159  TEXT("has_lights"),
1161  Parameters.HasLights ? TEXT("true") : TEXT("false")});
1162  Success = CheckActorDefinition(Definition);
1163 }
1164 
1165 template <typename T, typename Functor>
1167  const TArray<T> &ParameterArray,
1168  TArray<FActorDefinition> &Definitions,
1169  Functor Maker)
1170 {
1171  for (auto &Item : ParameterArray)
1172  {
1173  FActorDefinition Definition;
1174  bool Success = false;
1175  Maker(Item, Success, Definition);
1176  if (Success)
1177  {
1178  Definitions.Emplace(std::move(Definition));
1179  }
1180  }
1181 }
1182 
1184  const TArray<FVehicleParameters> &ParameterArray,
1185  TArray<FActorDefinition> &Definitions)
1186 {
1187  FillActorDefinitionArray(ParameterArray, Definitions, &MakeVehicleDefinition);
1188 }
1189 
1191  const FPedestrianParameters &Parameters,
1192  bool &Success,
1193  FActorDefinition &Definition)
1194 {
1195  /// @todo We need to validate here the params.
1196  FillIdAndTags(Definition, TEXT("walker"), TEXT("pedestrian"), Parameters.Id);
1197  AddRecommendedValuesForActorRoleName(Definition, {TEXT("pedestrian")});
1198  Definition.Class = Parameters.Class;
1199 
1200  auto GetGender = [](EPedestrianGender Value) {
1201  switch (Value)
1202  {
1203  case EPedestrianGender::Female: return TEXT("female");
1204  case EPedestrianGender::Male: return TEXT("male");
1205  default: return TEXT("other");
1206  }
1207  };
1208 
1209  auto GetAge = [](EPedestrianAge Value) {
1210  switch (Value)
1211  {
1212  case EPedestrianAge::Child: return TEXT("child");
1213  case EPedestrianAge::Teenager: return TEXT("teenager");
1214  case EPedestrianAge::Elderly: return TEXT("elderly");
1215  default: return TEXT("adult");
1216  }
1217  };
1218 
1219  Definition.Attributes.Emplace(FActorAttribute{
1220  TEXT("gender"),
1222  GetGender(Parameters.Gender)});
1223 
1224  Definition.Attributes.Emplace(FActorAttribute{
1225  TEXT("generation"),
1227  FString::FromInt(Parameters.Generation)});
1228 
1229  Definition.Attributes.Emplace(FActorAttribute{
1230  TEXT("age"),
1232  GetAge(Parameters.Age)});
1233 
1234  if (Parameters.Speed.Num() > 0)
1235  {
1236  FActorVariation Speed;
1237  Speed.Id = TEXT("speed");
1239  for (auto &Value : Parameters.Speed)
1240  {
1241  Speed.RecommendedValues.Emplace(FString::SanitizeFloat(Value));
1242  }
1243  Speed.bRestrictToRecommended = false;
1244  Definition.Variations.Emplace(Speed);
1245  }
1246 
1247  FActorVariation IsInvincible;
1248  IsInvincible.Id = TEXT("is_invincible");
1249  IsInvincible.Type = EActorAttributeType::Bool;
1250  IsInvincible.RecommendedValues = { TEXT("true") };
1251  IsInvincible.bRestrictToRecommended = false;
1252  Definition.Variations.Emplace(IsInvincible);
1253 
1254  Success = CheckActorDefinition(Definition);
1255 }
1256 
1258  const TArray<FPedestrianParameters> &ParameterArray,
1259  TArray<FActorDefinition> &Definitions)
1260 {
1261  FillActorDefinitionArray(ParameterArray, Definitions, &MakePedestrianDefinition);
1262 }
1263 
1265  const TArray<FString> &ParameterArray,
1266  TArray<FActorDefinition> &Definitions)
1267 {
1268  FillActorDefinitionArray(ParameterArray, Definitions, &MakeTriggerDefinition);
1269 }
1270 
1272  const FString &Id,
1273  bool &Success,
1274  FActorDefinition &Definition)
1275 {
1276  FillIdAndTags(Definition, TEXT("static"), TEXT("trigger"), Id);
1277  AddVariationsForTrigger(Definition);
1278  Success = CheckActorDefinition(Definition);
1279  check(Success);
1280 }
1281 
1283  const FPropParameters &Parameters,
1284  bool &Success,
1285  FActorDefinition &Definition)
1286 {
1287  /// @todo We need to validate here the params.
1288  FillIdAndTags(Definition, TEXT("static"), TEXT("prop"), Parameters.Name);
1289  AddRecommendedValuesForActorRoleName(Definition, {TEXT("prop")});
1290 
1291  auto GetSize = [](EPropSize Value) {
1292  switch (Value)
1293  {
1294  case EPropSize::Tiny: return TEXT("tiny");
1295  case EPropSize::Small: return TEXT("small");
1296  case EPropSize::Medium: return TEXT("medium");
1297  case EPropSize::Big: return TEXT("big");
1298  case EPropSize::Huge: return TEXT("huge");
1299  default: return TEXT("unknown");
1300  }
1301  };
1302 
1303  Definition.Attributes.Emplace(FActorAttribute{
1304  TEXT("size"),
1306  GetSize(Parameters.Size)});
1307 
1308  Success = CheckActorDefinition(Definition);
1309 }
1310 
1312  const TArray<FPropParameters> &ParameterArray,
1313  TArray<FActorDefinition> &Definitions)
1314 {
1315  FillActorDefinitionArray(ParameterArray, Definitions, &MakePropDefinition);
1316 }
1317 
1319  const FString &Type,
1320  const FString &Id,
1321  FActorDefinition &Definition)
1322 {
1323  Definition = MakeGenericSensorDefinition(TEXT("other"), TEXT("obstacle"));
1324  AddVariationsForSensor(Definition);
1325  // Distance.
1326  FActorVariation distance;
1327  distance.Id = TEXT("distance");
1328  distance.Type = EActorAttributeType::Float;
1329  distance.RecommendedValues = { TEXT("5.0") };
1330  distance.bRestrictToRecommended = false;
1331  // HitRadius.
1332  FActorVariation hitradius;
1333  hitradius.Id = TEXT("hit_radius");
1334  hitradius.Type = EActorAttributeType::Float;
1335  hitradius.RecommendedValues = { TEXT("0.5") };
1336  hitradius.bRestrictToRecommended = false;
1337  // Only Dynamics
1338  FActorVariation onlydynamics;
1339  onlydynamics.Id = TEXT("only_dynamics");
1340  onlydynamics.Type = EActorAttributeType::Bool;
1341  onlydynamics.RecommendedValues = { TEXT("false") };
1342  onlydynamics.bRestrictToRecommended = false;
1343  // Debug Line Trace
1344  FActorVariation debuglinetrace;
1345  debuglinetrace.Id = TEXT("debug_linetrace");
1346  debuglinetrace.Type = EActorAttributeType::Bool;
1347  debuglinetrace.RecommendedValues = { TEXT("false") };
1348  debuglinetrace.bRestrictToRecommended = false;
1349 
1350  Definition.Variations.Append({
1351  distance,
1352  hitradius,
1353  onlydynamics,
1354  debuglinetrace
1355  });
1356 
1357 }
1358 /// ============================================================================
1359 /// -- Helpers to retrieve attribute values ------------------------------------
1360 /// ============================================================================
1361 
1363  const FActorAttribute &ActorAttribute,
1364  bool Default)
1365 {
1366  if (ActorAttribute.Type != EActorAttributeType::Bool)
1367  {
1368  UE_LOG(LogCarla, Error, TEXT("ActorAttribute '%s' is not a bool"), *ActorAttribute.Id);
1369  return Default;
1370  }
1371  return ActorAttribute.Value.ToBool();
1372 }
1373 
1375  const FActorAttribute &ActorAttribute,
1376  int32 Default)
1377 {
1378  if (ActorAttribute.Type != EActorAttributeType::Int)
1379  {
1380  UE_LOG(LogCarla, Error, TEXT("ActorAttribute '%s' is not an int"), *ActorAttribute.Id);
1381  return Default;
1382  }
1383  return FCString::Atoi(*ActorAttribute.Value);
1384 }
1385 
1387  const FActorAttribute &ActorAttribute,
1388  float Default)
1389 {
1390  if (ActorAttribute.Type != EActorAttributeType::Float)
1391  {
1392  UE_LOG(LogCarla, Error, TEXT("ActorAttribute '%s' is not a float"), *ActorAttribute.Id);
1393  return Default;
1394  }
1395  return FCString::Atof(*ActorAttribute.Value);
1396 }
1397 
1399  const FActorAttribute &ActorAttribute,
1400  const FString &Default)
1401 {
1402  if (ActorAttribute.Type != EActorAttributeType::String)
1403  {
1404  UE_LOG(LogCarla, Error, TEXT("ActorAttribute '%s' is not a string"), *ActorAttribute.Id);
1405  return Default;
1406  }
1407  return ActorAttribute.Value;
1408 }
1409 
1411  const FActorAttribute &ActorAttribute,
1412  const FColor &Default)
1413 {
1414  if (ActorAttribute.Type != EActorAttributeType::RGBColor)
1415  {
1416  UE_LOG(LogCarla, Error, TEXT("ActorAttribute '%s' is not a color"), *ActorAttribute.Id);
1417  return Default;
1418  }
1419  TArray<FString> Channels;
1420  ActorAttribute.Value.ParseIntoArray(Channels, TEXT(","), false);
1421  if (Channels.Num() != 3)
1422  {
1423  UE_LOG(LogCarla,
1424  Error,
1425  TEXT("ActorAttribute '%s': invalid color '%s'"),
1426  *ActorAttribute.Id,
1427  *ActorAttribute.Value);
1428  return Default;
1429  }
1430  TArray<uint8> Colors;
1431  for (auto &Str : Channels)
1432  {
1433  auto Val = FCString::Atoi(*Str);
1434  if ((Val < 0) || (Val > std::numeric_limits<uint8>::max()))
1435  {
1436  UE_LOG(LogCarla,
1437  Error,
1438  TEXT("ActorAttribute '%s': invalid color '%s'"),
1439  *ActorAttribute.Id,
1440  *ActorAttribute.Value);
1441  return Default;
1442  }
1443  Colors.Add(Val);
1444  }
1445  FColor Color;
1446  Color.R = Colors[0u];
1447  Color.G = Colors[1u];
1448  Color.B = Colors[2u];
1449  return Color;
1450 }
1451 
1453  const FString &Id,
1454  const TMap<FString, FActorAttribute> &Attributes,
1455  bool Default)
1456 {
1457  return Attributes.Contains(Id) ?
1458  ActorAttributeToBool(Attributes[Id], Default) :
1459  Default;
1460 }
1461 
1463  const FString &Id,
1464  const TMap<FString, FActorAttribute> &Attributes,
1465  int32 Default)
1466 {
1467  return Attributes.Contains(Id) ?
1468  ActorAttributeToInt(Attributes[Id], Default) :
1469  Default;
1470 }
1471 
1473  const FString &Id,
1474  const TMap<FString, FActorAttribute> &Attributes,
1475  float Default)
1476 {
1477  return Attributes.Contains(Id) ?
1478  ActorAttributeToFloat(Attributes[Id], Default) :
1479  Default;
1480 }
1481 
1483  const FString &Id,
1484  const TMap<FString, FActorAttribute> &Attributes,
1485  const FString &Default)
1486 {
1487  return Attributes.Contains(Id) ?
1488  ActorAttributeToString(Attributes[Id], Default) :
1489  Default;
1490 }
1491 
1493  const FString &Id,
1494  const TMap<FString, FActorAttribute> &Attributes,
1495  const FColor &Default)
1496 {
1497  return Attributes.Contains(Id) ?
1498  ActorAttributeToColor(Attributes[Id], Default) :
1499  Default;
1500 }
1501 
1502 /// ============================================================================
1503 /// -- Helpers to set Actors ---------------------------------------------------
1504 /// ============================================================================
1505 
1506 // Here we do different checks when we are in editor because we don't want the
1507 // editor crashing while people are testing new actor definitions.
1508 #if WITH_EDITOR
1509 # define CARLA_ABFL_CHECK_ACTOR(ActorPtr) \
1510  if ((ActorPtr == nullptr) || ActorPtr->IsPendingKill()) \
1511  { \
1512  UE_LOG(LogCarla, Error, TEXT("Cannot set empty actor!")); \
1513  return; \
1514  }
1515 #else
1516 # define CARLA_ABFL_CHECK_ACTOR(ActorPtr) \
1517  check((ActorPtr != nullptr) && !ActorPtr->IsPendingKill());
1518 #endif // WITH_EDITOR
1519 
1521  const FActorDescription &Description,
1522  ASceneCaptureSensor *Camera)
1523 {
1524  CARLA_ABFL_CHECK_ACTOR(Camera);
1525  Camera->SetImageSize(
1526  RetrieveActorAttributeToInt("image_size_x", Description.Variations, 800),
1527  RetrieveActorAttributeToInt("image_size_y", Description.Variations, 600));
1528  Camera->SetFOVAngle(
1529  RetrieveActorAttributeToFloat("fov", Description.Variations, 90.0f));
1530  if (Description.Variations.Contains("enable_postprocess_effects"))
1531  {
1533  ActorAttributeToBool(
1534  Description.Variations["enable_postprocess_effects"],
1535  true));
1536  Camera->SetTargetGamma(
1537  RetrieveActorAttributeToFloat("gamma", Description.Variations, 2.4f));
1538  Camera->SetMotionBlurIntensity(
1539  RetrieveActorAttributeToFloat("motion_blur_intensity", Description.Variations, 0.5f));
1541  RetrieveActorAttributeToFloat("motion_blur_max_distortion", Description.Variations, 5.0f));
1543  RetrieveActorAttributeToFloat("motion_blur_min_object_screen_size", Description.Variations, 0.5f));
1544  Camera->SetLensFlareIntensity(
1545  RetrieveActorAttributeToFloat("lens_flare_intensity", Description.Variations, 0.1f));
1546  Camera->SetBloomIntensity(
1547  RetrieveActorAttributeToFloat("bloom_intensity", Description.Variations, 0.675f));
1548  // Exposure, histogram mode by default
1549  if (RetrieveActorAttributeToString("exposure_mode", Description.Variations, "histogram") == "histogram")
1550  {
1551  Camera->SetExposureMethod(EAutoExposureMethod::AEM_Histogram);
1552  }
1553  else
1554  {
1555  Camera->SetExposureMethod(EAutoExposureMethod::AEM_Manual);
1556  }
1557  Camera->SetExposureCompensation(
1558  RetrieveActorAttributeToFloat("exposure_compensation", Description.Variations, 0.0f));
1559  Camera->SetShutterSpeed(
1560  RetrieveActorAttributeToFloat("shutter_speed", Description.Variations, 200.0f));
1561  Camera->SetISO(
1562  RetrieveActorAttributeToFloat("iso", Description.Variations, 100.0f));
1563  Camera->SetAperture(
1564  RetrieveActorAttributeToFloat("fstop", Description.Variations, 1.4f));
1565 
1566  Camera->SetExposureMinBrightness(
1567  RetrieveActorAttributeToFloat("exposure_min_bright", Description.Variations, 7.0f));
1568  Camera->SetExposureMaxBrightness(
1569  RetrieveActorAttributeToFloat("exposure_max_bright", Description.Variations, 9.0f));
1570  Camera->SetExposureSpeedUp(
1571  RetrieveActorAttributeToFloat("exposure_speed_up", Description.Variations, 3.0f));
1572  Camera->SetExposureSpeedDown(
1573  RetrieveActorAttributeToFloat("exposure_speed_down", Description.Variations, 1.0f));
1575  RetrieveActorAttributeToFloat("calibration_constant", Description.Variations, 16.0f));
1576 
1577  Camera->SetFocalDistance(
1578  RetrieveActorAttributeToFloat("focal_distance", Description.Variations, 1000.0f));
1579  Camera->SetDepthBlurAmount(
1580  RetrieveActorAttributeToFloat("blur_amount", Description.Variations, 1.0f));
1581  Camera->SetDepthBlurRadius(
1582  RetrieveActorAttributeToFloat("blur_radius", Description.Variations, 0.0f));
1583  Camera->SetDepthOfFieldMinFstop(
1584  RetrieveActorAttributeToFloat("min_fstop", Description.Variations, 1.2f));
1585  Camera->SetBladeCount(
1586  RetrieveActorAttributeToInt("blade_count", Description.Variations, 5));
1587 
1588  Camera->SetFilmSlope(
1589  RetrieveActorAttributeToFloat("slope", Description.Variations, 0.88f));
1590  Camera->SetFilmToe(
1591  RetrieveActorAttributeToFloat("toe", Description.Variations, 0.55f));
1592  Camera->SetFilmShoulder(
1593  RetrieveActorAttributeToFloat("shoulder", Description.Variations, 0.26f));
1594  Camera->SetFilmBlackClip(
1595  RetrieveActorAttributeToFloat("black_clip", Description.Variations, 0.0f));
1596  Camera->SetFilmWhiteClip(
1597  RetrieveActorAttributeToFloat("white_clip", Description.Variations, 0.04f));
1598 
1599  Camera->SetWhiteTemp(
1600  RetrieveActorAttributeToFloat("temp", Description.Variations, 6500.0f));
1601  Camera->SetWhiteTint(
1602  RetrieveActorAttributeToFloat("tint", Description.Variations, 0.0f));
1603 
1604  Camera->SetChromAberrIntensity(
1605  RetrieveActorAttributeToFloat("chromatic_aberration_intensity", Description.Variations, 0.0f));
1606  Camera->SetChromAberrOffset(
1607  RetrieveActorAttributeToFloat("chromatic_aberration_offset", Description.Variations, 0.0f));
1608  }
1609 }
1610 
1612  const FActorDescription &Description,
1613  AShaderBasedSensor *Camera)
1614 {
1615  CARLA_ABFL_CHECK_ACTOR(Camera);
1616  Camera->SetFloatShaderParameter(0, TEXT("CircleFalloff_NState"),
1617  RetrieveActorAttributeToFloat("lens_circle_falloff", Description.Variations, 5.0f));
1618  Camera->SetFloatShaderParameter(0, TEXT("CircleMultiplier_NState"),
1619  RetrieveActorAttributeToFloat("lens_circle_multiplier", Description.Variations, 0.0f));
1620  Camera->SetFloatShaderParameter(0, TEXT("K_NState"),
1621  RetrieveActorAttributeToFloat("lens_k", Description.Variations, -1.0f));
1622  Camera->SetFloatShaderParameter(0, TEXT("kcube"),
1623  RetrieveActorAttributeToFloat("lens_kcube", Description.Variations, 0.0f));
1624  Camera->SetFloatShaderParameter(0, TEXT("XSize_NState"),
1625  RetrieveActorAttributeToFloat("lens_x_size", Description.Variations, 0.08f));
1626  Camera->SetFloatShaderParameter(0, TEXT("YSize_NState"),
1627  RetrieveActorAttributeToFloat("lens_y_size", Description.Variations, 0.08f));
1628 }
1629 
1631  const FActorDescription &Description,
1632  FLidarDescription &Lidar)
1633 {
1634  constexpr float TO_CENTIMETERS = 1e2;
1635  Lidar.Channels =
1636  RetrieveActorAttributeToInt("channels", Description.Variations, Lidar.Channels);
1637  Lidar.Range =
1638  RetrieveActorAttributeToFloat("range", Description.Variations, 10.0f) * TO_CENTIMETERS;
1639  Lidar.PointsPerSecond =
1640  RetrieveActorAttributeToInt("points_per_second", Description.Variations, Lidar.PointsPerSecond);
1641  Lidar.RotationFrequency =
1642  RetrieveActorAttributeToFloat("rotation_frequency", Description.Variations, Lidar.RotationFrequency);
1643  Lidar.UpperFovLimit =
1644  RetrieveActorAttributeToFloat("upper_fov", Description.Variations, Lidar.UpperFovLimit);
1645  Lidar.LowerFovLimit =
1646  RetrieveActorAttributeToFloat("lower_fov", Description.Variations, Lidar.LowerFovLimit);
1647  Lidar.HorizontalFov =
1648  RetrieveActorAttributeToFloat("horizontal_fov", Description.Variations, Lidar.HorizontalFov);
1649  Lidar.AtmospAttenRate =
1650  RetrieveActorAttributeToFloat("atmosphere_attenuation_rate", Description.Variations, Lidar.AtmospAttenRate);
1651  Lidar.RandomSeed =
1652  RetrieveActorAttributeToInt("noise_seed", Description.Variations, Lidar.RandomSeed);
1653  Lidar.DropOffGenRate =
1654  RetrieveActorAttributeToFloat("dropoff_general_rate", Description.Variations, Lidar.DropOffGenRate);
1655  Lidar.DropOffIntensityLimit =
1656  RetrieveActorAttributeToFloat("dropoff_intensity_limit", Description.Variations, Lidar.DropOffIntensityLimit);
1657  Lidar.DropOffAtZeroIntensity =
1658  RetrieveActorAttributeToFloat("dropoff_zero_intensity", Description.Variations, Lidar.DropOffAtZeroIntensity);
1659  Lidar.NoiseStdDev =
1660  RetrieveActorAttributeToFloat("noise_stddev", Description.Variations, Lidar.NoiseStdDev);
1661 }
1662 
1664  const FActorDescription &Description,
1665  AGnssSensor *Gnss)
1666 {
1667  CARLA_ABFL_CHECK_ACTOR(Gnss);
1668  if (Description.Variations.Contains("noise_seed"))
1669  {
1670  Gnss->SetSeed(
1671  RetrieveActorAttributeToInt("noise_seed", Description.Variations, 0));
1672  }
1673  else
1674  {
1675  Gnss->SetSeed(Gnss->GetRandomEngine()->GenerateRandomSeed());
1676  }
1677 
1678  Gnss->SetLatitudeDeviation(
1679  RetrieveActorAttributeToFloat("noise_lat_stddev", Description.Variations, 0.0f));
1680  Gnss->SetLongitudeDeviation(
1681  RetrieveActorAttributeToFloat("noise_lon_stddev", Description.Variations, 0.0f));
1682  Gnss->SetAltitudeDeviation(
1683  RetrieveActorAttributeToFloat("noise_alt_stddev", Description.Variations, 0.0f));
1684  Gnss->SetLatitudeBias(
1685  RetrieveActorAttributeToFloat("noise_lat_bias", Description.Variations, 0.0f));
1686  Gnss->SetLongitudeBias(
1687  RetrieveActorAttributeToFloat("noise_lon_bias", Description.Variations, 0.0f));
1688  Gnss->SetAltitudeBias(
1689  RetrieveActorAttributeToFloat("noise_alt_bias", Description.Variations, 0.0f));
1690 }
1691 
1693  const FActorDescription &Description,
1695 {
1697  if (Description.Variations.Contains("noise_seed"))
1698  {
1699  IMU->SetSeed(
1700  RetrieveActorAttributeToInt("noise_seed", Description.Variations, 0));
1701  }
1702  else
1703  {
1704  IMU->SetSeed(IMU->GetRandomEngine()->GenerateRandomSeed());
1705  }
1706 
1708  RetrieveActorAttributeToFloat("noise_accel_stddev_x", Description.Variations, 0.0f),
1709  RetrieveActorAttributeToFloat("noise_accel_stddev_y", Description.Variations, 0.0f),
1710  RetrieveActorAttributeToFloat("noise_accel_stddev_z", Description.Variations, 0.0f)});
1711 
1713  RetrieveActorAttributeToFloat("noise_gyro_stddev_x", Description.Variations, 0.0f),
1714  RetrieveActorAttributeToFloat("noise_gyro_stddev_y", Description.Variations, 0.0f),
1715  RetrieveActorAttributeToFloat("noise_gyro_stddev_z", Description.Variations, 0.0f)});
1716 
1717  IMU->SetGyroscopeBias({
1718  RetrieveActorAttributeToFloat("noise_gyro_bias_x", Description.Variations, 0.0f),
1719  RetrieveActorAttributeToFloat("noise_gyro_bias_y", Description.Variations, 0.0f),
1720  RetrieveActorAttributeToFloat("noise_gyro_bias_z", Description.Variations, 0.0f)});
1721 }
1722 
1724  const FActorDescription &Description,
1725  ARadar *Radar)
1726 {
1727  CARLA_ABFL_CHECK_ACTOR(Radar);
1728  constexpr float TO_CENTIMETERS = 1e2;
1729 
1730  if (Description.Variations.Contains("noise_seed"))
1731  {
1732  Radar->SetSeed(
1733  RetrieveActorAttributeToInt("noise_seed", Description.Variations, 0));
1734  }
1735  else
1736  {
1737  Radar->SetSeed(Radar->GetRandomEngine()->GenerateRandomSeed());
1738  }
1739 
1740  Radar->SetHorizontalFOV(
1741  RetrieveActorAttributeToFloat("horizontal_fov", Description.Variations, 30.0f));
1742  Radar->SetVerticalFOV(
1743  RetrieveActorAttributeToFloat("vertical_fov", Description.Variations, 30.0f));
1744  Radar->SetRange(
1745  RetrieveActorAttributeToFloat("range", Description.Variations, 100.0f) * TO_CENTIMETERS);
1746  Radar->SetPointsPerSecond(
1747  RetrieveActorAttributeToInt("points_per_second", Description.Variations, 1500));
1748 }
1749 
1750 #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:80
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:72
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:75
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:85
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:90
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)
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:70
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:65
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: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)