19 #define LIBCARLA_SENSOR_REGISTRY_WITH_SENSOR_INCLUDES 21 #undef LIBCARLA_SENSOR_REGISTRY_WITH_SENSOR_INCLUDES 23 #include <type_traits> 44 TArray<FActorDefinition> Definitions;
57 template<
typename T,
typename =
void>
65 template <
typename SensorType>
66 static typename std::enable_if<is_spawnable<SensorType>::value,
void>
::type 69 auto Def = SensorType::GetSensorDefinition();
71 Def.Class = SensorType::StaticClass();
72 Definitions.Emplace(Def);
75 template <
typename SensorType>
76 static typename std::enable_if<!is_spawnable<SensorType>::value,
void>
::type 79 template <
size_t Index>
83 using SensorType =
typename std::remove_pointer<SensorPtrType>::type;
84 AppendDefinitions<SensorType>(Definitions);
87 template <
size_t... Is>
89 TArray<FActorDefinition> &Definitions,
90 std::index_sequence<Is...>)
92 std::initializer_list<int> ({(AppendDefinitions<Is>(Definitions), 0)...});
109 auto *World = GetWorld();
110 if (World ==
nullptr)
112 UE_LOG(LogCarla, Error, TEXT(
"ASensorFactory: cannot spawn sensor into an empty world."));
117 if (GameInstance ==
nullptr)
119 UE_LOG(LogCarla, Error, TEXT(
"ASensorFactory: cannot spawn sensor, incompatible game instance."));
123 auto *Sensor = World->SpawnActorDeferred<
ASensor>(
128 ESpawnActorCollisionHandlingMethod::AlwaysSpawn);
129 if (Sensor ==
nullptr)
131 UE_LOG(LogCarla, Error, TEXT(
"ASensorFactory: spawn sensor failed."));
136 check(Episode !=
nullptr);
138 Sensor->SetEpisode(*Episode);
139 Sensor->Set(Description);
159 UGameplayStatics::FinishSpawningActor(Sensor, Transform);
static void AppendDefinitions(TArray< FActorDefinition > &Definitions, std::index_sequence< Is... >)
static constexpr size_t size()
CompositeSerializer< std::pair< ACollisionSensor *, s11n::CollisionEventSerializer >, std::pair< ADepthCamera *, s11n::ImageSerializer >, std::pair< ANormalsCamera *, s11n::NormalsImageSerializer >, std::pair< ADVSCamera *, s11n::DVSEventArraySerializer >, std::pair< AGnssSensor *, s11n::GnssSerializer >, std::pair< AInertialMeasurementUnit *, s11n::IMUSerializer >, std::pair< ALaneInvasionSensor *, s11n::NoopSerializer >, std::pair< AObstacleDetectionSensor *, s11n::ObstacleDetectionEventSerializer >, std::pair< AOpticalFlowCamera *, s11n::OpticalFlowImageSerializer >, std::pair< ARadar *, s11n::RadarSerializer >, std::pair< ARayCastSemanticLidar *, s11n::SemanticLidarSerializer >, std::pair< ARayCastLidar *, s11n::LidarSerializer >, std::pair< ARssSensor *, s11n::NoopSerializer >, std::pair< ASceneCaptureCamera *, s11n::ImageSerializer >, std::pair< ASemanticSegmentationCamera *, s11n::ImageSerializer >, std::pair< AInstanceSegmentationCamera *, s11n::ImageSerializer >, std::pair< FWorldObserver *, s11n::EpisodeStateSerializer >, std::pair< FCameraGBufferUint8 *, s11n::GBufferUint8Serializer >, std::pair< FCameraGBufferFloat *, s11n::GBufferFloatSerializer > > SensorRegistry
Contains a registry of all the sensors available and allows serializing and deserializing sensor data...
FDataStream OpenStream() const
Retrieve the definitions of all the sensors registered in the SensorRegistry by calling their static ...
The game instance contains elements that must be kept alive in between levels.
const FCarlaServer & GetServer() const
Compile-time map for mapping sensor objects to serializers.
static UCarlaGameInstance * GetGameInstance(const UObject *WorldContextObject)
static void AppendDefinitions(TArray< FActorDefinition > &Definitions)
FActorSpawnResult SpawnActor(const FTransform &SpawnAtTransform, const FActorDescription &ActorDescription) final
Spawn an actor based on ActorDescription and Transform.
static std::enable_if< is_spawnable< SensorType >::value, void >::type AppendDefinitions(TArray< FActorDefinition > &Definitions)
TSubclassOf< AActor > Class
Class of the actor to be spawned.
A description of a Carla Actor with all its variation.
typename detail::CompileTimeTypeMapImpl< sizeof...(Items), Items... >::template get_by_index< Index > get_by_index
Result of an actor spawn function.
TArray< FActorDefinition > GetDefinitions() final
Retrieve the definitions of all the sensors registered in the SensorRegistry.
geom::Transform Transform
static std::enable_if<!is_spawnable< SensorType >::value, void >::type AppendDefinitions(TArray< FActorDefinition > &)
static auto GetSensorDefinitions()
UCarlaEpisode * GetCarlaEpisode()