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 
15 class SurveyPlayback : public Simulation {
16 
17 public:
18  // *** ATTRIBUTES *** //
19  // ******************** //
23  bool mLegStarted = false;
28  bool lasOutput = false;
32  bool zipOutput = false;
33 
38  std::shared_ptr<Survey> mSurvey;
39 
43  std::string mOutputFilePathString = "";
50  std::string mFormatString = "%03d";
51 
52 private:
56  const std::string outputPath;
57 
61  int numEffectiveLegs = 0; // = -1 leg if survey !onGround
66  double elapsedLength = 0; // Sum of legs length traveled
70  double progress = 0;
74  double legProgress = 0;
78  long legStartTime_ns = 0;
82  long elapsedTime_ms = 0;
86  long remainingTime_ms = 0;
95 
96 public:
97  // *** CONSTRUCTION / DESTRUCTION *** //
98  // ************************************ //
116  std::shared_ptr<Survey> survey,
117  const std::string outputPath,
118  size_t numThreads,
119  bool lasOutput,
120  bool zipOutput,
121  bool exportToFile=true
122  );
123 
124 
125  // *** M E T H O D S *** //
126  // *********************** //
135  void estimateTime(
136  int legCurrentProgress,
137  bool onGround,
138  double legElapsedLength
139  );
144  void trackProgress();
148  virtual void doSimStep();
152  void onLegComplete();
161  void startLeg(unsigned int legIndex, bool manual);
167  void prepareOutput();
171  void clearPointcloudFile();
179  void startNextLeg(bool manual);
185  void shutdown();
193  std::string milliToString(long millis);
206  void stopAndTurn(unsigned int legIndex, std::shared_ptr<Leg> leg);
207 
208 
209  // *** GETTERS and SETTERS *** //
210  // ***************************** //
216  std::shared_ptr<Leg> getCurrentLeg();
221  int getCurrentLegIndex();
226  std::string getLegOutputPrefix();
231  std::string getCurrentOutputPath();
236  std::string getTrajectoryOutputPath();
237 
242  double getProgress() {return this->progress;}
243 
248  double getLegProgress() {return this->legProgress;}
249 
254  int getNumEffectiveLegs() {return this->numEffectiveLegs;}
255 
260  long long getElapsedTime() {return this->elapsedTime_ms;}
261 
266  long getRemainingTime() {return this->remainingTime_ms;}
267 
272  long long getLegElapsedTime() {return this->legElapsedTime_ms;}
278 };
double getLegProgress()
Obtain current leg progress.
Definition: SurveyPlayback.h:248
void shutdown()
Handle survey playback shutdown.
Definition: SurveyPlayback.cpp:306
double getProgress()
Obtain simulation progress.
Definition: SurveyPlayback.h:242
std::string mFormatString
Output format string. It is not used at the moment and might be removed in the future.
Definition: SurveyPlayback.h:50
long getRemainingTime()
Obtain expected remaining time.
Definition: SurveyPlayback.h:266
long legElapsedTime_ms
Elapsed time (milliseconds) since current leg started.
Definition: SurveyPlayback.h:90
std::string mOutputFilePathString
Path to output file.
Definition: SurveyPlayback.h:43
double elapsedLength
Currently elapsed length. It can be understood as the summation of all traveled legs.
Definition: SurveyPlayback.h:66
double progress
Survey simulation progress tracking.
Definition: SurveyPlayback.h:70
Class representing a simulation.
Definition: Simulation.h:17
long legRemainingTime_ms
Expected remaining time (milliseconds) for current leg completion.
Definition: SurveyPlayback.h:94
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:91
long remainingTime_ms
Expected remaining time (milliseconds) for survey simulation.
Definition: SurveyPlayback.h:86
std::string getCurrentOutputPath()
Obtain current output path.
Definition: SurveyPlayback.cpp:191
int getNumEffectiveLegs()
Obtain the number of effective legs.
Definition: SurveyPlayback.h:254
long legStartTime_ns
Time (nanoseconds) when the leg started.
Definition: SurveyPlayback.h:78
long getLegRemainingTime()
Obtain current leg expected remaining time.
Definition: SurveyPlayback.h:277
void stopAndTurn(unsigned int legIndex, std::shared_ptr< Leg > leg)
Perform stop and turn operation to advance to next leg.
Definition: SurveyPlayback.cpp:321
bool zipOutput
Flag to specify if output must be zipped (true) or not (false)
Definition: SurveyPlayback.h:32
int getCurrentLegIndex()
Obtain current leg index.
Definition: SurveyPlayback.cpp:180
void startLeg(unsigned int legIndex, bool manual)
Start specified leg.
Definition: SurveyPlayback.cpp:220
std::string getLegOutputPrefix()
Obtain current leg output prefix.
Definition: SurveyPlayback.cpp:184
std::string getTrajectoryOutputPath()
Obtain current trajectory output path.
Definition: SurveyPlayback.cpp:203
long long getElapsedTime()
Obtain elapsed time.
Definition: SurveyPlayback.h:260
std::string milliToString(long millis)
Translate milliseconds to time stamp string.
Definition: SurveyPlayback.cpp:311
bool mLegStarted
Flag to specify if leg has been started (true) or not (false)
Definition: SurveyPlayback.h:23
bool exportToFile
Flag specifying if simulation output must be exported to a file (true) or not (false) ...
Definition: Simulation.h:94
void prepareOutput()
Prepare output for current leg (measurements, trajectory and fullwave)
Definition: SurveyPlayback.cpp:354
Survey playback class, used to extend simulation functionalities so it can be controlled.
Definition: SurveyPlayback.h:15
void startNextLeg(bool manual)
Start next leg.
Definition: SurveyPlayback.cpp:289
int numEffectiveLegs
Number of effective legs.
Definition: SurveyPlayback.h:61
virtual void doSimStep()
Perform computations for current simulation step.
Definition: SurveyPlayback.cpp:153
const std::string outputPath
Root output path.
Definition: SurveyPlayback.h:56
void clearPointcloudFile()
Clear point cloud file for current leg.
Definition: SurveyPlayback.cpp:390
std::shared_ptr< Leg > getCurrentLeg()
Obtain current leg.
Definition: SurveyPlayback.cpp:171
void onLegComplete()
Handle leg completion.
Definition: SurveyPlayback.cpp:211
long long getLegElapsedTime()
Obtain current leg elapsed time.
Definition: SurveyPlayback.h:272
double legProgress
Progress tracking for current leg.
Definition: SurveyPlayback.h:74
bool lasOutput
Flag to specify if LAS format must be used for the output (true) or not (false)
Definition: SurveyPlayback.h:28
SurveyPlayback(std::shared_ptr< Survey > survey, const std::string outputPath, size_t numThreads, bool lasOutput, bool zipOutput, bool exportToFile=true)
Survey playback constructor.
Definition: SurveyPlayback.cpp:23
long elapsedTime_ms
Elapsed time (milliseconds) since survey simulation started.
Definition: SurveyPlayback.h:82
void trackProgress()
Progress tracking and time estimation.
Definition: SurveyPlayback.cpp:133
std::shared_ptr< Survey > mSurvey
The survey itself.
Definition: SurveyPlayback.h:38