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, 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. 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...
 
int estimateSpatialLegProgress (double const legElapsedLength)
 Estimate the leg progress from linear space progress. More...
 
int estimateAngularLegProgress (double const legElapsedAngle)
 Estimate leg progress from angular progress. More...
 
int estimateTemporalLegProgress ()
 Estimate leg progress from temporal progress. 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 const legIndex, bool const 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...
 
std::shared_ptr< LeggetPreviousLeg ()
 Obtain the previous leg, if any. More...
 
int getCurrentLegIndex ()
 Obtain current leg index. More...
 
std::string getLegOutputPrefix (std::string format="%03d")
 Obtain current leg output prefix. More...
 
double getProgress ()
 Obtain simulation progress. More...
 
double getLegProgress ()
 Obtain current leg progress. More...
 
int getNumEffectiveLegs ()
 Obtain the number of effective legs. More...
 
std::chrono::nanoseconds getElapsedTime ()
 Obtain elapsed time. More...
 
double getElapsedLength ()
 Obtain elapsed length. More...
 
long getRemainingTime ()
 Obtain expected remaining time. More...
 
std::chrono::nanoseconds getLegStartTime ()
 Obtain the leg start time in nanoseconds. More...
 
std::chrono::nanoseconds getLegElapsedTime ()
 Obtain current leg elapsed time. More...
 
long getLegRemainingTime ()
 Obtain current leg expected remaining time. More...
 
- Public Member Functions inherited from Simulation
 Simulation (int const parallelizationStrategy, std::shared_ptr< PulseThreadPoolInterface > pulseThreadPoolInterface, int const chunkSize, std::string fixedGpsTimeStart="")
 Simulation constructor. More...
 
virtual void prepareSimulation (int simFrequency_hz)
 Prepare the simulation before starting its main loop. 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.
 
double calcCurrentGpsTime ()
 Compute the current GPS time (nanoseconds) More...
 
void setSimSpeedFactor (double factor)
 Set the simulation speed factor. More...
 
double getSimSpeedFactor () const
 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 () const
 Check if simulation is paused (true) or not (false) More...
 
bool isStopped () const
 Check if simulation is stopped (true) or not (false) More...
 
size_t getSimFrequency () const
 Obtain simulation frequency. More...
 
void setSimFrequency (size_t const simFrequency)
 Set simulation frequency. More...
 
size_t getCallbackFrequency () const
 Get the callback frequency. It is, how many steps must elapse between consecutive callbacks. More...
 
void setCallbackFrequency (size_t const callbackFrequency)
 Set the new callback frequency. More...
 
SimulationStepLoopgetStepLoop ()
 Get the simulation step loop of the simulation. More...
 

Public Attributes

bool mLegStarted = false
 Flag to specify if leg has been started (true) or not (false)
 
std::shared_ptr< SurveymSurvey
 The survey itself. More...
 
shared_ptr< FMSFacadefms = nullptr
 Main facade to file management system.
 
- 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< SimulationCycleCallbackcallback = nullptr
 

Private Attributes

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.
 
std::chrono::nanoseconds legStartTime_ns
 Time (nanoseconds) when the leg started.
 
std::chrono::nanoseconds elapsedTime_ns
 Elapsed time (nanoseconds) since survey simulation started.
 
long long remainingTime_ns
 Expected remaining time (nanoseconds) for survey simulation.
 
std::chrono::nanoseconds legElapsedTime_ns
 Elapsed time (nanoseconds) since current leg started.
 
long long legRemainingTime_ns
 Expected remaining time (nanoseconds) for current leg completion.
 

Additional Inherited Members

- Protected Attributes inherited from Simulation
int parallelizationStrategy
 Specify the parallelization strategy. More...
 
std::shared_ptr< PulseThreadPoolInterfacethreadPool
 Pulse thread pool. More...
 
PulseTaskDropper taskDropper
 Pulse task dropper. More...
 
double mSimSpeedFactor = 1
 Simulation speed factor.
 
std::shared_ptr< ScannermScanner = nullptr
 Scanner used by the simulation. More...
 
SimulationStepLoop stepLoop
 The handler for simulation steps, it also contains the discrete time object that hanldes simulation frequency and time.
 
size_t callbackFrequency = 0
 The callback frequency. It specifies how many steps must elapse between consecutive callbacks.
 
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)
 
std::chrono::nanoseconds timeStart_ns
 Time corresponding to simulation start (nanoseconds)
 
double currentGpsTime_ns = 0
 Time corresponding to simulation start (currentGpsTime in nanoseconds)
 
double stepGpsTime_ns = 0
 The time step for GPS time (in nanoseconds) More...
 
std::string fixedGpsTimeStart = ""
 Given fixed time start for GPS time as a string. More...
 
SimulationReporter reporter
 The report to generate reports about simulation. More...
 

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,
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.

Parameters
surveyThe survey itself
fmsThe main facade of file management system
exportToFileFlag to specify if output must be written to a file (true) or not (false)
See also
Survey
Simulation::Simulation(unsigned, double, size_t)

Member Function Documentation

◆ estimateAngularLegProgress()

int SurveyPlayback::estimateAngularLegProgress ( double const  legElapsedAngle)

Estimate leg progress from angular progress.

Let \(\theta\) be the elapsed angular distance in radians and \(\Delta\) be the difference between end and start angles in radians too. But then, the leg progress \(l_p\) can be estimated these angles as follows:

\[ l_p = 100 \frac{\theta}{\Delta} \]

Parameters
legElapsedAngleThe elapsed angular distance of the current leg. Noted as \(\theta\).
Returns
Leg progress estimated from angular progress.

◆ estimateSpatialLegProgress()

int SurveyPlayback::estimateSpatialLegProgress ( double const  legElapsedLength)

Estimate the leg progress from linear space progress.

Let \(l\) be the leg elapsed length and \(L\) be the total length of the leg. But then, the leg progress \(l_p\) can be estimated from linear space as follows:

\[ l_p = 100 \frac{l}{L} \]

Parameters
legElapsedLengthThe elapsed L2 spatial distance (euclidean distance, standard vector norm) of the current leg. Noted as \(l\).
Returns
Leg progress estimated from linear space progress.

◆ estimateTemporalLegProgress()

int SurveyPlayback::estimateTemporalLegProgress ( )

Estimate leg progress from temporal progress.

Let \(t\) be the current time, \(t_a\) be the starting time point of the simulated time, and \(t_b\) the ending time point of the simulation time. Thus, the leg progress \(l_p\) can be estimated from time as follows:

\[ l_p = 100 \frac{t - t_a}{t_b - t_a} \]

Returns
Leg progress estimated from temporal progress.

◆ 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
SurveyPlayback::getPreviousLeg

◆ getCurrentLegIndex()

int SurveyPlayback::getCurrentLegIndex ( )

Obtain current leg index.

Returns
Current leg index

◆ getElapsedLength()

double SurveyPlayback::getElapsedLength ( )
inline

Obtain elapsed length.

Returns
The elapsed length
See also
SurveyPlayback::elapsedLength

◆ getElapsedTime()

std::chrono::nanoseconds SurveyPlayback::getElapsedTime ( )
inline

Obtain elapsed time.

Returns
Elapsed time (nanoseconds)

◆ getLegElapsedTime()

std::chrono::nanoseconds SurveyPlayback::getLegElapsedTime ( )
inline

Obtain current leg elapsed time.

Returns
Current leg elapsed time (nanoseconds)

◆ getLegOutputPrefix()

string SurveyPlayback::getLegOutputPrefix ( std::string  format = "%03d")

Obtain current leg output prefix.

Parameters
formatThe integer format string to handle how many digits use to numerate both strip and leg prefixes
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 (nanoseconds)

◆ getLegStartTime()

std::chrono::nanoseconds SurveyPlayback::getLegStartTime ( )
inline

Obtain the leg start time in nanoseconds.

Returns
The leg start time (nanoseconds)

◆ getNumEffectiveLegs()

int SurveyPlayback::getNumEffectiveLegs ( )
inline

Obtain the number of effective legs.

Returns
Number of effective legs

◆ getPreviousLeg()

shared_ptr< Leg > SurveyPlayback::getPreviousLeg ( )

Obtain the previous leg, if any.

Returns
Previous leg, nullptr if there is no previous leg
See also
Leg
SurveyPlayback::getCurrentLeg

◆ getProgress()

double SurveyPlayback::getProgress ( )
inline

Obtain simulation progress.

Returns
Simulation progress

◆ getRemainingTime()

long SurveyPlayback::getRemainingTime ( )
inline

Obtain expected remaining time.

Returns
Expected remaining time (nanoseconds)

◆ 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 const  legIndex,
bool const  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

◆ mSurvey

std::shared_ptr<Survey> SurveyPlayback::mSurvey

The survey itself.

See also
Survey

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