ARGoS  3
A parallel, multi-engine simulator for swarm robotics
simulator.cpp
Go to the documentation of this file.
1 
7 #include "simulator.h"
8 
9 #include <iostream>
10 #include <string>
11 #include <sys/time.h>
12 #include <argos3/core/utility/logging/argos_log.h>
13 #include <argos3/core/utility/profiler/profiler.h>
14 #include <argos3/core/utility/string_utilities.h>
15 #include <argos3/core/utility/plugins/dynamic_loading.h>
16 #include <argos3/core/utility/math/rng.h>
17 #include <argos3/core/simulator/space/space_no_threads.h>
18 #include <argos3/core/simulator/space/space_multi_thread_balance_quantity.h>
19 #include <argos3/core/simulator/space/space_multi_thread_balance_length.h>
20 #include <argos3/core/simulator/visualization/default_visualization.h>
21 #include <argos3/core/simulator/physics_engine/physics_engine.h>
22 #include <argos3/core/simulator/loop_functions.h>
23 #include <argos3/core/simulator/entity/composable_entity.h>
24 #include <argos3/core/simulator/entity/embodied_entity.h>
25 
26 namespace argos {
27 
31 #if __cplusplus >= 201103L
32  template <typename T>
33  using auto_ptr = std::unique_ptr<T>;
34 #else
35  using std::auto_ptr;
36 #endif
37 
38  /****************************************/
39  /****************************************/
40 
41  CSimulator::CSimulator() :
42  m_pcVisualization(NULL),
43  m_pcSpace(NULL),
44  m_pcLoopFunctions(NULL),
45  m_unMaxSimulationClock(0),
46  m_bWasRandomSeedSet(false),
47  m_unThreads(0),
48  m_pcProfiler(NULL),
49  m_bHumanReadableProfile(true),
50  m_bRealTimeClock(false),
51  m_bTerminated(false) {}
52 
53  /****************************************/
54  /****************************************/
55 
56  CSimulator::~CSimulator() {
57  if(IsProfiling()) {
58  delete m_pcProfiler;
59  }
60  /* Delete the visualization */
61  if(m_pcVisualization != NULL) delete m_pcVisualization;
62  /* Delete all the media */
63  for(CMedium::TMap::iterator it = m_mapMedia.begin();
64  it != m_mapMedia.end(); ++it) {
65  delete it->second;
66  }
67  m_mapMedia.clear();
68  m_vecMedia.clear();
69  /* Delete all the physics engines */
70  for(CPhysicsEngine::TMap::iterator it = m_mapPhysicsEngines.begin();
71  it != m_mapPhysicsEngines.end(); ++it) {
72  delete it->second;
73  }
74  m_mapPhysicsEngines.clear();
75  m_vecPhysicsEngines.clear();
76  /* Delete the space and the dynamic linking manager */
77  if(m_pcSpace != NULL) {
78  delete m_pcSpace;
79  }
80  /* Get rid of all libraries */
81  CDynamicLoading::UnloadAllLibraries();
82  }
83 
84  /****************************************/
85  /****************************************/
86 
87  CSimulator& CSimulator::GetInstance() {
88  static auto_ptr<CSimulator> pcSimulatorInstance(new CSimulator());
89  return *(pcSimulatorInstance.get());
90  }
91 
92  /****************************************/
93  /****************************************/
94 
95  CPhysicsEngine& CSimulator::GetPhysicsEngine(const std::string& str_id) const {
96  CPhysicsEngine::TMap::const_iterator it = m_mapPhysicsEngines.find(str_id);
97  ARGOS_ASSERT(it != m_mapPhysicsEngines.end(), "Physics engine \"" << str_id << "\" not found.")
98  return *(it->second);
99  }
100 
101  /****************************************/
102  /****************************************/
103 
104  TConfigurationNode& CSimulator::GetConfigForController(const std::string& str_id) {
105  TControllerConfigurationMap::iterator it = m_mapControllerConfig.find(str_id);
106  if(it == m_mapControllerConfig.end()) {
107  THROW_ARGOSEXCEPTION("Can't find XML configuration for controller id \"" << str_id << "\"");
108  }
109  return *(it->second);
110  }
111 
112  /****************************************/
113  /****************************************/
114 
115  void CSimulator::LoadExperiment() {
116  /* Build configuration tree */
117  m_tConfiguration.LoadFile(m_strExperimentConfigFileName);
118  m_tConfigurationRoot = *m_tConfiguration.FirstChildElement();
119  /* Init the experiment */
120  Init();
121  LOG.Flush();
122  LOGERR.Flush();
123  }
124 
125  /****************************************/
126  /****************************************/
127 
128  void CSimulator::Init() {
129  /* General configuration */
130  InitFramework(GetNode(m_tConfigurationRoot, "framework"));
131  /* Initialize controllers */
132  InitControllers(GetNode(m_tConfigurationRoot, "controllers"));
133  /* Create loop functions */
134  if(NodeExists(m_tConfigurationRoot, "loop_functions")) {
135  /* User specified a loop_functions section in the XML */
136  InitLoopFunctions(GetNode(m_tConfigurationRoot, "loop_functions"));
137  }
138  else {
139  /* No loop_functions in the XML */
140  m_pcLoopFunctions = new CLoopFunctions;
141  }
142  /* Physics engines */
143  InitPhysics(GetNode(m_tConfigurationRoot, "physics_engines"));
144  /* Media */
145  InitMedia(GetNode(m_tConfigurationRoot, "media"));
146  /* Space */
147  InitSpace(GetNode(m_tConfigurationRoot, "arena"));
148  /* Call user init function */
149  if(NodeExists(m_tConfigurationRoot, "loop_functions")) {
150  m_pcLoopFunctions->Init(GetNode(m_tConfigurationRoot, "loop_functions"));
151  }
152  /* Physics engines */
153  InitPhysics2();
154  /* Media */
155  InitMedia2();
156  /* Initialise visualization */
157  TConfigurationNodeIterator itVisualization;
158  if(NodeExists(m_tConfigurationRoot, "visualization") &&
159  ((itVisualization = itVisualization.begin(&GetNode(m_tConfigurationRoot, "visualization"))) != itVisualization.end())) {
160  InitVisualization(GetNode(m_tConfigurationRoot, "visualization"));
161  }
162  else {
163  LOG << "[INFO] No visualization selected." << std::endl;
164  m_pcVisualization = new CDefaultVisualization();
165  }
166  /* Start profiling, if needed */
167  if(IsProfiling()) {
168  m_pcProfiler->Start();
169  }
170  }
171 
172  /****************************************/
173  /****************************************/
174 
175  void CSimulator::Reset() {
176  /* Reset terminated flag */
177  m_bTerminated = false;
178  /* if random seed is 0 or is not specified, init with the current timeval */
179  if(m_bWasRandomSeedSet) {
180  CRandom::SetSeedOf("argos", m_unRandomSeed);
181  }
182  else {
183  /* Prepare the default value based on the current clock time */
184  struct timeval sTimeValue;
185  ::gettimeofday(&sTimeValue, NULL);
186  UInt32 unSeed = static_cast<UInt32>(sTimeValue.tv_usec);
187  CRandom::SetSeedOf("argos", unSeed);
188  m_unRandomSeed = unSeed;
189  LOG << "[INFO] Using random seed = " << m_unRandomSeed << std::endl;
190  }
191  CRandom::GetCategory("argos").ResetRNGs();
192  /* Reset the space */
193  m_pcSpace->Reset();
194  /* Reset the media */
195  for(CMedium::TMap::iterator it = m_mapMedia.begin();
196  it != m_mapMedia.end(); ++it) {
197  it->second->Reset();
198  }
199  /* Reset the physics engines */
200  for(CPhysicsEngine::TMap::iterator it = m_mapPhysicsEngines.begin();
201  it != m_mapPhysicsEngines.end(); ++it) {
202  it->second->Reset();
203  }
204  /* Reset the loop functions */
205  m_pcLoopFunctions->Reset();
206  LOG.Flush();
207  LOGERR.Flush();
208  }
209 
210  /****************************************/
211  /****************************************/
212 
213  void CSimulator::Destroy() {
214  /* Call user destroy function */
215  if (m_pcLoopFunctions != NULL) {
216  m_pcLoopFunctions->Destroy();
217  delete m_pcLoopFunctions;
218  m_pcLoopFunctions = NULL;
219  }
220  /* Destroy the visualization */
221  if(m_pcVisualization != NULL) {
222  m_pcVisualization->Destroy();
223  }
224  /* Destroy simulated space */
225  if(m_pcSpace != NULL) {
226  m_pcSpace->Destroy();
227  }
228  /* Destroy media */
229  for(CMedium::TMap::iterator it = m_mapMedia.begin();
230  it != m_mapMedia.end(); ++it) {
231  it->second->Destroy();
232  delete it->second;
233  }
234  m_mapMedia.clear();
235  m_vecMedia.clear();
236  /* Destroy physics engines */
237  for(CPhysicsEngine::TMap::iterator it = m_mapPhysicsEngines.begin();
238  it != m_mapPhysicsEngines.end(); ++it) {
239  it->second->Destroy();
240  delete it->second;
241  }
242  m_mapPhysicsEngines.clear();
243  m_vecPhysicsEngines.clear();
244  /* Get rid of ARGoS category */
245  if(CRandom::ExistsCategory("argos")) {
246  CRandom::RemoveCategory("argos");
247  }
248  /* Free up factory data */
257  /* Stop profiling and flush the data */
258  if(IsProfiling()) {
259  m_pcProfiler->Stop();
260  m_pcProfiler->Flush(m_bHumanReadableProfile);
261  }
262  LOG.Flush();
263  LOGERR.Flush();
264  }
265 
266  /****************************************/
267  /****************************************/
268 
269  void CSimulator::Execute() {
270  m_pcVisualization->Execute();
271  }
272 
273  /****************************************/
274  /****************************************/
275 
276  void CSimulator::UpdateSpace() {
277  /* Update the space */
278  m_pcSpace->Update();
279  }
280 
281  /****************************************/
282  /****************************************/
283 
284  bool CSimulator::IsExperimentFinished() const {
285  /* Check if the simulation must be terminated */
286  if(m_bTerminated) {
287  return true;
288  }
289  /* Check simulation clock */
290  if (m_unMaxSimulationClock > 0 &&
291  m_pcSpace->GetSimulationClock() >= m_unMaxSimulationClock) {
292  return true;
293  }
294  /* Call loop function */
295  return m_pcLoopFunctions->IsExperimentFinished();
296  }
297 
298  /****************************************/
299  /****************************************/
300 
301  void CSimulator::InitFramework(TConfigurationNode& t_tree) {
302  try {
303  /* Parse the 'system' node */
304  if(NodeExists(t_tree, "system")) {
305  TConfigurationNode tSystem;
306  tSystem = GetNode(t_tree, "system");
307  GetNodeAttributeOrDefault(tSystem, "threads", m_unThreads, m_unThreads);
308  if(m_unThreads == 0) {
309  LOG << "[INFO] Not using threads" << std::endl;
310  m_pcSpace = new CSpaceNoThreads();
311  }
312  else {
313  LOG << "[INFO] Using " << m_unThreads << " parallel threads" << std::endl;
314  std::string strThreadingMethod = "balance_quantity";
315  GetNodeAttributeOrDefault(tSystem, "method", strThreadingMethod, strThreadingMethod);
316  if(strThreadingMethod == "balance_quantity") {
317  LOG << "[INFO] Chosen method \"balance_quantity\": threads will be assigned the same"
318  << std::endl
319  << "[INFO] number of tasks, independently of the task length."
320  << std::endl;
321  m_pcSpace = new CSpaceMultiThreadBalanceQuantity();
322  }
323  else if(strThreadingMethod == "balance_length") {
324  LOG << "[INFO] Chosen method \"balance_length\": threads will be assigned different"
325  << std::endl
326  << "[INFO] numbers of tasks, depending on the task length."
327  << std::endl;
328  m_pcSpace = new CSpaceMultiThreadBalanceLength();
329  }
330  else {
331  THROW_ARGOSEXCEPTION("Error parsing the <system> tag. Unknown threading method \"" << strThreadingMethod << "\". Available methods: \"balance_quantity\" and \"balance_length\".");
332  }
333  }
334  }
335  else {
336  LOG << "[INFO] Not using threads" << std::endl;
337  m_pcSpace = new CSpaceNoThreads();
338  }
339  /* Get 'experiment' node */
340  TConfigurationNode tExperiment;
341  tExperiment = GetNode(t_tree, "experiment");
342  /* Parse random seed */
343  /* Buffer to hold the random seed */
344  if(!m_bWasRandomSeedSet)
345  GetNodeAttributeOrDefault(tExperiment,
346  "random_seed",
347  m_unRandomSeed,
348  static_cast<UInt32>(0));
349  /* if random seed is 0 or is not specified, init with the current timeval */
350  if(m_unRandomSeed != 0) {
351  CRandom::CreateCategory("argos", m_unRandomSeed);
352  LOG << "[INFO] Using random seed = " << m_unRandomSeed << std::endl;
353  m_bWasRandomSeedSet = true;
354  }
355  else {
356  /* Prepare the default value based on the current clock time */
357  m_bWasRandomSeedSet = false;
358  struct timeval sTimeValue;
359  ::gettimeofday(&sTimeValue, NULL);
360  UInt32 unSeed = static_cast<UInt32>(sTimeValue.tv_usec);
361  m_unRandomSeed = unSeed;
362  CRandom::CreateCategory("argos", unSeed);
363  LOG << "[INFO] Using random seed = " << unSeed << std::endl;
364  }
365  m_pcRNG = CRandom::CreateRNG("argos");
366  /* Set the simulation clock tick length */
367  UInt32 unTicksPerSec;
368  GetNodeAttribute(tExperiment,
369  "ticks_per_second",
370  unTicksPerSec);
371  CPhysicsEngine::SetSimulationClockTick(1.0 / static_cast<Real>(unTicksPerSec));
372  /* Set the maximum simulation duration (in seconds) */
373  Real fExpLength;
374  GetNodeAttributeOrDefault<Real>(tExperiment,
375  "length",
376  fExpLength,
377  0.0f);
378  m_unMaxSimulationClock = fExpLength * unTicksPerSec;
379  LOG << "[INFO] Total experiment length in clock ticks = "
380  << (m_unMaxSimulationClock ? ToString(m_unMaxSimulationClock) : "unlimited")
381  << std::endl;
382  /* Check for the 'real_time' attribute */
383  GetNodeAttributeOrDefault(tExperiment, "real_time", m_bRealTimeClock, m_bRealTimeClock);
384  if(m_bRealTimeClock) {
385  LOG << "[INFO] Using the real-time clock." << std::endl;
386  }
387  /* Get the profiling tag, if present */
388  if(NodeExists(t_tree, "profiling")) {
389  TConfigurationNode& tProfiling = GetNode(t_tree, "profiling");
390  std::string strFile;
391  GetNodeAttribute(tProfiling, "file", strFile);
392  std::string strFormat;
393  GetNodeAttribute(tProfiling, "format", strFormat);
394  if(strFormat == "human_readable") {
395  m_bHumanReadableProfile = true;
396  }
397  else if(strFormat == "table") {
398  m_bHumanReadableProfile = false;
399  }
400  else {
401  THROW_ARGOSEXCEPTION("Unrecognized profile format \"" << strFormat << "\". Accepted values are \"human_readable\" and \"table\".");
402  }
403  bool bTrunc = true;
404  GetNodeAttributeOrDefault(tProfiling, "truncate_file", bTrunc, bTrunc);
405  m_pcProfiler = new CProfiler(strFile, bTrunc);
406  }
407  }
408  catch(CARGoSException& ex) {
409  THROW_ARGOSEXCEPTION_NESTED("Failed to initialize the simulator. Parse error inside the <framework> tag.", ex);
410  }
411  }
412 
413  /****************************************/
414  /****************************************/
415 
416  void CSimulator::InitLoopFunctions(TConfigurationNode& t_tree) {
417  try {
418  std::string strLibrary, strLabel;
419  GetNodeAttributeOrDefault(t_tree, "library", strLibrary, strLibrary);
420  GetNodeAttribute(t_tree, "label", strLabel);
421  if(! strLibrary.empty()) {
422  CDynamicLoading::LoadLibrary(strLibrary);
423  }
424  m_pcLoopFunctions = CFactory<CLoopFunctions>::New(strLabel);
425  }
426  catch(CARGoSException& ex) {
427  THROW_ARGOSEXCEPTION_NESTED("Error initializing loop functions", ex);
428  }
429  }
430 
431  /****************************************/
432  /****************************************/
433 
434  void CSimulator::InitControllers(TConfigurationNode& t_tree) {
435  /*
436  * Go through controllers, loading the library of each of them
437  * and storing type, id and XML tree of each of them for later use
438  */
439  if(! t_tree.NoChildren()) {
440  try {
441  std::string strLibrary;
442  std::string strId;
444  for(it = it.begin(&t_tree);
445  it != it.end(); ++it) {
446  /* Get controller id */
447  try {
448  GetNodeAttribute(*it, "id", strId);
449  }
450  catch(CARGoSException& ex) {
451  std::string strValue;
452  it->GetValue(&strValue);
453  THROW_ARGOSEXCEPTION_NESTED("Controller type \"" << strValue << "\" has no assigned id.", ex);
454  }
455  /* Bomb out if id is already in map */
456  if(m_mapControllerConfig.find(strId) != m_mapControllerConfig.end()) {
457  THROW_ARGOSEXCEPTION("Controller id \"" << strId << "\" duplicated");
458  }
459  /* Optionally, process "library" attribute if present */
460  if(NodeAttributeExists(*it, "library")) {
461  /* Get library name */
462  GetNodeAttribute(*it, "library", strLibrary);
463  /* Load library */
464  CDynamicLoading::LoadLibrary(strLibrary);
465  }
466  /* Store XML info in map by id */
467  m_mapControllerConfig.insert(std::pair<std::string, TConfigurationNode*>(strId, &(*it)));
468  }
469  }
470  catch(CARGoSException& ex) {
471  THROW_ARGOSEXCEPTION_NESTED("Error initializing controllers", ex);
472  }
473  }
474  }
475 
476  /****************************************/
477  /****************************************/
478 
479  void CSimulator::InitSpace(TConfigurationNode& t_tree) {
480  try {
481  m_pcSpace->Init(t_tree);
482  }
483  catch(CARGoSException& ex) {
484  THROW_ARGOSEXCEPTION_NESTED("Failed to initialize the space.", ex);
485  }
486  }
487 
488  /****************************************/
489  /****************************************/
490 
491  void CSimulator::InitPhysics(TConfigurationNode& t_tree) {
492  try {
493  /* Cycle through the physics engines */
494  TConfigurationNodeIterator itEngines;
495  for(itEngines = itEngines.begin(&t_tree);
496  itEngines != itEngines.end();
497  ++itEngines) {
498  /* Create the physics engine */
499  CPhysicsEngine* pcEngine = CFactory<CPhysicsEngine>::New(itEngines->Value());
500  try {
501  /* Initialize the engine */
502  pcEngine->Init(*itEngines);
503  /* Check that an engine with that ID does not exist yet */
504  if(m_mapPhysicsEngines.find(pcEngine->GetId()) == m_mapPhysicsEngines.end()) {
505  /* Add it to the lists */
506  m_mapPhysicsEngines[pcEngine->GetId()] = pcEngine;
507  m_vecPhysicsEngines.push_back(pcEngine);
508  }
509  else {
510  /* Duplicate id -> error */
511  THROW_ARGOSEXCEPTION("A physics engine with id \"" << pcEngine->GetId() << "\" exists already. The ids must be unique!");
512  }
513  }
514  catch(CARGoSException& ex) {
515  /* Error while executing engine init, destroy what done to prevent memory leaks */
516  pcEngine->Destroy();
517  delete pcEngine;
518  THROW_ARGOSEXCEPTION_NESTED("Error initializing physics engine type \"" << itEngines->Value() << "\"", ex);
519  }
520  }
521  }
522  catch(CARGoSException& ex) {
523  THROW_ARGOSEXCEPTION_NESTED("Failed to initialize the physics engines. Parse error in the <physics_engines> subtree.", ex);
524  }
525  }
526 
527  /****************************************/
528  /****************************************/
529 
530  void CSimulator::InitPhysics2() {
531  try {
532  /* Cycle through the physics engines */
533  CPhysicsEngine::TMap::iterator it;
534  for(it = m_mapPhysicsEngines.begin(); it != m_mapPhysicsEngines.end(); ++it) {
535  CPhysicsEngine& cPhysicsEngine = *(it->second);
536  try {
537  /* Initialize the physicsengine */
538  cPhysicsEngine.PostSpaceInit();
539  }
540  catch(CARGoSException& ex) {
541  /* Error while executing physicsengine post space init, destroy what done to prevent memory leaks */
542  std::ostringstream ossMsg;
543  ossMsg << "Error executing post-space initialization of physics engine \"" << cPhysicsEngine.GetId() << "\"";
544  cPhysicsEngine.Destroy();
545  THROW_ARGOSEXCEPTION_NESTED(ossMsg.str(), ex);
546  }
547  }
548  }
549  catch(CARGoSException& ex) {
550  THROW_ARGOSEXCEPTION_NESTED("Failed to initialize the physics engines. Parse error in the <physics_engines> subtree.", ex);
551  }
552  }
553 
554  /****************************************/
555  /****************************************/
556 
557  void CSimulator::InitMedia(TConfigurationNode& t_tree) {
558  try {
559  /* Cycle through the media */
561  for(itMedia = itMedia.begin(&t_tree);
562  itMedia != itMedia.end();
563  ++itMedia) {
564  /* Create the medium */
565  CMedium* pcMedium = CFactory<CMedium>::New(itMedia->Value());
566  try {
567  /* Initialize the medium */
568  pcMedium->Init(*itMedia);
569  /* Check that an medium with that ID does not exist yet */
570  if(m_mapMedia.find(pcMedium->GetId()) == m_mapMedia.end()) {
571  /* Add it to the lists */
572  m_mapMedia[pcMedium->GetId()] = pcMedium;
573  m_vecMedia.push_back(pcMedium);
574  }
575  else {
576  /* Duplicate id -> error */
577  THROW_ARGOSEXCEPTION("A medium with id \"" << pcMedium->GetId() << "\" exists already. The ids must be unique!");
578  }
579  }
580  catch(CARGoSException& ex) {
581  /* Error while executing medium init, destroy what done to prevent memory leaks */
582  pcMedium->Destroy();
583  delete pcMedium;
584  THROW_ARGOSEXCEPTION_NESTED("Error initializing medium type \"" << itMedia->Value() << "\"", ex);
585  }
586  }
587  }
588  catch(CARGoSException& ex) {
589  THROW_ARGOSEXCEPTION_NESTED("Failed to initialize the media. Parse error in the <media> subtree.", ex);
590  }
591  }
592 
593  /****************************************/
594  /****************************************/
595 
596  void CSimulator::InitMedia2() {
597  try {
598  /* Cycle through the media */
599  CMedium::TMap::iterator it;
600  for(it = m_mapMedia.begin(); it != m_mapMedia.end(); ++it) {
601  CMedium& cMedium = *(it->second);
602  try {
603  /* Initialize the medium */
604  cMedium.PostSpaceInit();
605  }
606  catch(CARGoSException& ex) {
607  /* Error while executing medium post space init, destroy what done to prevent memory leaks */
608  std::ostringstream ossMsg;
609  ossMsg << "Error executing post-space initialization of medium \"" << cMedium.GetId() << "\"";
610  cMedium.Destroy();
611  THROW_ARGOSEXCEPTION_NESTED(ossMsg.str(), ex);
612  }
613  }
614  }
615  catch(CARGoSException& ex) {
616  THROW_ARGOSEXCEPTION_NESTED("Failed to initialize the media. Parse error in the <media> subtree.", ex);
617  }
618  }
619 
620  /****************************************/
621  /****************************************/
622 
623  void CSimulator::InitVisualization(TConfigurationNode& t_tree) {
624  try {
625  /* Consider only the first visualization */
626  TConfigurationNodeIterator itVisualization;
627  itVisualization = itVisualization.begin(&t_tree);
628  /* Create the visualization */
629  m_pcVisualization = CFactory<CVisualization>::New(itVisualization->Value());
630  /* Initialize the visualization */
631  m_pcVisualization->Init(*itVisualization);
632  }
633  catch(CARGoSException& ex) {
634  THROW_ARGOSEXCEPTION_NESTED("Failed to initialize the visualization. Parse error in the <visualization> subtree.", ex);
635  }
636  }
637 
638  /****************************************/
639  /****************************************/
640 
641 }
argos::CDefaultVisualization
Definition: default_visualization.h:21
argos::LOG
CARGoSLog LOG(std::cout, SLogColor(ARGOS_LOG_ATTRIBUTE_BRIGHT, ARGOS_LOG_COLOR_GREEN))
Definition: argos_log.h:179
argos
The namespace containing all the ARGoS related code.
Definition: ci_actuator.h:12
argos::GetNode
TConfigurationNode & GetNode(TConfigurationNode &t_node, const std::string &str_tag)
Given a tree root node, returns the first of its child nodes with the wanted name.
Definition: argos_configuration.h:63
argos::CSimulator
The core class of ARGOS.
Definition: simulator.h:62
argos::LOGERR
CARGoSLog LOGERR(std::cerr, SLogColor(ARGOS_LOG_ATTRIBUTE_BRIGHT, ARGOS_LOG_COLOR_RED))
Definition: argos_log.h:180
argos::TConfigurationNode
ticpp::Element TConfigurationNode
The ARGoS configuration XML node.
Definition: argos_configuration.h:27
argos::CFactory
Basic factory template.
Definition: factory.h:59
argos::CARGoSLog::Flush
void Flush()
Definition: argos_log.h:147
THROW_ARGOSEXCEPTION_NESTED
#define THROW_ARGOSEXCEPTION_NESTED(message, nested)
This macro throws an ARGoS exception with the passed message and nesting the passed exception.
Definition: argos_exception.h:115
argos::TConfigurationNodeIterator
ticpp::Iterator< ticpp::Element > TConfigurationNodeIterator
The iterator for the ARGoS configuration XML node.
Definition: argos_configuration.h:29
THROW_ARGOSEXCEPTION
#define THROW_ARGOSEXCEPTION(message)
This macro throws an ARGoS exception with the passed message.
Definition: argos_exception.h:111
argos::NodeExists
bool NodeExists(TConfigurationNode &t_node, const std::string &str_tag)
Given a tree root node, returns true if one of its child nodes has the wanted name.
Definition: argos_configuration.h:44
argos::CPhysicsEngine
Definition: physics_engine.h:90
argos::CSpaceNoThreads
Definition: space_no_threads.h:22
argos::ToString
std::string ToString(const T &t_value)
Converts the given parameter to a std::string.
Definition: string_utilities.h:36
ARGOS_ASSERT
#define ARGOS_ASSERT(condition, message)
When code is compiled in debug, this macro throws an ARGoS exception with the passed message if the s...
Definition: argos_exception.h:122
UInt32
unsigned int UInt32
32-bit unsigned integer.
Definition: datatypes.h:97
argos::GetNodeAttributeOrDefault
void GetNodeAttributeOrDefault(TConfigurationNode &t_node, const std::string &str_attribute, T &t_buffer, const T &t_default)
Returns the value of a node's attribute, or the passed default value.
Definition: argos_configuration.h:318
argos::GetNodeAttribute
void GetNodeAttribute(TConfigurationNode &t_node, const std::string &str_attribute, T &t_buffer)
Returns the value of a node's attribute.
Definition: argos_configuration.h:208
argos::NodeAttributeExists
bool NodeAttributeExists(TConfigurationNode &t_node, const std::string &str_attribute)
Returns true if the specified attribute of a node exists.
Definition: argos_configuration.h:172
simulator.h
argos::CLoopFunctions
A set of hook functions to customize an experimental run.
Definition: loop_functions.h:68
Real
float Real
Collects all ARGoS code.
Definition: datatypes.h:39