Helios++
Helios software for LiDAR simulations
SurveyPlayback Class Reference

Survey playback class, used to extend simulation functionalities so it can be controlled. More...

#include <SurveyPlayback.h>

Inheritance diagram for SurveyPlayback:
Collaboration diagram for SurveyPlayback:

Public Member Functions

 SurveyPlayback (std::shared_ptr< Survey > survey, const std::string outputPath, size_t numThreads, bool lasOutput, bool zipOutput, bool exportToFile=true)
 Survey playback constructor. More...
 
void estimateTime (int legCurrentProgress, bool onGround, double legElapsedLength)
 Time estimation for the entire simulation and current leg. NOTICE this function is called from trackProgress. More...
 
void trackProgress ()
 Progress tracking and time estimation. More...
 
virtual void doSimStep ()
 Perform computations for current simulation step.
 
void onLegComplete ()
 Handle leg completion.
 
void startLeg (unsigned int legIndex, bool manual)
 Start specified leg. More...
 
void prepareOutput ()
 Prepare output for current leg (measurements, trajectory and fullwave) More...
 
void clearPointcloudFile ()
 Clear point cloud file for current leg.
 
void startNextLeg (bool manual)
 Start next leg. More...
 
void shutdown ()
 Handle survey playback shutdown. More...
 
std::string milliToString (long millis)
 Translate milliseconds to time stamp string. More...
 
void stopAndTurn (unsigned int legIndex, std::shared_ptr< Leg > leg)
 Perform stop and turn operation to advance to next leg. More...
 
std::shared_ptr< LeggetCurrentLeg ()
 Obtain current leg. More...
 
int getCurrentLegIndex ()
 Obtain current leg index. More...
 
std::string getLegOutputPrefix ()
 Obtain current leg output prefix. More...
 
std::string getCurrentOutputPath ()
 Obtain current output path. More...
 
std::string getTrajectoryOutputPath ()
 Obtain current trajectory output path. More...
 
double getProgress ()
 Obtain simulation progress. More...
 
double getLegProgress ()
 Obtain current leg progress. More...
 
int getNumEffectiveLegs ()
 Obtain the number of effective legs. More...
 
long long getElapsedTime ()
 Obtain elapsed time. More...
 
long getRemainingTime ()
 Obtain expected remaining time. More...
 
long long getLegElapsedTime ()
 Obtain current leg elapsed time. More...
 
long getLegRemainingTime ()
 Obtain current leg expected remaining time. More...
 
- Public Member Functions inherited from Simulation
 Simulation (unsigned numThreads, double deviceAccuracy)
 Simulation constructor. More...
 
void start ()
 Start the simmulation.
 
void stop ()
 Stop the simulation. More...
 
void pause (bool pause)
 Pause or unpause the simulation. More...
 
void shutdown ()
 Handle simulation shutdown.
 
void setSimSpeedFactor (double factor)
 Set the simulation speed factor. More...
 
double getSimSpeedFactor ()
 Obtain simulation speed factor. More...
 
void setScanner (std::shared_ptr< Scanner > scanner)
 Set scanner for the simulation. More...
 
std::shared_ptr< ScannergetScanner ()
 Obtain simulation scanner. More...
 
bool isPaused ()
 Check if simulation is paused (true) or not (false) More...
 
bool isStopped ()
 Check if simulation is stopped (true) or not (false) More...
 
size_t getSimFrequency ()
 Obtain simulation frequency. More...
 
void setSimFrequency (size_t simFrequency)
 Set simulation frequency. More...
 

Public Attributes

bool mLegStarted = false
 Flag to specify if leg has been started (true) or not (false)
 
bool lasOutput = false
 Flag to specify if LAS format must be used for the output (true) or not (false)
 
bool zipOutput = false
 Flag to specify if output must be zipped (true) or not (false)
 
std::shared_ptr< SurveymSurvey
 The survey itself. More...
 
std::string mOutputFilePathString = ""
 Path to output file.
 
std::string mFormatString = "%03d"
 Output format string. It is not used at the moment and might be removed in the future. More...
 
- Public Attributes inherited from Simulation
unsigned int mCurrentLegIndex = 0
 Index of leg at current simulation stage.
 
bool exportToFile = true
 Flag specifying if simulation output must be exported to a file (true) or not (false)
 
bool exitAtEnd = false
 Flag specifying if simulation must end when current leg has been completed (true) or not (false)
 
bool finished = false
 Flag specifying if simulation has finished (true) or not (false)
 
std::shared_ptr< MeasurementsBuffermbuffer = NULL
 
std::shared_ptr< SimulationCycleCallbackcallback = nullptr
 

Private Attributes

const std::string outputPath
 Root output path.
 
int numEffectiveLegs = 0
 Number of effective legs.
 
double elapsedLength = 0
 Currently elapsed length. It can be understood as the summation of all traveled legs.
 
double progress = 0
 Survey simulation progress tracking.
 
double legProgress = 0
 Progress tracking for current leg.
 
long legStartTime_ns = 0
 Time (nanoseconds) when the leg started.
 
long elapsedTime_ms = 0
 Elapsed time (milliseconds) since survey simulation started.
 
long remainingTime_ms = 0
 Expected remaining time (milliseconds) for survey simulation.
 
long legElapsedTime_ms = 0
 Elapsed time (milliseconds) since current leg started.
 
long legRemainingTime_ms = 0
 Expected remaining time (milliseconds) for current leg completion.
 

Additional Inherited Members

- Protected Attributes inherited from Simulation
unsigned numSysThreads = std::thread::hardware_concurrency()
 Number of threads available in the system.
 
thread_pool threadPool
 Thread pool. More...
 
double mSimSpeedFactor = 1
 Simulation speed factor.
 
std::shared_ptr< ScannermScanner = NULL
 Scanner used by the simulation. More...
 
size_t simFrequency = 0
 Simulation frequency. If it is 0 then no pause is possible.
 
std::mutex mutex
 Mutex to handle simulation pause and iterations on a multi threading context.
 
std::condition_variable condvar
 Condition variable tu handle simulation iterations on a multi threading context.
 
std::shared_ptr< std::unique_lock< std::mutex > > pauseLock = nullptr
 Shared pointer to the lock used to handle the mutex for simulation pause purposes. More...
 
bool mStopped = false
 Flag specifying if the simulation has been stopped (true) or not (false)
 
bool mPaused = false
 Flag specifying if the simulation has been paused (true) or not (false)
 
long timeStart_ms = 0
 Time corresponding to simulation start (milliseconds)
 
- Static Protected Attributes inherited from Simulation
static const long NANOSECONDS_PER_SECOND = 1000000000
 How many nanoseconds there are in a second.
 

Detailed Description

Survey playback class, used to extend simulation functionalities so it can be controlled.

See also
Simulation

Constructor & Destructor Documentation

◆ SurveyPlayback()

SurveyPlayback::SurveyPlayback ( std::shared_ptr< Survey survey,
const std::string  outputPath,
size_t  numThreads,
bool  lasOutput,
bool  zipOutput,
bool  exportToFile = true 
)

Survey playback constructor.

Parameters
surveyThe survey itself
outputPathRoot output path
numThreadsNumber of threads to be used
lasOutputFlag to specify LAS format for the output (true) or not (false)
zipOutputFlag to specify if output must be zipped (true) or not (false)
exportToFileFlag to specify if output must be written to a file (true) or not (false)
See also
SurveyPlayback::lasOutput
SurveyPlayback::zipOutput
SurveyPlayback::outputPath
Survey

Member Function Documentation

◆ estimateTime()

void SurveyPlayback::estimateTime ( int  legCurrentProgress,
bool  onGround,
double  legElapsedLength 
)

Time estimation for the entire simulation and current leg. NOTICE this function is called from trackProgress.

Parameters
legCurrentProgressCurrent leg progress
onGroundNot used at the moment
legElapsedLengthElapsed length for current leg
See also
SurveyPlayback::trackProgress

◆ getCurrentLeg()

shared_ptr< Leg > SurveyPlayback::getCurrentLeg ( )

Obtain current leg.

Returns
Current leg
See also
Leg

◆ getCurrentLegIndex()

int SurveyPlayback::getCurrentLegIndex ( )

Obtain current leg index.

Returns
Current leg index

◆ getCurrentOutputPath()

string SurveyPlayback::getCurrentOutputPath ( )

Obtain current output path.

Returns
Current output path

◆ getElapsedTime()

long long SurveyPlayback::getElapsedTime ( )
inline

Obtain elapsed time.

Returns
Elapsed time (milliseconds)

◆ getLegElapsedTime()

long long SurveyPlayback::getLegElapsedTime ( )
inline

Obtain current leg elapsed time.

Returns
Current leg elapsed time (milliseconds)

◆ getLegOutputPrefix()

string SurveyPlayback::getLegOutputPrefix ( )

Obtain current leg output prefix.

Returns
Current leg output prefix

◆ getLegProgress()

double SurveyPlayback::getLegProgress ( )
inline

Obtain current leg progress.

Returns
Current leg progress

◆ getLegRemainingTime()

long SurveyPlayback::getLegRemainingTime ( )
inline

Obtain current leg expected remaining time.

Returns
Current leg expected remaining time (milliseconds)

◆ getNumEffectiveLegs()

int SurveyPlayback::getNumEffectiveLegs ( )
inline

Obtain the number of effective legs.

Returns
Number of effective legs

◆ getProgress()

double SurveyPlayback::getProgress ( )
inline

Obtain simulation progress.

Returns
Simulation progress

◆ getRemainingTime()

long SurveyPlayback::getRemainingTime ( )
inline

Obtain expected remaining time.

Returns
Expected remaining time (milliseconds)

◆ getTrajectoryOutputPath()

string SurveyPlayback::getTrajectoryOutputPath ( )

Obtain current trajectory output path.

Returns
Current trajectory output path

◆ milliToString()

string SurveyPlayback::milliToString ( long  millis)

Translate milliseconds to time stamp string.

Parameters
millis
Returns
Time stamp string corresponding to given milliseconds. Its format is "DD HH:MM:SS"

◆ prepareOutput()

void SurveyPlayback::prepareOutput ( )

Prepare output for current leg (measurements, trajectory and fullwave)

See also
SyncFileWriter

◆ shutdown()

void SurveyPlayback::shutdown ( )

Handle survey playback shutdown.

See also
Simulation::shutdown
Scanner::AbstractDetector

◆ startLeg()

void SurveyPlayback::startLeg ( unsigned int  legIndex,
bool  manual 
)

Start specified leg.

Parameters
legIndexIndex of leg to start
manualSpecify if leg initialization must be manual (true) or not (false)
See also
Platform::initLeg
Platform::initLegManual

◆ startNextLeg()

void SurveyPlayback::startNextLeg ( bool  manual)

Start next leg.

Parameters
manualSpecify if manual leg initialization must be used (true) or not (false)
See also
Platform::initLeg
Platform::initLegManual

◆ stopAndTurn()

void SurveyPlayback::stopAndTurn ( unsigned int  legIndex,
std::shared_ptr< Leg leg 
)

Perform stop and turn operation to advance to next leg.

Notice this operation is only supported for HelicopterPlatform. Trying to use it with other platforms leads to undefined behaviors and should be avoided.

Parameters
legIndexIndex of current leg
legCurrent leg
See also
Platform::stopAndTurn
HelicopterPlatform

◆ trackProgress()

void SurveyPlayback::trackProgress ( )

Progress tracking and time estimation.

See also
SurveyPlayback::estimateTime

Member Data Documentation

◆ mFormatString

std::string SurveyPlayback::mFormatString = "%03d"

Output format string. It is not used at the moment and might be removed in the future.

Deprecated:
mFormatString can be considered as deprecated

◆ mSurvey

std::shared_ptr<Survey> SurveyPlayback::mSurvey

The survey itself.

See also
Survey

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