CARLA
Loading...
Searching...
No Matches
ActorBlueprintFunctionLibrary.cpp
Go to the documentation of this file.
1// Copyright (c) 2026 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
8#include "Engine/Engine.h"
9#include "Carla.h"
13#include "Carla/Sensor/Radar.h"
24#include "Engine/StaticMeshActor.h"
25
26#include <algorithm>
27#include <limits>
28#include <stack>
29
30static constexpr float DefaultKannalaBrandtCoefficients[] =
31{
32 0.08309221636708493f,
33 0.01112126630599195f,
34 0.008587261043925865f,
35 0.0008542188930970716f
36};
37
38/// Checks validity of FActorDefinition.
40{
41public:
42 /// Iterate all actor definitions and their properties and display messages on
43 /// error.
44 bool AreValid(const TArray<FActorDefinition> &ActorDefinitions)
45 {
46 return AreValid(TEXT("Actor Definition"), ActorDefinitions);
47 }
48
49 /// Validate @a ActorDefinition and display messages on error.
50 bool SingleIsValid(const FActorDefinition &Definition)
51 {
52 auto ScopeText = FString::Printf(TEXT("[Actor Definition : %s]"), *Definition.Id);
53 auto Scope = Stack.PushScope(ScopeText);
54 return IsValid(Definition);
55 }
56
57private:
58 /// If @a Predicate is false, print an error message. If possible the message
59 /// is printed to the editor window.
60 template <typename T, typename... ARGS>
61 bool OnScreenAssert(bool Predicate, const T &Format, ARGS &&...Args) const
62 {
63 if (!Predicate)
64 {
65 FString Message;
66 for (auto &String : Stack)
67 {
68 Message += String;
69 }
70 Message += TEXT(" ");
71 // FString::Printf validates its format string at compile time in UE 5.8,
72 // which rejects a format forwarded through a function parameter.
73 // FCString::Snprintf accepts the forwarded literal reference.
74 TCHAR Formatted[4096];
75 FCString::Snprintf(Formatted, UE_ARRAY_COUNT(Formatted), Format, std::forward<ARGS>(Args)...);
76 Message += Formatted;
77
78 UE_LOG(LogCarla, Error, TEXT("%s"), *Message);
79#if WITH_EDITOR
80 if (GEngine)
81 {
82 GEngine->AddOnScreenDebugMessage(42, 15.0f, FColor::Red, Message);
83 }
84#endif // WITH_EDITOR
85 }
86 return Predicate;
87 }
88
89 template <typename T>
90 FString GetDisplayId(const FString &Type, size_t Index, const T &Item)
91 {
92 return FString::Printf(TEXT("[%s %d : %s]"), *Type, Index, *Item.Id);
93 }
94
95 FString GetDisplayId(const FString &Type, size_t Index, const FString &Item)
96 {
97 return FString::Printf(TEXT("[%s %d : %s]"), *Type, Index, *Item);
98 }
99
100 /// Applies @a Validator to each item in @a Array. Pushes a new context to the
101 /// stack for each item.
102 template <typename T, typename F>
103 bool ForEach(const FString &Type, const TArray<T> &Array, F Validator)
104 {
105 bool Result = true;
106 auto Counter = 0u;
107 for (const auto &Item : Array)
108 {
109 auto Scope = Stack.PushScope(GetDisplayId(Type, Counter, Item));
110 Result &= Validator(Item);
111 ++Counter;
112 }
113 return Result;
114 }
115
116 /// Applies @a IsValid to each item in @a Array. Pushes a new context to the
117 /// stack for each item.
118 template <typename T>
119 bool AreValid(const FString &Type, const TArray<T> &Array)
120 {
121 return ForEach(Type, Array, [this](const auto &Item)
122 { return IsValid(Item); });
123 }
124
125 bool IsIdValid(const FString &Id)
126 {
127 /// @todo Do more checks.
128 return OnScreenAssert((!Id.IsEmpty() && Id != TEXT(".")), TEXT("Id cannot be empty"));
129 }
130
131 bool AreTagsValid(const FString &Tags)
132 {
133 /// @todo Do more checks.
134 return OnScreenAssert(!Tags.IsEmpty(), TEXT("Tags cannot be empty"));
135 }
136
138 {
139 /// @todo Do more checks.
140 return OnScreenAssert(Type < EActorAttributeType::SIZE, TEXT("Invalid type"));
141 }
142
143 bool ValueIsValid(const EActorAttributeType Type, const FString &Value)
144 {
145 /// @todo Do more checks.
146 return true;
147 }
148
149 bool IsValid(const FActorVariation &Variation)
150 {
151 return IsIdValid(Variation.Id) &&
152 IsValid(Variation.Type) &&
153 OnScreenAssert(Variation.RecommendedValues.Num() > 0, TEXT("Recommended values cannot be empty")) &&
154 ForEach(TEXT("Recommended Value"), Variation.RecommendedValues, [&](auto &Value)
155 { return ValueIsValid(Variation.Type, Value); });
156 }
157
158 bool IsValid(const FActorAttribute &Attribute)
159 {
160 return IsIdValid(Attribute.Id) &&
161 IsValid(Attribute.Type) &&
162 ValueIsValid(Attribute.Type, Attribute.Value);
163 }
164
165 bool IsValid(const FActorDefinition &ActorDefinition)
166 {
167 /// @todo Validate Class and make sure IDs are not repeated.
168 return IsIdValid(ActorDefinition.Id) &&
169 AreTagsValid(ActorDefinition.Tags) &&
170 AreValid(TEXT("Variation"), ActorDefinition.Variations) &&
171 AreValid(TEXT("Attribute"), ActorDefinition.Attributes);
172 }
173
175};
176
177template <typename... ARGS>
178static FString JoinStrings(const FString &Separator, ARGS &&...Args)
179{
180 return FString::Join(TArray<FString>{std::forward<ARGS>(Args)...}, *Separator);
181}
182
183static FString ColorToFString(const FColor &Color)
184{
185 return JoinStrings(
186 TEXT(","),
187 FString::FromInt(Color.R),
188 FString::FromInt(Color.G),
189 FString::FromInt(Color.B));
190}
191
192static FString VectorToFString(const FVector &TextVector)
193{
194 return JoinStrings(
195 TEXT(","),
196 FString::SanitizeFloat(TextVector.X),
197 FString::SanitizeFloat(TextVector.Y),
198 FString::SanitizeFloat(TextVector.Z));
199}
200
201/// ============================================================================
202/// -- Actor definition validators ---------------------------------------------
203/// ============================================================================
204
206{
208 return Validator.SingleIsValid(ActorDefinition);
209}
210
211bool UActorBlueprintFunctionLibrary::CheckActorDefinitions(const TArray<FActorDefinition> &ActorDefinitions)
212{
214 return Validator.AreValid(ActorDefinitions);
215}
216
217/// ============================================================================
218/// -- Helpers to create actor definitions -------------------------------------
219/// ============================================================================
220
221template <typename... TStrs>
222static void FillIdAndTags(FActorDefinition &Def, TStrs &&...Strings)
223{
224 Def.Id = JoinStrings(TEXT("."), std::forward<TStrs>(Strings)...).ToLower();
225 Def.Tags = JoinStrings(TEXT(","), std::forward<TStrs>(Strings)...).ToLower();
226
227 // each actor gets an actor role name attribute (empty by default)
228 FActorVariation ActorRole;
229 ActorRole.Id = TEXT("role_name");
231 ActorRole.RecommendedValues = {TEXT("default")};
232 ActorRole.bRestrictToRecommended = false;
233 Def.Variations.Emplace(ActorRole);
234
235 // ROS2
236 {
237 FActorVariation Var;
238 Var.Id = TEXT("ros_name");
240 Var.RecommendedValues = {Def.Id};
241 Var.bRestrictToRecommended = false;
242 Def.Variations.Emplace(Var);
243 }
244
245 // Exact ROS2 topic-name override (tier4 Autoware port); when left at the
246 // default (== blueprint id) the runtime generates the conventional topic.
247 {
248 FActorVariation Var;
249 Var.Id = TEXT("ros_topic_name");
251 Var.RecommendedValues = {Def.Id};
252 Var.bRestrictToRecommended = false;
253 Def.Variations.Emplace(Var);
254 }
255}
256
258 FActorDefinition &Definition,
259 TArray<FString> &&RecommendedValues)
260{
261 for (auto &&ActorVariation : Definition.Variations)
262 {
263 if (ActorVariation.Id == "role_name")
264 {
265 ActorVariation.RecommendedValues = RecommendedValues;
266 return;
267 }
268 }
269}
270
272{
273 AddRecommendedValuesForActorRoleName(Definition, {TEXT("front"), TEXT("back"), TEXT("left"), TEXT("right"), TEXT("front_left"), TEXT("front_right"), TEXT("back_left"), TEXT("back_right")});
274}
275
277{
278 FActorVariation Tick;
279
280 Tick.Id = TEXT("sensor_tick");
282 Tick.RecommendedValues = {TEXT("0.0")};
283 Tick.bRestrictToRecommended = false;
284
285 Def.Variations.Emplace(Tick);
286}
287
289{
290 // Friction
291 FActorVariation Friction;
292 Friction.Id = FString("friction");
294 Friction.RecommendedValues = {TEXT("3.5f")};
295 Friction.bRestrictToRecommended = false;
296 Def.Variations.Emplace(Friction);
297
298 // Extent
299 FString Extent("extent");
300 FString Coordinates[3] = {FString("x"), FString("y"), FString("z")};
301
302 for (auto Coordinate : Coordinates)
303 {
304 FActorVariation ExtentCoordinate;
305
306 ExtentCoordinate.Id = JoinStrings(TEXT("_"), Extent, Coordinate);
307 ExtentCoordinate.Type = EActorAttributeType::Float;
308 ExtentCoordinate.RecommendedValues = {TEXT("1.0f")};
309 ExtentCoordinate.bRestrictToRecommended = false;
310
311 Def.Variations.Emplace(ExtentCoordinate);
312 }
313}
314
316 const FString &Category,
317 const FString &Type,
318 const FString &Id)
319{
320 FActorDefinition Definition;
321 FillIdAndTags(Definition, Category, Type, Id);
322 return Definition;
323}
324
326 const FString &Type,
327 const FString &Id)
328{
329 auto Definition = MakeGenericDefinition(TEXT("sensor"), Type, Id);
331 return Definition;
332}
333
334/// Show-only render mode attributes shared by every scene-capture camera
335/// family (pinhole, wide-angle cubemap and ray-traced lens). See
336/// FCarlaShowOnlyFilter for the semantics.
338{
339 FActorVariation ShowOnlyTags;
340 ShowOnlyTags.Id = TEXT("show_only_tags");
341 ShowOnlyTags.Type = EActorAttributeType::String;
342 ShowOnlyTags.RecommendedValues = {TEXT("")};
343 ShowOnlyTags.bRestrictToRecommended = false;
344
345 FActorVariation ShadowCatcherTags;
346 ShadowCatcherTags.Id = TEXT("shadow_catcher_tags");
347 ShadowCatcherTags.Type = EActorAttributeType::String;
348 ShadowCatcherTags.RecommendedValues = {TEXT("")};
349 ShadowCatcherTags.bRestrictToRecommended = false;
350
351 FActorVariation ShowOnlyActorIds;
352 ShowOnlyActorIds.Id = TEXT("show_only_actor_ids");
353 ShowOnlyActorIds.Type = EActorAttributeType::String;
354 ShowOnlyActorIds.RecommendedValues = {TEXT("")};
355 ShowOnlyActorIds.bRestrictToRecommended = false;
356
357 Definition.Variations.Append({ShowOnlyTags, ShadowCatcherTags, ShowOnlyActorIds});
358}
359
360template <typename CameraT>
361static void SetShowOnlyFromDescription(const FActorDescription &Description, CameraT *Camera)
362{
364 const auto &Variations = Description.Variations;
365 if (Variations.Contains("show_only_tags"))
366 Camera->SetShowOnlyTags(L::RetrieveActorAttributeToString("show_only_tags", Variations, TEXT("")));
367 if (Variations.Contains("shadow_catcher_tags"))
368 Camera->SetShadowCatcherTags(L::RetrieveActorAttributeToString("shadow_catcher_tags", Variations, TEXT("")));
369 if (Variations.Contains("show_only_actor_ids"))
370 Camera->SetShowOnlyActorIds(L::RetrieveActorAttributeToString("show_only_actor_ids", Variations, TEXT("")));
371}
372
374 const FString &Id,
375 const bool bEnableModifyingPostProcessEffects)
376{
377 FActorDefinition Definition;
378 bool Success;
379 MakeCameraDefinition(Id, bEnableModifyingPostProcessEffects, Success, Definition);
380 check(Success);
381 return Definition;
382}
383
385 const FString &Id,
386 const bool bEnableModifyingPostProcessEffects,
387 bool &Success,
388 FActorDefinition &Definition)
389{
390 FillIdAndTags(Definition, TEXT("sensor"), TEXT("camera"), Id);
392 AddVariationsForSensor(Definition);
393
394 // FOV
395 FActorVariation FOV;
396 FOV.Id = TEXT("fov");
398 FOV.RecommendedValues = {TEXT("90.0")};
399 FOV.bRestrictToRecommended = false;
400
401 // Resolution
402 FActorVariation ResX;
403 ResX.Id = TEXT("image_size_x");
405 ResX.RecommendedValues = {TEXT("800")};
406 ResX.bRestrictToRecommended = false;
407
408 FActorVariation ResY;
409 ResY.Id = TEXT("image_size_y");
411 ResY.RecommendedValues = {TEXT("600")};
412 ResY.bRestrictToRecommended = false;
413
414 // Lens parameters
415 FActorVariation LensCircleFalloff;
416 LensCircleFalloff.Id = TEXT("lens_circle_falloff");
417 LensCircleFalloff.Type = EActorAttributeType::Float;
418 LensCircleFalloff.RecommendedValues = {TEXT("5.0")};
419 LensCircleFalloff.bRestrictToRecommended = false;
420
421 FActorVariation LensCircleMultiplier;
422 LensCircleMultiplier.Id = TEXT("lens_circle_multiplier");
423 LensCircleMultiplier.Type = EActorAttributeType::Float;
424 LensCircleMultiplier.RecommendedValues = {TEXT("0.0")};
425 LensCircleMultiplier.bRestrictToRecommended = false;
426
427 FActorVariation LensK;
428 LensK.Id = TEXT("lens_k");
430 LensK.RecommendedValues = {TEXT("-1.0")};
431 LensK.bRestrictToRecommended = false;
432
433 FActorVariation LensKcube;
434 LensKcube.Id = TEXT("lens_kcube");
436 LensKcube.RecommendedValues = {TEXT("0.0")};
437 LensKcube.bRestrictToRecommended = false;
438
439 FActorVariation LensXSize;
440 LensXSize.Id = TEXT("lens_x_size");
442 LensXSize.RecommendedValues = {TEXT("0.08")};
443 LensXSize.bRestrictToRecommended = false;
444
445 FActorVariation LensYSize;
446 LensYSize.Id = TEXT("lens_y_size");
448 LensYSize.RecommendedValues = {TEXT("0.08")};
449 LensYSize.bRestrictToRecommended = false;
450
451 // Per-sensor hardware ray-tracing opt-out. Defaults to true so camera
452 // output matches the simulator viewport. Set to false to skip the ~700
453 // MiB-1 GiB VRAM cost of per-camera HW-RT for sensors that do not need
454 // it (depth, semantic, lidar). The global CVar carla.Camera.UseRayTracing
455 // forces on/off across every camera regardless of this attribute.
456 FActorVariation UseRayTracing;
457 UseRayTracing.Id = TEXT("use_ray_tracing");
458 UseRayTracing.Type = EActorAttributeType::Bool;
459 UseRayTracing.RecommendedValues = {TEXT("true")};
460 UseRayTracing.bRestrictToRecommended = false;
461
462 // Optional DLSS Super Resolution upscaling: render the capture internally at
463 // dlss_screen_percentage (25-100) of the output resolution and let DLSS fill
464 // the full-size image. Off by default so non-NVIDIA users keep the stock
465 // full-resolution path; without NVIDIA hardware an enabled sensor degrades
466 // to a bilinear upscale (output stays full size and valid). Requires
467 // enable_postprocess_effects=true for DLSS (temporal AA) to engage.
468 FActorVariation EnableDLSS;
469 EnableDLSS.Id = TEXT("enable_dlss");
470 EnableDLSS.Type = EActorAttributeType::Bool;
471 EnableDLSS.RecommendedValues = {TEXT("false")};
472 EnableDLSS.bRestrictToRecommended = false;
473
474 FActorVariation DLSSScreenPercentage;
475 DLSSScreenPercentage.Id = TEXT("dlss_screen_percentage");
476 DLSSScreenPercentage.Type = EActorAttributeType::Float;
477 // 50 renders a quarter of the pixels (DLSS "Performance"); 33 one ninth
478 // ("Ultra Performance").
479 DLSSScreenPercentage.RecommendedValues = {TEXT("50.0")};
480 DLSSScreenPercentage.bRestrictToRecommended = false;
481
482 Definition.Variations.Append({ResX,
483 ResY,
484 FOV,
485 LensCircleFalloff,
486 LensCircleMultiplier,
487 LensK,
488 LensKcube,
489 LensXSize,
490 LensYSize,
491 UseRayTracing,
492 EnableDLSS,
493 DLSSScreenPercentage});
494
495 if (bEnableModifyingPostProcessEffects)
496 {
497 FActorVariation PostProccess;
498 PostProccess.Id = TEXT("enable_postprocess_effects");
499 PostProccess.Type = EActorAttributeType::Bool;
500 PostProccess.RecommendedValues = {TEXT("true")};
501 PostProccess.bRestrictToRecommended = false;
502
503 // post_process_profile
504 FActorVariation post_process_profile;
505 post_process_profile.Id = TEXT("post_process_profile");
506 post_process_profile.Type = EActorAttributeType::String;
507 post_process_profile.RecommendedValues = {TEXT("")};
508 post_process_profile.bRestrictToRecommended = false;
509
510 Definition.Variations.Append({PostProccess, post_process_profile});
511
512 }
513
514 AddShowOnlyVariations(Definition);
515
516 Success = CheckActorDefinition(Definition);
517}
518
520 const FString &Id,
521 bool bEnableModifyingPostProcessEffects)
522{
523 FActorDefinition Definition;
524 bool Success;
525 MakeWideAngleLensCameraDefinition(Id, bEnableModifyingPostProcessEffects, Success, Definition);
526 check(Success);
527 return Definition;
528}
529
531 const FString &Id,
532 bool bEnableModifyingPostProcessEffects,
533 bool &Success,
534 FActorDefinition &Definition)
535{
536 FillIdAndTags(Definition, TEXT("sensor"), TEXT("camera"), Id + TEXT("_fisheye"));
538 AddVariationsForSensor(Definition);
539
540 // Camera Model (same names as sensor.camera.rt_lens; "kannala-brandt" is
541 // also accepted for backwards compatibility).
542 FActorVariation CameraModel;
543 CameraModel.Id = TEXT("camera_model");
544 CameraModel.Type = EActorAttributeType::String;
545 CameraModel.RecommendedValues =
546 {
547 TEXT("perspective"),
548 TEXT("stereographic"),
549 TEXT("equidistant"),
550 TEXT("equisolid"),
551 TEXT("orthographic"),
552 TEXT("kannala_brandt"),
553 TEXT("lut"),
554 TEXT("ftheta")
555 };
556 CameraModel.bRestrictToRecommended = false;
557
558 // Lens calibration shared with sensor.camera.rt_lens (see
559 // ASceneCaptureSensor_WideAngleLens::SetLensIntrinsics / SetLensLUT):
560 // fx, fy, cx, cy in normalized viewport units (x_px = (cx + fx * R cos phi)
561 // * width, y_px = (cy + fy * R sin phi) * height). fx <= 0 keeps the legacy
562 // fov / focal_length projection centred on the image.
563 FActorVariation WAL_Fx;
564 WAL_Fx.Id = TEXT("fx");
566 WAL_Fx.RecommendedValues = {TEXT("0.0")};
567 WAL_Fx.bRestrictToRecommended = false;
568
569 FActorVariation WAL_Fy;
570 WAL_Fy.Id = TEXT("fy");
572 WAL_Fy.RecommendedValues = {TEXT("0.0")};
573 WAL_Fy.bRestrictToRecommended = false;
574
575 FActorVariation WAL_Cx;
576 WAL_Cx.Id = TEXT("cx");
578 WAL_Cx.RecommendedValues = {TEXT("0.5")};
579 WAL_Cx.bRestrictToRecommended = false;
580
581 FActorVariation WAL_Cy;
582 WAL_Cy.Id = TEXT("cy");
584 WAL_Cy.RecommendedValues = {TEXT("0.5")};
585 WAL_Cy.bRestrictToRecommended = false;
586
587 // camera_model=lut: comma-separated R(theta) samples, uniformly spaced over
588 // [0, theta_max_deg], in the units of fx (R * fx * width = pixels).
589 FActorVariation WAL_Lut;
590 WAL_Lut.Id = TEXT("lut");
592 WAL_Lut.RecommendedValues = {TEXT("")};
593 WAL_Lut.bRestrictToRecommended = false;
594
595 FActorVariation WAL_ThetaMaxDeg;
596 WAL_ThetaMaxDeg.Id = TEXT("theta_max_deg");
597 WAL_ThetaMaxDeg.Type = EActorAttributeType::Float;
598 WAL_ThetaMaxDeg.RecommendedValues = {TEXT("0.0")};
599 WAL_ThetaMaxDeg.bRestrictToRecommended = false;
600
601 // Side of the six cube-face render targets in pixels; 0 = max(image_size_x,
602 // image_size_y). Each face carries a full scene view, so this is the GPU
603 // memory knob of the sensor.
604 FActorVariation WAL_FaceSize;
605 WAL_FaceSize.Id = TEXT("face_size");
606 WAL_FaceSize.Type = EActorAttributeType::Int;
607 WAL_FaceSize.RecommendedValues = {TEXT("0")};
608 WAL_FaceSize.bRestrictToRecommended = false;
609
610 // Coefficient #1
612 K0.Id = TEXT("k0");
614 K0.RecommendedValues = {FString::SanitizeFloat(DefaultKannalaBrandtCoefficients[0])};
615 K0.bRestrictToRecommended = false;
616
617 // Coefficient #2
619 K1.Id = TEXT("k1");
621 K1.RecommendedValues = {FString::SanitizeFloat(DefaultKannalaBrandtCoefficients[1])};
622 K1.bRestrictToRecommended = false;
623
624 // Coefficient #3
626 K2.Id = TEXT("k2");
628 K2.RecommendedValues = {FString::SanitizeFloat(DefaultKannalaBrandtCoefficients[2])};
629 K2.bRestrictToRecommended = false;
630
631 // Coefficient #4
633 K3.Id = TEXT("k3");
635 K3.RecommendedValues = {FString::SanitizeFloat(DefaultKannalaBrandtCoefficients[3])};
636 K3.bRestrictToRecommended = false;
637
638 // FOV
639 FActorVariation WAL_FOV;
640 WAL_FOV.Id = TEXT("fov");
642 WAL_FOV.RecommendedValues = {TEXT("90.0")};
643 WAL_FOV.bRestrictToRecommended = false;
644
645 // Focal Length
646 FActorVariation FocalLength;
647 FocalLength.Id = TEXT("focal_length");
648 FocalLength.Type = EActorAttributeType::Float;
649 FocalLength.RecommendedValues = {TEXT("0.0")};
650 FocalLength.bRestrictToRecommended = false;
651
652 FActorVariation WAL_Perspective;
653 WAL_Perspective.Id = TEXT("perspective");
654 WAL_Perspective.Type = EActorAttributeType::Bool;
655 WAL_Perspective.RecommendedValues = {TEXT("false")};
656 WAL_Perspective.bRestrictToRecommended = false;
657
658 FActorVariation Equirectangular;
659 Equirectangular.Id = TEXT("equirectangular");
660 Equirectangular.Type = EActorAttributeType::Bool;
661 Equirectangular.RecommendedValues = {TEXT("false")};
662 Equirectangular.bRestrictToRecommended = false;
663
664 FActorVariation FOVMask;
665 FOVMask.Id = TEXT("fov_mask");
667 FOVMask.RecommendedValues = {TEXT("false")};
668 FOVMask.bRestrictToRecommended = false;
669
670 FActorVariation FOVFadeSize;
671 FOVFadeSize.Id = TEXT("fov_fade_size");
672 FOVFadeSize.Type = EActorAttributeType::Float;
673 FOVFadeSize.RecommendedValues = {TEXT("0.0")};
674 FOVFadeSize.bRestrictToRecommended = false;
675
676 FActorVariation LongitudeOffset;
677 LongitudeOffset.Id = TEXT("longitude_offset");
678 LongitudeOffset.Type = EActorAttributeType::Float;
679 LongitudeOffset.RecommendedValues = {TEXT("0.0")};
680 LongitudeOffset.bRestrictToRecommended = false;
681
682 // Resolution
683 FActorVariation WAL_ResX;
684 WAL_ResX.Id = TEXT("image_size_x");
686 WAL_ResX.RecommendedValues = {TEXT("800")};
687 WAL_ResX.bRestrictToRecommended = false;
688
689 FActorVariation WAL_ResY;
690 WAL_ResY.Id = TEXT("image_size_y");
692 WAL_ResY.RecommendedValues = {TEXT("600")};
693 WAL_ResY.bRestrictToRecommended = false;
694
695 // Lens parameters
696 FActorVariation WAL_LensCircleFalloff;
697 WAL_LensCircleFalloff.Id = TEXT("lens_circle_falloff");
698 WAL_LensCircleFalloff.Type = EActorAttributeType::Float;
699 WAL_LensCircleFalloff.RecommendedValues = {TEXT("5.0")};
700 WAL_LensCircleFalloff.bRestrictToRecommended = false;
701
702 FActorVariation WAL_LensCircleMultiplier;
703 WAL_LensCircleMultiplier.Id = TEXT("lens_circle_multiplier");
704 WAL_LensCircleMultiplier.Type = EActorAttributeType::Float;
705 WAL_LensCircleMultiplier.RecommendedValues = {TEXT("0.0")};
706 WAL_LensCircleMultiplier.bRestrictToRecommended = false;
707
708 FActorVariation WAL_LensK;
709 WAL_LensK.Id = TEXT("lens_k");
711 WAL_LensK.RecommendedValues = {TEXT("-1.0")};
712 WAL_LensK.bRestrictToRecommended = false;
713
714 FActorVariation WAL_LensKcube;
715 WAL_LensKcube.Id = TEXT("lens_kcube");
716 WAL_LensKcube.Type = EActorAttributeType::Float;
717 WAL_LensKcube.RecommendedValues = {TEXT("0.0")};
718 WAL_LensKcube.bRestrictToRecommended = false;
719
720 FActorVariation WAL_LensXSize;
721 WAL_LensXSize.Id = TEXT("lens_x_size");
722 WAL_LensXSize.Type = EActorAttributeType::Float;
723 WAL_LensXSize.RecommendedValues = {TEXT("0.08")};
724 WAL_LensXSize.bRestrictToRecommended = false;
725
726 FActorVariation WAL_LensYSize;
727 WAL_LensYSize.Id = TEXT("lens_y_size");
728 WAL_LensYSize.Type = EActorAttributeType::Float;
729 WAL_LensYSize.RecommendedValues = {TEXT("0.08")};
730 WAL_LensYSize.bRestrictToRecommended = false;
731
732 Definition.Variations.Append({
733 CameraModel,
734 K0, K1, K2, K3,
735 WAL_Fx, WAL_Fy, WAL_Cx, WAL_Cy,
736 WAL_Lut, WAL_ThetaMaxDeg, WAL_FaceSize,
737 WAL_ResX,
738 WAL_ResY,
739 WAL_FOV,
740 FocalLength,
741 Equirectangular,
742 FOVMask,
743 FOVFadeSize,
744 LongitudeOffset,
745 WAL_Perspective,
746 WAL_LensCircleFalloff,
747 WAL_LensCircleMultiplier,
748 WAL_LensK,
749 WAL_LensKcube,
750 WAL_LensXSize,
751 WAL_LensYSize});
752
753 if (bEnableModifyingPostProcessEffects)
754 {
755 FActorVariation PostProccess;
756 PostProccess.Id = TEXT("enable_postprocess_effects");
757 PostProccess.Type = EActorAttributeType::Bool;
758 PostProccess.RecommendedValues = {TEXT("true")};
759 PostProccess.bRestrictToRecommended = false;
760
761 // post_process_profile: same camera-lens presets as the pinhole cameras
762 // (Content/Carla/Config/PostProcess/<name>.json), loaded into every cube
763 // face so exposure, tonemapper and grading match a pinhole sensor.
764 FActorVariation WAL_PostProcessProfile;
765 WAL_PostProcessProfile.Id = TEXT("post_process_profile");
766 WAL_PostProcessProfile.Type = EActorAttributeType::String;
767 WAL_PostProcessProfile.RecommendedValues = {TEXT("")};
768 WAL_PostProcessProfile.bRestrictToRecommended = false;
769
770 // Gamma
771 FActorVariation WAL_Gamma;
772 WAL_Gamma.Id = TEXT("gamma");
774 WAL_Gamma.RecommendedValues = {TEXT("2.2")};
775 WAL_Gamma.bRestrictToRecommended = false;
776
777 // Motion Blur
778 FActorVariation MBIntesity;
779 MBIntesity.Id = TEXT("motion_blur_intensity");
780 MBIntesity.Type = EActorAttributeType::Float;
781 MBIntesity.RecommendedValues = {TEXT("0.45")};
782 MBIntesity.bRestrictToRecommended = false;
783
784 FActorVariation MBMaxDistortion;
785 MBMaxDistortion.Id = TEXT("motion_blur_max_distortion");
786 MBMaxDistortion.Type = EActorAttributeType::Float;
787 MBMaxDistortion.RecommendedValues = {TEXT("0.35")};
788 MBMaxDistortion.bRestrictToRecommended = false;
789
790 FActorVariation MBMinObjectScreenSize;
791 MBMinObjectScreenSize.Id = TEXT("motion_blur_min_object_screen_size");
792 MBMinObjectScreenSize.Type = EActorAttributeType::Float;
793 MBMinObjectScreenSize.RecommendedValues = {TEXT("0.1")};
794 MBMinObjectScreenSize.bRestrictToRecommended = false;
795
796 // Lens Flare
797 FActorVariation LensFlareIntensity;
798 LensFlareIntensity.Id = TEXT("lens_flare_intensity");
799 LensFlareIntensity.Type = EActorAttributeType::Float;
800 LensFlareIntensity.RecommendedValues = {TEXT("0.1")};
801 LensFlareIntensity.bRestrictToRecommended = false;
802
803 // Bloom
804 FActorVariation BloomIntensity;
805 BloomIntensity.Id = TEXT("bloom_intensity");
806 BloomIntensity.Type = EActorAttributeType::Float;
807 BloomIntensity.RecommendedValues = {TEXT("0.675")};
808 BloomIntensity.bRestrictToRecommended = false;
809
810 // Exposure
811 FActorVariation ExposureMode;
812 ExposureMode.Id = TEXT("exposure_mode");
813 ExposureMode.Type = EActorAttributeType::String;
814 ExposureMode.RecommendedValues = {TEXT("histogram"), TEXT("manual")};
815 ExposureMode.bRestrictToRecommended = true;
816
817 FActorVariation ExposureCompensation;
818 ExposureCompensation.Id = TEXT("exposure_compensation");
819 ExposureCompensation.Type = EActorAttributeType::Float;
820 ExposureCompensation.RecommendedValues = {TEXT("0.0")};
821 ExposureCompensation.bRestrictToRecommended = false;
822
823 // The camera shutter speed in seconds.
824 FActorVariation ShutterSpeed; // (1/t)
825 ShutterSpeed.Id = TEXT("shutter_speed");
826 ShutterSpeed.Type = EActorAttributeType::Float;
827 ShutterSpeed.RecommendedValues = {TEXT("200.0")};
828 ShutterSpeed.bRestrictToRecommended = false;
829
830 // The camera sensor sensitivity.
831 FActorVariation ISO; // S
832 ISO.Id = TEXT("iso");
834 ISO.RecommendedValues = {TEXT("100.0")};
835 ISO.bRestrictToRecommended = false;
836
837 // Defines the size of the opening for the camera lens.
838 FActorVariation Aperture; // N
839 Aperture.Id = TEXT("fstop");
841 Aperture.RecommendedValues = {TEXT("1.4")};
842 Aperture.bRestrictToRecommended = false;
843
844 FActorVariation ExposureMinBright;
845 ExposureMinBright.Id = TEXT("exposure_min_bright");
846 ExposureMinBright.Type = EActorAttributeType::Float;
847 ExposureMinBright.RecommendedValues = {TEXT("10.0")};
848 ExposureMinBright.bRestrictToRecommended = false;
849
850 FActorVariation ExposureMaxBright;
851 ExposureMaxBright.Id = TEXT("exposure_max_bright");
852 ExposureMaxBright.Type = EActorAttributeType::Float;
853 ExposureMaxBright.RecommendedValues = {TEXT("12.0")};
854 ExposureMaxBright.bRestrictToRecommended = false;
855
856 FActorVariation ExposureSpeedUp;
857 ExposureSpeedUp.Id = TEXT("exposure_speed_up");
858 ExposureSpeedUp.Type = EActorAttributeType::Float;
859 ExposureSpeedUp.RecommendedValues = {TEXT("3.0")};
860 ExposureSpeedUp.bRestrictToRecommended = false;
861
862 FActorVariation ExposureSpeedDown;
863 ExposureSpeedDown.Id = TEXT("exposure_speed_down");
864 ExposureSpeedDown.Type = EActorAttributeType::Float;
865 ExposureSpeedDown.RecommendedValues = {TEXT("1.0")};
866 ExposureSpeedDown.bRestrictToRecommended = false;
867
868 // Calibration constant for 18% Albedo.
869 FActorVariation CalibrationConstant;
870 CalibrationConstant.Id = TEXT("calibration_constant");
871 CalibrationConstant.Type = EActorAttributeType::Float;
872 CalibrationConstant.RecommendedValues = {TEXT("16.0")};
873 CalibrationConstant.bRestrictToRecommended = false;
874
875 // Distance in which the Depth of Field effect should be sharp (cm).
876 FActorVariation FocalDistance;
877 FocalDistance.Id = TEXT("focal_distance");
878 FocalDistance.Type = EActorAttributeType::Float;
879 FocalDistance.RecommendedValues = {TEXT("1000.0")};
880 FocalDistance.bRestrictToRecommended = false;
881
882 // Depth blur km for 50%
883 FActorVariation DepthBlurAmount;
884 DepthBlurAmount.Id = TEXT("blur_amount");
885 DepthBlurAmount.Type = EActorAttributeType::Float;
886 DepthBlurAmount.RecommendedValues = {TEXT("1.0")};
887 DepthBlurAmount.bRestrictToRecommended = false;
888
889 // Depth blur radius in pixels at 1920x
890 FActorVariation DepthBlurRadius;
891 DepthBlurRadius.Id = TEXT("blur_radius");
892 DepthBlurRadius.Type = EActorAttributeType::Float;
893 DepthBlurRadius.RecommendedValues = {TEXT("0.0")};
894 DepthBlurRadius.bRestrictToRecommended = false;
895
896 FActorVariation MaxAperture;
897 MaxAperture.Id = TEXT("min_fstop");
898 MaxAperture.Type = EActorAttributeType::Float;
899 MaxAperture.RecommendedValues = {TEXT("1.2")};
900 MaxAperture.bRestrictToRecommended = false;
901
902 FActorVariation BladeCount;
903 BladeCount.Id = TEXT("blade_count");
904 BladeCount.Type = EActorAttributeType::Int;
905 BladeCount.RecommendedValues = {TEXT("5")};
906 BladeCount.bRestrictToRecommended = false;
907
908 FActorVariation FilmSlope;
909 FilmSlope.Id = TEXT("slope");
911 FilmSlope.RecommendedValues = {TEXT("0.88")};
912 FilmSlope.bRestrictToRecommended = false;
913
914 FActorVariation FilmToe;
915 FilmToe.Id = TEXT("toe");
917 FilmToe.RecommendedValues = {TEXT("0.55")};
918 FilmToe.bRestrictToRecommended = false;
919
920 FActorVariation FilmShoulder;
921 FilmShoulder.Id = TEXT("shoulder");
922 FilmShoulder.Type = EActorAttributeType::Float;
923 FilmShoulder.RecommendedValues = {TEXT("0.26")};
924 FilmShoulder.bRestrictToRecommended = false;
925
926 FActorVariation FilmBlackClip;
927 FilmBlackClip.Id = TEXT("black_clip");
928 FilmBlackClip.Type = EActorAttributeType::Float;
929 FilmBlackClip.RecommendedValues = {TEXT("0.0")};
930 FilmBlackClip.bRestrictToRecommended = false;
931
932 FActorVariation FilmWhiteClip;
933 FilmWhiteClip.Id = TEXT("white_clip");
934 FilmWhiteClip.Type = EActorAttributeType::Float;
935 FilmWhiteClip.RecommendedValues = {TEXT("0.04")};
936 FilmWhiteClip.bRestrictToRecommended = false;
937
938 // Color
939 FActorVariation Temperature;
940 Temperature.Id = TEXT("temp");
941 Temperature.Type = EActorAttributeType::Float;
942 Temperature.RecommendedValues = {TEXT("6500.0")};
943 Temperature.bRestrictToRecommended = false;
944
945 FActorVariation Tint;
946 Tint.Id = TEXT("tint");
948 Tint.RecommendedValues = {TEXT("0.0")};
949 Tint.bRestrictToRecommended = false;
950
951 FActorVariation ChromaticIntensity;
952 ChromaticIntensity.Id = TEXT("chromatic_aberration_intensity");
953 ChromaticIntensity.Type = EActorAttributeType::Float;
954 ChromaticIntensity.RecommendedValues = {TEXT("0.0")};
955 ChromaticIntensity.bRestrictToRecommended = false;
956
957 FActorVariation ChromaticOffset;
958 ChromaticOffset.Id = TEXT("chromatic_aberration_offset");
959 ChromaticOffset.Type = EActorAttributeType::Float;
960 ChromaticOffset.RecommendedValues = {TEXT("0.0")};
961 ChromaticOffset.bRestrictToRecommended = false;
962
963 Definition.Variations.Append({
964 ExposureMode,
965 ExposureCompensation,
966 ShutterSpeed,
967 ISO,
968 Aperture,
969 PostProccess,
970 WAL_PostProcessProfile,
971 WAL_Gamma,
972 MBIntesity,
973 MBMaxDistortion,
974 LensFlareIntensity,
975 BloomIntensity,
976 MBMinObjectScreenSize,
977 ExposureMinBright,
978 ExposureMaxBright,
979 ExposureSpeedUp,
980 ExposureSpeedDown,
981 CalibrationConstant,
982 FocalDistance,
983 MaxAperture,
984 BladeCount,
985 DepthBlurAmount,
986 DepthBlurRadius,
987 FilmSlope,
988 FilmToe,
989 FilmShoulder,
990 FilmBlackClip,
991 FilmWhiteClip,
992 Temperature,
993 Tint,
994 ChromaticIntensity,
995 ChromaticOffset});
996 }
997
998 AddShowOnlyVariations(Definition);
999
1000 Success = CheckActorDefinition(Definition);
1001}
1002
1004{
1005 FActorDefinition Definition;
1006 bool Success;
1008 check(Success);
1009 return Definition;
1010}
1011
1013{
1014 FillIdAndTags(Definition, TEXT("sensor"), TEXT("camera"), TEXT("normals"));
1016 AddVariationsForSensor(Definition);
1017
1018 // FOV
1019 FActorVariation FOV;
1020 FOV.Id = TEXT("fov");
1022 FOV.RecommendedValues = {TEXT("90.0")};
1023 FOV.bRestrictToRecommended = false;
1024
1025 // Resolution
1026 FActorVariation ResX;
1027 ResX.Id = TEXT("image_size_x");
1029 ResX.RecommendedValues = {TEXT("800")};
1030 ResX.bRestrictToRecommended = false;
1031
1032 FActorVariation ResY;
1033 ResY.Id = TEXT("image_size_y");
1035 ResY.RecommendedValues = {TEXT("600")};
1036 ResY.bRestrictToRecommended = false;
1037
1038 // Lens parameters
1039 FActorVariation LensCircleFalloff;
1040 LensCircleFalloff.Id = TEXT("lens_circle_falloff");
1041 LensCircleFalloff.Type = EActorAttributeType::Float;
1042 LensCircleFalloff.RecommendedValues = {TEXT("5.0")};
1043 LensCircleFalloff.bRestrictToRecommended = false;
1044
1045 FActorVariation LensCircleMultiplier;
1046 LensCircleMultiplier.Id = TEXT("lens_circle_multiplier");
1047 LensCircleMultiplier.Type = EActorAttributeType::Float;
1048 LensCircleMultiplier.RecommendedValues = {TEXT("0.0")};
1049 LensCircleMultiplier.bRestrictToRecommended = false;
1050
1051 FActorVariation LensK;
1052 LensK.Id = TEXT("lens_k");
1054 LensK.RecommendedValues = {TEXT("-1.0")};
1055 LensK.bRestrictToRecommended = false;
1056
1057 FActorVariation LensKcube;
1058 LensKcube.Id = TEXT("lens_kcube");
1059 LensKcube.Type = EActorAttributeType::Float;
1060 LensKcube.RecommendedValues = {TEXT("0.0")};
1061 LensKcube.bRestrictToRecommended = false;
1062
1063 FActorVariation LensXSize;
1064 LensXSize.Id = TEXT("lens_x_size");
1065 LensXSize.Type = EActorAttributeType::Float;
1066 LensXSize.RecommendedValues = {TEXT("0.08")};
1067 LensXSize.bRestrictToRecommended = false;
1068
1069 FActorVariation LensYSize;
1070 LensYSize.Id = TEXT("lens_y_size");
1071 LensYSize.Type = EActorAttributeType::Float;
1072 LensYSize.RecommendedValues = {TEXT("0.08")};
1073 LensYSize.bRestrictToRecommended = false;
1074
1075 // Per-sensor hardware ray-tracing opt-out. See MakeCameraDefinition for the
1076 // full rationale; the normals pipeline does not need RT, so leaving the
1077 // default at "true" still costs ~700 MiB-1 GiB of GPU memory until the
1078 // attribute is set false.
1079 FActorVariation UseRayTracing;
1080 UseRayTracing.Id = TEXT("use_ray_tracing");
1081 UseRayTracing.Type = EActorAttributeType::Bool;
1082 UseRayTracing.RecommendedValues = {TEXT("true")};
1083 UseRayTracing.bRestrictToRecommended = false;
1084
1085 Definition.Variations.Append({ResX,
1086 ResY,
1087 FOV,
1088 LensCircleFalloff,
1089 LensCircleMultiplier,
1090 LensK,
1091 LensKcube,
1092 LensXSize,
1093 LensYSize,
1094 UseRayTracing});
1095
1096 Success = CheckActorDefinition(Definition);
1097}
1098
1100 const FString &Id,
1101 const bool bEnableModifyingPostProcessEffects)
1102{
1103 FActorDefinition Definition;
1104 bool Success;
1105 MakeRayTracedLensCameraDefinition(Id, bEnableModifyingPostProcessEffects, Success, Definition);
1106 check(Success);
1107 return Definition;
1108}
1109
1111 const FString &Id,
1112 const bool bEnableModifyingPostProcessEffects,
1113 bool &Success,
1114 FActorDefinition &Definition)
1115{
1116 FillIdAndTags(Definition, TEXT("sensor"), TEXT("camera"), Id);
1118 AddVariationsForSensor(Definition);
1119
1120 // FOV
1121 FActorVariation FOV;
1122 FOV.Id = TEXT("fov");
1124 FOV.RecommendedValues = {TEXT("90.0")};
1125 FOV.bRestrictToRecommended = false;
1126
1127 // Resolution
1128 FActorVariation ResX;
1129 ResX.Id = TEXT("image_size_x");
1131 ResX.RecommendedValues = {TEXT("800")};
1132 ResX.bRestrictToRecommended = false;
1133
1134 FActorVariation ResY;
1135 ResY.Id = TEXT("image_size_y");
1137 ResY.RecommendedValues = {TEXT("600")};
1138 ResY.bRestrictToRecommended = false;
1139
1140 // Kept for attribute-surface parity with the other cameras, but the
1141 // constructor's SetUseRayTracing(true) wins regardless: the path tracer has
1142 // no rasterized fallback the way ASceneCaptureCamera does.
1143 FActorVariation UseRayTracing;
1144 UseRayTracing.Id = TEXT("use_ray_tracing");
1145 UseRayTracing.Type = EActorAttributeType::Bool;
1146 UseRayTracing.RecommendedValues = {TEXT("true")};
1147 UseRayTracing.bRestrictToRecommended = false;
1148
1149 // Lens model (see Util/CameraModelUtil.h for FLensModelDescriptor).
1150 FActorVariation CameraModelVar;
1151 CameraModelVar.Id = TEXT("camera_model");
1152 CameraModelVar.Type = EActorAttributeType::String;
1153 CameraModelVar.RecommendedValues =
1154 {
1155 TEXT("perspective"),
1156 TEXT("stereographic"),
1157 TEXT("equidistant"),
1158 TEXT("equisolid"),
1159 TEXT("orthographic"),
1160 TEXT("kannala_brandt"),
1161 TEXT("brown_conrady"),
1162 TEXT("lut"),
1163 TEXT("ftheta")
1164 };
1165 CameraModelVar.bRestrictToRecommended = false;
1166
1167 // Comma-separated distortion coefficients; meaning is camera_model-specific
1168 // (KannalaBrandt: k1..k4, BrownConrady: k1,k2,k3,p1,p2, FTheta: c0..c7 of
1169 // theta = sum c_i r^i with r in pixels when fx = 1/width -- the NVIDIA rig
1170 // pixeldist_to_angle polynomial verbatim).
1171 FActorVariation DistortionCoeffs;
1172 DistortionCoeffs.Id = TEXT("distortion_coeffs");
1173 DistortionCoeffs.Type = EActorAttributeType::String;
1174 DistortionCoeffs.RecommendedValues = {TEXT("")};
1175 DistortionCoeffs.bRestrictToRecommended = false;
1176
1177 // Comma-separated theta->r samples for camera_model=lut. Optional.
1178 FActorVariation Lut;
1179 Lut.Id = TEXT("lut");
1181 Lut.RecommendedValues = {TEXT("")};
1182 Lut.bRestrictToRecommended = false;
1183
1184 // Focal lengths, normalized per axis: fx by the image width, fy by its height.
1185 // 0 = derive from the fov attribute through the camera_model, with square pixels.
1186 FActorVariation Fx;
1187 Fx.Id = TEXT("fx");
1189 Fx.RecommendedValues = {TEXT("0.0")};
1190 Fx.bRestrictToRecommended = false;
1191
1192 FActorVariation Fy;
1193 Fy.Id = TEXT("fy");
1195 Fy.RecommendedValues = {TEXT("0.0")};
1196 Fy.bRestrictToRecommended = false;
1197
1198 FActorVariation Cx;
1199 Cx.Id = TEXT("cx");
1201 Cx.RecommendedValues = {TEXT("0.5")};
1202 Cx.bRestrictToRecommended = false;
1203
1204 FActorVariation Cy;
1205 Cy.Id = TEXT("cy");
1207 Cy.RecommendedValues = {TEXT("0.5")};
1208 Cy.bRestrictToRecommended = false;
1209
1210 // Maximum half-angle accepted by the lens, in degrees. 0 = automatic:
1211 // large enough that every pixel out to the frame corners receives a ray.
1212 FActorVariation ThetaMaxDeg;
1213 ThetaMaxDeg.Id = TEXT("theta_max_deg");
1214 ThetaMaxDeg.Type = EActorAttributeType::Float;
1215 ThetaMaxDeg.RecommendedValues = {TEXT("0.0")};
1216 ThetaMaxDeg.bRestrictToRecommended = false;
1217
1218 // Depth of field. aperture_fstop=0 means pinhole (no DOF).
1219 FActorVariation ApertureFstop;
1220 ApertureFstop.Id = TEXT("aperture_fstop");
1221 ApertureFstop.Type = EActorAttributeType::Float;
1222 ApertureFstop.RecommendedValues = {TEXT("0.0")};
1223 ApertureFstop.bRestrictToRecommended = false;
1224
1225 FActorVariation FocusDistanceM;
1226 FocusDistanceM.Id = TEXT("focus_distance_m");
1227 FocusDistanceM.Type = EActorAttributeType::Float;
1228 FocusDistanceM.RecommendedValues = {TEXT("1000.0")};
1229 FocusDistanceM.bRestrictToRecommended = false;
1230
1231 // Chromatic aberration: per-channel radial scale relative to green (1.0 = none).
1232 FActorVariation CAShiftR;
1233 CAShiftR.Id = TEXT("ca_shift_r");
1235 CAShiftR.RecommendedValues = {TEXT("1.0")};
1236 CAShiftR.bRestrictToRecommended = false;
1237
1238 FActorVariation CAShiftB;
1239 CAShiftB.Id = TEXT("ca_shift_b");
1241 CAShiftB.RecommendedValues = {TEXT("1.0")};
1242 CAShiftB.bRestrictToRecommended = false;
1243
1244 // Path-tracer quality.
1245 FActorVariation SamplesPerPixel;
1246 SamplesPerPixel.Id = TEXT("samples_per_pixel");
1247 SamplesPerPixel.Type = EActorAttributeType::Int;
1248 SamplesPerPixel.RecommendedValues = {TEXT("16")};
1249 SamplesPerPixel.bRestrictToRecommended = false;
1250
1251 FActorVariation EnableDenoiser;
1252 EnableDenoiser.Id = TEXT("enable_denoiser");
1253 EnableDenoiser.Type = EActorAttributeType::Bool;
1254 EnableDenoiser.RecommendedValues = {TEXT("true")};
1255 EnableDenoiser.bRestrictToRecommended = false;
1256
1257 // Exposure. "auto" = the post_process_profile's auto exposure, its upper end
1258 // capped by carla.RTLens.MaxAutoExposureEV; "manual" = the physical camera of
1259 // the profile, deterministic frame to frame (compositing).
1260 // exposure_compensation (EV) adds to the profile's bias.
1261 FActorVariation RTExposureMode;
1262 RTExposureMode.Id = TEXT("exposure_mode");
1263 RTExposureMode.Type = EActorAttributeType::String;
1264 RTExposureMode.RecommendedValues = {TEXT("auto"), TEXT("manual")};
1265 RTExposureMode.bRestrictToRecommended = false;
1266 FActorVariation RTExposureCompensation;
1267 RTExposureCompensation.Id = TEXT("exposure_compensation");
1268 RTExposureCompensation.Type = EActorAttributeType::Float;
1269 RTExposureCompensation.RecommendedValues = {TEXT("0.0")};
1270 RTExposureCompensation.bRestrictToRecommended = false;
1271
1272 Definition.Variations.Append({ResX,
1273 ResY,
1274 FOV,
1275 UseRayTracing,
1276 CameraModelVar,
1277 DistortionCoeffs,
1278 Lut,
1279 Fx,
1280 Fy,
1281 Cx,
1282 Cy,
1283 ThetaMaxDeg,
1284 ApertureFstop,
1285 FocusDistanceM,
1286 CAShiftR,
1287 CAShiftB,
1288 SamplesPerPixel,
1289 EnableDenoiser,
1290 RTExposureMode,
1291 RTExposureCompensation});
1292
1293 if (bEnableModifyingPostProcessEffects)
1294 {
1295 FActorVariation PostProccess;
1296 PostProccess.Id = TEXT("enable_postprocess_effects");
1297 PostProccess.Type = EActorAttributeType::Bool;
1298 PostProccess.RecommendedValues = {TEXT("true")};
1299 PostProccess.bRestrictToRecommended = false;
1300
1301 FActorVariation post_process_profile;
1302 post_process_profile.Id = TEXT("post_process_profile");
1303 post_process_profile.Type = EActorAttributeType::String;
1304 post_process_profile.RecommendedValues = {TEXT("")};
1305 post_process_profile.bRestrictToRecommended = false;
1306
1307 Definition.Variations.Append({PostProccess, post_process_profile});
1308 }
1309
1310 AddShowOnlyVariations(Definition);
1311
1312 Success = CheckActorDefinition(Definition);
1313}
1314
1316{
1317 FActorDefinition Definition;
1318 bool Success;
1319 MakeIMUDefinition(Success, Definition);
1320 check(Success);
1321 return Definition;
1322}
1323
1325 bool &Success,
1326 FActorDefinition &Definition)
1327{
1328 FillIdAndTags(Definition, TEXT("sensor"), TEXT("other"), TEXT("imu"));
1329 AddVariationsForSensor(Definition);
1330
1331 // - Noise seed --------------------------------
1332 FActorVariation NoiseSeed;
1333 NoiseSeed.Id = TEXT("noise_seed");
1334 NoiseSeed.Type = EActorAttributeType::Int;
1335 NoiseSeed.RecommendedValues = {TEXT("0")};
1336 NoiseSeed.bRestrictToRecommended = false;
1337
1338 // - Accelerometer Standard Deviation ----------
1339 // X Component
1340 FActorVariation StdDevAccelX;
1341 StdDevAccelX.Id = TEXT("noise_accel_stddev_x");
1342 StdDevAccelX.Type = EActorAttributeType::Float;
1343 StdDevAccelX.RecommendedValues = {TEXT("0.0")};
1344 StdDevAccelX.bRestrictToRecommended = false;
1345 // Y Component
1346 FActorVariation StdDevAccelY;
1347 StdDevAccelY.Id = TEXT("noise_accel_stddev_y");
1348 StdDevAccelY.Type = EActorAttributeType::Float;
1349 StdDevAccelY.RecommendedValues = {TEXT("0.0")};
1350 StdDevAccelY.bRestrictToRecommended = false;
1351 // Z Component
1352 FActorVariation StdDevAccelZ;
1353 StdDevAccelZ.Id = TEXT("noise_accel_stddev_z");
1354 StdDevAccelZ.Type = EActorAttributeType::Float;
1355 StdDevAccelZ.RecommendedValues = {TEXT("0.0")};
1356 StdDevAccelZ.bRestrictToRecommended = false;
1357
1358 // - Gyroscope Standard Deviation --------------
1359 // X Component
1360 FActorVariation StdDevGyroX;
1361 StdDevGyroX.Id = TEXT("noise_gyro_stddev_x");
1362 StdDevGyroX.Type = EActorAttributeType::Float;
1363 StdDevGyroX.RecommendedValues = {TEXT("0.0")};
1364 StdDevGyroX.bRestrictToRecommended = false;
1365 // Y Component
1366 FActorVariation StdDevGyroY;
1367 StdDevGyroY.Id = TEXT("noise_gyro_stddev_y");
1368 StdDevGyroY.Type = EActorAttributeType::Float;
1369 StdDevGyroY.RecommendedValues = {TEXT("0.0")};
1370 StdDevGyroY.bRestrictToRecommended = false;
1371 // Z Component
1372 FActorVariation StdDevGyroZ;
1373 StdDevGyroZ.Id = TEXT("noise_gyro_stddev_z");
1374 StdDevGyroZ.Type = EActorAttributeType::Float;
1375 StdDevGyroZ.RecommendedValues = {TEXT("0.0")};
1376 StdDevGyroZ.bRestrictToRecommended = false;
1377
1378 // - Gyroscope Bias ----------------------------
1379 // X Component
1380 FActorVariation BiasGyroX;
1381 BiasGyroX.Id = TEXT("noise_gyro_bias_x");
1382 BiasGyroX.Type = EActorAttributeType::Float;
1383 BiasGyroX.RecommendedValues = {TEXT("0.0")};
1384 BiasGyroX.bRestrictToRecommended = false;
1385 // Y Component
1386 FActorVariation BiasGyroY;
1387 BiasGyroY.Id = TEXT("noise_gyro_bias_y");
1388 BiasGyroY.Type = EActorAttributeType::Float;
1389 BiasGyroY.RecommendedValues = {TEXT("0.0")};
1390 BiasGyroY.bRestrictToRecommended = false;
1391 // Z Component
1392 FActorVariation BiasGyroZ;
1393 BiasGyroZ.Id = TEXT("noise_gyro_bias_z");
1394 BiasGyroZ.Type = EActorAttributeType::Float;
1395 BiasGyroZ.RecommendedValues = {TEXT("0.0")};
1396 BiasGyroZ.bRestrictToRecommended = false;
1397
1398 Definition.Variations.Append({NoiseSeed,
1399 StdDevAccelX,
1400 StdDevAccelY,
1401 StdDevAccelZ,
1402 StdDevGyroX,
1403 StdDevGyroY,
1404 StdDevGyroZ,
1405 BiasGyroX,
1406 BiasGyroY,
1407 BiasGyroZ});
1408
1409 Success = CheckActorDefinition(Definition);
1410}
1411
1413{
1414 FActorDefinition Definition;
1415 bool Success;
1416 MakeRadarDefinition(Success, Definition);
1417 check(Success);
1418 return Definition;
1419}
1420
1422 bool &Success,
1423 FActorDefinition &Definition)
1424{
1425 FillIdAndTags(Definition, TEXT("sensor"), TEXT("other"), TEXT("radar"));
1426 AddVariationsForSensor(Definition);
1427
1428 FActorVariation HorizontalFOV;
1429 HorizontalFOV.Id = TEXT("horizontal_fov");
1430 HorizontalFOV.Type = EActorAttributeType::Float;
1431 HorizontalFOV.RecommendedValues = {TEXT("30")};
1432 HorizontalFOV.bRestrictToRecommended = false;
1433
1434 FActorVariation VerticalFOV;
1435 VerticalFOV.Id = TEXT("vertical_fov");
1436 VerticalFOV.Type = EActorAttributeType::Float;
1437 VerticalFOV.RecommendedValues = {TEXT("30")};
1438 VerticalFOV.bRestrictToRecommended = false;
1439
1440 FActorVariation Range;
1441 Range.Id = TEXT("range");
1443 Range.RecommendedValues = {TEXT("100")};
1444 Range.bRestrictToRecommended = false;
1445
1446 FActorVariation PointsPerSecond;
1447 PointsPerSecond.Id = TEXT("points_per_second");
1448 PointsPerSecond.Type = EActorAttributeType::Int;
1449 PointsPerSecond.RecommendedValues = {TEXT("1500")};
1450 PointsPerSecond.bRestrictToRecommended = false;
1451
1452 // Noise seed
1453 FActorVariation NoiseSeed;
1454 NoiseSeed.Id = TEXT("noise_seed");
1455 NoiseSeed.Type = EActorAttributeType::Int;
1456 NoiseSeed.RecommendedValues = {TEXT("0")};
1457 NoiseSeed.bRestrictToRecommended = false;
1458
1459 Definition.Variations.Append({HorizontalFOV,
1460 VerticalFOV,
1461 Range,
1462 PointsPerSecond,
1463 NoiseSeed});
1464
1465 Success = CheckActorDefinition(Definition);
1466}
1467
1469 const FString &Id)
1470{
1471 FActorDefinition Definition;
1472 bool Success;
1473 MakeLidarDefinition(Id, Success, Definition);
1474 check(Success);
1475 return Definition;
1476}
1477
1479 const FString &Id,
1480 bool &Success,
1481 FActorDefinition &Definition)
1482{
1483 FillIdAndTags(Definition, TEXT("sensor"), TEXT("lidar"), Id);
1485 AddVariationsForSensor(Definition);
1486 // Number of channels.
1487 FActorVariation Channels;
1488 Channels.Id = TEXT("channels");
1489 Channels.Type = EActorAttributeType::Int;
1490 Channels.RecommendedValues = {TEXT("64")};
1491 // Range.
1492 FActorVariation Range;
1493 Range.Id = TEXT("range");
1495 Range.RecommendedValues = {TEXT("50.0")}; // 50 meters
1496 // Points per second.
1497 FActorVariation PointsPerSecond;
1498 PointsPerSecond.Id = TEXT("points_per_second");
1499 PointsPerSecond.Type = EActorAttributeType::Int;
1500 PointsPerSecond.RecommendedValues = {TEXT("600000")};
1501 // Frequency.
1502 FActorVariation Frequency;
1503 Frequency.Id = TEXT("rotation_frequency");
1504 Frequency.Type = EActorAttributeType::Float;
1505 Frequency.RecommendedValues = {TEXT("60.0")};
1506 // Upper FOV limit.
1507 FActorVariation UpperFOV;
1508 UpperFOV.Id = TEXT("upper_fov");
1510 UpperFOV.RecommendedValues = {TEXT("10.0")};
1511 // Lower FOV limit.
1512 FActorVariation LowerFOV;
1513 LowerFOV.Id = TEXT("lower_fov");
1515 LowerFOV.RecommendedValues = {TEXT("-30.0")};
1516 // Horizontal FOV.
1517 FActorVariation HorizontalFOV;
1518 HorizontalFOV.Id = TEXT("horizontal_fov");
1519 HorizontalFOV.Type = EActorAttributeType::Float;
1520 HorizontalFOV.RecommendedValues = {TEXT("360.0")};
1521 // Atmospheric Attenuation Rate.
1522 FActorVariation AtmospAttenRate;
1523 AtmospAttenRate.Id = TEXT("atmosphere_attenuation_rate");
1524 AtmospAttenRate.Type = EActorAttributeType::Float;
1525 AtmospAttenRate.RecommendedValues = {TEXT("0.004")};
1526 // Noise seed
1527 FActorVariation NoiseSeed;
1528 NoiseSeed.Id = TEXT("noise_seed");
1529 NoiseSeed.Type = EActorAttributeType::Int;
1530 NoiseSeed.RecommendedValues = {TEXT("0")};
1531 NoiseSeed.bRestrictToRecommended = false;
1532 // Dropoff General Rate
1533 FActorVariation DropOffGenRate;
1534 DropOffGenRate.Id = TEXT("dropoff_general_rate");
1535 DropOffGenRate.Type = EActorAttributeType::Float;
1536 DropOffGenRate.RecommendedValues = {TEXT("0.45")};
1537 // Dropoff intensity limit.
1538 FActorVariation DropOffIntensityLimit;
1539 DropOffIntensityLimit.Id = TEXT("dropoff_intensity_limit");
1540 DropOffIntensityLimit.Type = EActorAttributeType::Float;
1541 DropOffIntensityLimit.RecommendedValues = {TEXT("0.8")};
1542 // Dropoff at zero intensity.
1543 FActorVariation DropOffAtZeroIntensity;
1544 DropOffAtZeroIntensity.Id = TEXT("dropoff_zero_intensity");
1545 DropOffAtZeroIntensity.Type = EActorAttributeType::Float;
1546 DropOffAtZeroIntensity.RecommendedValues = {TEXT("0.4")};
1547 // Noise in lidar cloud points.
1548 FActorVariation StdDevLidar;
1549 StdDevLidar.Id = TEXT("noise_stddev");
1550 StdDevLidar.Type = EActorAttributeType::Float;
1551 StdDevLidar.RecommendedValues = {TEXT("0.0")};
1552
1553 if (Id == "ray_cast")
1554 {
1555 Definition.Variations.Append({Channels,
1556 Range,
1557 PointsPerSecond,
1558 Frequency,
1559 UpperFOV,
1560 LowerFOV,
1561 AtmospAttenRate,
1562 NoiseSeed,
1563 DropOffGenRate,
1564 DropOffIntensityLimit,
1565 DropOffAtZeroIntensity,
1566 StdDevLidar,
1567 HorizontalFOV});
1568 }
1569 else if (Id == "hss_lidar")
1570 {
1571 FActorVariation HorizontalResolution;
1572 HorizontalResolution.Id = TEXT("horizontal_resolution");
1573 HorizontalResolution.Type = EActorAttributeType::Float;
1574 HorizontalResolution.RecommendedValues = { TEXT("0.1") };
1575
1576 Channels.RecommendedValues = { TEXT("128") };
1577 Range.RecommendedValues = { TEXT("200") };
1578 Frequency.RecommendedValues = { TEXT("20") };
1579 UpperFOV.RecommendedValues = { TEXT("12.9") };
1580 LowerFOV.RecommendedValues = { TEXT("-12.5") };
1581 HorizontalFOV.RecommendedValues = { TEXT("120.0") };
1582
1583 Definition.Variations.Append({
1584 Channels,
1585 Range,
1586 Frequency,
1587 UpperFOV,
1588 LowerFOV,
1589 AtmospAttenRate,
1590 NoiseSeed,
1591 DropOffGenRate,
1592 DropOffIntensityLimit,
1593 DropOffAtZeroIntensity,
1594 StdDevLidar,
1595 HorizontalFOV,
1596 HorizontalResolution});
1597 }
1598 else if (Id == "ray_cast_semantic")
1599 {
1600 Definition.Variations.Append({Channels,
1601 Range,
1602 PointsPerSecond,
1603 Frequency,
1604 UpperFOV,
1605 LowerFOV,
1606 HorizontalFOV});
1607 }
1608 else
1609 {
1610 DEBUG_ASSERT(false);
1611 }
1612
1613 Success = CheckActorDefinition(Definition);
1614}
1615
1617{
1618 FActorDefinition Definition;
1619 bool Success;
1620 MakeGnssDefinition(Success, Definition, TEXT("gnss"));
1621 check(Success);
1622 return Definition;
1623}
1624
1626{
1627 FActorDefinition Definition;
1628 bool Success;
1629 MakeGnssDefinition(Success, Definition, TEXT("autoware_gnss"));
1630 check(Success);
1631 return Definition;
1632}
1633
1635{
1636 FActorDefinition Definition;
1637 FillIdAndTags(Definition, TEXT("sensor"), TEXT("other"), TEXT("vehicle_status"));
1638 AddVariationsForSensor(Definition);
1639
1640 // Optional attribute exposed in the Python API (tier4 port).
1641 Definition.Attributes.Emplace(FActorAttribute{
1642 TEXT("speed_units"),
1644 TEXT("mps")});
1645
1646 bool Success = CheckActorDefinition(Definition);
1647 check(Success);
1648 return Definition;
1649}
1650
1652 bool &Success,
1653 FActorDefinition &Definition,
1654 FString Name)
1655{
1656 FillIdAndTags(Definition, TEXT("sensor"), TEXT("other"), Name);
1657 AddVariationsForSensor(Definition);
1658
1659 // - Noise seed --------------------------------
1660 FActorVariation NoiseSeed;
1661 NoiseSeed.Id = TEXT("noise_seed");
1662 NoiseSeed.Type = EActorAttributeType::Int;
1663 NoiseSeed.RecommendedValues = {TEXT("0")};
1664 NoiseSeed.bRestrictToRecommended = false;
1665
1666 // - Latitude ----------------------------------
1667 FActorVariation StdDevLat;
1668 StdDevLat.Id = TEXT("noise_lat_stddev");
1669 StdDevLat.Type = EActorAttributeType::Float;
1670 StdDevLat.RecommendedValues = {TEXT("0.0")};
1671 StdDevLat.bRestrictToRecommended = false;
1672 FActorVariation BiasLat;
1673 BiasLat.Id = TEXT("noise_lat_bias");
1675 BiasLat.RecommendedValues = {TEXT("0.0")};
1676 BiasLat.bRestrictToRecommended = false;
1677
1678 // - Longitude ---------------------------------
1679 FActorVariation StdDevLong;
1680 StdDevLong.Id = TEXT("noise_lon_stddev");
1681 StdDevLong.Type = EActorAttributeType::Float;
1682 StdDevLong.RecommendedValues = {TEXT("0.0")};
1683 StdDevLong.bRestrictToRecommended = false;
1684 FActorVariation BiasLong;
1685 BiasLong.Id = TEXT("noise_lon_bias");
1687 BiasLong.RecommendedValues = {TEXT("0.0")};
1688 BiasLong.bRestrictToRecommended = false;
1689
1690 // - Altitude ----------------------------------
1691 FActorVariation StdDevAlt;
1692 StdDevAlt.Id = TEXT("noise_alt_stddev");
1693 StdDevAlt.Type = EActorAttributeType::Float;
1694 StdDevAlt.RecommendedValues = {TEXT("0.0")};
1695 StdDevAlt.bRestrictToRecommended = false;
1696 FActorVariation BiasAlt;
1697 BiasAlt.Id = TEXT("noise_alt_bias");
1699 BiasAlt.RecommendedValues = {TEXT("0.0")};
1700 BiasAlt.bRestrictToRecommended = false;
1701
1702 Definition.Variations.Append({NoiseSeed,
1703 StdDevLat,
1704 BiasLat,
1705 StdDevLong,
1706 BiasLong,
1707 StdDevAlt,
1708 BiasAlt});
1709
1710 Success = CheckActorDefinition(Definition);
1711}
1712
1714 const FVehicleParameters &Parameters,
1715 bool &Success,
1716 FActorDefinition &Definition)
1717{
1718 /// @todo We need to validate here the params.
1719 FillIdAndTags(Definition, TEXT("vehicle"), Parameters.Make, Parameters.Model);
1721 {TEXT("autopilot"), TEXT("scenario"), TEXT("ego_vehicle")});
1722 // Resolve the soft class at definition time. The catalog stores
1723 // TSoftClassPtr so JSON parsing does not force-load; the UClass is needed
1724 // here to hand the dispatcher a concrete spawn target.
1725 Definition.Class = Parameters.Class.LoadSynchronous();
1726
1727 if (Parameters.RecommendedColors.Num() > 0)
1728 {
1729 FActorVariation Colors;
1730 Colors.Id = TEXT("color");
1732 Colors.bRestrictToRecommended = false;
1733 for (auto &Color : Parameters.RecommendedColors)
1734 {
1735 Colors.RecommendedValues.Emplace(ColorToFString(Color));
1736 }
1737 Definition.Variations.Emplace(Colors);
1738 }
1739
1740 if (Parameters.SupportedDrivers.Num() > 0)
1741 {
1742 FActorVariation Drivers;
1743 Drivers.Id = TEXT("driver_id");
1745 Drivers.bRestrictToRecommended = true;
1746 for (auto &Id : Parameters.SupportedDrivers)
1747 {
1748 Drivers.RecommendedValues.Emplace(FString::FromInt(Id));
1749 }
1750 Definition.Variations.Emplace(Drivers);
1751 }
1752
1753 FActorVariation StickyControl;
1754 StickyControl.Id = TEXT("sticky_control");
1755 StickyControl.Type = EActorAttributeType::Bool;
1756 StickyControl.bRestrictToRecommended = false;
1757 StickyControl.RecommendedValues.Emplace(TEXT("true"));
1758 Definition.Variations.Emplace(StickyControl);
1759
1760 FActorVariation TerramechanicsAttribute;
1761 TerramechanicsAttribute.Id = TEXT("terramechanics");
1762 TerramechanicsAttribute.Type = EActorAttributeType::Bool;
1763 TerramechanicsAttribute.bRestrictToRecommended = false;
1764 TerramechanicsAttribute.RecommendedValues.Emplace(TEXT("false"));
1765 Definition.Variations.Emplace(TerramechanicsAttribute);
1766
1767 // Opt-in to the ROS 2 Ackermann control topic. When true the vehicle subscribes to
1768 // the Ackermann control command instead of the direct VehicleControl command; the two
1769 // are mutually exclusive so they cannot fight over the actor frame to frame.
1770 FActorVariation ROS2AckermannControl;
1771 ROS2AckermannControl.Id = TEXT("ros2_ackermann_control");
1772 ROS2AckermannControl.Type = EActorAttributeType::Bool;
1773 ROS2AckermannControl.bRestrictToRecommended = false;
1774 ROS2AckermannControl.RecommendedValues.Emplace(TEXT("false"));
1775 Definition.Variations.Emplace(ROS2AckermannControl);
1776
1777 // ROS2: opt-in flag wiring the Autoware /control/command/* + /vehicle/engage
1778 // subscribers instead of the direct or Ackermann control topic (tier4 port).
1779 FActorVariation ROS2AutowareControl;
1780 ROS2AutowareControl.Id = TEXT("ros2_autoware_control");
1781 ROS2AutowareControl.Type = EActorAttributeType::Bool;
1782 ROS2AutowareControl.bRestrictToRecommended = false;
1783 ROS2AutowareControl.RecommendedValues.Emplace(TEXT("false"));
1784 Definition.Variations.Emplace(ROS2AutowareControl);
1785
1786 Definition.Attributes.Emplace(FActorAttribute{
1787 TEXT("object_type"),
1789 Parameters.ObjectType});
1790
1791 Definition.Attributes.Emplace(FActorAttribute{
1792 TEXT("base_type"),
1794 Parameters.BaseType});
1795 Success = CheckActorDefinition(Definition);
1796
1797 Definition.Attributes.Emplace(FActorAttribute{
1798 TEXT("special_type"),
1800 Parameters.SpecialType});
1801 Success = CheckActorDefinition(Definition);
1802
1803 Definition.Attributes.Emplace(FActorAttribute{
1804 TEXT("number_of_wheels"),
1806 FString::FromInt(Parameters.NumberOfWheels)});
1807 Success = CheckActorDefinition(Definition);
1808
1809 Definition.Attributes.Emplace(FActorAttribute{
1810 TEXT("generation"),
1812 FString::FromInt(Parameters.Generation)});
1813 Success = CheckActorDefinition(Definition);
1814
1815 Definition.Attributes.Emplace(FActorAttribute{
1816 TEXT("has_dynamic_doors"),
1818 Parameters.HasDynamicDoors ? TEXT("true") : TEXT("false")});
1819 Success = CheckActorDefinition(Definition);
1820
1821 Definition.Attributes.Emplace(FActorAttribute{
1822 TEXT("has_lights"),
1824 Parameters.HasLights ? TEXT("true") : TEXT("false")});
1825 Success = CheckActorDefinition(Definition);
1826}
1827
1828template <typename T, typename Functor>
1830 const TArray<T> &ParameterArray,
1831 TArray<FActorDefinition> &Definitions,
1832 Functor Maker)
1833{
1834 for (auto &Item : ParameterArray)
1835 {
1836 FActorDefinition Definition;
1837 bool Success = false;
1838 Maker(Item, Success, Definition);
1839 if (Success)
1840 {
1841 Definitions.Emplace(std::move(Definition));
1842 }
1843 }
1844}
1845
1847 const TArray<FVehicleParameters> &ParameterArray,
1848 TArray<FActorDefinition> &Definitions)
1849{
1850 FillActorDefinitionArray(ParameterArray, Definitions, &MakeVehicleDefinition);
1851}
1852
1854 const FPedestrianParameters &Parameters,
1855 bool &Success,
1856 FActorDefinition &Definition)
1857{
1858 /// @todo We need to validate here the params.
1859 FillIdAndTags(Definition, TEXT("walker"), TEXT("pedestrian"), Parameters.Id);
1860 AddRecommendedValuesForActorRoleName(Definition, {TEXT("pedestrian")});
1861 // Resolve the soft class at definition time (see MakeVehicleDefinition).
1862 Definition.Class = Parameters.Class.LoadSynchronous();
1863
1864 auto GetGender = [](EPedestrianGender Value)
1865 {
1866 switch (Value)
1867 {
1868 case EPedestrianGender::Female:
1869 return TEXT("female");
1870 case EPedestrianGender::Male:
1871 return TEXT("male");
1872 default:
1873 return TEXT("other");
1874 }
1875 };
1876
1877 auto GetAge = [](EPedestrianAge Value)
1878 {
1879 switch (Value)
1880 {
1881 case EPedestrianAge::Child:
1882 return TEXT("child");
1883 case EPedestrianAge::Teenager:
1884 return TEXT("teenager");
1885 case EPedestrianAge::Elderly:
1886 return TEXT("elderly");
1887 default:
1888 return TEXT("adult");
1889 }
1890 };
1891
1892 Definition.Attributes.Emplace(FActorAttribute{
1893 TEXT("gender"),
1895 GetGender(Parameters.Gender)});
1896
1897 Definition.Attributes.Emplace(FActorAttribute{
1898 TEXT("generation"),
1900 FString::FromInt(Parameters.Generation)});
1901
1902 Definition.Attributes.Emplace(FActorAttribute{
1903 TEXT("age"),
1905 GetAge(Parameters.Age)});
1906
1907 Definition.Attributes.Emplace(FActorAttribute{
1908 TEXT("can_use_wheelchair"),
1910 Parameters.bCanUseWheelChair ? TEXT("true") : TEXT("false")});
1911
1912 Definition.Attributes.Emplace(FActorAttribute{
1913 TEXT("special_type"),
1915 Parameters.SpecialType});
1916
1917 if (Parameters.Speed.Num() > 0)
1918 {
1919 FActorVariation Speed;
1920 Speed.Id = TEXT("speed");
1922 for (auto &Value : Parameters.Speed)
1923 {
1924 Speed.RecommendedValues.Emplace(FString::SanitizeFloat(Value));
1925 }
1926 Speed.bRestrictToRecommended = false;
1927 Definition.Variations.Emplace(Speed);
1928 }
1929
1930 FActorVariation IsInvincible;
1931 IsInvincible.Id = TEXT("is_invincible");
1932 IsInvincible.Type = EActorAttributeType::Bool;
1933 IsInvincible.RecommendedValues = {TEXT("true")};
1934 IsInvincible.bRestrictToRecommended = false;
1935 Definition.Variations.Emplace(IsInvincible);
1936
1937 FActorVariation WheelChairVariation;
1938 WheelChairVariation.Id = TEXT("use_wheelchair");
1939 WheelChairVariation.Type = EActorAttributeType::Bool;
1940 if (Parameters.bCanUseWheelChair)
1941 {
1942 WheelChairVariation.RecommendedValues = {TEXT("false"), TEXT("true")};
1943 }
1944 else
1945 {
1946 WheelChairVariation.RecommendedValues = {TEXT("false")};
1947 }
1948 WheelChairVariation.bRestrictToRecommended = true;
1949 Definition.Variations.Emplace(WheelChairVariation);
1950
1951 Success = CheckActorDefinition(Definition);
1952}
1953
1955 const TArray<FPedestrianParameters> &ParameterArray,
1956 TArray<FActorDefinition> &Definitions)
1957{
1958 FillActorDefinitionArray(ParameterArray, Definitions, &MakePedestrianDefinition);
1959}
1960
1962 const TArray<FString> &ParameterArray,
1963 TArray<FActorDefinition> &Definitions)
1964{
1965 FillActorDefinitionArray(ParameterArray, Definitions, &MakeTriggerDefinition);
1966}
1967
1969 const FString &Id,
1970 bool &Success,
1971 FActorDefinition &Definition)
1972{
1973 FillIdAndTags(Definition, TEXT("static"), TEXT("trigger"), Id);
1974 AddVariationsForTrigger(Definition);
1975 Success = CheckActorDefinition(Definition);
1976 check(Success);
1977}
1978
1980 const FPropParameters &Parameters,
1981 bool &Success,
1982 FActorDefinition &Definition)
1983{
1984 /// @todo We need to validate here the params.
1985 FillIdAndTags(Definition, TEXT("static"), TEXT("prop"), Parameters.Name);
1986 AddRecommendedValuesForActorRoleName(Definition, {TEXT("prop")});
1987
1988 Definition.Class = AStaticMeshActor::StaticClass();
1989 if (!Parameters.Mesh.IsNull())
1990 {
1991 Definition.Variations.Emplace(FActorVariation{
1992 TEXT("mesh_path"),
1994 {Parameters.Mesh.ToSoftObjectPath().ToString()},
1995 false});
1996 }
1997
1998 auto GetSize = [](EPropSize Value)
1999 {
2000 switch (Value)
2001 {
2002 case EPropSize::Tiny:
2003 return TEXT("tiny");
2004 case EPropSize::Small:
2005 return TEXT("small");
2006 case EPropSize::Medium:
2007 return TEXT("medium");
2008 case EPropSize::Big:
2009 return TEXT("big");
2010 case EPropSize::Huge:
2011 return TEXT("huge");
2012 default:
2013 return TEXT("unknown");
2014 }
2015 };
2016
2017 Definition.Attributes.Emplace(FActorAttribute{
2018 TEXT("size"),
2020 GetSize(Parameters.Size)});
2021
2022 Definition.Attributes.Emplace(FActorAttribute{
2023 TEXT("base_type"),
2025 Parameters.BaseType});
2026
2027 Definition.Attributes.Emplace(FActorAttribute{
2028 TEXT("subtype"),
2030 Parameters.SubType});
2031
2032 Success = CheckActorDefinition(Definition);
2033}
2034
2036 const TArray<FPropParameters> &ParameterArray,
2037 TArray<FActorDefinition> &Definitions)
2038{
2039 FillActorDefinitionArray(ParameterArray, Definitions, &MakePropDefinition);
2040}
2041
2043 const FBlueprintParameters &Parameters,
2044 bool &Success,
2045 FActorDefinition &Definition)
2046{
2047 FillIdAndTags(Definition, TEXT("blueprint"), Parameters.Name);
2048 AddRecommendedValuesForActorRoleName(Definition, {TEXT("blueprint")});
2049
2050 // The catalog stores the blueprint's class path; an asset path is accepted
2051 // too by appending the generated-class suffix (see MakeVehicleDefinition).
2052 FString ClassPath = Parameters.Path;
2053 if (!ClassPath.IsEmpty() && !ClassPath.EndsWith(TEXT("_C")))
2054 {
2055 ClassPath += TEXT("_C");
2056 }
2057 Definition.Class = LoadClass<AActor>(nullptr, *ClassPath);
2058
2059 // Definition.Attributes.Emplace(FActorAttribute{
2060 // EActorAttributeType::String,
2061 // Parameters.ObjectType});
2062
2063 Success = CheckActorDefinition(Definition);
2064}
2065
2067 const TArray<FBlueprintParameters> &ParameterArray,
2068 TArray<FActorDefinition> &Definitions)
2069{
2070 FillActorDefinitionArray(ParameterArray, Definitions, &MakeBlueprintDefinition);
2071}
2072
2074 const FString &Type,
2075 const FString &Id,
2076 FActorDefinition &Definition)
2077{
2078 Definition = MakeGenericSensorDefinition(TEXT("other"), TEXT("obstacle"));
2079 AddVariationsForSensor(Definition);
2080 // Distance.
2082 distance.Id = TEXT("distance");
2084 distance.RecommendedValues = {TEXT("5.0")};
2085 distance.bRestrictToRecommended = false;
2086 // HitRadius.
2087 FActorVariation hitradius;
2088 hitradius.Id = TEXT("hit_radius");
2089 hitradius.Type = EActorAttributeType::Float;
2090 hitradius.RecommendedValues = {TEXT("0.5")};
2091 hitradius.bRestrictToRecommended = false;
2092 // Only Dynamics
2093 FActorVariation onlydynamics;
2094 onlydynamics.Id = TEXT("only_dynamics");
2095 onlydynamics.Type = EActorAttributeType::Bool;
2096 onlydynamics.RecommendedValues = {TEXT("false")};
2097 onlydynamics.bRestrictToRecommended = false;
2098 // Debug Line Trace
2099 FActorVariation debuglinetrace;
2100 debuglinetrace.Id = TEXT("debug_linetrace");
2101 debuglinetrace.Type = EActorAttributeType::Bool;
2102 debuglinetrace.RecommendedValues = {TEXT("false")};
2103 debuglinetrace.bRestrictToRecommended = false;
2104
2105 Definition.Variations.Append({distance,
2106 hitradius,
2107 onlydynamics,
2108 debuglinetrace});
2109}
2110/// ============================================================================
2111/// -- Helpers to retrieve attribute values ------------------------------------
2112/// ============================================================================
2113
2115 const FActorAttribute &ActorAttribute,
2116 bool Default)
2117{
2118 if (ActorAttribute.Type != EActorAttributeType::Bool)
2119 {
2120 UE_LOG(LogCarla, Error, TEXT("ActorAttribute '%s' is not a bool"), *ActorAttribute.Id);
2121 return Default;
2122 }
2123 return ActorAttribute.Value.ToBool();
2124}
2125
2127 const FActorAttribute &ActorAttribute,
2128 int32 Default)
2129{
2130 if (ActorAttribute.Type != EActorAttributeType::Int)
2131 {
2132 UE_LOG(LogCarla, Error, TEXT("ActorAttribute '%s' is not an int"), *ActorAttribute.Id);
2133 return Default;
2134 }
2135 return FCString::Atoi(*ActorAttribute.Value);
2136}
2137
2139 const FActorAttribute &ActorAttribute,
2140 float Default)
2141{
2142 if (ActorAttribute.Type != EActorAttributeType::Float)
2143 {
2144 UE_LOG(LogCarla, Error, TEXT("ActorAttribute '%s' is not a float"), *ActorAttribute.Id);
2145 return Default;
2146 }
2147 return FCString::Atof(*ActorAttribute.Value);
2148}
2149
2151 const FActorAttribute &ActorAttribute,
2152 const FString &Default)
2153{
2154 if (ActorAttribute.Type != EActorAttributeType::String)
2155 {
2156 UE_LOG(LogCarla, Error, TEXT("ActorAttribute '%s' is not a string"), *ActorAttribute.Id);
2157 return Default;
2158 }
2159 return ActorAttribute.Value;
2160}
2161
2163 const FActorAttribute &ActorAttribute,
2164 const FColor &Default)
2165{
2166 if (ActorAttribute.Type != EActorAttributeType::RGBColor)
2167 {
2168 UE_LOG(LogCarla, Error, TEXT("ActorAttribute '%s' is not a color"), *ActorAttribute.Id);
2169 return Default;
2170 }
2171 TArray<FString> Channels;
2172 ActorAttribute.Value.ParseIntoArray(Channels, TEXT(","), false);
2173 if (Channels.Num() != 3)
2174 {
2175 UE_LOG(LogCarla,
2176 Error,
2177 TEXT("ActorAttribute '%s': invalid color '%s'"),
2178 *ActorAttribute.Id,
2179 *ActorAttribute.Value);
2180 return Default;
2181 }
2182 TArray<uint8> Colors;
2183 for (auto &Str : Channels)
2184 {
2185 auto Val = FCString::Atoi(*Str);
2186 if ((Val < 0) || (Val > std::numeric_limits<uint8>::max()))
2187 {
2188 UE_LOG(LogCarla,
2189 Error,
2190 TEXT("ActorAttribute '%s': invalid color '%s'"),
2191 *ActorAttribute.Id,
2192 *ActorAttribute.Value);
2193 return Default;
2194 }
2195 Colors.Add(Val);
2196 }
2197 FColor Color;
2198 Color.R = Colors[0u];
2199 Color.G = Colors[1u];
2200 Color.B = Colors[2u];
2201 Color.A = 255u;
2202 return Color;
2203}
2204
2206 const FActorAttribute &ActorAttribute,
2207 const FVector &Default)
2208{
2209 if (ActorAttribute.Type != EActorAttributeType::Vector)
2210 {
2211 UE_LOG(LogCarla, Error, TEXT("ActorAttribute '%s' is not a vector"), *ActorAttribute.Id);
2212 return Default;
2213 }
2214 TArray<FString> Values;
2215 ActorAttribute.Value.ParseIntoArray(Values, TEXT(","), false);
2216 if (Values.Num() != 3)
2217 {
2218 UE_LOG(LogCarla,
2219 Error,
2220 TEXT("ActorAttribute '%s': invalid vector '%s' must contain 3 values separated with comma"),
2221 *ActorAttribute.Id,
2222 *ActorAttribute.Value);
2223 return Default;
2224 }
2225
2226 FVector NewVector;
2227 NewVector.X = FCString::Atof(*(Values[0]));
2228 NewVector.Y = FCString::Atof(*(Values[1]));
2229 NewVector.Z = FCString::Atof(*(Values[2]));
2230 return NewVector;
2231}
2232
2234 const FString &Id,
2235 const TMap<FString, FActorAttribute> &Attributes,
2236 bool Default)
2237{
2238 return Attributes.Contains(Id) ? ActorAttributeToBool(Attributes[Id], Default) : Default;
2239}
2240
2242 const FString &Id,
2243 const TMap<FString, FActorAttribute> &Attributes,
2244 int32 Default)
2245{
2246 return Attributes.Contains(Id) ? ActorAttributeToInt(Attributes[Id], Default) : Default;
2247}
2248
2250 const FString &Id,
2251 const TMap<FString, FActorAttribute> &Attributes,
2252 float Default)
2253{
2254 return Attributes.Contains(Id) ? ActorAttributeToFloat(Attributes[Id], Default) : Default;
2255}
2256
2258 const FString &Id,
2259 const TMap<FString, FActorAttribute> &Attributes,
2260 const FString &Default)
2261{
2262 return Attributes.Contains(Id) ? ActorAttributeToString(Attributes[Id], Default) : Default;
2263}
2264
2266 const FString &Id,
2267 const TMap<FString, FActorAttribute> &Attributes,
2268 const FColor &Default)
2269{
2270 return Attributes.Contains(Id) ? ActorAttributeToColor(Attributes[Id], Default) : Default;
2271}
2272
2274 const FString &Id,
2275 const TMap<FString, FActorAttribute> &Attributes,
2276 const FVector &Default)
2277{
2278 return Attributes.Contains(Id) ? ActorAttributeToVector(Attributes[Id], Default) : Default;
2279}
2280
2281/// ============================================================================
2282/// -- Helpers to set Actors ---------------------------------------------------
2283/// ============================================================================
2284
2285// Here we do different checks when we are in editor because we don't want the
2286// editor crashing while people are testing new actor definitions.
2287#if WITH_EDITOR
2288#define CARLA_ABFL_CHECK_ACTOR(ActorPtr) \
2289 if (!IsValid(ActorPtr)) \
2290 { \
2291 UE_LOG(LogCarla, Error, TEXT("Cannot set empty actor!")); \
2292 return; \
2293 }
2294#else
2295#define CARLA_ABFL_CHECK_ACTOR(ActorPtr) \
2296 IsValid(ActorPtr);
2297#endif // WITH_EDITOR
2298
2300 const FActorDescription &Description,
2301 ASceneCaptureSensor *Camera)
2302{
2303 CARLA_ABFL_CHECK_ACTOR(Camera);
2304 Camera->SetImageSize(
2305 RetrieveActorAttributeToInt("image_size_x", Description.Variations, 800),
2306 RetrieveActorAttributeToInt("image_size_y", Description.Variations, 600));
2307 Camera->SetFOVAngle(
2308 RetrieveActorAttributeToFloat("fov", Description.Variations, 90.0f));
2309 if (Description.Variations.Contains("use_ray_tracing"))
2310 {
2311 Camera->SetUseRayTracing(
2313 Description.Variations["use_ray_tracing"],
2314 true));
2315 }
2316 if (Description.Variations.Contains("enable_dlss"))
2317 {
2318 Camera->SetDLSSUpscale(
2319 ActorAttributeToBool(Description.Variations["enable_dlss"], false),
2320 RetrieveActorAttributeToFloat("dlss_screen_percentage", Description.Variations, 50.0f));
2321 }
2322 if (Description.Variations.Contains("enable_postprocess_effects"))
2323 {
2326 Description.Variations["enable_postprocess_effects"],
2327 true));
2328
2329 FString PostProcessProfileName = RetrieveActorAttributeToString(
2330 "post_process_profile",
2331 Description.Variations,
2332 TEXT(""));
2333
2334 // Post-process profiles are camera presets (AutomotiveHDR, GoPro, ...),
2335 // not per-map looks. Empty or "Default" means no preference: the sensor
2336 // default (carla.PostProcess.Profile).
2337 PostProcessProfileName = UPostProcessJsonUtils::ResolveProfileName(PostProcessProfileName);
2338
2340 Camera->GetCaptureComponent(),
2341 PostProcessProfileName);
2342 }
2343 SetShowOnlyFromDescription(Description, Camera);
2344}
2345
2347 const FActorDescription &Description,
2348 AShaderBasedSensor *Camera)
2349{
2350 CARLA_ABFL_CHECK_ACTOR(Camera);
2351 Camera->SetFloatShaderParameter(0, TEXT("CircleFalloff_NState"),
2352 RetrieveActorAttributeToFloat("lens_circle_falloff", Description.Variations, 5.0f));
2353 Camera->SetFloatShaderParameter(0, TEXT("CircleMultiplier_NState"),
2354 RetrieveActorAttributeToFloat("lens_circle_multiplier", Description.Variations, 0.0f));
2355 Camera->SetFloatShaderParameter(0, TEXT("K_NState"),
2356 RetrieveActorAttributeToFloat("lens_k", Description.Variations, -1.0f));
2357 Camera->SetFloatShaderParameter(0, TEXT("kcube"),
2358 RetrieveActorAttributeToFloat("lens_kcube", Description.Variations, 0.0f));
2359 Camera->SetFloatShaderParameter(0, TEXT("XSize_NState"),
2360 RetrieveActorAttributeToFloat("lens_x_size", Description.Variations, 0.08f));
2361 Camera->SetFloatShaderParameter(0, TEXT("YSize_NState"),
2362 RetrieveActorAttributeToFloat("lens_y_size", Description.Variations, 0.08f));
2363}
2364
2366 const FActorDescription &Desc,
2368{
2369 CARLA_ABFL_CHECK_ACTOR(Camera);
2370
2371 const auto &Variations = Desc.Variations;
2372
2373 auto CameraModelName = RetrieveActorAttributeToString(
2374 "camera_model", Variations, "perspective");
2375
2376 // rt_lens spells it with an underscore; accept both.
2377 if (CameraModelName == TEXT("kannala_brandt"))
2378 CameraModelName = TEXT("kannala-brandt");
2379
2380 static const FString Lookup[] =
2381 {
2382 TEXT("perspective"),
2383 TEXT("stereographic"),
2384 TEXT("equidistant"),
2385 TEXT("equisolid"),
2386 TEXT("orthographic"),
2387 TEXT("kannala-brandt"),
2388 TEXT("brown_conrady"),
2389 TEXT("lut"),
2390 TEXT("ftheta")
2391 };
2392
2393 using I = std::underlying_type_t<ECameraModel>;
2394
2395 static_assert(
2396 sizeof(Lookup) / sizeof(Lookup[0]) == (I)ECameraModel::MaxEnum,
2397 "CameraModel string lookup size mismatch.");
2398
2399 I CameraModelID = 0;
2400
2401 while (CameraModelID < (I)ECameraModel::MaxEnum && CameraModelName != Lookup[CameraModelID])
2402 ++CameraModelID;
2403
2404 auto CameraModel =
2405 CameraModelID != (I)ECameraModel::MaxEnum ?
2406 (ECameraModel)CameraModelID :
2408 if (CameraModel == ECameraModel::FTheta)
2409 {
2410 // The cube-map family is deprecated and has no f-theta resampler; use sensor.camera.rt_lens.
2411 UE_LOG(LogCarla, Warning, TEXT("camera_model=ftheta is only supported by sensor.camera.rt_lens; rendering perspective."));
2412 CameraModel = ECameraModel::Default;
2413 }
2414
2415 Camera->SetImageSize(
2416 RetrieveActorAttributeToInt("image_size_x", Variations, 800),
2417 RetrieveActorAttributeToInt("image_size_y", Variations, 600));
2418
2419 Camera->SetFaceSize(RetrieveActorAttributeToInt("face_size", Variations, 0));
2420
2421 Camera->SetCameraModel(CameraModel);
2422
2423 if (CameraModel == ECameraModel::KannalaBrandt)
2424 {
2425 const float Coefficients[] =
2426 {
2427 RetrieveActorAttributeToFloat("k0", Variations, 0.08309221636708493f),
2428 RetrieveActorAttributeToFloat("k1", Variations, 0.01112126630599195f),
2429 RetrieveActorAttributeToFloat("k2", Variations, 0.008587261043925865f),
2430 RetrieveActorAttributeToFloat("k3", Variations, 0.0008542188930970716f)
2431 };
2432
2433 Camera->SetCameraCoefficients(
2434 TArrayView<const float>(Coefficients, 4));
2435 }
2436
2437 // Explicit calibration (shared attribute set with sensor.camera.rt_lens).
2438 {
2439 float Fx = RetrieveActorAttributeToFloat("fx", Variations, 0.0f);
2440 const float Fy = RetrieveActorAttributeToFloat("fy", Variations, 0.0f);
2441 const float Cx = RetrieveActorAttributeToFloat("cx", Variations, 0.5f);
2442 const float Cy = RetrieveActorAttributeToFloat("cy", Variations, 0.5f);
2443
2444 if (CameraModel == ECameraModel::LUT1D)
2445 {
2446 TArray<float> Samples;
2447 {
2448 TArray<FString> Parts;
2449 RetrieveActorAttributeToString("lut", Variations, TEXT(""))
2450 .ParseIntoArray(Parts, TEXT(","), true);
2451 Samples.Reserve(Parts.Num());
2452 for (const auto &Part : Parts)
2453 Samples.Add(FCString::Atof(*Part));
2454 }
2455 const float ThetaMaxDeg = RetrieveActorAttributeToFloat("theta_max_deg", Variations, 0.0f);
2456 if (Samples.Num() < 2 || ThetaMaxDeg <= 0.0f)
2457 {
2458 UE_LOG(LogCarla, Warning,
2459 TEXT("%s: camera_model=lut needs a 'lut' with at least two samples and theta_max_deg > 0 (got %d samples, %.2f deg)."),
2460 *Camera->GetName(), Samples.Num(), ThetaMaxDeg);
2461 }
2462 if (Fx <= 0.0f)
2463 {
2464 UE_LOG(LogCarla, Warning,
2465 TEXT("%s: camera_model=lut needs an explicit fx; using fx=1 (lut samples in units of the image width)."),
2466 *Camera->GetName());
2467 Fx = 1.0f;
2468 }
2469 Camera->SetLensLUT(Samples, FMath::DegreesToRadians(ThetaMaxDeg));
2470 }
2471
2472 Camera->SetLensIntrinsics(Fx, Fy, Cx, Cy);
2473 }
2474
2475 const auto FOV = RetrieveActorAttributeToFloat("fov", Variations, 90.0f);
2476 const auto FocalLength = RetrieveActorAttributeToFloat("focal_length", Variations, 0.0f);
2477
2478 if (FOV != 0.0f)
2479 Camera->SetFOVAngle(FOV);
2480
2481 if (FocalLength != 0.0f)
2482 Camera->SetFocalLength(FocalLength);
2483
2484 Camera->SetRenderPerspective(RetrieveActorAttributeToBool("perspective", Variations, false));
2485 Camera->SetRenderEquirectangular(RetrieveActorAttributeToBool("equirectangular", Variations, false));
2486 Camera->SetFOVMaskEnable(RetrieveActorAttributeToBool("fov_mask", Variations, false));
2487
2488 if (Camera->GetRenderEquirectangular())
2490 RetrieveActorAttributeToFloat("longitude_offset", Variations, 0.0f));
2491
2492 if (Camera->GetFOVMaskEnable())
2493 Camera->SetFOVFadeSize(RetrieveActorAttributeToFloat("fov_fade_size", Variations, 0.0f));
2494
2495 // Apply the post-processing attributes only when advertised (the RGB
2496 // fisheye camera adds them); leaving them untouched preserves the
2497 // post-processing state each derived sensor sets in its constructor.
2498 if (Variations.Contains("enable_postprocess_effects"))
2499 {
2501 ActorAttributeToBool(Variations["enable_postprocess_effects"], true));
2502
2503 // Load the same lens preset as the pinhole cameras into every cube face.
2504 // Without it the faces keep the constructor's bare manual exposure at
2505 // Unreal's default ISO / shutter / f-stop, which saturates under CARLA's
2506 // photometric sun as soon as r.EyeAdaptation.MethodOverride forces manual.
2507 FString PostProcessProfileName = RetrieveActorAttributeToString(
2508 "post_process_profile", Variations, TEXT(""));
2509 PostProcessProfileName = UPostProcessJsonUtils::ResolveProfileName(PostProcessProfileName);
2510 for (auto *Face : Camera->GetCaptureComponents2D())
2512 Face, PostProcessProfileName);
2513 }
2514
2515 if (Variations.Contains("gamma"))
2516 Camera->SetTargetGamma(
2517 RetrieveActorAttributeToFloat("gamma", Variations, 2.2f));
2518
2519 SetShowOnlyFromDescription(Desc, Camera);
2520}
2521
2523 const FActorDescription &Description,
2525{
2526 CARLA_ABFL_CHECK_ACTOR(Camera);
2527 Camera->SetFloatShaderParameter(0, TEXT("CircleFalloff_NState"),
2528 RetrieveActorAttributeToFloat("lens_circle_falloff", Description.Variations, 5.0f));
2529 Camera->SetFloatShaderParameter(0, TEXT("CircleMultiplier_NState"),
2530 RetrieveActorAttributeToFloat("lens_circle_multiplier", Description.Variations, 0.0f));
2531 Camera->SetFloatShaderParameter(0, TEXT("K_NState"),
2532 RetrieveActorAttributeToFloat("lens_k", Description.Variations, -1.0f));
2533 Camera->SetFloatShaderParameter(0, TEXT("kcube"),
2534 RetrieveActorAttributeToFloat("lens_kcube", Description.Variations, 0.0f));
2535 Camera->SetFloatShaderParameter(0, TEXT("XSize_NState"),
2536 RetrieveActorAttributeToFloat("lens_x_size", Description.Variations, 0.08f));
2537 Camera->SetFloatShaderParameter(0, TEXT("YSize_NState"),
2538 RetrieveActorAttributeToFloat("lens_y_size", Description.Variations, 0.08f));
2539}
2540
2542 const FActorDescription &Description,
2543 FLidarDescription &Lidar)
2544{
2545 constexpr float TO_CENTIMETERS = 1e2;
2546 Lidar.Channels =
2547 RetrieveActorAttributeToInt("channels", Description.Variations, Lidar.Channels);
2548 Lidar.Range =
2549 RetrieveActorAttributeToFloat("range", Description.Variations, 10.0f) * TO_CENTIMETERS;
2550 Lidar.PointsPerSecond =
2551 RetrieveActorAttributeToInt("points_per_second", Description.Variations, Lidar.PointsPerSecond);
2552 Lidar.RotationFrequency =
2553 RetrieveActorAttributeToFloat("rotation_frequency", Description.Variations, Lidar.RotationFrequency);
2554 Lidar.UpperFovLimit =
2555 RetrieveActorAttributeToFloat("upper_fov", Description.Variations, Lidar.UpperFovLimit);
2556 Lidar.LowerFovLimit =
2557 RetrieveActorAttributeToFloat("lower_fov", Description.Variations, Lidar.LowerFovLimit);
2558 Lidar.HorizontalFov =
2559 RetrieveActorAttributeToFloat("horizontal_fov", Description.Variations, Lidar.HorizontalFov);
2560 Lidar.AtmospAttenRate =
2561 RetrieveActorAttributeToFloat("atmosphere_attenuation_rate", Description.Variations, Lidar.AtmospAttenRate);
2562 Lidar.RandomSeed =
2563 RetrieveActorAttributeToInt("noise_seed", Description.Variations, Lidar.RandomSeed);
2564 Lidar.DropOffGenRate =
2565 RetrieveActorAttributeToFloat("dropoff_general_rate", Description.Variations, Lidar.DropOffGenRate);
2566 Lidar.DropOffIntensityLimit =
2567 RetrieveActorAttributeToFloat("dropoff_intensity_limit", Description.Variations, Lidar.DropOffIntensityLimit);
2569 RetrieveActorAttributeToFloat("dropoff_zero_intensity", Description.Variations, Lidar.DropOffAtZeroIntensity);
2570 Lidar.NoiseStdDev =
2571 RetrieveActorAttributeToFloat("noise_stddev", Description.Variations, Lidar.NoiseStdDev);
2572 Lidar.HorizontalResolution =
2573 RetrieveActorAttributeToFloat("horizontal_resolution", Description.Variations, Lidar.HorizontalResolution);
2574}
2575
2577 const FActorDescription &Description,
2578 AGnssSensor *Gnss)
2579{
2581 if (Description.Variations.Contains("noise_seed"))
2582 {
2583 Gnss->SetSeed(
2584 RetrieveActorAttributeToInt("noise_seed", Description.Variations, 0));
2585 }
2586 else
2587 {
2588 Gnss->SetSeed(Gnss->GetRandomEngine()->GenerateRandomSeed());
2589 }
2590
2592 RetrieveActorAttributeToFloat("noise_lat_stddev", Description.Variations, 0.0f));
2594 RetrieveActorAttributeToFloat("noise_lon_stddev", Description.Variations, 0.0f));
2596 RetrieveActorAttributeToFloat("noise_alt_stddev", Description.Variations, 0.0f));
2597 Gnss->SetLatitudeBias(
2598 RetrieveActorAttributeToFloat("noise_lat_bias", Description.Variations, 0.0f));
2599 Gnss->SetLongitudeBias(
2600 RetrieveActorAttributeToFloat("noise_lon_bias", Description.Variations, 0.0f));
2601 Gnss->SetAltitudeBias(
2602 RetrieveActorAttributeToFloat("noise_alt_bias", Description.Variations, 0.0f));
2603}
2604
2606 const FActorDescription &Description,
2607 AAutowareGnssSensor *Gnss)
2608{
2610 if (Description.Variations.Contains("noise_seed"))
2611 {
2612 Gnss->SetSeed(
2613 RetrieveActorAttributeToInt("noise_seed", Description.Variations, 0));
2614 }
2615 else
2616 {
2617 Gnss->SetSeed(Gnss->GetRandomEngine()->GenerateRandomSeed());
2618 }
2619
2621 RetrieveActorAttributeToFloat("noise_lat_stddev", Description.Variations, 0.0f));
2623 RetrieveActorAttributeToFloat("noise_lon_stddev", Description.Variations, 0.0f));
2625 RetrieveActorAttributeToFloat("noise_alt_stddev", Description.Variations, 0.0f));
2626 Gnss->SetLatitudeBias(
2627 RetrieveActorAttributeToFloat("noise_lat_bias", Description.Variations, 0.0f));
2628 Gnss->SetLongitudeBias(
2629 RetrieveActorAttributeToFloat("noise_lon_bias", Description.Variations, 0.0f));
2630 Gnss->SetAltitudeBias(
2631 RetrieveActorAttributeToFloat("noise_alt_bias", Description.Variations, 0.0f));
2632}
2633
2635 const FActorDescription &Description,
2637{
2639 if (Description.Variations.Contains("noise_seed"))
2640 {
2641 IMU->SetSeed(
2642 RetrieveActorAttributeToInt("noise_seed", Description.Variations, 0));
2643 }
2644 else
2645 {
2647 }
2648
2649 IMU->SetAccelerationStandardDeviation({RetrieveActorAttributeToFloat("noise_accel_stddev_x", Description.Variations, 0.0f),
2650 RetrieveActorAttributeToFloat("noise_accel_stddev_y", Description.Variations, 0.0f),
2651 RetrieveActorAttributeToFloat("noise_accel_stddev_z", Description.Variations, 0.0f)});
2652
2653 IMU->SetGyroscopeStandardDeviation({RetrieveActorAttributeToFloat("noise_gyro_stddev_x", Description.Variations, 0.0f),
2654 RetrieveActorAttributeToFloat("noise_gyro_stddev_y", Description.Variations, 0.0f),
2655 RetrieveActorAttributeToFloat("noise_gyro_stddev_z", Description.Variations, 0.0f)});
2656
2657 IMU->SetGyroscopeBias({RetrieveActorAttributeToFloat("noise_gyro_bias_x", Description.Variations, 0.0f),
2658 RetrieveActorAttributeToFloat("noise_gyro_bias_y", Description.Variations, 0.0f),
2659 RetrieveActorAttributeToFloat("noise_gyro_bias_z", Description.Variations, 0.0f)});
2660}
2661
2663 const FActorDescription &Description,
2664 ARadar *Radar)
2665{
2667 constexpr float TO_CENTIMETERS = 1e2;
2668
2669 if (Description.Variations.Contains("noise_seed"))
2670 {
2671 Radar->SetSeed(
2672 RetrieveActorAttributeToInt("noise_seed", Description.Variations, 0));
2673 }
2674 else
2675 {
2676 Radar->SetSeed(Radar->GetRandomEngine()->GenerateRandomSeed());
2677 }
2678
2679 Radar->SetHorizontalFOV(
2680 RetrieveActorAttributeToFloat("horizontal_fov", Description.Variations, 30.0f));
2681 Radar->SetVerticalFOV(
2682 RetrieveActorAttributeToFloat("vertical_fov", Description.Variations, 30.0f));
2683 Radar->SetRange(
2684 RetrieveActorAttributeToFloat("range", Description.Variations, 100.0f) * TO_CENTIMETERS);
2685 Radar->SetPointsPerSecond(
2686 RetrieveActorAttributeToInt("points_per_second", Description.Variations, 1500));
2687}
2688
2689// ===========================================================================
2690// -- V2X sensors ------------------------------------------------------------
2691// ===========================================================================
2692
2694{
2695 FActorDefinition Definition;
2696 bool Success;
2697 MakeV2XDefinition(Success, Definition);
2698 check(Success);
2699 return Definition;
2700}
2701
2703 bool &Success,
2704 FActorDefinition &Definition)
2705{
2706 FillIdAndTags(Definition, TEXT("sensor"), TEXT("other"), TEXT("v2x"));
2707 AddVariationsForSensor(Definition);
2708
2709 // - Channel id --------------------------------
2710 FActorVariation ChannelId;
2711 ChannelId.Id = TEXT("channel_id");
2713 ChannelId.RecommendedValues = { TEXT("Default") };
2714 ChannelId.bRestrictToRecommended = false;
2715
2716 // - Noise seed --------------------------------
2717 FActorVariation NoiseSeed;
2718 NoiseSeed.Id = TEXT("noise_seed");
2719 NoiseSeed.Type = EActorAttributeType::Int;
2720 NoiseSeed.RecommendedValues = { TEXT("0") };
2721 NoiseSeed.bRestrictToRecommended = false;
2722
2723 //Frequency
2724 FActorVariation Frequency;
2725 Frequency.Id = TEXT("frequency_ghz");
2726 Frequency.Type = EActorAttributeType::Float;
2727 Frequency.RecommendedValues = { TEXT("5.9")};
2728
2729 //TransmitPower
2730 FActorVariation TransmitPower;
2731 TransmitPower.Id = TEXT("transmit_power");
2732 TransmitPower.Type = EActorAttributeType::Float;
2733 TransmitPower.RecommendedValues = { TEXT("21.5")};
2734
2735 //ReceiveSensitivity
2736 FActorVariation ReceiverSensitivity;
2737 ReceiverSensitivity.Id = TEXT("receiver_sensitivity");
2738 ReceiverSensitivity.Type = EActorAttributeType::Float;
2739 ReceiverSensitivity.RecommendedValues = { TEXT("-99.0")};
2740
2741 //Combined Antenna Gain in dBi
2742 FActorVariation CombinedAntennaGain;
2743 CombinedAntennaGain.Id = TEXT("combined_antenna_gain");
2744 CombinedAntennaGain.Type = EActorAttributeType::Float;
2745 CombinedAntennaGain.RecommendedValues = { TEXT("10.0")};
2746
2747 //Scenario
2748 FActorVariation Scenario;
2749 Scenario.Id = TEXT("scenario");
2751 Scenario.RecommendedValues = { TEXT("highway"), TEXT("rural"), TEXT("urban")};
2752 Scenario.bRestrictToRecommended = true;
2753
2754 //Path loss exponent
2755 FActorVariation PLE;
2756 PLE.Id = TEXT("path_loss_exponent");
2758 PLE.RecommendedValues = { TEXT("2.7")};
2759
2760
2761 //FSPL reference distance for LDPL calculation
2762 FActorVariation FSPL_RefDistance;
2763 FSPL_RefDistance.Id = TEXT("d_ref");
2764 FSPL_RefDistance.Type = EActorAttributeType::Float;
2765 FSPL_RefDistance.RecommendedValues = { TEXT("1.0")};
2766
2767 //filter distance to speed up calculation
2768 FActorVariation FilterDistance;
2769 FilterDistance.Id = TEXT("filter_distance");
2770 FilterDistance.Type = EActorAttributeType::Float;
2771 FilterDistance.RecommendedValues = { TEXT("500.0")};
2772
2773 //etsi fading
2774 FActorVariation EtsiFading;
2775 EtsiFading.Id = TEXT("use_etsi_fading");
2776 EtsiFading.Type = EActorAttributeType::Bool;
2777 EtsiFading.RecommendedValues = { TEXT("true")};
2778
2779 //custom fading std deviation
2780 FActorVariation CustomFadingStddev;
2781 CustomFadingStddev.Id = TEXT("custom_fading_stddev");
2782 CustomFadingStddev.Type = EActorAttributeType::Float;
2783 CustomFadingStddev.RecommendedValues = { TEXT("0.0")};
2784
2785 // Min Cam Generation
2786 FActorVariation GenCamMin;
2787 GenCamMin.Id = TEXT("gen_cam_min");
2788 GenCamMin.Type = EActorAttributeType::Float;
2789 GenCamMin.RecommendedValues = { TEXT("0.1")};
2790
2791 // Max Cam Generation
2792 FActorVariation GenCamMax;
2793 GenCamMax.Id = TEXT("gen_cam_max");
2794 GenCamMax.Type = EActorAttributeType::Float;
2795 GenCamMax.RecommendedValues = { TEXT("1.0")};
2796
2797 //Fixed Rate
2798 FActorVariation FixedRate;
2799 FixedRate.Id = TEXT("fixed_rate");
2800 FixedRate.Type = EActorAttributeType::Bool;
2801 FixedRate.RecommendedValues = { TEXT("false")};
2802
2803 //path loss model
2804 FActorVariation PLModel;
2805 PLModel.Id = TEXT("path_loss_model");
2807 PLModel.RecommendedValues = { TEXT("winner"), TEXT("geometric")};
2808 PLModel.bRestrictToRecommended = true;
2809
2810 //V2x Sensor sends GNSS position in CAM messages
2811 // - Latitude ----------------------------------
2812 FActorVariation StdDevLat;
2813 StdDevLat.Id = TEXT("noise_lat_stddev");
2814 StdDevLat.Type = EActorAttributeType::Float;
2815 StdDevLat.RecommendedValues = { TEXT("0.0") };
2816 StdDevLat.bRestrictToRecommended = false;
2817 FActorVariation BiasLat;
2818 BiasLat.Id = TEXT("noise_lat_bias");
2820 BiasLat.RecommendedValues = { TEXT("0.0") };
2821 BiasLat.bRestrictToRecommended = false;
2822
2823 // - Longitude ---------------------------------
2824 FActorVariation StdDevLong;
2825 StdDevLong.Id = TEXT("noise_lon_stddev");
2826 StdDevLong.Type = EActorAttributeType::Float;
2827 StdDevLong.RecommendedValues = { TEXT("0.0") };
2828 StdDevLong.bRestrictToRecommended = false;
2829 FActorVariation BiasLong;
2830 BiasLong.Id = TEXT("noise_lon_bias");
2832 BiasLong.RecommendedValues = { TEXT("0.0") };
2833 BiasLong.bRestrictToRecommended = false;
2834
2835 // - Altitude ----------------------------------
2836 FActorVariation StdDevAlt;
2837 StdDevAlt.Id = TEXT("noise_alt_stddev");
2838 StdDevAlt.Type = EActorAttributeType::Float;
2839 StdDevAlt.RecommendedValues = { TEXT("0.0") };
2840 StdDevAlt.bRestrictToRecommended = false;
2841 FActorVariation BiasAlt;
2842 BiasAlt.Id = TEXT("noise_alt_bias");
2844 BiasAlt.RecommendedValues = { TEXT("0.0") };
2845 BiasAlt.bRestrictToRecommended = false;
2846
2847 // - Heading ----------------------------------
2848 FActorVariation StdDevHeading;
2849 StdDevHeading.Id = TEXT("noise_head_stddev");
2850 StdDevHeading.Type = EActorAttributeType::Float;
2851 StdDevHeading.RecommendedValues = { TEXT("0.0") };
2852 StdDevHeading.bRestrictToRecommended = false;
2853 FActorVariation BiasHeading;
2854 BiasHeading.Id = TEXT("noise_head_bias");
2855 BiasHeading.Type = EActorAttributeType::Float;
2856 BiasHeading.RecommendedValues = { TEXT("0.0") };
2857 BiasHeading.bRestrictToRecommended = false;
2858
2859 //V2x Sensor sends acceleration in CAM messages
2860 // - Accelerometer Standard Deviation ----------
2861 // X Component
2862 FActorVariation StdDevAccelX;
2863 StdDevAccelX.Id = TEXT("noise_accel_stddev_x");
2864 StdDevAccelX.Type = EActorAttributeType::Float;
2865 StdDevAccelX.RecommendedValues = { TEXT("0.0") };
2866 StdDevAccelX.bRestrictToRecommended = false;
2867 // Y Component
2868 FActorVariation StdDevAccelY;
2869 StdDevAccelY.Id = TEXT("noise_accel_stddev_y");
2870 StdDevAccelY.Type = EActorAttributeType::Float;
2871 StdDevAccelY.RecommendedValues = { TEXT("0.0") };
2872 StdDevAccelY.bRestrictToRecommended = false;
2873 // Z Component
2874 FActorVariation StdDevAccelZ;
2875 StdDevAccelZ.Id = TEXT("noise_accel_stddev_z");
2876 StdDevAccelZ.Type = EActorAttributeType::Float;
2877 StdDevAccelZ.RecommendedValues = { TEXT("0.0") };
2878 StdDevAccelZ.bRestrictToRecommended = false;
2879
2880 // Yaw rate
2881 FActorVariation StdDevYawrate;
2882 StdDevYawrate.Id = TEXT("noise_yawrate_stddev");
2883 StdDevYawrate.Type = EActorAttributeType::Float;
2884 StdDevYawrate.RecommendedValues = { TEXT("0.0") };
2885 StdDevYawrate.bRestrictToRecommended = false;
2886 FActorVariation BiasYawrate;
2887 BiasYawrate.Id = TEXT("noise_yawrate_bias");
2888 BiasYawrate.Type = EActorAttributeType::Float;
2889 BiasYawrate.RecommendedValues = { TEXT("0.0") };
2890 BiasYawrate.bRestrictToRecommended = false;
2891
2892 //V2x Sensor sends speed in CAM messages
2893 // X Component
2894 FActorVariation StdDevVelX;
2895 StdDevVelX.Id = TEXT("noise_vel_stddev_x");
2896 StdDevVelX.Type = EActorAttributeType::Float;
2897 StdDevVelX.RecommendedValues = { TEXT("0.0") };
2898 StdDevVelX.bRestrictToRecommended = false;
2899
2900 Definition.Variations.Append({
2901 ChannelId,
2902 NoiseSeed,
2903 TransmitPower,
2904 ReceiverSensitivity,
2905 Frequency,
2906 CombinedAntennaGain,
2907 Scenario,
2908 PLModel,
2909 PLE,
2910 FSPL_RefDistance,
2911 FilterDistance,
2912 EtsiFading,
2913 CustomFadingStddev,
2914 GenCamMin,
2915 GenCamMax,
2916 FixedRate,
2917 StdDevLat,
2918 BiasLat,
2919 StdDevLong,
2920 BiasLong,
2921 StdDevAlt,
2922 BiasAlt,
2923 StdDevHeading,
2924 BiasHeading,
2925 StdDevAccelX,
2926 StdDevAccelY,
2927 StdDevAccelZ,
2928 StdDevYawrate,
2929 BiasYawrate,
2930 StdDevVelX});
2931 Success = CheckActorDefinition(Definition);
2932}
2933
2935{
2936 FActorDefinition Definition;
2937 bool Success;
2938 MakeCustomV2XDefinition(Success, Definition);
2939 check(Success);
2940 return Definition;
2941}
2942
2944 bool &Success,
2945 FActorDefinition &Definition)
2946{
2947 FillIdAndTags(Definition, TEXT("sensor"), TEXT("other"), TEXT("v2x_custom"));
2948 AddVariationsForSensor(Definition);
2949
2950 // - Channel id --------------------------------
2951 FActorVariation ChannelId;
2952 ChannelId.Id = TEXT("channel_id");
2954 ChannelId.RecommendedValues = { TEXT("Default") };
2955 ChannelId.bRestrictToRecommended = false;
2956
2957 // - Noise seed --------------------------------
2958 FActorVariation NoiseSeed;
2959 NoiseSeed.Id = TEXT("noise_seed");
2960 NoiseSeed.Type = EActorAttributeType::Int;
2961 NoiseSeed.RecommendedValues = { TEXT("0") };
2962 NoiseSeed.bRestrictToRecommended = false;
2963
2964 //TransmitPower
2965 FActorVariation TransmitPower;
2966 TransmitPower.Id = TEXT("transmit_power");
2967 TransmitPower.Type = EActorAttributeType::Float;
2968 TransmitPower.RecommendedValues = { TEXT("21.5")};
2969
2970 //ReceiveSensitivity
2971 FActorVariation ReceiverSensitivity;
2972 ReceiverSensitivity.Id = TEXT("receiver_sensitivity");
2973 ReceiverSensitivity.Type = EActorAttributeType::Float;
2974 ReceiverSensitivity.RecommendedValues = { TEXT("-99.0")};
2975
2976 //Frequency
2977 FActorVariation Frequency;
2978 Frequency.Id = TEXT("frequency_ghz");
2979 Frequency.Type = EActorAttributeType::Float;
2980 Frequency.RecommendedValues = { TEXT("5.9")};
2981
2982 //Combined Antenna Gain in dBi
2983 FActorVariation CombinedAntennaGain;
2984 CombinedAntennaGain.Id = TEXT("combined_antenna_gain");
2985 CombinedAntennaGain.Type = EActorAttributeType::Float;
2986 CombinedAntennaGain.RecommendedValues = { TEXT("10.0")};
2987
2988 //Scenario
2989 FActorVariation Scenario;
2990 Scenario.Id = TEXT("scenario");
2992 Scenario.RecommendedValues = { TEXT("highway"), TEXT("rural"), TEXT("urban")};
2993 Scenario.bRestrictToRecommended = true;
2994
2995 //Path loss exponent
2996 FActorVariation PLE;
2997 PLE.Id = TEXT("path_loss_exponent");
2999 PLE.RecommendedValues = { TEXT("2.7")};
3000
3001
3002 //FSPL reference distance for LDPL calculation
3003 FActorVariation FSPL_RefDistance;
3004 FSPL_RefDistance.Id = TEXT("d_ref");
3005 FSPL_RefDistance.Type = EActorAttributeType::Float;
3006 FSPL_RefDistance.RecommendedValues = { TEXT("1.0")};
3007
3008 //filter distance to speed up calculation
3009 FActorVariation FilterDistance;
3010 FilterDistance.Id = TEXT("filter_distance");
3011 FilterDistance.Type = EActorAttributeType::Float;
3012 FilterDistance.RecommendedValues = { TEXT("500.0")};
3013
3014 //etsi fading
3015 FActorVariation EtsiFading;
3016 EtsiFading.Id = TEXT("use_etsi_fading");
3017 EtsiFading.Type = EActorAttributeType::Bool;
3018 EtsiFading.RecommendedValues = { TEXT("true")};
3019
3020 //custom fading std deviation
3021 FActorVariation CustomFadingStddev;
3022 CustomFadingStddev.Id = TEXT("custom_fading_stddev");
3023 CustomFadingStddev.Type = EActorAttributeType::Float;
3024 CustomFadingStddev.RecommendedValues = { TEXT("0.0")};
3025
3026 //path loss model
3027 FActorVariation PLModel;
3028 PLModel.Id = TEXT("path_loss_model");
3030 PLModel.RecommendedValues = { TEXT("winner"), TEXT("geometric")};
3031 PLModel.bRestrictToRecommended = true;
3032
3033
3034 Definition.Variations.Append({
3035 ChannelId,
3036 NoiseSeed,
3037 TransmitPower,
3038 ReceiverSensitivity,
3039 Frequency,
3040 CombinedAntennaGain,
3041 Scenario,
3042 PLModel,
3043 PLE,
3044 FSPL_RefDistance,
3045 FilterDistance,
3046 EtsiFading,
3047 CustomFadingStddev
3048});
3049
3050 Success = CheckActorDefinition(Definition);
3051}
3052
3053
3055 const FActorDescription &Description,
3056 AV2XSensor* V2X)
3057{
3059 if (Description.Variations.Contains("noise_seed"))
3060 {
3061 V2X->SetSeed(
3062 RetrieveActorAttributeToInt("noise_seed", Description.Variations, 0));
3063 }
3064 else
3065 {
3067 }
3068
3070 RetrieveActorAttributeToFloat("transmit_power", Description.Variations, 21.5),
3071 RetrieveActorAttributeToFloat("receiver_sensitivity", Description.Variations, -99.0),
3072 RetrieveActorAttributeToFloat("frequency_ghz", Description.Variations, 5.9),
3073 RetrieveActorAttributeToFloat("combined_antenna_gain", Description.Variations, 10.0),
3074 RetrieveActorAttributeToFloat("path_loss_exponent", Description.Variations, 2.7),
3075 RetrieveActorAttributeToFloat("d_ref", Description.Variations, 1.0),
3076 RetrieveActorAttributeToFloat("filter_distance", Description.Variations, 500.0),
3077 RetrieveActorAttributeToBool("use_etsi_fading", Description.Variations, true),
3078 RetrieveActorAttributeToFloat("custom_fading_stddev", Description.Variations, 0.0f)
3079 );
3080
3081 if (RetrieveActorAttributeToString("scenario", Description.Variations, "urban") == "urban")
3082 {
3084 }
3085 else if (RetrieveActorAttributeToString("scenario", Description.Variations, "urban") == "rural")
3086 {
3088 }
3089 else
3090 {
3092 }
3093
3094 V2X->SetCaServiceParams(
3095 RetrieveActorAttributeToFloat("gen_cam_min", Description.Variations, 0.1),
3096 RetrieveActorAttributeToFloat("gen_cam_max", Description.Variations, 1.0),
3097 RetrieveActorAttributeToBool("fixed_rate", Description.Variations, false));
3098
3100 RetrieveActorAttributeToFloat("noise_accel_stddev_x", Description.Variations, 0.0f),
3101 RetrieveActorAttributeToFloat("noise_accel_stddev_y", Description.Variations, 0.0f),
3102 RetrieveActorAttributeToFloat("noise_accel_stddev_z", Description.Variations, 0.0f)});
3103
3104 V2X->SetGNSSDeviation(
3105 RetrieveActorAttributeToFloat("noise_lat_stddev", Description.Variations, 0.0f),
3106 RetrieveActorAttributeToFloat("noise_lon_stddev", Description.Variations, 0.0f),
3107 RetrieveActorAttributeToFloat("noise_alt_stddev", Description.Variations, 0.0f),
3108 RetrieveActorAttributeToFloat("noise_head_stddev", Description.Variations, 0.0f),
3109 RetrieveActorAttributeToFloat("noise_lat_bias", Description.Variations, 0.0f),
3110 RetrieveActorAttributeToFloat("noise_lon_bias", Description.Variations, 0.0f),
3111 RetrieveActorAttributeToFloat("noise_alt_bias", Description.Variations, 0.0f),
3112 RetrieveActorAttributeToFloat("noise_head_bias", Description.Variations, 0.0f));
3113
3114 V2X->SetVelDeviation(
3115 RetrieveActorAttributeToFloat("noise_vel_stddev_x", Description.Variations, 0.0f)
3116 );
3118 RetrieveActorAttributeToFloat("noise_yawrate_stddev", Description.Variations, 0.0f),
3119 RetrieveActorAttributeToFloat("noise_yawrate_bias", Description.Variations, 0.0f)
3120 );
3121
3122 if (RetrieveActorAttributeToString("path_loss_model", Description.Variations, "geometric") == "winner")
3123 {
3125 }
3126 else if(RetrieveActorAttributeToString("path_loss_model", Description.Variations, "geometric") == "geometric")
3127 {
3129 }
3130
3131
3132}
3133
3135 const FActorDescription &Description,
3136 ACustomV2XSensor* V2X)
3137{
3139 if (Description.Variations.Contains("noise_seed"))
3140 {
3141 V2X->SetSeed(
3142 RetrieveActorAttributeToInt("noise_seed", Description.Variations, 0));
3143 }
3144 else
3145 {
3147 }
3148
3150 RetrieveActorAttributeToFloat("transmit_power", Description.Variations, 21.5),
3151 RetrieveActorAttributeToFloat("receiver_sensitivity", Description.Variations, -99.0),
3152 RetrieveActorAttributeToFloat("frequency_ghz", Description.Variations, 5.9),
3153 RetrieveActorAttributeToFloat("combined_antenna_gain", Description.Variations, 10.0),
3154 RetrieveActorAttributeToFloat("path_loss_exponent", Description.Variations, 2.7),
3155 RetrieveActorAttributeToFloat("d_ref", Description.Variations, 1.0),
3156 RetrieveActorAttributeToFloat("filter_distance", Description.Variations, 500.0),
3157 RetrieveActorAttributeToBool("use_etsi_fading", Description.Variations, true),
3158 RetrieveActorAttributeToFloat("custom_fading_stddev", Description.Variations, 0.0f)
3159 );
3160
3161 if (RetrieveActorAttributeToString("scenario", Description.Variations, "urban") == "urban")
3162 {
3164 }
3165 else if (RetrieveActorAttributeToString("scenario", Description.Variations, "urban") == "rural")
3166 {
3168 }
3169 else
3170 {
3172 }
3173
3174
3175 if (RetrieveActorAttributeToString("path_loss_model", Description.Variations, "geometric") == "winner")
3176 {
3178 }
3179 else if(RetrieveActorAttributeToString("path_loss_model", Description.Variations, "geometric") == "geometric")
3180 {
3182 }
3183}
3184
3185#undef CARLA_ABFL_CHECK_ACTOR
static constexpr float DefaultKannalaBrandtCoefficients[]
static void AddVariationsForTrigger(FActorDefinition &Def)
static void FillIdAndTags(FActorDefinition &Def, TStrs &&...Strings)
============================================================================
static void SetShowOnlyFromDescription(const FActorDescription &Description, CameraT *Camera)
static void AddShowOnlyVariations(FActorDefinition &Definition)
Show-only render mode attributes shared by every scene-capture camera family (pinhole,...
static void AddRecommendedValuesForSensorRoleNames(FActorDefinition &Definition)
#define CARLA_ABFL_CHECK_ACTOR(ActorPtr)
============================================================================
static void AddRecommendedValuesForActorRoleName(FActorDefinition &Definition, TArray< FString > &&RecommendedValues)
static FString VectorToFString(const FVector &TextVector)
static void AddVariationsForSensor(FActorDefinition &Def)
static FString ColorToFString(const FColor &Color)
static void FillActorDefinitionArray(const TArray< T > &ParameterArray, TArray< FActorDefinition > &Definitions, Functor Maker)
static FString JoinStrings(const FString &Separator, ARGS &&...Args)
ECameraModel
float distance
#define DEBUG_ASSERT(predicate)
Definition Debug.h:66
@ Rural
@ Urban
@ Highway
@ Winner
@ Geometric
EPedestrianGender
EPropSize
EActorAttributeType
List of valid types for actor attributes.
Autoware GNSS sensor ("sensor.other.autoware_gnss"): streams GeoLocation to the client like the regul...
void SetAltitudeDeviation(float Value)
void SetLatitudeDeviation(float Value)
void SetLongitudeBias(float Value)
void SetLatitudeBias(float Value)
void SetLongitudeDeviation(float Value)
void SetAltitudeBias(float Value)
void SetPathLossModel(const EPathLossModel path_loss_model)
void SetPropagationParams(const float TransmitPower, const float ReceiverSensitivity, const float Frequency, const float combined_antenna_gain, const float path_loss_exponent, const float reference_distance_fspl, const float filter_distance, const bool use_etsi_fading, const float custom_fading_stddev)
void SetScenario(EScenario scenario)
Gnss sensor representation The actual position calculation is done one server side.
Definition GnssSensor.h:24
void SetLatitudeDeviation(float Value)
void SetLongitudeBias(float Value)
void SetLongitudeDeviation(float Value)
void SetAltitudeDeviation(float Value)
void SetAltitudeBias(float Value)
void SetLatitudeBias(float Value)
void SetGyroscopeBias(const FVector &Vec)
void SetAccelerationStandardDeviation(const FVector &Vec)
void SetGyroscopeStandardDeviation(const FVector &Vec)
A ray-cast based Radar sensor.
Definition Radar.h:21
void SetFaceSize(int32 Side)
Side length in pixels of the six cube-face render targets.
void SetCameraCoefficients(TArrayView< const float > Coefficients)
void SetLensLUT(const TArray< float > &Samples, float ThetaMaxRadians)
LUT1D camera model: R(Theta) samples, uniformly spaced over [0, ThetaMaxRadians], monotonically non-d...
TArrayView< USceneCaptureComponent2D_CARLA * > GetCaptureComponents2D()
void SetLensIntrinsics(float Fx, float Fy, float Cx, float Cy)
Explicit intrinsics in normalized viewport units, the same convention as sensor.camera....
Base class for sensors using a USceneCaptureComponent2D for rendering the scene.
void SetFOVAngle(float FOVAngle)
void SetImageSize(uint32 Width, uint32 Height)
USceneCaptureComponent2D_CARLA * GetCaptureComponent() const
void SetUseRayTracing(bool Enable)
void EnablePostProcessingEffects(bool Enable=true)
void SetDLSSUpscale(bool Enable, float ScreenPercentage)
Render the capture at ScreenPercentage (25-100) of the target resolution and upscale it back with DLS...
void SetSeed(int32 InSeed)
Definition Sensor.cpp:104
void SetFloatShaderParameter(uint8_t ShaderIndex, const FName &ParameterName, float Value)
A sensor that produces data by applying post-process materials (shaders) to a scene capture image.
void SetFloatShaderParameter(uint8_t ShaderIndex, const FName &ParameterName, float Value)
void SetPropagationParams(const float TransmitPower, const float ReceiverSensitivity, const float Frequency, const float combined_antenna_gain, const float path_loss_exponent, const float reference_distance_fspl, const float filter_distance, const bool use_etsi_fading, const float custom_fading_stddev)
Definition V2XSensor.cpp:84
void SetGNSSDeviation(const float noise_lat_stddev, const float noise_lon_stddev, const float noise_alt_stddev, const float noise_head_stddev, const float noise_lat_bias, const float noise_lon_bias, const float noise_alt_bias, const float noise_head_bias)
void SetAccelerationStandardDeviation(const FVector &Vec)
void SetPathLossModel(const EPathLossModel path_loss_model)
Definition V2XSensor.cpp:98
void SetScenario(EScenario scenario)
void SetYawrateDeviation(const float noise_yawrate_stddev, const float noise_yawrate_bias)
void SetCaServiceParams(const float GenCamMin, const float GenCamMax, const bool FixedRate)
Definition V2XSensor.cpp:78
void SetVelDeviation(const float noise_vel_stddev)
Checks validity of FActorDefinition.
bool IsValid(const FActorVariation &Variation)
FString GetDisplayId(const FString &Type, size_t Index, const T &Item)
bool SingleIsValid(const FActorDefinition &Definition)
Validate ActorDefinition and display messages on error.
bool IsValid(const EActorAttributeType Type)
bool AreValid(const FString &Type, const TArray< T > &Array)
Applies IsValid to each item in Array.
bool AreValid(const TArray< FActorDefinition > &ActorDefinitions)
Iterate all actor definitions and their properties and display messages on error.
bool ValueIsValid(const EActorAttributeType Type, const FString &Value)
bool IsValid(const FActorAttribute &Attribute)
bool ForEach(const FString &Type, const TArray< T > &Array, F Validator)
Applies Validator to each item in Array.
bool OnScreenAssert(bool Predicate, const T &Format, ARGS &&...Args) const
If Predicate is false, print an error message.
bool IsValid(const FActorDefinition &ActorDefinition)
FString GetDisplayId(const FString &Type, size_t Index, const FString &Item)
A stack to keep track of nested scopes.
Definition ScopedStack.h:14
auto PushScope(V &&Value)
Push this scope into the stack.
Definition ScopedStack.h:21
static FActorDefinition MakeWideAngleLensCameraDefinition(const FString &Id, bool bEnableModifyingPostProcessEffects=false)
static void MakePropDefinitions(const TArray< FPropParameters > &ParameterArray, TArray< FActorDefinition > &Definitions)
static bool ActorAttributeToBool(const FActorAttribute &ActorAttribute, bool Default)
============================================================================
static void MakeTriggerDefinition(const FString &Id, bool &Success, FActorDefinition &Definition)
static void SetGnss(const FActorDescription &Description, AGnssSensor *Gnss)
static void SetLidar(const FActorDescription &Description, FLidarDescription &Lidar)
static void SetRadar(const FActorDescription &Description, ARadar *Radar)
static int32 RetrieveActorAttributeToInt(const FString &Id, const TMap< FString, FActorAttribute > &Attributes, int32 Default)
static FVector ActorAttributeToVector(const FActorAttribute &ActorAttribute, const FVector &Default)
static float ActorAttributeToFloat(const FActorAttribute &ActorAttribute, float Default)
static FActorDefinition MakeLidarDefinition(const FString &Id)
static void MakeTriggerDefinitions(const TArray< FString > &ParameterArray, TArray< FActorDefinition > &Definitions)
static void MakeVehicleDefinition(const FVehicleParameters &Parameters, bool &Success, FActorDefinition &Definition)
static void SetV2X(const FActorDescription &Description, AV2XSensor *V2X)
static void MakePropDefinition(const FPropParameters &Parameters, bool &Success, FActorDefinition &Definition)
static FColor ActorAttributeToColor(const FActorAttribute &ActorAttribute, const FColor &Default)
static void SetCamera(const FActorDescription &Description, ASceneCaptureSensor *Camera)
static FActorDefinition MakeCameraDefinition(const FString &Id, bool bEnableModifyingPostProcessEffects=false)
static FActorDefinition MakeRayTracedLensCameraDefinition(const FString &Id, bool bEnableModifyingPostProcessEffects=false)
static FString RetrieveActorAttributeToString(const FString &Id, const TMap< FString, FActorAttribute > &Attributes, const FString &Default)
static FString ActorAttributeToString(const FActorAttribute &ActorAttribute, const FString &Default)
static FColor RetrieveActorAttributeToColor(const FString &Id, const TMap< FString, FActorAttribute > &Attributes, const FColor &Default)
static float RetrieveActorAttributeToFloat(const FString &Id, const TMap< FString, FActorAttribute > &Attributes, float Default)
static void MakeBlueprintDefinitions(const TArray< FBlueprintParameters > &ParameterArray, TArray< FActorDefinition > &Definitions)
static void SetAutowareGnss(const FActorDescription &Description, AAutowareGnssSensor *Gnss)
static void MakePedestrianDefinition(const FPedestrianParameters &Parameters, bool &Success, FActorDefinition &Definition)
static bool CheckActorDefinitions(const TArray< FActorDefinition > &ActorDefinitions)
Return whether the list of actor definitions is valid.
static FVector RetrieveActorAttributeToVector(const FString &Id, const TMap< FString, FActorAttribute > &Attributes, const FVector &Default)
static FActorDefinition MakeGenericSensorDefinition(const FString &Type, const FString &Id)
static void SetCustomV2X(const FActorDescription &Description, ACustomV2XSensor *V2X)
static int32 ActorAttributeToInt(const FActorAttribute &ActorAttribute, int32 Default)
static FActorDefinition MakeGenericDefinition(const FString &Category, const FString &Type, const FString &Id)
static void MakePedestrianDefinitions(const TArray< FPedestrianParameters > &ParameterArray, TArray< FActorDefinition > &Definitions)
static bool RetrieveActorAttributeToBool(const FString &Id, const TMap< FString, FActorAttribute > &Attributes, bool Default)
static void MakeBlueprintDefinition(const FBlueprintParameters &Parameters, bool &Success, FActorDefinition &Definition)
static bool CheckActorDefinition(const FActorDefinition &ActorDefinitions)
Return whether the actor definition is valid. Prints all the errors found.
static void MakeObstacleDetectorDefinitions(const FString &Type, const FString &Id, FActorDefinition &Definition)
static void SetIMU(const FActorDescription &Description, AInertialMeasurementUnit *IMU)
static void MakeVehicleDefinitions(const TArray< FVehicleParameters > &ParameterArray, TArray< FActorDefinition > &Definitions)
static FString ResolveProfileName(const FString &Requested)
static bool LoadAllPostProcessFromJsonToSceneCapture(USceneCaptureComponent2D *SensorCamera, const FString &FileName)
static int32 GenerateRandomSeed()
Generate a non-deterministic random seed.
An actor attribute, may be an intrinsic (non-modifiable) attribute of the actor or an user-defined ac...
A definition of a Carla Actor with all the variation and attributes.
TArray< FActorVariation > Variations
Variations represent variables the user can modify to generate variations of the actor.
TArray< FActorAttribute > Attributes
Attributes represent non-modifiable properties of the actor that might help the user identifying and ...
TSubclassOf< AActor > Class
Class of the actor to be spawned (Optional).
A description of a Carla Actor with all its variation.
TMap< FString, FActorAttribute > Variations
User selected variations of the actor.
float DropOffAtZeroIntensity
General drop off rate.
float HorizontalFov
Horizontal field of view.
int RandomSeed
Random seed for the noise/dropoff used by this sensor.
float LowerFovLimit
Lower laser angle, counts from horizontal, negative values means under horizontal line.
float Range
Measure distance in centimeters.
float DropOffGenRate
General drop off rate.
uint32 Channels
Number of lasers.
float DropOffIntensityLimit
General drop off rate.
uint32 PointsPerSecond
Points generated by all lasers per second.
float RotationFrequency
Lidar rotation frequency.
float AtmospAttenRate
Attenuation Rate in the atmosphere in m^-1.
float HorizontalResolution
Horizontal resolution of the lidar, in degrees.
float UpperFovLimit
Upper laser angle, counts from horizontal, positive values means above horizontal line.
TSoftClassPtr< ACharacter > Class
TSoftObjectPtr< UStaticMesh > Mesh
TArray< FColor > RecommendedColors
TArray< int32 > SupportedDrivers
List of IDs of the drivers (pedestrians) supported by this vehicle, leave empty if no driver is suppo...
FString BaseType
(OPTIONAL) Use for a base classification of vehicles (car / truck / van / bycicle / motorcycle).
FString ObjectType
(OPTIONAL) Use for custom classification of vehicles.
TSoftClassPtr< ACarlaWheeledVehicle > Class
FString SpecialType
(OPTIONAL) Use for a more in-depth classification of vehicles (electric / emergency / taxi ....