ARGoS
3
A parallel, multi-engine simulator for swarm robotics
|
Go to the documentation of this file.
19 #include <argos3/core/utility/datatypes/any.h>
20 #include <argos3/core/simulator/medium/medium.h>
21 #include <argos3/core/simulator/space/positional_indices/positional_index.h>
22 #include <argos3/core/simulator/entity/embodied_entity.h>
23 #include <argos3/core/simulator/entity/controllable_entity.h>
54 typedef std::map <std::string, CAny, std::less <std::string> >
TMapPerType;
77 typedef std::map <std::string, TMapPerType, std::less <std::string> >
TMapPerTypePerId;
103 virtual void Reset();
150 return *(it->second);
153 "\" when requesting entity from space.");
165 const std::string& str_pattern);
253 template <
typename ENTITY>
255 std::string strEntityQualifiedName = c_entity.GetContext() + c_entity.GetId();
259 c_entity.GetTypeDescription() <<
260 " entity with id \"" <<
261 strEntityQualifiedName <<
262 "\". An entity with that id already exists.");
265 if(!c_entity.HasParent()) {
278 template <
typename ENTITY>
280 std::string strEntityQualifiedName = c_entity.GetContext() + c_entity.GetId();
285 TMapPerType::iterator itMapPerTypePerId = itMapPerType->second.find(strEntityQualifiedName);
286 if(itMapPerTypePerId != itMapPerType->second.end()) {
288 CEntity::TVector::iterator itVec = find(
m_vecEntities.begin(),
293 itMapPerType->second.erase(itMapPerTypePerId);
295 if(!c_entity.HasParent()) {
308 strEntityQualifiedName <<
309 "\" has not been found in the indexes.");
453 template <
typename ACTION>
473 #define SPACE_OPERATION_ADD_ENTITY(ENTITY) \
474 class CSpaceOperationAdd ## ENTITY : public CSpaceOperationAddEntity { \
476 void ApplyTo(CSpace& c_space, ENTITY& c_entity) { \
477 c_space.AddEntity(c_entity); \
481 #define SPACE_OPERATION_REMOVE_ENTITY(ENTITY) \
482 class CSpaceOperationRemove ## ENTITY : public CSpaceOperationRemoveEntity { \
484 void ApplyTo(CSpace& c_space, ENTITY& c_entity) { \
485 c_space.RemoveEntity(c_entity); \
489 #define REGISTER_SPACE_OPERATION(ACTION, OPERATION, ENTITY) \
490 REGISTER_ENTITY_OPERATION(ACTION, CSpace, OPERATION, void, ENTITY);
492 #define REGISTER_STANDARD_SPACE_OPERATION_ADD_ENTITY(ENTITY) \
493 SPACE_OPERATION_ADD_ENTITY(ENTITY) \
494 REGISTER_SPACE_OPERATION(CSpaceOperationAddEntity, \
495 CSpaceOperationAdd ## ENTITY, \
498 #define REGISTER_STANDARD_SPACE_OPERATION_REMOVE_ENTITY(ENTITY) \
499 SPACE_OPERATION_REMOVE_ENTITY(ENTITY) \
500 REGISTER_SPACE_OPERATION(CSpaceOperationRemoveEntity, \
501 CSpaceOperationRemove ## ENTITY, \
504 #define REGISTER_STANDARD_SPACE_OPERATIONS_ON_ENTITY(ENTITY) \
505 REGISTER_STANDARD_SPACE_OPERATION_ADD_ENTITY(ENTITY) \
506 REGISTER_STANDARD_SPACE_OPERATION_REMOVE_ENTITY(ENTITY)
friend class CSpaceOperationRemoveControllableEntity
CControllableEntity::TVector m_vecControllableEntities
A vector of controllable entities.
TMapPerType & GetEntitiesByType(const std::string &str_type)
Returns a map containing all the objects of a given type.
This class is the base of all XML-configurable ARGoS interface.
UInt32 GetNumberEntities() const
Returns the number of entities contained in the space.
virtual void RemoveControllableEntity(CControllableEntity &c_entity)
CRange< CVector3 > m_cArenaLimits
Arena limits.
void Distribute(TConfigurationNode &t_tree)
The basic operation to be stored in the vtable.
virtual void UpdateMedia()=0
CEntity::TVector & GetEntityVector()
Returns a vector of all the entities in the space.
The namespace containing all the ARGoS related code.
virtual void Destroy()
Destroys the space and all its entities.
virtual void UpdateControllableEntitiesAct()=0
virtual void UpdatePhysics()=0
friend class CSpaceOperationAddEmbodiedEntity
CEntity & GetEntity(const std::string &str_id)
Returns the entity with the given id.
CVector3 m_cArenaSize
Arena size.
This entity is a link to a body in the physics engine.
CSimulator & m_cSimulator
ticpp::Element TConfigurationNode
The ARGoS configuration XML node.
CPhysicsEngine::TVector * m_ptPhysicsEngines
A pointer to the list of physics engines.
virtual void UpdateControllableEntitiesSenseStep()=0
friend class CSpaceOperationAddControllableEntity
CSpace()
Class constructor.
std::vector< CMedium * > TVector
void IncreaseSimulationClock(UInt32 un_increase=1)
Increases the simulation clock by the wanted value.
const CVector3 & GetArenaCenter() const
Returns the arena center.
void AddEntity(ENTITY &c_entity)
Adds an entity of the given type.
void SetArenaCenter(const CVector3 &c_center)
Sets the arena center.
#define THROW_ARGOSEXCEPTION(message)
This macro throws an ARGoS exception with the passed message.
virtual void AddControllableEntity(CControllableEntity &c_entity)
void AddBoxStrip(TConfigurationNode &t_tree)
void SetFloorEntity(CFloorEntity &c_floor_entity)
Sets the floor entity.
const CVector3 & GetArenaSize() const
Returns the arena size.
unordered_map< std::string, CEntity * > TMap
A map of entities.
UInt32 GetSimulationClock() const
Returns the current value of the simulation clock.
CFloorEntity & GetFloorEntity()
Returns the floor entity.
std::map< std::string, CAny, std::less< std::string > > TMapPerType
A map of entities indexed by type description.
CMedium::TVector * m_ptMedia
A pointer to the list of media.
virtual ~CSpace()
Class destructor.
unsigned int UInt32
32-bit unsigned integer.
CEntity::TVector m_vecEntities
A vector of entities.
CVector3 m_cArenaCenter
Arena center.
CFloorEntity * m_pcFloorEntity
The floor entity.
std::vector< CPhysicsEngine * > TVector
virtual ~CSpaceOperationRemoveEntity()
TMapPerTypePerId m_mapEntitiesPerTypePerId
A map of maps of all the simulated entities.
virtual ~CSpaceOperationAddEntity()
CEntity::TVector m_vecRootEntities
A vector of all the entities without a parent.
TMapPerTypePerId & GetEntityMapPerTypePerId()
Returns a nested map of entities, ordered by type and by id.
virtual void Update()
Updates the space.
virtual void AddEntityToPhysicsEngine(CEmbodiedEntity &c_entity)
virtual void Reset()
Reset the space and all its entities.
An entity that contains a pointer to the user-defined controller.
CEntity::TMap m_mapEntitiesPerId
A map of entities.
CEntity::TMap & GetEntityMapPerId()
Returns a map of all entities ordered by id.
virtual ~CSpaceOperation()
CEntity::TVector & GetRootEntityVector()
Returns a vector of all the root entities in the space.
const CRange< CVector3 > & GetArenaLimits() const
std::vector< CEntity * > TVector
A vector of entities.
void RemoveEntity(ENTITY &c_entity)
Removes an entity of the given type.
void SetSimulationClock(UInt32 un_simulation_clock)
Sets a new value for the simulation clock.
void SetArenaSize(const CVector3 &c_size)
Sets the arena size.
UInt32 m_unSimulationClock
The current simulation clock.
virtual void Init(TConfigurationNode &t_tree)
Initializes the space using the <arena> section of the XML configuration file.
void GetEntitiesMatching(CEntity::TVector &t_buffer, const std::string &str_pattern)
Returns the entities matching a given pattern.
std::map< std::string, TMapPerType, std::less< std::string > > TMapPerTypePerId
A map of entities indexed by type description and by id.
std::vector< CControllableEntity * > TVector
A vector of controllable entities.