The core class of ARGOS. More...
#include <simulator.h>
Public Member Functions | |
~CSimulator () | |
Class destructor. More... | |
CSpace & | GetSpace () const |
Returns a reference to the simulated space. More... | |
CPhysicsEngine & | GetPhysicsEngine (const std::string &str_id) const |
Returns a reference to a physics engine. More... | |
CPhysicsEngine::TVector & | GetPhysicsEngines () |
Returns the list of currently existing physics engines. More... | |
template<typename T > | |
T & | GetMedium (const std::string &str_id) |
Returns a reference to a medium. More... | |
CMedium::TVector & | GetMedia () |
Returns the list of currently existing media. More... | |
CVisualization & | GetVisualization () |
Returns a reference to the visualization. More... | |
TConfigurationNode & | GetConfigurationRoot () |
Returns a reference to the root node of the parsed XML configuration file. More... | |
CProfiler & | GetProfiler () |
Returns a reference to the profiler. More... | |
bool | IsProfiling () const |
Returns true if ARGoS is being profiled. More... | |
UInt32 | GetRandomSeed () const |
Returns the random seed of the "argos" category of the random seed. More... | |
void | SetRandomSeed (UInt32 un_random_seed) |
Sets the random seed of the "argos" category of the random seed. More... | |
CRandom::CRNG * | GetRNG () |
Returns the random generator of the "argos" category. More... | |
const std::string & | GetExperimentFileName () const |
Returns the name of the XML configuration file parsed by Load(). More... | |
void | SetExperimentFileName (const std::string &str_file_name) |
Sets the name of the XML configuration file parsed by Load(). More... | |
CLoopFunctions & | GetLoopFunctions () |
Returns a reference to the loop functions associated to the current experiment. More... | |
void | SetLoopFunctions (CLoopFunctions &c_loop_functions) |
Asociates loop functions to the current experiment. More... | |
UInt32 | GetMaxSimulationClock () const |
Returns the time limit on this experiment. More... | |
UInt32 | GetNumThreads () const |
Returns the number of threads used during the experiment. More... | |
bool | IsRealTimeClock () const |
Returns true if the clock tick follows the real time. More... | |
void | SetRealTimeClock (bool b_real_time) |
When passed true , the clock tick follows the real time. More... | |
void | Terminate () |
Puts an end to the simulation. More... | |
std::string | GetInstallationDirectory () const |
Returns the base directory in which the ARGoS core was installed. More... | |
TConfigurationNode & | GetConfigForController (const std::string &str_id) |
Returns the XML portion relative to the controller with the given ID. More... | |
void | Load (ticpp::Document &t_tree) |
Loads an already-parsed XML configuration tree. More... | |
void | LoadExperiment () |
Loads the XML configuration file. More... | |
void | Init () |
Initializes the experiment. More... | |
void | Reset () |
Resets the experiment. More... | |
void | Reset (UInt32 un_new_random_seed) |
Resets the experiment. More... | |
void | Destroy () |
Undoes whatever was done by Init(). More... | |
void | Execute () |
Executes the simulation loop. More... | |
void | UpdateSpace () |
Performs an update step of the space. More... | |
bool | IsExperimentFinished () const |
Returns true if the experiment has finished. More... | |
Static Public Member Functions | |
static CSimulator & | GetInstance () |
Returns the instance to the CSimulator class. More... | |
The core class of ARGOS.
Class CSimulator is the core class of ARGOS. CSimulator organises the flow of data coming from the modules of ARGoS and provides the main simulation loop.
Definition at line 62 of file simulator.h.
argos::CSimulator::~CSimulator | ( | ) |
Class destructor.
Definition at line 47 of file simulator.cpp.
void argos::CSimulator::Destroy | ( | ) |
Undoes whatever was done by Init().
Definition at line 217 of file simulator.cpp.
void argos::CSimulator::Execute | ( | ) |
Executes the simulation loop.
Definition at line 273 of file simulator.cpp.
TConfigurationNode & argos::CSimulator::GetConfigForController | ( | const std::string & | str_id | ) |
Returns the XML portion relative to the controller with the given ID.
Definition at line 95 of file simulator.cpp.
|
inline |
Returns a reference to the root node of the parsed XML configuration file.
Definition at line 166 of file simulator.h.
|
inline |
Returns the name of the XML configuration file parsed by Load().
Definition at line 219 of file simulator.h.
|
inline |
Returns the base directory in which the ARGoS core was installed.
Usually it is /usr
or /usr/local
.
Definition at line 292 of file simulator.h.
|
static |
Returns the instance to the CSimulator class.
Since CSimulator is a singleton, the instance is created at the first call of this function and returned thereafter.
Definition at line 78 of file simulator.cpp.
|
inline |
Returns a reference to the loop functions associated to the current experiment.
Definition at line 236 of file simulator.h.
|
inline |
Returns the time limit on this experiment.
Definition at line 252 of file simulator.h.
|
inline |
Returns the list of currently existing media.
Definition at line 149 of file simulator.h.
|
inline |
Returns a reference to a medium.
str_id | The id of the wanted medium. |
Definition at line 129 of file simulator.h.
|
inline |
Returns the number of threads used during the experiment.
Definition at line 260 of file simulator.h.
CPhysicsEngine & argos::CSimulator::GetPhysicsEngine | ( | const std::string & | str_id | ) | const |
Returns a reference to a physics engine.
str_id | The id of the wanted physics engine. |
Definition at line 86 of file simulator.cpp.
|
inline |
Returns the list of currently existing physics engines.
Definition at line 119 of file simulator.h.
|
inline |
Returns a reference to the profiler.
Definition at line 174 of file simulator.h.
|
inline |
Returns the random seed of the "argos" category of the random seed.
Definition at line 191 of file simulator.h.
|
inline |
Returns the random generator of the "argos" category.
Definition at line 210 of file simulator.h.
|
inline |
Returns a reference to the simulated space.
Definition at line 104 of file simulator.h.
|
inline |
Returns a reference to the visualization.
Definition at line 157 of file simulator.h.
void argos::CSimulator::Init | ( | ) |
Initializes the experiment.
It works on the assumption that method LoadExperiment() has been called already.
Definition at line 132 of file simulator.cpp.
bool argos::CSimulator::IsExperimentFinished | ( | ) | const |
Returns true
if the experiment has finished.
The experiment is considered finished when at least one of these conditions holds true:
true
. true
if the experiment has finished. Definition at line 288 of file simulator.cpp.
|
inline |
Returns true
if ARGoS is being profiled.
true
if ARGoS is being profiled. Definition at line 182 of file simulator.h.
|
inline |
Returns true
if the clock tick follows the real time.
By default, this flag is false
.
Definition at line 268 of file simulator.h.
void argos::CSimulator::Load | ( | ticpp::Document & | t_tree | ) |
Loads an already-parsed XML configuration tree.
The tree should have the same structure as an ARGoS file. The variable m_tConfigurationRoot is set here.
Definition at line 106 of file simulator.cpp.
void argos::CSimulator::LoadExperiment | ( | ) |
Loads the XML configuration file.
The XML configuration file is parsed by this function. The variable m_tConfigurationRoot is set here.
Definition at line 119 of file simulator.cpp.
void argos::CSimulator::Reset | ( | ) |
Resets the experiment.
Restores the state of the experiment right after Init() and before any step is executed.
Definition at line 179 of file simulator.cpp.
|
inline |
Resets the experiment.
Restores the state of the experiment right after Init() and before any step is executed. This variant changes the random seed to allow for resetting the experiment to a different state. This method is useful, for instance, when embedding ARGoS in an optimization algorithm, and multiple, different runs of an experiment must be executed. This method is faster than destroying and recreating the experiment with a different seed, but it is functionally equivalent.
un_new_random_seed | The new random seed. |
Definition at line 337 of file simulator.h.
|
inline |
Sets the name of the XML configuration file parsed by Load().
str_file_name | The name of the XML configuration file parsed by Load(). |
Definition at line 228 of file simulator.h.
|
inline |
Asociates loop functions to the current experiment.
c_loop_functions | A reference to the loop functions to associate to the current experiment. |
Definition at line 244 of file simulator.h.
|
inline |
Sets the random seed of the "argos" category of the random seed.
un_random_seed | sets random seed of the "argos" category of the random seed. |
Definition at line 200 of file simulator.h.
|
inline |
When passed true
, the clock tick follows the real time.
b_real_time | true to make the clock tick follow the real time; false otherwise. |
Definition at line 276 of file simulator.h.
|
inline |
Puts an end to the simulation.
Definition at line 283 of file simulator.h.
void argos::CSimulator::UpdateSpace | ( | ) |
Performs an update step of the space.
Definition at line 280 of file simulator.cpp.