Helios++
Helios software for LiDAR simulations
|
Class representing a simulation. More...
#include <Simulation.h>
Public Member Functions | |
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... | |
virtual void | doSimStep () |
Perform computations for current simulation step. | |
virtual void | onLegComplete ()=0 |
Handle leg completion. | |
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 | |
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 |
Protected Attributes | |
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... | |
Friends | |
class | SimulationReporter |
Class representing a simulation.
Simulation::Simulation | ( | int const | parallelizationStrategy, |
std::shared_ptr< PulseThreadPoolInterface > | pulseThreadPoolInterface, | ||
int const | chunkSize, | ||
std::string | fixedGpsTimeStart = "" |
||
) |
Simulation constructor.
pulseThreadPoolInterface | The thread pool to be used for parallel computation during simulation |
double Simulation::calcCurrentGpsTime | ( | ) |
Compute the current GPS time (nanoseconds)
|
inline |
Get the callback frequency. It is, how many steps must elapse between consecutive callbacks.
|
inline |
|
inline |
|
inline |
|
inline |
Get the simulation step loop of the simulation.
|
inline |
Check if simulation is paused (true) or not (false)
|
inline |
Check if simulation is stopped (true) or not (false)
void Simulation::pause | ( | bool | pause | ) |
Pause or unpause the simulation.
pause | True to pause the simulation, false to unpause it |
|
virtual |
Prepare the simulation before starting its main loop.
simFrequency_hz | The simulation frequency in hertz |
|
inline |
Set the new callback frequency.
callbackFrequency | New callback frequency |
void Simulation::setScanner | ( | std::shared_ptr< Scanner > | scanner | ) |
Set scanner for the simulation.
scanner | New scanner for the simulation |
|
inline |
Set simulation frequency.
simFrequency | New simulation frequency (hertz) |
void Simulation::setSimSpeedFactor | ( | double | factor | ) |
Set the simulation speed factor.
Factors less than or equal to 0 will be setted to 0.0001 and factors greater than 10000 will be truncated to 10000.
In consequence, simulation speed factor will always be in interval \([0.0001, 10000]\) when setted through this setter
factor | New simulation speed factor |
|
inline |
Stop the simulation.
NOTICE this method will not stop simulation immediately but when possible without compromising its execution. This means stop will occur in a safe way.
|
protected |
Given fixed time start for GPS time as a string.
Valid formats are either "YYYY-MM-DD hh:mm:ss" or POSIX timestamp.
If it is an empty string "", then it means no fixed GPS time start must be considered
|
protected |
|
protected |
Specify the parallelization strategy.
|
protected |
Shared pointer to the lock used to handle the mutex for simulation pause purposes.
|
protected |
The report to generate reports about simulation.
|
protected |
The time step for GPS time (in nanoseconds)
|
protected |
Pulse task dropper.
|
protected |
Pulse thread pool.