Added postprocess method for noise and intensity dropoff

This commit is contained in:
Daniel Santos-Olivan 2020-07-28 15:33:17 +02:00 committed by DSantosO
parent f5e68a275b
commit b5a297fea2
2 changed files with 18 additions and 1 deletions

View File

@ -101,6 +101,21 @@ ARayCastLidar::FDetection ARayCastLidar::ComputeDetection(const FHitResult& HitI
return true;
}
bool ARayCastLidar::PostprocessDetection(FDetection& Detection) const
{
if (Description.NoiseStdDev > std::numeric_limits<float>::epsilon()) {
const auto ForwardVector = Detection.point.MakeUnitVector();
const auto Noise = ForwardVector * RandomEngine->GetNormalDistribution(0.0f, Description.NoiseStdDev);
Detection.point += Noise;
}
const float Intensity = Detection.intensity;
if(Intensity > Description.DropOffIntensityLimit)
return true;
else
return RandomEngine->GetUniformFloat() < DropOffAlpha * Intensity + DropOffBeta;
}
void ARayCastLidar::ComputeAndSaveDetections(const FTransform& SensorTransform) {
std::vector<u_int32_t> PointsPerChannel(Description.Channels);
@ -111,7 +126,8 @@ ARayCastLidar::FDetection ARayCastLidar::ComputeDetection(const FHitResult& HitI
for (auto idxChannel = 0u; idxChannel < Description.Channels; ++idxChannel) {
for (auto& hit : RecordedHits[idxChannel]) {
FDetection Detection = ComputeDetection(hit, SensorTransform);
LidarData.WritePointSync(Detection);
if (PostprocessDetection(Detection))
LidarData.WritePointSync(Detection);
}
}
}

View File

@ -41,6 +41,7 @@ private:
FDetection ComputeDetection(const FHitResult& HitInfo, const FTransform& SensorTransf) const;
bool PreprocessRay() const override;
bool PostprocessDetection(FDetection& Detection) const;
void ComputeAndSaveDetections(const FTransform& SensorTransform) override;