Helios++
Helios software for LiDAR simulations
|
Survey playback class, used to extend simulation functionalities so it can be controlled. More...
#include <SurveyPlayback.h>
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< Leg > | getCurrentLeg () |
Obtain current leg. More... | |
std::shared_ptr< Leg > | getPreviousLeg () |
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... | |
![]() | |
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< Scanner > | getScanner () |
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... | |
SimulationStepLoop & | getStepLoop () |
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< Survey > | mSurvey |
The survey itself. More... | |
shared_ptr< FMSFacade > | fms = nullptr |
Main facade to file management system. | |
![]() | |
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< SimulationCycleCallback > | callback = 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 | |
![]() | |
int | parallelizationStrategy |
Specify the parallelization strategy. More... | |
std::shared_ptr< PulseThreadPoolInterface > | threadPool |
Pulse thread pool. More... | |
PulseTaskDropper | taskDropper |
Pulse task dropper. More... | |
double | mSimSpeedFactor = 1 |
Simulation speed factor. | |
std::shared_ptr< Scanner > | mScanner = 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... | |
Survey playback class, used to extend simulation functionalities so it can be controlled.
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 |
||
) |
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} \]
legElapsedAngle | The elapsed angular distance of the current leg. Noted as \(\theta\). |
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} \]
legElapsedLength | The elapsed L2 spatial distance (euclidean distance, standard vector norm) of the current leg. Noted as \(l\). |
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} \]
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.
legCurrentProgress | Current leg progress |
onGround | Not used at the moment |
legElapsedLength | Elapsed length for current leg |
shared_ptr< Leg > SurveyPlayback::getCurrentLeg | ( | ) |
int SurveyPlayback::getCurrentLegIndex | ( | ) |
Obtain current leg index.
|
inline |
|
inline |
Obtain elapsed time.
|
inline |
Obtain current leg elapsed time.
string SurveyPlayback::getLegOutputPrefix | ( | std::string | format = "%03d" | ) |
Obtain current leg output prefix.
format | The integer format string to handle how many digits use to numerate both strip and leg prefixes |
|
inline |
Obtain current leg progress.
|
inline |
Obtain current leg expected remaining time.
|
inline |
Obtain the leg start time in nanoseconds.
|
inline |
Obtain the number of effective legs.
shared_ptr< Leg > SurveyPlayback::getPreviousLeg | ( | ) |
Obtain the previous leg, if any.
|
inline |
Obtain simulation progress.
|
inline |
Obtain expected remaining time.
string SurveyPlayback::milliToString | ( | long | millis | ) |
Translate milliseconds to time stamp string.
millis |
void SurveyPlayback::prepareOutput | ( | ) |
Prepare output for current leg (measurements, trajectory and fullwave)
void SurveyPlayback::shutdown | ( | ) |
Handle survey playback shutdown.
void SurveyPlayback::startLeg | ( | unsigned int const | legIndex, |
bool const | manual | ||
) |
Start specified leg.
legIndex | Index of leg to start |
manual | Specify if leg initialization must be manual (true) or not (false) |
void SurveyPlayback::startNextLeg | ( | bool | manual | ) |
Start next leg.
manual | Specify if manual leg initialization must be used (true) or not (false) |
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.
legIndex | Index of current leg |
leg | Current leg |
void SurveyPlayback::trackProgress | ( | ) |
Progress tracking and time estimation.