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;
24class ADVSCamera;
25class ARadar;
28class AOverlapSensor;
29
34struct FCameraParameters;
35struct FLidarParameters;
36struct FRadarParameters;
37
43UCLASS()
44class AGRARSENSE_API USensorFactory : public UBlueprintFunctionLibrary
45{
46 GENERATED_BODY()
47
48public:
49
50 UFUNCTION(BlueprintCallable, BlueprintPure, Category = "Sensor")
51 static USensorMapDataAsset* GetSensorMapDataAsset();
52
62 UFUNCTION(BlueprintCallable, Category = "Sensor")
63 static ALidar* SpawnLidarSensor(const FTransform& transform, const FString sensorIdentifier, const FString sensorName, FLidarParameters lidarParameters, bool SimulateSensor = true, AActor* Parent = nullptr);
64
74 UFUNCTION(BlueprintCallable, Category = "Sensor")
75 static ACamera* SpawnCamera(const FTransform& transform, const FString sensorIdentifier, const FString sensorName, FCameraBaseParameters cameraParameters, bool SimulateSensor = true, AActor* Parent = nullptr);
76
86 UFUNCTION(BlueprintCallable, Category = "Sensor")
87 static AThermalCamera* SpawnThermalCamera(const FTransform& transform, const FString sensorIdentifier, const FString sensorName, FThermalCameraParameters thermalCameraParameters, bool SimulateSensor = true, AActor* Parent = nullptr);
88
98 UFUNCTION(BlueprintCallable, Category = "Sensor")
99 static ADepthCamera* SpawnDepthCamera(const FTransform& transform, const FString sensorIdentifier, const FString sensorName, FDepthCameraParameters depthCameraParameters, bool SimulateSensor = true, AActor* Parent = nullptr);
100
110 UFUNCTION(BlueprintCallable, Category = "Sensor")
111 static ASemanticSegmentationCamera* SpawnSegmentationCamera(const FTransform& transform, const FString sensorIdentifier, const FString sensorName, FCameraBaseParameters cameraParameters, bool SimulateSensor = true, AActor* Parent = nullptr);
112
122 UFUNCTION(BlueprintCallable, Category = "Sensor")
123 static AInstanceSegmentationCamera* SpawnInstanceSegmentationCamera(const FTransform& transform, const FString sensorIdentifier, const FString sensorName, FCameraBaseParameters cameraParameters, bool SimulateSensor = true, AActor* Parent = nullptr);
124
125
135 UFUNCTION(BlueprintCallable, Category = "Sensor")
136 static ADVSCamera* SpawnDVSCamera(const FTransform& transform, const FString sensorIdentifier, const FString sensorName, FDVSCameraParameters DVSCameraParameters, bool SimulateSensor, AActor* Parent = nullptr);
137
147 UFUNCTION(BlueprintCallable, Category = "Sensor")
148 static ARadar* SpawnRadar(const FTransform& transform, const FString sensorIdentifier, const FString sensorName, FRadarParameters radarParameters, bool SimulateSensor = true, AActor* Parent = nullptr);
149
157 UFUNCTION(BlueprintCallable, Category = "Sensor")
158 static ACollisionSensor* SpawnCollisionSensor(const FTransform& transform, AActor* Owner, const FString sensorIdentifier, const FString sensorName, bool SimulateSensor = true, AActor* Parent = nullptr);
159
168 UFUNCTION(BlueprintCallable, Category = "Sensor")
169 static ATransformSensor* SpawnTransformSensor(const FTransform& transform, FTransformSensorParameters Parameters, const FString sensorIdentifier, const FString sensorName, bool SimulateSensor = true, AActor* Parent = nullptr);
170
178 UFUNCTION(BlueprintCallable, Category = "Sensor")
179 static AOverlapSensor* SpawnOverlapSensor(const FTransform& transform, FOverlapSensorParameters Parameters, const FString sensorIdentifier, const FString sensorName, AActor* Parent = nullptr);
180
181
182private:
183
184 /*
185 * Templated function that spawns an Actor of the specified class and returns a pointer to the Actor.
186 *
187 * This function dynamically creates and initializes an Actor of the specified class using the provided transform.
188 * It returns a pointer to the spawned Actor. Make sure to call the Init() function on the returned Actor
189 * to properly initialize its parameters and simulation mode.
190 *
191 * @param transform The transform used to spawn the Actor.
192 * @return Pointer to the spawned Actor or nullptr
193 */
194 template <typename T>
195 static T* SpawnSensor(const FTransform& transform, const FString& sensorIdentifier, const FString& sensorName, bool SpawnSensorModel = true, AActor* Parent = nullptr);
196
203 static void SetSensorIdentifierAndNameWithFallbacks(ASensor* sensor, const FString& sensorIdentifier, const FString& sensorName);
204
210 static ASensorModel* SpawnModelClassForSensor(ASensor* attachTo);
211
218 static ASensorModel* SpawnModelClass(TSubclassOf<ASensorModel> modelClass, ASensor* attachTo);
219
223 static void Initialize();
224
228 static TWeakObjectPtr<USensorMapDataAsset> SensorMapDataAsset;
229};
Definition: Camera.h:53
Definition: Lidar.h:35
Definition: Radar.h:26
Definition: Sensor.h:45
static TWeakObjectPtr< USensorMapDataAsset > SensorMapDataAsset