Warning: include(php/utility.php): Failed to open stream: No such file or directory in /home/argos/argos3/doc/api/embedded/a02214.php on line 2

Warning: include(): Failed opening 'php/utility.php' for inclusion (include_path='.:/usr/lib64/php') in /home/argos/argos3/doc/api/embedded/a02214.php on line 2
The ARGoS Website

#include <space.h>

Inheritance diagram for argos::CSpace:
Collaboration diagram for argos::CSpace:

Public Types

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

Public Member Functions

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

Protected Member Functions

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

Protected Attributes

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

Detailed Description

Definition at line 29 of file space.h.

Member Typedef Documentation

◆ TMapPerType

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.

◆ TMapPerTypePerId

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

◆ CSpace()

argos::CSpace::CSpace ( )

Class constructor.

Definition at line 27 of file space.cpp.

◆ ~CSpace()

virtual argos::CSpace::~CSpace ( )
inlinevirtual

Class destructor.

Definition at line 91 of file space.h.

Member Function Documentation

◆ AddBoxStrip()

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

◆ AddControllableEntity()

void argos::CSpace::AddControllableEntity ( CControllableEntity c_entity)
virtual

Reimplemented in argos::CSpaceMultiThreadBalanceQuantity.

Definition at line 144 of file space.cpp.

◆ AddEntity()

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 253 of file space.h.

◆ AddEntityToPhysicsEngine()

void argos::CSpace::AddEntityToPhysicsEngine ( CEmbodiedEntity c_entity)
virtual

Definition at line 163 of file space.cpp.

◆ Destroy()

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 85 of file space.cpp.

◆ Distribute()

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

Definition at line 410 of file space.cpp.

◆ GetArenaCenter()

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

Returns the arena center.

Returns
the arena center.

Definition at line 368 of file space.h.

◆ GetArenaLimits()

const CRange<CVector3>& argos::CSpace::GetArenaLimits ( ) const
inline

Definition at line 388 of file space.h.

◆ GetArenaSize()

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

Returns the arena size.

Returns
the arena size.

Definition at line 350 of file space.h.

◆ GetEntitiesByType()

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 108 of file space.cpp.

◆ GetEntitiesMatching()

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 95 of file space.cpp.

◆ GetEntity()

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.

◆ GetEntityMapPerId()

CEntity::TMap& argos::CSpace::GetEntityMapPerId ( )
inline

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.

◆ GetEntityMapPerTypePerId()

TMapPerTypePerId& argos::CSpace::GetEntityMapPerTypePerId ( )
inline

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.

◆ GetEntityVector()

CEntity::TVector& argos::CSpace::GetEntityVector ( )
inline

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.

◆ GetFloorEntity()

CFloorEntity& argos::CSpace::GetFloorEntity ( )
inline

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.

◆ GetNumberEntities()

UInt32 argos::CSpace::GetNumberEntities ( ) const
inline

Returns the number of entities contained in the space.

Definition at line 112 of file space.h.

◆ GetRootEntityVector()

CEntity::TVector& argos::CSpace::GetRootEntityVector ( )
inline

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.

◆ GetSimulationClock()

UInt32 argos::CSpace::GetSimulationClock ( ) const
inline

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 324 of file space.h.

◆ IncreaseSimulationClock()

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 342 of file space.h.

◆ Init()

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 37 of file space.cpp.

◆ RemoveControllableEntity()

void argos::CSpace::RemoveControllableEntity ( CControllableEntity c_entity)
virtual

Reimplemented in argos::CSpaceMultiThreadBalanceQuantity.

Definition at line 151 of file space.cpp.

◆ RemoveEntity()

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 286 of file space.h.

◆ Reset()

void argos::CSpace::Reset ( )
virtual

Reset the space and all its entities.

Implements argos::CBaseConfigurableResource.

Definition at line 73 of file space.cpp.

◆ SetArenaCenter()

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

Sets the arena center.

Returns
the arena center.

Definition at line 376 of file space.h.

◆ SetArenaSize()

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

Sets the arena size.

Returns
the arena size.

Definition at line 358 of file space.h.

◆ SetFloorEntity()

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.

◆ SetSimulationClock()

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 333 of file space.h.

◆ Update()

void argos::CSpace::Update ( )
virtual

◆ UpdateControllableEntitiesAct()

virtual void argos::CSpace::UpdateControllableEntitiesAct ( )
protectedpure virtual

◆ UpdateControllableEntitiesSenseStep()

virtual void argos::CSpace::UpdateControllableEntitiesSenseStep ( )
protectedpure virtual

◆ UpdateMedia()

virtual void argos::CSpace::UpdateMedia ( )
protectedpure virtual

◆ UpdatePhysics()

virtual void argos::CSpace::UpdatePhysics ( )
protectedpure virtual

Member Data Documentation

◆ m_cArenaCenter

CVector3 argos::CSpace::m_cArenaCenter
protected

Arena center.

Definition at line 422 of file space.h.

◆ m_cArenaLimits

CRange<CVector3> argos::CSpace::m_cArenaLimits
protected

Arena limits.

Definition at line 428 of file space.h.

◆ m_cArenaSize

CVector3 argos::CSpace::m_cArenaSize
protected

Arena size.

Definition at line 425 of file space.h.

◆ m_cSimulator

CSimulator& argos::CSpace::m_cSimulator
protected

Definition at line 416 of file space.h.

◆ m_mapEntitiesPerId

CEntity::TMap argos::CSpace::m_mapEntitiesPerId
protected

A map of entities.

Definition at line 437 of file space.h.

◆ m_mapEntitiesPerTypePerId

TMapPerTypePerId argos::CSpace::m_mapEntitiesPerTypePerId
protected

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 442 of file space.h.

◆ m_pcFloorEntity

CFloorEntity* argos::CSpace::m_pcFloorEntity
protected

The floor entity.

Definition at line 448 of file space.h.

◆ m_ptMedia

CMedium::TVector* argos::CSpace::m_ptMedia
protected

A pointer to the list of media.

Definition at line 454 of file space.h.

◆ m_ptPhysicsEngines

CPhysicsEngine::TVector* argos::CSpace::m_ptPhysicsEngines
protected

A pointer to the list of physics engines.

Definition at line 451 of file space.h.

◆ m_unSimulationClock

UInt32 argos::CSpace::m_unSimulationClock
protected

The current simulation clock.

Definition at line 419 of file space.h.

◆ m_vecControllableEntities

CControllableEntity::TVector argos::CSpace::m_vecControllableEntities
protected

A vector of controllable entities.

Definition at line 445 of file space.h.

◆ m_vecEntities

CEntity::TVector argos::CSpace::m_vecEntities
protected

A vector of entities.

Definition at line 431 of file space.h.

◆ m_vecRootEntities

CEntity::TVector argos::CSpace::m_vecRootEntities
protected

A vector of all the entities without a parent.

Definition at line 434 of file space.h.