RayCastLidar: Optimizing the normal lidar.

This commit is contained in:
Daniel Santos-Olivan 2020-07-27 19:57:23 +02:00 committed by DSantosO
parent 247c3731b7
commit afd43914e9
2 changed files with 21 additions and 8 deletions

View File

@ -76,6 +76,24 @@ float ARayCastLidar::ComputeIntensity(const FRawDetection& RawDetection) const
return IntRec;
}
ARayCastLidar::FDetection ARayCastLidar::ComputeDetection(const FHitResult& HitInfo, const FTransform& SensorTransf) const
{
FDetection Detection;
const FVector HitPoint = HitInfo.ImpactPoint;
Detection.point = SensorTransf.Inverse().TransformPosition(HitPoint);
const float Distance = Detection.point.Length();
const float AttenAtm = Description.AtmospAttenRate;
const float AbsAtm = exp(-AttenAtm * Distance);
const float IntRec = AbsAtm;
Detection.intensity = IntRec;
return Detection;
}
bool ARayCastLidar::PreprocessRay(const float& VerticalAngle, float &HorizontalAngle) const {
if(DropOffGenActive && RandomEngine->GetUniformFloat() < Description.DropOffGenRate)
return false;
@ -86,20 +104,14 @@ float ARayCastLidar::ComputeIntensity(const FRawDetection& RawDetection) const
void ARayCastLidar::ComputeAndSaveDetections(const FTransform& SensorTransform) {
std::vector<u_int32_t> PointsPerChannel(Description.Channels);
UE_LOG(LogCarla, Warning, TEXT("ARayCastLidar::ComputeAndSaveDetections()!!!! "));
for (auto idxChannel = 0u; idxChannel < Description.Channels; ++idxChannel)
PointsPerChannel[idxChannel] = RecordedHits[idxChannel].size();
LidarData.ResetSerPoints(PointsPerChannel);
for (auto idxChannel = 0u; idxChannel < Description.Channels; ++idxChannel) {
for (auto& hit : RecordedHits[idxChannel]) {
FRawDetection raw_detection;
ComputeRawDetection(hit, SensorTransform, raw_detection);
float intensity = ComputeIntensity(raw_detection);
FDetection detection(raw_detection.point, intensity);
LidarData.WritePointSync(detection);
FDetection Detection = ComputeDetection(hit, SensorTransform);
LidarData.WritePointSync(Detection);
}
}
}

View File

@ -38,6 +38,7 @@ public:
private:
/// Compute the received intensity of the point
float ComputeIntensity(const FRawDetection& RawDetection) const;
FDetection ComputeDetection(const FHitResult& HitInfo, const FTransform& SensorTransf) const;
bool PreprocessRay(const float& VerticalAngle, float &HorizontalAngle) const override;