Helios++
Helios software for LiDAR simulations
FullWaveformPulseRunnable Class Reference

Concrete implementation of abstract pulse runnable to compute full waveform pulses. More...

#include <FullWaveformPulseRunnable.h>

Inheritance diagram for FullWaveformPulseRunnable:
Collaboration diagram for FullWaveformPulseRunnable:

Public Member Functions

 FullWaveformPulseRunnable (std::shared_ptr< FullWaveformPulseDetector > detector, glm::dvec3 absoluteBeamOrigin, Rotation absoluteBeamAttitude, int currentPulseNum, long currentGpsTime, bool writeWaveform, bool calcEchowidth, std::vector< Measurement > *allMeasurements, std::mutex *allMeasurementsMutex, std::vector< Measurement > *cycleMeasurements, std::mutex *cycleMeasurementsMutex, unsigned int legIndex)
 Base constructor for full waveform pulse runnable. More...
 
double calcIntensity (double incidenceAngle, double targetRange, double targetReflectivity, double targetSpecularity, double targetSpecularExponent, double targetArea, double radius)
 Compute intensity.
 
double calcIntensity (double targetRange, double radius, double sigma)
 Compute intensity.
 
void operator() () override
 Full waveform pulse runnable void functor. It is necessary due to compatibility reasons. More...
 
void operator() (std::vector< std::vector< double >> &apMatrix, RandomnessGenerator< double > &randGen, RandomnessGenerator< double > &randGen2, NoiseSource< double > &intersectionHandlingNoiseSource)
 Full waveform pulse runnable functor. More...
 
- Public Member Functions inherited from AbstractPulseRunnable
 AbstractPulseRunnable (std::shared_ptr< AbstractDetector > detector, glm::dvec3 absoluteBeamOrigin, Rotation absoluteBeamAttitude, int pulseNumber, long gpsTime)
 Base constructor for pulse runnables. More...
 
double calcCrossSection (double f, double Alf, double theta)
 Compute cross section. More...
 
double phongBDRF (double incidenceAngle, double targetSpecularity, double targetSpecularExponent)
 Compute the phong model. More...
 
double calcAtmosphericFactor (double targetRange)
 Compute atmospheric factor \(f\), understood as the energy left after attenuation by air particles in range \([0, 1]\). More...
 
double calcReceivedPower (double emittedPower, double targetRange, double incidenceAngle, double targetReflectivity, double targetSpecularity, double targetSpecularExponent, double targetArea)
 Solve the laser radar equation. More...
 
double calcReceivedPower (double emittedPower, double targetRange, double sigma)
 Alternative received power computation method. More...
 
void capturePoint (Measurement &m, RandomnessGenerator< double > &rg, std::vector< Measurement > *allMeasurements, std::mutex *allMeasurementsMutex, std::vector< Measurement > *cycleMeasurements, std::mutex *cycleMeasurementsMutex)
 Capture point if proceed and write it. More...
 
void applyMeasurementError (RandomnessGenerator< double > &rg, double &distance, glm::dvec3 &beamOrigin, glm::dvec3 &beamDirection)
 Apply error to received measurement. More...
 

Public Attributes

unsigned int legIndex = 0
 Which leg the FullWaveformPulseRunnable belongs to. More...
 
- Public Attributes inherited from AbstractPulseRunnable
std::shared_ptr< AbstractDetectordetector = nullptr
 Detector used to simulate pulse.
 
glm::dvec3 absoluteBeamOrigin
 Beam origin in absolute coordinates.
 
Rotation absoluteBeamAttitude
 Beam attitude.
 
int currentPulseNum
 Number of current pulse.
 
long currentGpsTime
 Current GPS time in milliseconds.
 
bool writeGround = true
 Flag to specify if ground points must be captured (true) or not (false)
 

Static Public Attributes

static const double eps = 0.001
 Decimal precision constant for FullWaveformPulseRunnable computations.
 

Private Member Functions

void computeSubrays (Scene &scene, NoiseSource< double > &intersectionHandlingNoiseSource, std::map< double, double > &reflections, vector< RaySceneIntersection > &intersects)
 Perform ray casting to find intersections. More...
 
void handleSubray (int circleStep, double circleStep_rad, Rotation &r1, Scene &scene, double divergenceAngle, NoiseSource< double > &intersectionHandlingNoiseSource, std::map< double, double > &reflections, vector< RaySceneIntersection > &intersects)
 Handle sub-rays along the circle. More...
 
void digestIntersections (std::vector< std::vector< double >> &apMatrix, RandomnessGenerator< double > &randGen, RandomnessGenerator< double > &randGen2, glm::dvec3 &beamDir, std::map< double, double > &reflections, vector< RaySceneIntersection > &intersects)
 Digest intersections found through ray casting. More...
 
void findMaxMinHitDistances (std::map< double, double > &reflections, double &minHitDist_m, double &maxHitDist_m)
 Find min and max hit distances in meters. More...
 
bool initializeFullWaveform (double minHitDist_m, double maxHitDist_m, double &minHitTime_ns, double &maxHitTime_ns, double &nsPerBin, double &distanceThreshold, int &peakIntensityIndex, int &numFullwaveBins)
 Initialize full waveform While the vector is not strictly initialized in this function, necessary variables are computed here. More...
 
void populateFullWaveform (std::map< double, double > &reflections, std::vector< double > &fullwave, double distanceThreshold, double minHitTime_ns, double nsPerBin)
 Populate a previously initialized full waveform vector. More...
 
void digestFullWaveform (std::vector< Measurement > &pointsMeasurement, int &numReturns, std::vector< std::vector< double >> &apMatrix, std::vector< double > &fullwave, vector< RaySceneIntersection > &intersects, glm::dvec3 &beamDir, double nsPerBin, int numFullwaveBins, int peakIntensityIndex, double minHitTime_ns)
 Digest a previously populated full waveform vector, generating measurements. More...
 
void exportOutput (std::vector< double > &fullwave, int &numReturns, std::vector< Measurement > &pointsMeasurement, glm::dvec3 &beamDir, double minHitTime_ns, double maxHitTime_ns, RandomnessGenerator< double > &randGen, RandomnessGenerator< double > &randGen2)
 Export measurements and full waveform data. More...
 
bool detectPeak (int i, int win_size, vector< double > &fullwave)
 Detect full waveform peaks.
 
double calcEmmitedPower (double radius, double targetRange)
 Compute the space distribution equation to calculate the beam energy decreasing the further away from the center.
 
void captureFullWave (std::vector< double > &fullwave, int fullwaveIndex, double min_time, double max_time, glm::dvec3 &beamOrigin, glm::dvec3 &beamDir, long gpstime, bool fullWaveNoise, RandomnessGenerator< double > &rg2)
 Capture full wave. More...
 

Private Attributes

std::shared_ptr< FullWaveformPulseDetectorfwDetector
 Full wavevform pulse detector used to handle pulse computation.
 
std::vector< Measurement > * allMeasurements = nullptr
 Vector of all measurements. It can be nullptr, since tracking historical of all measurements might not be requested.
 
std::mutex * allMeasurementsMutex = nullptr
 Mutex to handle concurrent access to vector of all measurements.
 
std::vector< Measurement > * cycleMeasurements = nullptr
 Vector of current cycle measurements. It can be nullptr, since tracking current cycle measurements might noit be requested.
 
std::mutex * cycleMeasurementsMutex = nullptr
 Mutex to handle concurrent access to vector of current cycle measurements.
 
bool writeWaveform
 Flag to specify if write waveform (true) or not (false)
 
bool calcEchowidth
 Flag to specify if calc echo width (true) or not (false)
 

Additional Inherited Members

- Static Public Member Functions inherited from AbstractPulseRunnable
static double _calcReceivedPower (double Pt, double Dr2, double R, double Bt2, double etaSys, double etaAtm, double sigma)
 Compute received power \(P_{r}\). More...
 

Detailed Description

Concrete implementation of abstract pulse runnable to compute full waveform pulses.

See also
AbstractPulseRunnable

Constructor & Destructor Documentation

◆ FullWaveformPulseRunnable()

FullWaveformPulseRunnable::FullWaveformPulseRunnable ( std::shared_ptr< FullWaveformPulseDetector detector,
glm::dvec3  absoluteBeamOrigin,
Rotation  absoluteBeamAttitude,
int  currentPulseNum,
long  currentGpsTime,
bool  writeWaveform,
bool  calcEchowidth,
std::vector< Measurement > *  allMeasurements,
std::mutex *  allMeasurementsMutex,
std::vector< Measurement > *  cycleMeasurements,
std::mutex *  cycleMeasurementsMutex,
unsigned int  legIndex 
)
inline

Member Function Documentation

◆ captureFullWave()

void FullWaveformPulseRunnable::captureFullWave ( std::vector< double > &  fullwave,
int  fullwaveIndex,
double  min_time,
double  max_time,
glm::dvec3 &  beamOrigin,
glm::dvec3 &  beamDir,
long  gpstime,
bool  fullWaveNoise,
RandomnessGenerator< double > &  rg2 
)
private

Capture full wave.

Parameters
fullwaveFull wave vector
fullwaveIndexFull wave index
min_timeMinimum hit time (nanoseconds)
max_timeMaximum hit time (nanoseconds)
beamOriginBeam origin in absolute coordinates
beamDirBeam director vector
gpstimeCurrent GPS time (milliseconds)
fullWaveNoiseflag to specify if noise must be added to the full wave (true) or not (false)
rg2Randomness generator to be used to add noise to the full wave if requested

◆ computeSubrays()

void FullWaveformPulseRunnable::computeSubrays ( Scene scene,
NoiseSource< double > &  intersectionHandlingNoiseSource,
std::map< double, double > &  reflections,
vector< RaySceneIntersection > &  intersects 
)
private

Perform ray casting to find intersections.

Parameters
[in]sceneReference to the scene to perform ray casting over
[out]reflectionsWhere reflections must be stored when a hit is registered
[out]intersectsWhere intersections must be stored when a hit is registered
See also
FullWaveformPulseRunnable::handleSubray

◆ digestFullWaveform()

void FullWaveformPulseRunnable::digestFullWaveform ( std::vector< Measurement > &  pointsMeasurement,
int &  numReturns,
std::vector< std::vector< double >> &  apMatrix,
std::vector< double > &  fullwave,
vector< RaySceneIntersection > &  intersects,
glm::dvec3 &  beamDir,
double  nsPerBin,
int  numFullwaveBins,
int  peakIntensityIndex,
double  minHitTime_ns 
)
private

Digest a previously populated full waveform vector, generating measurements.

Parameters
[out]pointsMeasurementWhere generated measurements will be stored
[out]numReturnsNumber of returns will be stored here
fullwaveFull waveform vector to be digested
See also
FullWaveformPulseRunnable::digestIntersections
FullWaveformPulseRunnable::populateFullWaveform
Measurement

◆ digestIntersections()

void FullWaveformPulseRunnable::digestIntersections ( std::vector< std::vector< double >> &  apMatrix,
RandomnessGenerator< double > &  randGen,
RandomnessGenerator< double > &  randGen2,
glm::dvec3 &  beamDir,
std::map< double, double > &  reflections,
vector< RaySceneIntersection > &  intersects 
)
private

Digest intersections found through ray casting.

Parameters
[in]beamDirBeam normalized director vector
[out]reflectionsWhere reflections must be stored when a hit is registered
[out]intersectsWhere intersections must be stored when a hit is registered
See also
FullWaveformPulseRunnable::computeSubrays
FullWaveformPulseRunnable::findMaxMinHitDistances
FullWaveformPulseRunnable::initializeFullWaveform
FullWaveformPulseRunnable::populateFullWaveform
FullWaveformPulseRunnable::digestFullWaveform
FullWaveformPulseRunnable::exportOutput

◆ exportOutput()

void FullWaveformPulseRunnable::exportOutput ( std::vector< double > &  fullwave,
int &  numReturns,
std::vector< Measurement > &  pointsMeasurement,
glm::dvec3 &  beamDir,
double  minHitTime_ns,
double  maxHitTime_ns,
RandomnessGenerator< double > &  randGen,
RandomnessGenerator< double > &  randGen2 
)
private

Export measurements and full waveform data.

Parameters
[in]fullwaveFull waveform data to export
[in]pointsMeasurementPoint cloud data to export
See also
FullWaveformPulseRunnable::digestIntersections

◆ findMaxMinHitDistances()

void FullWaveformPulseRunnable::findMaxMinHitDistances ( std::map< double, double > &  reflections,
double &  minHitDist_m,
double &  maxHitDist_m 
)
private

Find min and max hit distances in meters.

Parameters
[out]minHitDist_mMin hit distance will be stored here
[out]maxHitDist_mMax hit distance will be stored here
See also
FullWaveformPulseRunnable::digestIntersections

◆ handleSubray()

void FullWaveformPulseRunnable::handleSubray ( int  circleStep,
double  circleStep_rad,
Rotation r1,
Scene scene,
double  divergenceAngle,
NoiseSource< double > &  intersectionHandlingNoiseSource,
std::map< double, double > &  reflections,
vector< RaySceneIntersection > &  intersects 
)
private

Handle sub-rays along the circle.

Parameters
[in]circleStepThe iteration along the circle
[in]circleStep_radAngle in radians corresponding to the iteration
[in]r1Sub-beam rotation into divergence step
[in]divergenceAngleSubray divergence angle in radians
See also
FullWaveformPulseRunnable::computeSubrays

◆ initializeFullWaveform()

bool FullWaveformPulseRunnable::initializeFullWaveform ( double  minHitDist_m,
double  maxHitDist_m,
double &  minHitTime_ns,
double &  maxHitTime_ns,
double &  nsPerBin,
double &  distanceThreshold,
int &  peakIntensityIndex,
int &  numFullwaveBins 
)
private

Initialize full waveform While the vector is not strictly initialized in this function, necessary variables are computed here.

Parameters
[out]nsPerBinThe size of each bin in nano seconds
[out]distanceThresholdLimit distance threshold
[out]peakIntensityIndexIndex of intensity peak
[out]numFullwaveBinsHow many bins are necessary to discretize the full waveform
Returns
True if it is possible to initialize the full waveform, false otherwise.
See also
FullWaveformPulseRunnable::digestIntersections

◆ operator()() [1/2]

void FullWaveformPulseRunnable::operator() ( )
inlineoverridevirtual

Full waveform pulse runnable void functor. It is necessary due to compatibility reasons.

See also
AbstractPulseRunnable::operator()

Implements AbstractPulseRunnable.

◆ operator()() [2/2]

void FullWaveformPulseRunnable::operator() ( std::vector< std::vector< double >> &  apMatrix,
RandomnessGenerator< double > &  randGen,
RandomnessGenerator< double > &  randGen2,
NoiseSource< double > &  intersectionHandlingNoiseSource 
)

Full waveform pulse runnable functor.

Parameters
apMatrixReference to matrix to be used to compute Marquardt fitter
randGenA randomness generator
randGen2Another randomness generator
intersectionHandlingNoiseSourceNoise source to be used at intersection handling if necessary
See also
AbstractPulseRunnable::operator()()

◆ populateFullWaveform()

void FullWaveformPulseRunnable::populateFullWaveform ( std::map< double, double > &  reflections,
std::vector< double > &  fullwave,
double  distanceThreshold,
double  minHitTime_ns,
double  nsPerBin 
)
private

Populate a previously initialized full waveform vector.

Parameters
[out]fullwaveFull waveform vector to be populated
See also
FullWaveformPulseRunnable::digestIntersections
FullWaveformPulseRunnable::initializeFullWaveform

Member Data Documentation

◆ legIndex

unsigned int FullWaveformPulseRunnable::legIndex = 0

Which leg the FullWaveformPulseRunnable belongs to.

While this attribute is not strictly necessary for the FullWaveformPulseRunnable to do its job, it really helps with tracing and debugging concurrency issues.

For instance, to track what is going on with end of leg FullWaveformPulseRunnable threads while a new leg is being started.

This attribute could be safely removed without degenerating class mechanics. So, if in the future it is not wanted any more, feel free to remove it.


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