8#include "CoreMinimal.h"
9#include "Containers/Map.h"
10#include "Engine/HitResult.h"
18#include "ROSIntegration/Public/sensor_msgs/PointCloud2.h"
22#include "Lidar.generated.h"
24class AGeoReferencingSystem;
25class UNiagaraComponent;
40 ALidar(
const FObjectInitializer& ObjectInitializer);
61 UFUNCTION(BlueprintCallable)
68 UFUNCTION(BlueprintCallable)
69 void SetVisualizeLidarParticles(
bool Visualize);
75 UFUNCTION(BlueprintCallable)
76 void SetParticleLifeTime(
float ParticleLifeTime);
82 UFUNCTION(BlueprintCallable, BlueprintPure)
85 return LidarParameters;
92 UFUNCTION(BlueprintCallable)
93 UNiagaraComponent* GetNiagaraComponent()
const
95 return NiagaraComponent;
103 return StructToString(LidarParameters);
112 ClearContainers =
true;
120 SaveCurrentPointCloudToDiskRequested =
true;
127 virtual void EndPlay(
const EEndPlayReason::Type EndPlayReason)
override;
129 void CreateLogFile()
override;
131 void SaveLidarMetaDataToDisk(
const FString& FileName);
141 std::vector<FPointData> SimulateRaycastLidar(
const float DeltaTime);
147 UPROPERTY(VisibleAnywhere, Category =
"Sensor")
148 UNiagaraComponent* NiagaraComponent =
nullptr;
154 void SetNiagaraRendering(
bool Enabled);
159 void VisualizeLidarParticles(std::vector<
FPointData> HitPoints);
164 void ChangeParameters();
172 FORCEINLINE
bool ShootLaser(const UWorld* World, FHitResult& HitResult, const FVector& EndTrace, const FCollisionQueryParams& TraceParams,
173 const FVector& LidarBodyLocation, const int32 Channel, const
bool Semantic, const uint32 RGBDefault, const
bool UseLidarNoiseModel);
178 void ResetRecordedHits(int32 MaxPointsPerChannel);
185 FORCEINLINE uint32 GetSemanticData(const FHitResult& HitResult) const;
191 void SendData(const
float DeltaTime);
196 bool CanSendData(const
float DeltaTime);
201 void SendDataToTopic(const std::vector<
FPointData>& points);
206 void SaveDataToDisk();
213 void AddProcessingToHitResult(FHitResult& HitResult, const FVector& LidarBodyLocation, const
bool UseHorizontalNoise, const
bool UseSnowTerrainAdjustment);
224 void AddDistanceNoise(FHitResult& HitResult, const FVector& LidarBodyLocation);
233 void AddLateralNoise(FHitResult& HitResult, const FVector& LidarBodyLocation, const
bool UseHorizontalNoise);
240 void AddSnowTerrainAdjustment(FHitResult& HitResult, const FVector& LidarBodyLocation);
245 void UpdateLidarParticles(int32 NumberOfHits, const TArray<FVector>& HitPoints, const TArray<FLinearColor>& Colors);
254 AGeoReferencingSystem* GeoReferencingSystem =
nullptr;
256 UPROPERTY(VisibleAnywhere, Category = "Sensor")
264 TMap<FName, FColor> SemanticColors;
268 std::vector<std::vector<
FPointData>> PreProcessedHitImpactPoints;
273 std::vector<
float> LaserAngles;
275 std::random_device RandomDevice;
276 std::mt19937 Generator;
278 bool NeedToSavePointCloudWithoutNoise = false;
279 bool LidarParametersChanged = false;
280 bool SendDataEveryFrame = false;
284 float CurrentHorizontalAngle = 0.0f;
285 float SensorHzFrequency = 0.1f;
286 float SensorHzTimer = 0.0f;
288 float SnowHeightOffset = 0.0f;
292 uint32 CachedNoneColor;
294 uint32 CachedSnowflakeColor;
296 bool SaveCurrentPointCloudToDiskRequested = false;
298 bool ClearContainers = true;
TSharedPtr< ROSMessages::sensor_msgs::PointCloud2 > PointCloudMessage
UPROPERTY(BlueprintReadOnly)
void ForceClearContainers()
virtual FString GetParametersAsString() const override
void SaveCurrentPointCloudToDisk()
virtual ESensorTypes GetSensorType() const override
virtual void EndPlay(const EEndPlayReason::Type EndPlayReason) override
virtual void BeginPlay() override