Agrarsense
Static Public Member Functions | Static Private Member Functions | List of all members
LidarNoiseModel Class Reference

#include <LidarNoiseModel.h>

Static Public Member Functions

static bool CheckSnowflakeHit (FHitResult &HitInfo, const FVector EndTrace, const FVector LidarLocation, const FWeatherParameters &WeatherParameters)
 

Static Private Member Functions

static bool CheckSnowflakeHitWinterSim (FHitResult &HitInfo, const float PrecipitationAmount, const float ParticleSize, const FVector EndTrace, const FVector LidarLocation)
 
static float CalculatePrecipitationClass (const float PrecipitationAmount, float ParticleSize)
 

Detailed Description

LidarNoiseModel is a static class for checking whether linetrace "hit" snowflake based on certain Simulation weather parameters and selected noise model formula.

WinterSim formula: Wintersim Lidar noise model formula was originally created in WinterSim project during the project in 2020-2022. See more about the project and Lidar analysis here: https://a3s.fi/swift/v1/AUTH_8811c563a60e4395828a2393f44e064b/website_documents/wintersim/WinterSim_LidarAnalysis.pdf https://www.frostbit.fi/en/portfolio/wintersim-2/ https://wintersim.fi/ The WinterSim formula was created by analysing gathered Lidar, camera and weather data during winter 2021-2022 with Ouster OS1 Lidar sensor in various weather conditions. The noise model creates noise to the end Lidar pointcloud output when following simulation weather conditions are met: 1) Temperature is below zero 2) Precipitation is over zero

Definition at line 29 of file LidarNoiseModel.h.

Member Function Documentation

◆ CalculatePrecipitationClass()

float LidarNoiseModel::CalculatePrecipitationClass ( const float  PrecipitationAmount,
float  ParticleSize 
)
staticprivate

Calculates "precipitation class" based on rain and particle size.

Parameters
PrecipitationAmountThe amount of rain affecting the precipitation class, ranging from 0.0 to 100.0.
ParticleSizeThe size of the precipitation particles, ranging from 0.0 to 100.0.
Returns
The calculated precipitation class.

Definition at line 57 of file LidarNoiseModel.cpp.

58{
59 float PrecipitationClass = 0;
60
61 // Ensure ParticleSize is within the specified bounds (1.0 to 3.0) and adjust if necessary
62 if (ParticleSize < 1.0f) ParticleSize = 1.0f;
63 if (ParticleSize > 3.0f) ParticleSize = 3.0f;
64
65 if (PrecipitationAmount > 0 && PrecipitationAmount <= 33.33f) PrecipitationClass = 1 + ParticleSize;
66 else if (PrecipitationAmount > 33.33 && PrecipitationAmount <= 66.66f) PrecipitationClass = 2 + ParticleSize;
67 else if (PrecipitationAmount > 66.66 && PrecipitationAmount <= 100.00f) PrecipitationClass = 3 + ParticleSize;
68
69 return PrecipitationClass;
70}

Referenced by CheckSnowflakeHitWinterSim().

◆ CheckSnowflakeHit()

bool LidarNoiseModel::CheckSnowflakeHit ( FHitResult &  HitInfo,
const FVector  EndTrace,
const FVector  LidarLocation,
const FWeatherParameters WeatherParameters 
)
static

Evaluates whether a linetrace "intersects" with a snowflake within specific weather conditions, utilizing a designated noise model.

Parameters
NoiseModelThe noise model formula used to simulate lidar detection inaccuracies.
HitInfoReference to store the hit result details.
EndTraceThe end point of the linetrace.
LidarLocationThe starting point of the linetrace from the lidar device.
WeatherParametersThe environmental conditions affecting the detection probability.
Returns
bool Returns true if the linetrace is determined to intersect with a snowflake, false otherwise.

Definition at line 12 of file LidarNoiseModel.cpp.

13{
14 return CheckSnowflakeHitWinterSim(HitInfo, WeatherParameters.Precipitation, WeatherParameters.PrecipitationParticleSize, EndTrace, LidarLocation);;
15}
static bool CheckSnowflakeHitWinterSim(FHitResult &HitInfo, const float PrecipitationAmount, const float ParticleSize, const FVector EndTrace, const FVector LidarLocation)

References CheckSnowflakeHitWinterSim(), FWeatherParameters::Precipitation, and FWeatherParameters::PrecipitationParticleSize.

Referenced by ALidar::ShootLaser().

◆ CheckSnowflakeHitWinterSim()

bool LidarNoiseModel::CheckSnowflakeHitWinterSim ( FHitResult &  HitInfo,
const float  PrecipitationAmount,
const float  ParticleSize,
const FVector  EndTrace,
const FVector  LidarLocation 
)
staticprivate

Check snowflake hit using the WinterSim noise formula.

Returns
true if the line trace 'hit' a snowflake, false otherwise.

Definition at line 17 of file LidarNoiseModel.cpp.

18{
19 // Create random value between 0.0 and 1.0
20 const float RandomValue = FMath::FRandRange(0.0, 1.0f);
21
22 FVector MaxDistance = EndTrace; // lidar max range
23 FVector StartPoint = LidarLocation; // start point is lidar position
24
25 float PrecipitationClass = CalculatePrecipitationClass(PrecipitationAmount, ParticleSize);
26
27 if (HitInfo.bBlockingHit)
28 {
29 MaxDistance = HitInfo.ImpactPoint;
30 }
31
32 FVector DirectionVector = EndTrace - StartPoint;
33 FVector NewStartPoint = StartPoint + 0.01 * DirectionVector; // make start point away from center of lidar
34 FVector NewVector = MaxDistance - NewStartPoint; // new vector from new start point to end point
35 FVector NewHitpoint = NewStartPoint + RandomValue * NewVector; // generate new point from new start point to end point
36 NewHitpoint *= 1e-2;
37 float Distance = FVector::Dist(StartPoint, NewHitpoint) / 100; // distance between NewHitpoint and NewStartPoint divided by 100 to get meters
38
39 // Actual probability formula calculation
40 const float ProbabilityFormula = PrecipitationClass / 10 * exp(-pow(Distance - (4 + 0.2 * PrecipitationClass), 2.0)
41 / pow(2, 2.0)) + 0.2 * PrecipitationClass / 10 * exp(-pow(Distance - (7 + 0.2 * PrecipitationClass), 2.0) / pow(1, 2.0));
42
43 // If RandomValue is smaller than ProbabilityFormula from formula we 'hit' the trace to snowflake
44 bool HitSnowflake = RandomValue < ProbabilityFormula;
45 if (HitSnowflake)
46 {
47 // Assign new hitpoint
48 HitInfo.ImpactPoint = NewHitpoint;
49
50 // To identify the snowflake later, set component to nullptr if hitpoint is snowflake
51 HitInfo.Component = nullptr;
52 }
53
54 return HitSnowflake;
55}
static float CalculatePrecipitationClass(const float PrecipitationAmount, float ParticleSize)

References CalculatePrecipitationClass().

Referenced by CheckSnowflakeHit().


The documentation for this class was generated from the following files: