ARGoS  3
A parallel, multi-engine simulator for swarm robotics
argos::CSpace Class Reference

#include <space.h>

+ Inheritance diagram for argos::CSpace:

List of all members.

Public Types

typedef std::map< std::string,
CAny, std::less< std::string > > 
TMapPerType
 A map of entities indexed by type description.
typedef std::map< std::string,
TMapPerType, std::less
< std::string > > 
TMapPerTypePerId
 A map of entities indexed by type description and by id.

Public Member Functions

 CSpace ()
 Class constructor.
virtual ~CSpace ()
 Class destructor.
virtual void Init (TConfigurationNode &t_tree)
 Initializes the space using the <arena> section of the XML configuration file.
virtual void Reset ()
 Reset the space and all its entities.
virtual void Destroy ()
 Destroys the space and all its entities.
UInt32 GetNumberEntities () const
 Returns the number of entities contained in the space.
CEntity::TVectorGetEntityVector ()
 Returns a vector of all the entities in the space.
CEntity::TVectorGetRootEntityVector ()
 Returns a vector of all the root entities in the space.
CEntityGetEntity (const std::string &str_id)
 Returns the entity with the given id.
void GetEntitiesMatching (CEntity::TVector &t_buffer, const std::string &str_pattern)
 Returns the entities matching a given pattern.
CEntity::TMapGetEntityMapPerId ()
 Returns a map of all entities ordered by id.
TMapPerTypePerIdGetEntityMapPerTypePerId ()
 Returns a nested map of entities, ordered by type and by id.
TMapPerTypeGetEntitiesByType (const std::string &str_type)
 Returns a map containing all the objects of a given type.
CFloorEntityGetFloorEntity ()
 Returns the floor entity.
void SetFloorEntity (CFloorEntity &c_floor_entity)
 Sets the floor entity.
virtual void Update ()
 Updates the space.
template<typename ENTITY >
void AddEntity (ENTITY &c_entity)
 Adds an entity of the given type.
template<typename ENTITY >
void RemoveEntity (ENTITY &c_entity)
 Removes an entity of the given type.
UInt32 GetSimulationClock () const
 Returns the current value of the simulation clock.
void SetSimulationClock (UInt32 un_simulation_clock)
 Sets a new value for the simulation clock.
void IncreaseSimulationClock (UInt32 un_increase=1)
 Increases the simulation clock by the wanted value.
const CVector3GetArenaSize () const
 Returns the arena size.
void SetArenaSize (const CVector3 &c_size)
 Sets the arena size.
const CVector3GetArenaCenter () const
 Returns the arena center.
void SetArenaCenter (const CVector3 &c_center)
 Sets the arena center.
virtual void AddControllableEntity (CControllableEntity &c_entity)
virtual void RemoveControllableEntity (CControllableEntity &c_entity)
virtual void AddEntityToPhysicsEngine (CEmbodiedEntity &c_entity)

Protected Member Functions

virtual void UpdateControllableEntities ()=0
virtual void UpdatePhysics ()=0
virtual void UpdateMedia ()=0
void Distribute (TConfigurationNode &t_tree)
void AddBoxStrip (TConfigurationNode &t_tree)

Protected Attributes

UInt32 m_unSimulationClock
 The current simulation clock.
CVector3 m_cArenaCenter
 Arena center.
CVector3 m_cArenaSize
 Arena size.
CEntity::TVector m_vecEntities
 A vector of entities.
CEntity::TVector m_vecRootEntities
 A vector of all the entities without a parent.
CEntity::TMap m_mapEntitiesPerId
 A map of entities.
TMapPerTypePerId m_mapEntitiesPerTypePerId
 A map of maps of all the simulated entities.
CControllableEntity::TVector m_vecControllableEntities
 A vector of controllable entities.
CFloorEntitym_pcFloorEntity
 The floor entity.
CPhysicsEngine::TVectorm_ptPhysicsEngines
 A reference to the list of physics engines.
CMedium::TVectorm_ptMedia
 A reference to the list of media.

Friends

class CSpaceOperationAddControllableEntity
class CSpaceOperationRemoveControllableEntity
class CSpaceOperationAddEmbodiedEntity

Detailed Description

Definition at line 29 of file space.h.


Member Typedef Documentation

typedef std::map<std::string, CAny, std::less <std::string> > argos::CSpace::TMapPerType

A map of entities indexed by type description.

This map type is particularly useful when one wants to execute operations on a specific entity type. For instance, one could want to get the list of all robots of a specific type, and execute operations for that robot.

The elements in this map are indexed by type description (the string returned by CEntity::GetTypeDescription()). The elements themselves are stored as objects of the CAny class. This is because any_cast() is faster than dynamic_cast, and equally type-safe.

See also:
CSpace::GetEntitiesByType()
CEntity::GetTypeDescription()
CAny
any_cast()
TMapPerTypePerId

Definition at line 53 of file space.h.

typedef std::map<std::string, TMapPerType, std::less <std::string> > argos::CSpace::TMapPerTypePerId

A map of entities indexed by type description and by id.

This map type is particularly useful when one wants to execute operations on a specific entity type with a specific id. For instance, one could want to operate on a list of robots with a specific type and id, and execute operations for each robot.

The elements in this map are indexed by type description (the string returned by CEntity::GetTypeDescription()), and by id (the string returned by CEntity::GetId()). The elements themselves are stored as objects of the CAny class. This is because any_cast() is faster than dynamic_cast, and equally type-safe.

See also:
CSpace::GetEntitiesByType()
CEntity::GetTypeDescription()
CEntity::GetId()
CAny
any_cast()

Definition at line 76 of file space.h.


Constructor & Destructor Documentation

Class constructor.

Definition at line 25 of file space.cpp.

virtual argos::CSpace::~CSpace ( ) [inline, virtual]

Class destructor.

Definition at line 91 of file space.h.


Member Function Documentation

void argos::CSpace::AddBoxStrip ( TConfigurationNode t_tree) [protected]

Reimplemented in argos::CSpaceMultiThreadBalanceQuantity.

Definition at line 128 of file space.cpp.

template<typename ENTITY >
void argos::CSpace::AddEntity ( ENTITY &  c_entity) [inline]

Adds an entity of the given type.

This method is used internally, don't use it in your code. throws CARGoSException if the entity id already exists in the space indexes.

Definition at line 251 of file space.h.

Definition at line 147 of file space.cpp.

void argos::CSpace::Destroy ( ) [virtual]

Destroys the space and all its entities.

Implements argos::CBaseConfigurableResource.

Reimplemented in argos::CSpaceMultiThreadBalanceQuantity, and argos::CSpaceMultiThreadBalanceLength.

Definition at line 80 of file space.cpp.

void argos::CSpace::Distribute ( TConfigurationNode t_tree) [protected]

Definition at line 378 of file space.cpp.

const CVector3& argos::CSpace::GetArenaCenter ( ) const [inline]

Returns the arena center.

Returns:
the arena center.

Definition at line 356 of file space.h.

const CVector3& argos::CSpace::GetArenaSize ( ) const [inline]

Returns the arena size.

Returns:
the arena size.

Definition at line 340 of file space.h.

CSpace::TMapPerType & argos::CSpace::GetEntitiesByType ( const std::string &  str_type)

Returns a map containing all the objects of a given type.

The 'type' here refers to the string returned by CEntity::GetTypeDescription(). Take this example: CSpace::TMapPerType& theMap = space.GetEntitiesByType("box"); CBoxEntity* box = any_cast<CBoxEntity*>(theMap["my_box"]); // do stuff with the box ...

Parameters:
str_typeThe wanted type to search for.
Returns:
A map containing all the objects of a given type.
Exceptions:
CARGoSExceptionif the given type is not valid.
See also:
CEntity::GetTypeDescription()
TMapPerType
GetEntityMapPerTypePerId()

Definition at line 103 of file space.cpp.

void argos::CSpace::GetEntitiesMatching ( CEntity::TVector t_buffer,
const std::string &  str_pattern 
)

Returns the entities matching a given pattern.

The pattern must be a valid regexp.

Parameters:
t_bufferA vector filled with all the entities that match the given pattern.
str_patternThe pattern to match.
Returns:
The entity with the given id.
Exceptions:
CARGoSExceptionif the regexp is not valid.

Definition at line 90 of file space.cpp.

CEntity& argos::CSpace::GetEntity ( const std::string &  str_id) [inline]

Returns the entity with the given id.

Parameters:
str_idThe id of the wanted entity
Returns:
The entity with the given id.
Exceptions:
CARGoSExceptionif an entity with the wanted id does not exist

Definition at line 146 of file space.h.

Returns a map of all entities ordered by id.

Returns:
a map of all entities ordered by id.

Definition at line 170 of file space.h.

Returns a nested map of entities, ordered by type and by id.

The 'type' here refers to the string returned by CEntity::GetTypeDescription(). Take this example: CSpace::TMapPerTypePerId& theMap = space.GetEntityMapPerTypePerId(); // theMap["box"] is a CSpace::TMapPerType containing all the box entities, ordered by id // theMap["led"] is a CSpace::TMapPerType containing all the led entities, ordered by id // etc. CBoxEntity* box = any_cast<CBoxEntity*>(theMap["box"]["my_box_22"]); // do stuff with the box ...

Returns:
a nested map of entities, ordered by type and by id.
See also:
CEntity::GetTypeDescription()
TMapPerTypePerId
GetEntitiesByType()

Definition at line 191 of file space.h.

Returns a vector of all the entities in the space.

All entities are returned, i.e., all the components of a robot.

Returns:
a vector of all the entities in the space.
See also:
GetRootEntityVector()

Definition at line 122 of file space.h.

Returns the floor entity.

Exceptions:
CARGoSExceptionif the floor entity has not been added to the arena.
Returns:
The floor entity.

Definition at line 218 of file space.h.

Returns the number of entities contained in the space.

Definition at line 112 of file space.h.

Returns a vector of all the root entities in the space.

A root entity is an entity that has no parent. This method differs from GetEntityVector() in that the latter returns all entities including the components of a composable entity, while this method does not return any component, but only the parentless composables.

Returns:
a vector of all the root entities in the space.
See also:
GetEntityVector()

Definition at line 136 of file space.h.

Returns the current value of the simulation clock.

The clock is measured in ticks. You can set how much a tick is long in seconds in the XML.

Returns:
The current value of the simulation clock.

Definition at line 314 of file space.h.

void argos::CSpace::IncreaseSimulationClock ( UInt32  un_increase = 1) [inline]

Increases the simulation clock by the wanted value.

The clock is measured in ticks. You can set how much a tick is long in seconds in the XML.

Parameters:
un_increaseThe quantity to add to the current value of the simulation clock.

Definition at line 332 of file space.h.

void argos::CSpace::Init ( TConfigurationNode t_tree) [virtual]

Initializes the space using the <arena> section of the XML configuration file.

Parameters:
t_treethe <arena> section of the XML configuration file.

Implements argos::CBaseConfigurableResource.

Reimplemented in argos::CSpaceMultiThreadBalanceQuantity, and argos::CSpaceMultiThreadBalanceLength.

Definition at line 34 of file space.cpp.

Reimplemented in argos::CSpaceMultiThreadBalanceQuantity.

Definition at line 135 of file space.cpp.

template<typename ENTITY >
void argos::CSpace::RemoveEntity ( ENTITY &  c_entity) [inline]

Removes an entity of the given type.

This method is used internally, don't use it in your code. throws CARGoSException if the entity id does not exist in the space indexes.

Definition at line 276 of file space.h.

void argos::CSpace::Reset ( ) [virtual]

Reset the space and all its entities.

Implements argos::CBaseConfigurableResource.

Definition at line 68 of file space.cpp.

void argos::CSpace::SetArenaCenter ( const CVector3 c_center) [inline]

Sets the arena center.

Returns:
the arena center.

Definition at line 364 of file space.h.

void argos::CSpace::SetArenaSize ( const CVector3 c_size) [inline]

Sets the arena size.

Returns:
the arena size.

Definition at line 348 of file space.h.

void argos::CSpace::SetFloorEntity ( CFloorEntity c_floor_entity) [inline]

Sets the floor entity.

Parameters:
c_floor_entityThe floor entity.

Definition at line 227 of file space.h.

void argos::CSpace::SetSimulationClock ( UInt32  un_simulation_clock) [inline]

Sets a new value for the simulation clock.

The clock is measured in ticks. You can set how much a tick is long in seconds in the XML.

Parameters:
un_simulation_clockThe new value for the simulation clock.

Definition at line 323 of file space.h.

void argos::CSpace::Update ( ) [virtual]

Updates the space.

The operations are performed in the following order:

  1. UpdateControllableEntities()
  2. UpdatePhysics()
  3. UpdateMedia()
See also:
UpdateControllableEntities()
UpdatePhysics()
UpdateMedia()

Definition at line 116 of file space.cpp.


Friends And Related Function Documentation

friend class CSpaceOperationAddControllableEntity [friend]

Definition at line 384 of file space.h.

friend class CSpaceOperationAddEmbodiedEntity [friend]

Definition at line 386 of file space.h.

Definition at line 385 of file space.h.


Member Data Documentation

Arena center.

Definition at line 394 of file space.h.

Arena size.

Definition at line 397 of file space.h.

A map of entities.

Definition at line 406 of file space.h.

A map of maps of all the simulated entities.

The top-level map is indexed by type, as returned by CEntity::GetTypeDescription(). The second-level maps are indexed by entity id

Definition at line 411 of file space.h.

The floor entity.

Definition at line 417 of file space.h.

A reference to the list of media.

Definition at line 423 of file space.h.

A reference to the list of physics engines.

Definition at line 420 of file space.h.

The current simulation clock.

Definition at line 391 of file space.h.

A vector of controllable entities.

Definition at line 414 of file space.h.

A vector of entities.

Definition at line 400 of file space.h.

A vector of all the entities without a parent.

Definition at line 403 of file space.h.


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