loop_functions.h
Go to the documentation of this file.
1 
9 #ifndef LOOP_FUNCTIONS_H
10 #define LOOP_FUNCTIONS_H
11 
12 namespace argos {
13  class CLoopFunctions;
14  class CFloorEntity;
15  class CPositionalEntity;
16  class CEmbodiedEntity;
17 }
18 
19 #include <functional>
20 
21 #include <argos3/core/utility/configuration/base_configurable_resource.h>
22 #include <argos3/core/simulator/simulator.h>
23 #include <argos3/core/simulator/space/space.h>
24 #include <argos3/core/utility/datatypes/color.h>
25 #include <argos3/core/utility/math/vector2.h>
26 #include <argos3/core/utility/math/vector3.h>
27 #include <argos3/core/utility/math/quaternion.h>
28 #include <argos3/core/simulator/physics_engine/physics_engine.h>
29 
30 namespace argos {
31 
71 
72  public:
73 
78  m_cSimulator(CSimulator::GetInstance()),
79  m_cSpace(m_cSimulator.GetSpace()) {
80  }
81 
85  virtual ~CLoopFunctions() {}
86 
94  virtual void Init(TConfigurationNode& t_tree) {}
95 
103  virtual void Reset() {}
104 
111  virtual void Destroy() {}
112 
119  virtual void PreStep() {}
120 
127  virtual void PostStep() {}
128 
138  virtual bool IsExperimentFinished() {
139  return false;
140  }
141 
151  virtual void PostExperiment() {
152  }
153 
165  virtual CColor GetFloorColor(const CVector2& c_pos_on_floor) {
166  return CColor::WHITE;
167  }
168 
174  return m_cSimulator;
175  }
176 
181  inline CSpace& GetSpace() {
182  return m_cSpace;
183  }
184 
185  inline const CSpace& GetSpace() const {
186  return m_cSpace;
187  }
188 
195  virtual void MoveEntity(CPositionalEntity& c_entity,
196  const CVector3& c_position,
197  const CQuaternion& c_orientation);
198 
210  virtual bool MoveEntity(CEmbodiedEntity& c_entity,
211  const CVector3& c_position,
212  const CQuaternion& c_orientation,
213  bool b_check_only = false,
214  bool b_ignore_collisions = false);
215 
224  virtual void AddEntity(CEntity& c_entity);
225 
231  virtual void RemoveEntity(const std::string& str_entity_id);
232 
237  virtual void RemoveEntity(CEntity& c_entity);
238 
239 
265  m_cSpace.IterateOverControllableEntities(c_cb);
266  }
267 
268  private:
269 
271  CSimulator& m_cSimulator;
272 
274  CSpace& m_cSpace;
275 
276  };
277 }
278 
284 #define REGISTER_LOOP_FUNCTIONS(CLASSNAME, LABEL) \
285  REGISTER_SYMBOL(CLoopFunctions, \
286  CLASSNAME, \
287  LABEL, \
288  "undefined", \
289  "undefined", \
290  "undefined", \
291  "undefined", \
292  "undefined")
293 
294 #endif
The namespace containing all the ARGoS related code.
Definition: ci_actuator.h:12
ticpp::Element TConfigurationNode
The ARGoS configuration XML node.
This entity is a link to a body in the physics engine.
The basic entity type.
Definition: entity.h:90
A set of hook functions to customize an experimental run.
virtual void PostExperiment()
Executes user-defined logic when the experiment finishes.
const CSpace & GetSpace() const
virtual void PostStep()
Executes user-defined logic right after a control step is executed.
virtual void Destroy()
Executes user-defined destruction logic.
CSpace & GetSpace()
Returns a reference to the space state.
virtual void Init(TConfigurationNode &t_tree)
Executes user-defined initialization logic.
virtual CColor GetFloorColor(const CVector2 &c_pos_on_floor)
Returns the color of the floor in the specified point.
virtual bool IsExperimentFinished()
Returns true if the experiment is finished.
CLoopFunctions()
Class constructor.
virtual ~CLoopFunctions()
Class destructor.
virtual void RemoveEntity(const std::string &str_entity_id)
Removes an entity from the simulation.
virtual void MoveEntity(CPositionalEntity &c_entity, const CVector3 &c_position, const CQuaternion &c_orientation)
Moves the entity to the wanted position and orientation.
CSimulator & GetSimulator()
Returns the simulator instance.
virtual void PreStep()
Executes user-defined logic right before a control step is executed.
void IterateOverControllableEntities(const CSpace::TControllableEntityIterCBType &c_cb) const
Iterate over all controllable entities currently present in the arena (including those that are curre...
virtual void AddEntity(CEntity &c_entity)
Adds the passed entity to the simulation.
virtual void Reset()
Executes user-defined reset logic.
The core class of ARGOS.
Definition: simulator.h:62
virtual void IterateOverControllableEntities(const TControllableEntityIterCBType &c_cb)=0
Given a callback specified in the loop functions, iterate over all controllable entities currently pr...
std::function< void(CControllableEntity *)> TControllableEntityIterCBType
The callback type for iteration over controllable entities within the PreStep() and/or PostStep() par...
Definition: space.h:90
This class is the base of all XML-configurable ARGoS interface.
The basic color type.
Definition: color.h:25
static CColor WHITE
Definition: color.h:30
A 2D vector class.
Definition: vector2.h:27
A 3D vector class.
Definition: vector3.h:31