21#include "Engine/GameViewportClient.h"
34 FSoftObjectPath SensorMapDataAssetPath(TEXT(
"/Game/Agrarsense/Data/Sensors/SensorMap"));
40 UE_LOG(LogTemp, Warning, TEXT(
"USensorFactory.cpp: Loaded SensorMapDataAsset successfully."));
44 UE_LOG(LogTemp, Warning, TEXT(
"USensorFactory.cpp: Loading SensorMapDataAsset failed."));
65 bool generateIdentifier = sensorIdentifier.IsEmpty();
66 bool generateName = sensorName.IsEmpty();
68 FString generatedSensorIdentifier;
72 if (generateIdentifier)
83 sensor->
SetSensorIdentifier(generateIdentifier ? generatedSensorIdentifier : sensorIdentifier);
94 ALidar* LidarSensor =
nullptr;
95 LidarSensor = SpawnSensor<ALidar>(transform, sensorIdentifier, sensorName,
true);
98 LidarSensor->
Init(lidarParameters, SimulateSensor);
107 RGBCamera = SpawnSensor<ACamera>(transform, sensorIdentifier, sensorName,
true);
110 RGBCamera->Init(cameraParameters, SimulateSensor);
119 ThermalCamera = SpawnSensor<AThermalCamera>(transform, sensorIdentifier, sensorName,
true);
122 ThermalCamera->ThermalInit(thermalCameraParameters, SimulateSensor);
131 DepthCamera = SpawnSensor<ADepthCamera>(transform, sensorIdentifier, sensorName,
true);
134 DepthCamera->DepthInit(depthCameraParameters, SimulateSensor);
155 DVSCamera = SpawnSensor<ADVSCamera>(transform, sensorIdentifier, sensorName,
true);
158 DVSCamera->DVSInit(DVSCameraParameters, SimulateSensor);
166 ARadar* RadarSensor =
nullptr;
167 RadarSensor = SpawnSensor<ARadar>(transform, sensorIdentifier, sensorName,
true);
170 RadarSensor->
Init(radarParameters, SimulateSensor);
181 CollisionSensor = SpawnSensor<ACollisionSensor>(transform, sensorIdentifier, sensorName,
false);
184 CollisionSensor->
Init(Owner, SimulateSensor);
185 CollisionSensor->AttachToActor(Owner, FAttachmentTransformRules::KeepWorldTransform);
189 return CollisionSensor;
197 TransformSensor = SpawnSensor<ATransformSensor>(transform, sensorIdentifier, sensorName,
false);
200 TransformSensor->
Init(Owner, SimulateSensor);
201 TransformSensor->AttachToActor(Owner, FAttachmentTransformRules::KeepWorldTransform);
205 return TransformSensor;
211 OverlapSensor = SpawnSensor<AOverlapSensor>(transform, sensorIdentifier, sensorName,
false);
214 OverlapSensor->
Init(Parameters);
217 return OverlapSensor;
235 TSubclassOf<ASensorModel> modelClass =
nullptr;
241 if (matchFound && sensorData)
261 return createdModelActor;
264 UWorld* World =
nullptr;
265 if (GEngine && GEngine->GameViewport)
267 World = GEngine->GameViewport->GetWorld();
272 FVector sensorLocation = attachTo->GetActorLocation();
273 createdModelActor = World->SpawnActor<
ASensorModel>(modelClass);
275 if (createdModelActor)
277 createdModelActor->AttachToActor(attachTo, FAttachmentTransformRules::SnapToTargetIncludingScale);
285 return createdModelActor;
291 UWorld* World =
nullptr;
293 if (GEngine && GEngine->GameViewport)
296 World = GEngine->GameViewport->GetWorld();
303 Sensor = World->SpawnActorDeferred<T>(T::StaticClass(), transform);
307 Sensor->FinishSpawning(transform);
309 if (SpawnSensorModel)
@ SemanticSegmentationCamera
void Init(AActor *NewOwner, bool SimulateSensor=true)
void Init(FLidarParameters parameters, bool SimulateSensor=true)
void Init(FOverlapSensorParameters InParameters)
void Init(FRadarParameters parameters, bool SimulateSensor=true)
void SetAttachedToSensor(ASensor *NewAttachedToSensor)
void SetSensorModel(ASensorModel *NewSensorModel)
void SetSensorName(const FString newName)
FString GetSensorIdentifier() const
virtual ESensorTypes GetSensorType() const
void SetSensorIdentifier(const FString newIdentifier)
static FString ConvertSensorTypeToString(ESensorTypes Sensortype)
TSubclassOf< ASensorModel > ModelClass
static T * SpawnSensor(const FTransform &transform, const FString &sensorIdentifier, const FString &sensorName, bool SpawnSensorModel=true)
static ATransformSensor * SpawnTransformSensor(const FTransform &transform, AActor *Owner, const FString sensorIdentifier, const FString sensorName, bool SimulateSensor=true)
static void SetSensorIdentifierAndNameWithFallbacks(ASensor *sensor, const FString &sensorIdentifier, const FString &sensorName)
static ASensorModel * SpawnModelClassForSensor(ASensor *attachTo)
static ARadar * SpawnRadar(const FTransform &transform, const FString sensorIdentifier, const FString sensorName, FRadarParameters radarParameters, bool SimulateSensor=true)
static TWeakObjectPtr< USensorMapDataAsset > SensorMapDataAsset
static ACollisionSensor * SpawnCollisionSensor(const FTransform &transform, AActor *Owner, const FString sensorIdentifier, const FString sensorName, bool SimulateSensor=true)
static AThermalCamera * SpawnThermalCamera(const FTransform &transform, const FString sensorIdentifier, const FString sensorName, FThermalCameraParameters thermalCameraParameters, bool SimulateSensor=true)
static ACamera * SpawnCamera(const FTransform &transform, const FString sensorIdentifier, const FString sensorName, FCameraBaseParameters cameraParameters, bool SimulateSensor=true)
static ADVSCamera * SpawnDVSCamera(const FTransform &transform, const FString sensorIdentifier, const FString sensorName, FDVSCameraParameters DVSCameraParameters, bool SimulateSensor)
static USensorMapDataAsset * GetSensorMapDataAsset()
static ASensorModel * SpawnModelClass(TSubclassOf< ASensorModel > modelClass, ASensor *attachTo)
static ADepthCamera * SpawnDepthCamera(const FTransform &transform, const FString sensorIdentifier, const FString sensorName, FDepthCameraParameters depthCameraParameters, bool SimulateSensor=true)
static ALidar * SpawnLidarSensor(const FTransform &transform, const FString sensorIdentifier, const FString sensorName, FLidarParameters lidarParameters, bool SimulateSensor=true)
static AOverlapSensor * SpawnOverlapSensor(const FTransform &transform, FOverlapSensorParameters Parameters, const FString sensorIdentifier, const FString sensorName)
static ASemanticSegmentationCamera * SpawnSegmentationCamera(const FTransform &transform, const FString sensorIdentifier, const FString sensorName, FCameraBaseParameters cameraParameters, bool SimulateSensor=true)
USensorDataAsset * GetAssetDataBySensorType(ESensorTypes SensorType, bool &MatchFound)