Helios++
Helios software for LiDAR simulations
FullWaveformPulseRunnable.h
1 #pragma once
2 
3 #include <util/HeliosException.h>
4 #include "AbstractDetector.h"
5 #include "AbstractPulseRunnable.h"
6 #include "FullWaveformPulseDetector.h"
7 #include "RaySceneIntersection.h"
8 #include "ScenePart.h"
9 #include <noise/RandomnessGenerator.h>
10 #include <scanner/ScanningPulseProcess.h>
11 
12 #include <LadLut.h>
13 
14 #include <vector>
15 
23 public:
24  // *** CONSTANTS *** //
25  // ******************* //
30  static const double eps;
31 private:
32  // *** ATTRIBUTES *** //
33  // ******************** //
37  std::shared_ptr<FullWaveformPulseDetector> fwDetector = nullptr;
38 
39 public:
40 
41  // *** CONSTRUCTION / DESTRUCTION *** //
42  // ************************************ //
50  std::shared_ptr<Scanner> scanner,
51  SimulatedPulse const &pulse
52  ) :
54  {}
55 
56  virtual ~FullWaveformPulseRunnable(){}
57 
58 private:
59  // *** OPERATOR METHODS *** //
60  // ************************** //
70  void initialize() override;
81  void computeSubrays(
82  vector<double> const &tMinMax,
83  NoiseSource<double> &intersectionHandlingNoiseSource,
84  std::map<double, double> &reflections,
85  vector<RaySceneIntersection> &intersects
86  );
98  void handleSubray(
99  vector<double> const &tMinMax,
100  int const circleStep,
101  double const circleStep_rad,
102  Rotation &r1,
103  double const divergenceAngle,
104  NoiseSource<double> &intersectionHandlingNoiseSource,
105  std::map<double, double> &reflections,
106  vector<RaySceneIntersection> &intersects
107  );
122  void digestIntersections(
123  std::vector<std::vector<double>>& apMatrix,
125  RandomnessGenerator<double> &randGen2,
126  glm::dvec3 &beamDir,
127  std::map<double, double> &reflections,
128  vector<RaySceneIntersection> &intersects
129  );
137  std::map<double, double> &reflections,
138  double &minHitDist_m,
139  double &maxHitDist_m
140  );
155  double const minHitDist_m,
156  double const maxHitDist_m,
157  double &minHitTime_ns,
158  double &maxHitTime_ns,
159  double &nsPerBin,
160  double &distanceThreshold,
161  int &peakIntensityIndex,
162  int &numFullwaveBins
163  );
171  std::map<double, double> const &reflections,
172  std::vector<double> &fullwave,
173  double const distanceThreshold,
174  double const minHitTime_ns,
175  double const nsPerBin,
176  int const peakIntensityIndex
177  );
189  void digestFullWaveform(
190  std::vector<Measurement> &pointsMeasurement,
191  int &numReturns,
192  std::vector<std::vector<double>>& apMatrix,
193  std::vector<double> const &fullwave,
194  vector<RaySceneIntersection> const &intersects,
195  glm::dvec3 const &beamDir,
196  double const nsPerBin,
197  int const numFullwaveBins,
198  int const peakIntensityIndex,
199  double const minHitTime_ns
200  );
207  void exportOutput(
208  std::vector<double> &fullwave,
209  int const numReturns,
210  std::vector<Measurement> &pointsMeasurement,
211  glm::dvec3 const &beamDir,
212  double const minHitTime_ns,
213  double const maxHitTime_ns,
216  );
217 
218  // *** ASSISTANCE METHODS *** //
219  // **************************** //
228  virtual shared_ptr<RaySceneIntersection> findIntersection(
229  vector<double> const &tMinMax,
230  glm::dvec3 const &o,
231  glm::dvec3 const &v
232  ) const;
236  bool detectPeak(
237  int const i,
238  int const win_size,
239  vector<double> const &fullwave
240  );
241 
256  void captureFullWave(
257  std::vector<double> & fullwave,
258  int const fullwaveIndex,
259  double const min_time,
260  double const max_time,
261  glm::dvec3 const &beamOrigin,
262  glm::dvec3 const &beamDir,
263  double const gpstime,
264  bool const fullWaveNoise,
266  );
267 
268 public:
269  // *** O P E R A T O R *** //
270  // ************************* //
276  void operator()() override {
277  throw HeliosException(
278  "FullWaveformPulseRunnable operator()() must not be used"
279  );
280  }
291  void operator() (
292  std::vector<std::vector<double>>& apMatrix,
294  RandomnessGenerator<double> &randGen2,
295  NoiseSource<double> &intersectionHandlingNoiseSource
296  ) override;
297 };
Base abstract class for pulse runnables.
Definition: AbstractPulseRunnable.h:18
std::shared_ptr< Scanner > scanner
Scanner used to simulate the pulse.
Definition: AbstractPulseRunnable.h:25
SimulatedPulse pulse
The definition of the pulse to be simulated.
Definition: AbstractPulseRunnable.h:33
Concrete implementation of abstract pulse runnable to compute full waveform pulses.
Definition: FullWaveformPulseRunnable.h:22
bool detectPeak(int const i, int const win_size, vector< double > const &fullwave)
Detect full waveform peaks.
Definition: FullWaveformPulseRunnable.cpp:591
void exportOutput(std::vector< double > &fullwave, int const numReturns, std::vector< Measurement > &pointsMeasurement, glm::dvec3 const &beamDir, double const minHitTime_ns, double const maxHitTime_ns, RandomnessGenerator< double > &randGen, RandomnessGenerator< double > &randGen2)
Export measurements and full waveform data.
Definition: FullWaveformPulseRunnable.cpp:506
void initialize() override
Initialize pending attributes of the full waveform pulse runnable before doing further computations....
Definition: FullWaveformPulseRunnable.cpp:81
bool initializeFullWaveform(double const minHitDist_m, double const 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,...
Definition: FullWaveformPulseRunnable.cpp:341
void computeSubrays(vector< double > const &tMinMax, NoiseSource< double > &intersectionHandlingNoiseSource, std::map< double, double > &reflections, vector< RaySceneIntersection > &intersects)
Perform ray casting to find intersections.
Definition: FullWaveformPulseRunnable.cpp:87
static const double eps
Decimal precision constant for FullWaveformPulseRunnable computations.
Definition: FullWaveformPulseRunnable.h:30
std::shared_ptr< FullWaveformPulseDetector > fwDetector
Full waveform pulse detector used to handle pulse computation.
Definition: FullWaveformPulseRunnable.h:37
void digestFullWaveform(std::vector< Measurement > &pointsMeasurement, int &numReturns, std::vector< std::vector< double >> &apMatrix, std::vector< double > const &fullwave, vector< RaySceneIntersection > const &intersects, glm::dvec3 const &beamDir, double const nsPerBin, int const numFullwaveBins, int const peakIntensityIndex, double const minHitTime_ns)
Digest a previously populated full waveform vector, generating measurements.
Definition: FullWaveformPulseRunnable.cpp:398
void captureFullWave(std::vector< double > &fullwave, int const fullwaveIndex, double const min_time, double const max_time, glm::dvec3 const &beamOrigin, glm::dvec3 const &beamDir, double const gpstime, bool const fullWaveNoise, RandomnessGenerator< double > &rg2)
Capture full wave.
Definition: FullWaveformPulseRunnable.cpp:560
virtual shared_ptr< RaySceneIntersection > findIntersection(vector< double > const &tMinMax, glm::dvec3 const &o, glm::dvec3 const &v) const
Find the intersection between the scene and given ray, if any.
Definition: FullWaveformPulseRunnable.cpp:552
void findMaxMinHitDistances(std::map< double, double > &reflections, double &minHitDist_m, double &maxHitDist_m)
Find min and max hit distances in meters.
Definition: FullWaveformPulseRunnable.cpp:319
void operator()() override
Full waveform pulse runnable void functor. It is necessary due to compatibility reasons.
Definition: FullWaveformPulseRunnable.h:276
void handleSubray(vector< double > const &tMinMax, int const circleStep, double const circleStep_rad, Rotation &r1, double const divergenceAngle, NoiseSource< double > &intersectionHandlingNoiseSource, std::map< double, double > &reflections, vector< RaySceneIntersection > &intersects)
Handle sub-rays along the circle.
Definition: FullWaveformPulseRunnable.cpp:123
void populateFullWaveform(std::map< double, double > const &reflections, std::vector< double > &fullwave, double const distanceThreshold, double const minHitTime_ns, double const nsPerBin, int const peakIntensityIndex)
Populate a previously initialized full waveform vector.
Definition: FullWaveformPulseRunnable.cpp:364
FullWaveformPulseRunnable(std::shared_ptr< Scanner > scanner, SimulatedPulse const &pulse)
Base constructor for full waveform pulse runnable.
Definition: FullWaveformPulseRunnable.h:49
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.
Definition: FullWaveformPulseRunnable.cpp:247
Base class for Helios exceptions.
Definition: HeliosException.h:12
Definition: Rotation.h:80
Class representing a simulated laser pulse.
Definition: SimulatedPulse.h:10