Remove arguments from Preprocess to allow for optimization

This commit is contained in:
Daniel Santos-Olivan 2020-07-28 12:31:52 +02:00 committed by DSantosO
parent 20df95d202
commit d1889fed85
4 changed files with 11 additions and 9 deletions

View File

@ -94,7 +94,7 @@ ARayCastLidar::FDetection ARayCastLidar::ComputeDetection(const FHitResult& HitI
return Detection;
}
bool ARayCastLidar::PreprocessRay(const float& VerticalAngle, float &HorizontalAngle) const {
bool ARayCastLidar::PreprocessRay() const {
if(DropOffGenActive && RandomEngine->GetUniformFloat() < Description.DropOffGenRate)
return false;
else

View File

@ -40,7 +40,7 @@ private:
float ComputeIntensity(const FRawDetection& RawDetection) const;
FDetection ComputeDetection(const FHitResult& HitInfo, const FTransform& SensorTransf) const;
bool PreprocessRay(const float& VerticalAngle, float &HorizontalAngle) const override;
bool PreprocessRay() const override;
void ComputeAndSaveDetections(const FTransform& SensorTransform) override;

View File

@ -7,8 +7,8 @@
#include <PxScene.h>
#include <cmath>
#include "Carla.h"
#include "Carla/Sensor/RayCastRawLidar.h"
#include "Carla/Actor/ActorBlueprintFunctionLibrary.h"
#include "Carla/Sensor/RayCastRawLidar.h"
#include <compiler/disable-ue4-macros.h>
#include "carla/geom/Math.h"
@ -103,10 +103,9 @@ void ARayCastRawLidar::SimulateLidar(const float DeltaTime)
FCriticalSection Mutex;
ParallelFor(PointsToScanWithOneLaser, [&](int32 idxPtsOneLaser) {
FHitResult HitResult;
float VertAngle = LaserAngles[idxChannel];
float HorizAngle = CurrentHorizontalAngle + AngleDistanceOfLaserMeasure * idxPtsOneLaser;
bool PreprocessResult = PreprocessRay(VertAngle, HorizAngle);
const float VertAngle = LaserAngles[idxChannel];
const float HorizAngle = CurrentHorizontalAngle + AngleDistanceOfLaserMeasure * idxPtsOneLaser;
const bool PreprocessResult = PreprocessRay();
if (PreprocessResult && ShootLaser(VertAngle, HorizAngle, HitResult)) {
Mutex.Lock();

View File

@ -4,6 +4,8 @@
// This work is licensed under the terms of the MIT license.
// For a copy, see <https://opensource.org/licenses/MIT>.
#pragma once
#include "Carla/Sensor/Sensor.h"
@ -50,7 +52,7 @@ protected:
bool ShootLaser(const float VerticalAngle, float HorizontalAngle, FHitResult &RawData) const;
/// Method that allow to preprocess the ray before shoot it
virtual bool PreprocessRay(const float& VerticalAngle, float &HorizontalAngle) const {
virtual bool PreprocessRay() const {
// This method allows to introduce noise or drop points if needed
// A true return value will make the proposed ray to be actually computed.
return true;
@ -65,7 +67,8 @@ protected:
/// Clear the recorded data structure
void ResetRecordedHits(uint32_t Channels, uint32_t MaxPointsPerChannel);
/// Clear the recorded data structure
/// This method uses all the saved FHitResults, compute the
/// RawDetections and then send it to the LidarData structure.
virtual void ComputeAndSaveDetections(const FTransform &SensorTransform);
UPROPERTY(EditAnywhere)