Agrarsense
SensorFactory.h
Go to the documentation of this file.
1// Copyright (c) 2023 FrostBit Software Lab at the Lapland University of Applied Sciences
2//
3// This work is licensed under the terms of the MIT license.
4// For a copy, see <https://opensource.org/licenses/MIT>.
5
6#pragma once
7
8#include "CoreMinimal.h"
9#include "Kismet/BlueprintFunctionLibrary.h"
10#include "Engine.h"
11
14
15#include "SensorFactory.generated.h"
16
17class ASensor;
18class ALidar;
19class ACamera;
20class AThermalCamera;
21class ADepthCamera;
23class ADVSCamera;
24class ARadar;
27class AOverlapSensor;
28
32struct FCameraParameters;
33struct FLidarParameters;
34struct FRadarParameters;
35
41UCLASS()
42class AGRARSENSE_API USensorFactory : public UBlueprintFunctionLibrary
43{
44 GENERATED_BODY()
45
46public:
47
48 UFUNCTION(BlueprintCallable, BlueprintPure, Category = "Sensor")
49 static USensorMapDataAsset* GetSensorMapDataAsset();
50
60 UFUNCTION(BlueprintCallable, Category = "Sensor")
61 static ALidar* SpawnLidarSensor(const FTransform& transform, const FString sensorIdentifier, const FString sensorName, FLidarParameters lidarParameters, bool SimulateSensor = true);
62
72 UFUNCTION(BlueprintCallable, Category = "Sensor")
73 static ACamera* SpawnCamera(const FTransform& transform, const FString sensorIdentifier, const FString sensorName, FCameraBaseParameters cameraParameters, bool SimulateSensor = true);
74
84 UFUNCTION(BlueprintCallable, Category = "Sensor")
85 static AThermalCamera* SpawnThermalCamera(const FTransform& transform, const FString sensorIdentifier, const FString sensorName, FThermalCameraParameters thermalCameraParameters, bool SimulateSensor = true);
86
96 UFUNCTION(BlueprintCallable, Category = "Sensor")
97 static ADepthCamera* SpawnDepthCamera(const FTransform& transform, const FString sensorIdentifier, const FString sensorName, FDepthCameraParameters depthCameraParameters, bool SimulateSensor = true);
98
108 UFUNCTION(BlueprintCallable, Category = "Sensor")
109 static ASemanticSegmentationCamera* SpawnSegmentationCamera(const FTransform& transform, const FString sensorIdentifier, const FString sensorName, FCameraBaseParameters cameraParameters, bool SimulateSensor = true);
110
120 UFUNCTION(BlueprintCallable, Category = "Sensor")
121 static ADVSCamera* SpawnDVSCamera(const FTransform& transform, const FString sensorIdentifier, const FString sensorName, FDVSCameraParameters DVSCameraParameters, bool SimulateSensor);
122
132 UFUNCTION(BlueprintCallable, Category = "Sensor")
133 static ARadar* SpawnRadar(const FTransform& transform, const FString sensorIdentifier, const FString sensorName, FRadarParameters radarParameters, bool SimulateSensor = true);
134
142 UFUNCTION(BlueprintCallable, Category = "Sensor")
143 static ACollisionSensor* SpawnCollisionSensor(const FTransform& transform, AActor* Owner, const FString sensorIdentifier, const FString sensorName, bool SimulateSensor = true);
144
153 UFUNCTION(BlueprintCallable, Category = "Sensor")
154 static ATransformSensor* SpawnTransformSensor(const FTransform& transform, AActor* Owner, const FString sensorIdentifier, const FString sensorName, bool SimulateSensor = true);
155
163 UFUNCTION(BlueprintCallable, Category = "Sensor")
164 static AOverlapSensor* SpawnOverlapSensor(const FTransform& transform, FOverlapSensorParameters Parameters, const FString sensorIdentifier, const FString sensorName);
165
166
167private:
168
169 /*
170 * Templated function that spawns an Actor of the specified class and returns a pointer to the Actor.
171 *
172 * This function dynamically creates and initializes an Actor of the specified class using the provided transform.
173 * It returns a pointer to the spawned Actor. Make sure to call the Init() function on the returned Actor
174 * to properly initialize its parameters and simulation mode.
175 *
176 * @param transform The transform used to spawn the Actor.
177 * @return Pointer to the spawned Actor or nullptr
178 */
179 template <typename T>
180 static T* SpawnSensor(const FTransform& transform, const FString& sensorIdentifier, const FString& sensorName, bool SpawnSensorModel = true);
181
188 static void SetSensorIdentifierAndNameWithFallbacks(ASensor* sensor, const FString& sensorIdentifier, const FString& sensorName);
189
195 static ASensorModel* SpawnModelClassForSensor(ASensor* attachTo);
196
203 static ASensorModel* SpawnModelClass(TSubclassOf<ASensorModel> modelClass, ASensor* attachTo);
204
208 static void Initialize();
209
213 static TWeakObjectPtr<USensorMapDataAsset> SensorMapDataAsset;
214};
Definition: Camera.h:52
Definition: Lidar.h:34
Definition: Radar.h:26
Definition: Sensor.h:44
static TWeakObjectPtr< USensorMapDataAsset > SensorMapDataAsset