Helios++
Helios software for LiDAR simulations
SurveyPlayback.h
1 #pragma once
2 
3 #include <memory>
4 #include <string>
5 
6 #include <Simulation.h>
7 #include "Survey.h"
8 #include "typedef.h"
9 
10 namespace helios { namespace filems{ class FMSFacade;}}
12 
18 class SurveyPlayback : public Simulation {
19 
20 public:
21  // *** ATTRIBUTES *** //
22  // ******************** //
26  bool mLegStarted = false;
27 
32  std::shared_ptr<Survey> mSurvey;
36  shared_ptr<FMSFacade> fms = nullptr;
37 
38 private:
42  int numEffectiveLegs = 0; // = -1 leg if survey !onGround
47  double elapsedLength = 0; // Sum of legs length traveled
51  double progress = 0;
55  double legProgress = 0;
59  std::chrono::nanoseconds legStartTime_ns;
63  std::chrono::nanoseconds elapsedTime_ns;
67  long long remainingTime_ns;
71  std::chrono::nanoseconds legElapsedTime_ns;
76 
77 public:
78  // *** CONSTRUCTION / DESTRUCTION *** //
79  // ************************************ //
90  std::shared_ptr<Survey> survey,
91  std::shared_ptr<FMSFacade> fms,
92  int const parallelizationStrategy,
93  std::shared_ptr<PulseThreadPoolInterface> pulseThreadPoolInterface,
94  int const chunkSize,
95  std::string fixedGpsTimeStart,
96  bool const exportToFile=true
97  );
98 
99 
100  // *** M E T H O D S *** //
101  // *********************** //
110  void estimateTime(
111  int legCurrentProgress,
112  bool onGround,
113  double legElapsedLength
114  );
130  int estimateSpatialLegProgress(double const legElapsedLength);
147  int estimateAngularLegProgress(double const legElapsedAngle);
167  void trackProgress();
171  virtual void doSimStep();
175  void onLegComplete();
184  void startLeg(unsigned int const legIndex, bool const manual);
190  void prepareOutput();
194  void clearPointcloudFile();
202  void startNextLeg(bool manual);
208  void shutdown();
216  std::string milliToString(long millis);
229  void stopAndTurn(unsigned int legIndex, std::shared_ptr<Leg> leg);
230 
231 
232  // *** GETTERS and SETTERS *** //
233  // ***************************** //
240  std::shared_ptr<Leg> getCurrentLeg();
247  std::shared_ptr<Leg> getPreviousLeg();
252  int getCurrentLegIndex();
259  std::string getLegOutputPrefix(std::string format="%03d");
260 
265  double getProgress() {return this->progress;}
266 
271  double getLegProgress() {return this->legProgress;}
272 
277  int getNumEffectiveLegs() {return this->numEffectiveLegs;}
278 
283  std::chrono::nanoseconds getElapsedTime() {return this->elapsedTime_ns;}
289  double getElapsedLength() {return this->elapsedLength;}
290 
295  long getRemainingTime() {return this->remainingTime_ns;}
300  std::chrono::nanoseconds getLegStartTime() {return this->legStartTime_ns;}
305  std::chrono::nanoseconds getLegElapsedTime()
306  {return this->legElapsedTime_ns;}
312 };
Class representing a simulation.
Definition: Simulation.h:23
int parallelizationStrategy
Specify the parallelization strategy.
Definition: Simulation.h:35
bool exportToFile
Flag specifying if simulation output must be exported to a file (true) or not (false)
Definition: Simulation.h:140
std::string fixedGpsTimeStart
Given fixed time start for GPS time as a string.
Definition: Simulation.h:123
Survey playback class, used to extend simulation functionalities so it can be controlled.
Definition: SurveyPlayback.h:18
std::chrono::nanoseconds getElapsedTime()
Obtain elapsed time.
Definition: SurveyPlayback.h:283
shared_ptr< FMSFacade > fms
Main facade to file management system.
Definition: SurveyPlayback.h:36
std::chrono::nanoseconds elapsedTime_ns
Elapsed time (nanoseconds) since survey simulation started.
Definition: SurveyPlayback.h:63
double elapsedLength
Currently elapsed length. It can be understood as the summation of all traveled legs.
Definition: SurveyPlayback.h:47
double getElapsedLength()
Obtain elapsed length.
Definition: SurveyPlayback.h:289
std::shared_ptr< Leg > getCurrentLeg()
Obtain current leg.
Definition: SurveyPlayback.cpp:218
long long legRemainingTime_ns
Expected remaining time (nanoseconds) for current leg completion.
Definition: SurveyPlayback.h:75
long long remainingTime_ns
Expected remaining time (nanoseconds) for survey simulation.
Definition: SurveyPlayback.h:67
void estimateTime(int legCurrentProgress, bool onGround, double legElapsedLength)
Time estimation for the entire simulation and current leg. NOTICE this function is called from trackP...
Definition: SurveyPlayback.cpp:107
void trackProgress()
Progress tracking and time estimation.
Definition: SurveyPlayback.cpp:178
long getRemainingTime()
Obtain expected remaining time.
Definition: SurveyPlayback.h:295
std::shared_ptr< Survey > mSurvey
The survey itself.
Definition: SurveyPlayback.h:32
void startLeg(unsigned int const legIndex, bool const manual)
Start specified leg.
Definition: SurveyPlayback.cpp:264
void prepareOutput()
Prepare output for current leg (measurements, trajectory and fullwave)
Definition: SurveyPlayback.cpp:464
void onLegComplete()
Handle leg completion.
Definition: SurveyPlayback.cpp:255
int estimateAngularLegProgress(double const legElapsedAngle)
Estimate leg progress from angular progress.
Definition: SurveyPlayback.cpp:161
void shutdown()
Handle survey playback shutdown.
Definition: SurveyPlayback.cpp:416
virtual void doSimStep()
Perform computations for current simulation step.
Definition: SurveyPlayback.cpp:200
std::chrono::nanoseconds getLegStartTime()
Obtain the leg start time in nanoseconds.
Definition: SurveyPlayback.h:300
std::string getLegOutputPrefix(std::string format="%03d")
Obtain current leg output prefix.
Definition: SurveyPlayback.cpp:236
void clearPointcloudFile()
Clear point cloud file for current leg.
Definition: SurveyPlayback.cpp:489
double getLegProgress()
Obtain current leg progress.
Definition: SurveyPlayback.h:271
void stopAndTurn(unsigned int legIndex, std::shared_ptr< Leg > leg)
Perform stop and turn operation to advance to next leg.
Definition: SurveyPlayback.cpp:431
double legProgress
Progress tracking for current leg.
Definition: SurveyPlayback.h:55
void startNextLeg(bool manual)
Start next leg.
Definition: SurveyPlayback.cpp:399
double getProgress()
Obtain simulation progress.
Definition: SurveyPlayback.h:265
int numEffectiveLegs
Number of effective legs.
Definition: SurveyPlayback.h:42
int getNumEffectiveLegs()
Obtain the number of effective legs.
Definition: SurveyPlayback.h:277
int estimateSpatialLegProgress(double const legElapsedLength)
Estimate the leg progress from linear space progress.
Definition: SurveyPlayback.cpp:156
std::string milliToString(long millis)
Translate milliseconds to time stamp string.
Definition: SurveyPlayback.cpp:421
bool mLegStarted
Flag to specify if leg has been started (true) or not (false)
Definition: SurveyPlayback.h:26
std::shared_ptr< Leg > getPreviousLeg()
Obtain the previous leg, if any.
Definition: SurveyPlayback.cpp:227
SurveyPlayback(std::shared_ptr< Survey > survey, std::shared_ptr< FMSFacade > fms, int const parallelizationStrategy, std::shared_ptr< PulseThreadPoolInterface > pulseThreadPoolInterface, int const chunkSize, std::string fixedGpsTimeStart, bool const exportToFile=true)
Survey playback constructor.
Definition: SurveyPlayback.cpp:28
std::chrono::nanoseconds legStartTime_ns
Time (nanoseconds) when the leg started.
Definition: SurveyPlayback.h:59
std::chrono::nanoseconds legElapsedTime_ns
Elapsed time (nanoseconds) since current leg started.
Definition: SurveyPlayback.h:71
long getLegRemainingTime()
Obtain current leg expected remaining time.
Definition: SurveyPlayback.h:311
std::chrono::nanoseconds getLegElapsedTime()
Obtain current leg elapsed time.
Definition: SurveyPlayback.h:305
double progress
Survey simulation progress tracking.
Definition: SurveyPlayback.h:51
int getCurrentLegIndex()
Obtain current leg index.
Definition: SurveyPlayback.cpp:232
int estimateTemporalLegProgress()
Estimate leg progress from temporal progress.
Definition: SurveyPlayback.cpp:167
The main facade for file management system.
Definition: FMSFacade.h:19