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
33struct FCameraParameters;
34struct FLidarParameters;
35struct FRadarParameters;
36
42UCLASS()
43class AGRARSENSE_API USensorFactory : public UBlueprintFunctionLibrary
44{
45 GENERATED_BODY()
46
47public:
48
49 UFUNCTION(BlueprintCallable, BlueprintPure, Category = "Sensor")
50 static USensorMapDataAsset* GetSensorMapDataAsset();
51
61 UFUNCTION(BlueprintCallable, Category = "Sensor")
62 static ALidar* SpawnLidarSensor(const FTransform& transform, const FString sensorIdentifier, const FString sensorName, FLidarParameters lidarParameters, bool SimulateSensor = true, AActor* Parent = nullptr);
63
73 UFUNCTION(BlueprintCallable, Category = "Sensor")
74 static ACamera* SpawnCamera(const FTransform& transform, const FString sensorIdentifier, const FString sensorName, FCameraBaseParameters cameraParameters, bool SimulateSensor = true, AActor* Parent = nullptr);
75
85 UFUNCTION(BlueprintCallable, Category = "Sensor")
86 static AThermalCamera* SpawnThermalCamera(const FTransform& transform, const FString sensorIdentifier, const FString sensorName, FThermalCameraParameters thermalCameraParameters, bool SimulateSensor = true, AActor* Parent = nullptr);
87
97 UFUNCTION(BlueprintCallable, Category = "Sensor")
98 static ADepthCamera* SpawnDepthCamera(const FTransform& transform, const FString sensorIdentifier, const FString sensorName, FDepthCameraParameters depthCameraParameters, bool SimulateSensor = true, AActor* Parent = nullptr);
99
109 UFUNCTION(BlueprintCallable, Category = "Sensor")
110 static ASemanticSegmentationCamera* SpawnSegmentationCamera(const FTransform& transform, const FString sensorIdentifier, const FString sensorName, FCameraBaseParameters cameraParameters, bool SimulateSensor = true, AActor* Parent = nullptr);
111
121 UFUNCTION(BlueprintCallable, Category = "Sensor")
122 static ADVSCamera* SpawnDVSCamera(const FTransform& transform, const FString sensorIdentifier, const FString sensorName, FDVSCameraParameters DVSCameraParameters, bool SimulateSensor, AActor* Parent = nullptr);
123
133 UFUNCTION(BlueprintCallable, Category = "Sensor")
134 static ARadar* SpawnRadar(const FTransform& transform, const FString sensorIdentifier, const FString sensorName, FRadarParameters radarParameters, bool SimulateSensor = true, AActor* Parent = nullptr);
135
143 UFUNCTION(BlueprintCallable, Category = "Sensor")
144 static ACollisionSensor* SpawnCollisionSensor(const FTransform& transform, AActor* Owner, const FString sensorIdentifier, const FString sensorName, bool SimulateSensor = true, AActor* Parent = nullptr);
145
154 UFUNCTION(BlueprintCallable, Category = "Sensor")
155 static ATransformSensor* SpawnTransformSensor(const FTransform& transform, FTransformSensorParameters Parameters, const FString sensorIdentifier, const FString sensorName, bool SimulateSensor = true, AActor* Parent = nullptr);
156
164 UFUNCTION(BlueprintCallable, Category = "Sensor")
165 static AOverlapSensor* SpawnOverlapSensor(const FTransform& transform, FOverlapSensorParameters Parameters, const FString sensorIdentifier, const FString sensorName, AActor* Parent = nullptr);
166
167
168private:
169
170 /*
171 * Templated function that spawns an Actor of the specified class and returns a pointer to the Actor.
172 *
173 * This function dynamically creates and initializes an Actor of the specified class using the provided transform.
174 * It returns a pointer to the spawned Actor. Make sure to call the Init() function on the returned Actor
175 * to properly initialize its parameters and simulation mode.
176 *
177 * @param transform The transform used to spawn the Actor.
178 * @return Pointer to the spawned Actor or nullptr
179 */
180 template <typename T>
181 static T* SpawnSensor(const FTransform& transform, const FString& sensorIdentifier, const FString& sensorName, bool SpawnSensorModel = true, AActor* Parent = nullptr);
182
189 static void SetSensorIdentifierAndNameWithFallbacks(ASensor* sensor, const FString& sensorIdentifier, const FString& sensorName);
190
196 static ASensorModel* SpawnModelClassForSensor(ASensor* attachTo);
197
204 static ASensorModel* SpawnModelClass(TSubclassOf<ASensorModel> modelClass, ASensor* attachTo);
205
209 static void Initialize();
210
214 static TWeakObjectPtr<USensorMapDataAsset> SensorMapDataAsset;
215};
Definition: Camera.h:53
Definition: Lidar.h:35
Definition: Radar.h:26
Definition: Sensor.h:45
static TWeakObjectPtr< USensorMapDataAsset > SensorMapDataAsset