Helios++
Helios software for LiDAR simulations
|
Base abstract class for pulse runnables. More...
#include <AbstractPulseRunnable.h>
Public Member Functions | |
AbstractPulseRunnable (std::shared_ptr< Scanner > const scanner, SimulatedPulse const &pulse) | |
Base constructor for pulse runnables. More... | |
virtual void | initialize () |
Initialize pending attributes of the abstract pulse runnable before doing further computations. 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 | applyMeasurementErrorDirectly (RandomnessGenerator< double > &rg, double &distance, glm::dvec3 &beamOrigin, glm::dvec3 &beamDirection) |
Apply error to received measurement. More... | |
void | applyMeasurementErrorFromExpr (RandomnessGenerator< double > &rg, double &distance, glm::dvec3 &beamOrigin, glm::dvec3 &beamDirection) |
Apply error to received measurement. More... | |
![]() | |
virtual void | operator() ()=0 |
Pulse task void functor. It is necessary due to compatibility reasons. | |
virtual void | operator() (std::vector< std::vector< double >> &apMatrix, RandomnessGenerator< double > &randGen, RandomnessGenerator< double > &randGen2, NoiseSource< double > &intersectionHandlingNoiseSource)=0 |
Pulse task runnable functor. More... | |
Public Attributes | |
std::shared_ptr< Scanner > | scanner = nullptr |
Scanner used to simulate the pulse. | |
std::shared_ptr< AbstractDetector > | detector = nullptr |
Detector used to simulate pulse. | |
SimulatedPulse | pulse |
The definition of the pulse to be simulated. | |
Scene & | scene |
Reference to the scene that is being scanned. | |
std::function< void(RandomnessGenerator< double > &rg, double &distance, glm::dvec3 &beamOrigin, glm::dvec3 &beamDirection)> | applyMeasurementError |
Function to apply error to received measurement. More... | |
Base abstract class for pulse runnables.
AbstractPulseRunnable::AbstractPulseRunnable | ( | std::shared_ptr< Scanner > const | scanner, |
SimulatedPulse const & | pulse | ||
) |
Base constructor for pulse runnables.
void AbstractPulseRunnable::applyMeasurementErrorDirectly | ( | RandomnessGenerator< double > & | rg, |
double & | distance, | ||
glm::dvec3 & | beamOrigin, | ||
glm::dvec3 & | beamDirection | ||
) |
Apply error to received measurement.
Let \(y\) be the distance with error, \(x\) be the clean distance, and \(\mathcal{N} = \mathcal{N}(\mu=0, \sigma=d_{\mathrm{acc}})\) be a normal distribution with mean 0 and standard deviation equal to the device accuracy ( \(d_{\mathrm{acc}}\)). But then, the distance with error can be determined as follows:
\[ y = x + \mathcal{N} \]
rg | RandomnessGenerator to be used to apply error to the measure directly from a normal distribution |
distance | Reference to the distance where error shall be applied |
beamOrigin | Reference to the beam originWaypoint where error shall be applied @bream beamDirection Reference to the beam direction where error shall be applied |
void AbstractPulseRunnable::applyMeasurementErrorFromExpr | ( | RandomnessGenerator< double > & | rg, |
double & | distance, | ||
glm::dvec3 & | beamOrigin, | ||
glm::dvec3 & | beamDirection | ||
) |
Apply error to received measurement.
Let \(y\) be the distance with error, \(x\) be the clean distance, and \(\mathcal{N} = \mathcal{N}(\mu=0, \sigma=d_{\mathrm{acc}})\) be a normal distribution with mean \(0\) and standard deviation equal to the device accuracy ( \(d_{\mathrm{acc}}\)). But then, the distance with error can be determined as follows:
\[ y = x + \mathcal{N} f(x) \]
In the above equation, \(f(x)\) is a given expression. For instance, it is possible to define a distance dependent error in parts per million \(d_{ppm}\):
\[ \begin{split} y = &\; x + \frac{\mathcal{N}}{d_\mathrm{acc}} \left( d_{\mathrm{acc}} + x d_{\mathrm{ppm}} 10^{-6} \right) \\ = &\; x + \mathcal{N} \left( 1 + d_{\mathrm{acc}}^{-1} x d_{\mathrm{ppm}} 10^{-6} \right) \end{split} \]
More concretely, for the above expression:
\[ f(x) = 1 + \frac{x d_{\mathrm{ppm}} 10^{-6}}{d_{\mathrm{acc}}} \]
For example, let us assume \(d_{\mathrm{acc}} = 0.05\) and \(d_{ppm} = 30\). The expression string representing this would be (note \(t\) must be used as the variable when using UnivarExprTreeNode):
"1 + (t*30*10^(-6))/0.05"
Simplifying to use less operations (more efficient):
"1 + t*0.0006"
Both expressions define the function:
\[ f(x) = 1 + \frac{x \times 30 \times 10^{-6}}{0.05} \]
Continuing the previous example, it is possible to transform the noise to a standard normal distribution with mean \(0\) and standard deviation \(1\) using:
"1/0.05"
Or equivalently:
"20"
The above expression corresponds to the function:
\[ f(x) = \frac{1}{d_{\mathrm{acc}}} \]
rg | RandomnessGenerator to be used to apply error to the measure from a given univariate expression where \(t\) is the clean distance in the expression such that \(t = x\). |
distance | Reference to the distance where error shall be applied |
beamOrigin | Reference to the beam originWaypoint where error shall be applied |
beamDirection | Reference to the beam direction where error shall be applied |
void AbstractPulseRunnable::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.
m | Measurement |
rg | Randomness generator |
allMeasurements | Vector of all measurements to store captured point if requested |
allMeasurementsMutex | Mutex to handle concurrent access to vector of all measurements |
cycleMeasurements | Vector of current cycle measurements to store captured point if requested |
cycleMeasurementsMutex | Mutex to handle concurrent access to vector of current cycle measurements |
|
virtual |
Initialize pending attributes of the abstract pulse runnable before doing further computations.
NOTE that this method alleviates the burden of the sequential thread by supporting deferred initialization whenever possible.
Reimplemented in FullWaveformPulseRunnable.
std::function<void( RandomnessGenerator<double> &rg, double &distance, glm::dvec3 &beamOrigin, glm::dvec3 &beamDirection )> AbstractPulseRunnable::applyMeasurementError |
Function to apply error to received measurement.