Helios++
Helios software for LiDAR simulations
|
Class representing a simulation. More...
#include <Simulation.h>
Public Member Functions | |
Simulation (unsigned numThreads, double deviceAccuracy) | |
Simulation constructor. 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. | |
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< Scanner > | getScanner () |
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 | |
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< MeasurementsBuffer > | mbuffer = NULL |
std::shared_ptr< SimulationCycleCallback > | callback = nullptr |
Protected Attributes | |
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< Scanner > | mScanner = 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 | |
static const long | NANOSECONDS_PER_SECOND = 1000000000 |
How many nanoseconds there are in a second. | |
Class representing a simulation.
Simulation::Simulation | ( | unsigned | numThreads, |
double | deviceAccuracy | ||
) |
Simulation constructor.
numThreads | Number of threads to be used by the simulation |
deviceAccuracy | Parameter used to handle randomness generation impact on simulation results |
|
inline |
|
inline |
|
inline |
|
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 |
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 |
|
protected |
Shared pointer to the lock used to handle the mutex for simulation pause purposes.
|
protected |
Thread pool.