Helios++
Helios software for LiDAR simulations
Simulation Class Referenceabstract

Class representing a simulation. More...

#include <Simulation.h>

Inheritance diagram for Simulation:
Collaboration diagram for Simulation:

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

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
 

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

static const long NANOSECONDS_PER_SECOND = 1000000000
 How many nanoseconds there are in a second.
 

Detailed Description

Class representing a simulation.

Constructor & Destructor Documentation

◆ Simulation()

Simulation::Simulation ( unsigned  numThreads,
double  deviceAccuracy 
)

Simulation constructor.

Parameters
numThreadsNumber of threads to be used by the simulation
deviceAccuracyParameter used to handle randomness generation impact on simulation results

Member Function Documentation

◆ getScanner()

std::shared_ptr<Scanner> Simulation::getScanner ( )
inline

Obtain simulation scanner.

Returns
Simulation scanner
See also
Simulation::mScanner

◆ getSimFrequency()

size_t Simulation::getSimFrequency ( )
inline

Obtain simulation frequency.

Returns
Simulation frequency (hertz)
See also
Simulation::simFrequency

◆ getSimSpeedFactor()

double Simulation::getSimSpeedFactor ( )
inline

Obtain simulation speed factor.

Returns
Simulation speed factor
See also
Simulation::mSimSpeedFactor

◆ isPaused()

bool Simulation::isPaused ( )
inline

Check if simulation is paused (true) or not (false)

Returns
True if simulation is paused, false otherwise
See also
Simulation::mPaused

◆ isStopped()

bool Simulation::isStopped ( )
inline

Check if simulation is stopped (true) or not (false)

Returns
True if simulation is stopped, false otherwise
See also
Simulation::mStopped

◆ pause()

void Simulation::pause ( bool  pause)

Pause or unpause the simulation.

Parameters
pauseTrue to pause the simulation, false to unpause it

◆ setScanner()

void Simulation::setScanner ( std::shared_ptr< Scanner scanner)

Set scanner for the simulation.

Parameters
scannerNew scanner for the simulation
See also
Simulation::mScanner

◆ setSimFrequency()

void Simulation::setSimFrequency ( size_t  simFrequency)
inline

Set simulation frequency.

Parameters
simFrequencyNew simulation frequency (hertz)
See also
Simulation::simFrequency

◆ setSimSpeedFactor()

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

Parameters
factorNew simulation speed factor
See also
Simulation::mSimSpeedFactor

◆ stop()

void Simulation::stop ( )
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.

Member Data Documentation

◆ mScanner

std::shared_ptr<Scanner> Simulation::mScanner = NULL
protected

Scanner used by the simulation.

See also
Scanner

◆ pauseLock

std::shared_ptr<std::unique_lock<std::mutex> > Simulation::pauseLock = nullptr
protected

Shared pointer to the lock used to handle the mutex for simulation pause purposes.

See also
Simulation::mutex

◆ threadPool

thread_pool Simulation::threadPool
protected

Thread pool.

See also
thread_pool

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