argos::CEntity Class Reference

The basic entity type. More...

#include <entity.h>

Inheritance diagram for argos::CEntity:
Collaboration diagram for argos::CEntity:

Public Types

typedef std::vector< CEntity * > TVector
 A vector of entities. More...
 
typedef unordered_map< std::string, CEntity * > TMap
 A map of entities. More...
 
typedef std::multimap< std::string, CEntity * > TMultiMap
 A multi-map of entities. More...
 

Public Member Functions

 ENABLE_VTABLE ()
 
 CEntity (CComposableEntity *pc_parent)
 Class constructor. More...
 
 CEntity (CComposableEntity *pc_parent, const std::string &str_id)
 Class constructor. More...
 
virtual ~CEntity ()
 Class destructor. More...
 
virtual void Init (TConfigurationNode &t_tree)
 Initializes the state of the entity from the XML configuration tree. More...
 
virtual void Reset ()
 Resets the state of the entity to whatever it was after Init() or the standalone constructor was called. More...
 
virtual void Destroy ()
 Destroys the entity, undoing whatever was done by Init() or by the standalone constructor. More...
 
const std::string & GetId () const
 Returns the id of this entity. More...
 
std::string GetContext () const
 Returns the context of this entity. More...
 
bool HasParent () const
 Returns true if this entity has a parent. More...
 
CEntityGetRootEntity ()
 Returns the root entity containing this entity. More...
 
const CEntityGetRootEntity () const
 Returns the root entity containing this entity. More...
 
CComposableEntityGetParent ()
 Returns this entity's parent. More...
 
const CComposableEntityGetParent () const
 Returns this entity's parent. More...
 
void SetParent (CComposableEntity &c_parent)
 Sets this entity's parent. More...
 
virtual std::string GetTypeDescription () const
 Returns a string label for this class. More...
 
virtual void Update ()
 Updates the state of this entity. More...
 
ssize_t GetIndex () const
 Returns the entity index. More...
 
void SetIndex (ssize_t n_idx)
 Sets the entity index. More...
 
bool IsEnabled () const
 Returns true if the entity is enabled. More...
 
void Enable ()
 Enables the entity. More...
 
void Disable ()
 Disables the entity. More...
 
virtual void SetEnabled (bool b_enabled)
 Enables or disables an entity. More...
 
TConfigurationNodeGetConfigurationNode ()
 Returns a pointer to the configuration node that was used to create this entity. More...
 
- Public Member Functions inherited from argos::CBaseConfigurableResource
virtual ~CBaseConfigurableResource ()
 Class destructor. More...
 
- Public Member Functions inherited from argos::EnableVTableFor< CEntity >
size_t GetTagHelper (const DERIVED *) const
 

Detailed Description

The basic entity type.

The simulation data is organized into basic items referred to as entities ARGoS natively offers several entity types, and the user can customize them or add new ones if necessary. Each type of entity stores information about a specific aspect of the simulation.

For instance, to store the complete state of a wheeled robot, a CComposableEntity is used. CComposableEntity are logical containers that are used to group other entities. CComposableEntity can be nested to form trees of arbitrary complexity. The CControllableEntity is a component that stores a reference to the user-defined control code and to the robot's sensors and actuators. The CEmbodiedEntity component stores the position, orientation and 3D bounding box of the robot. The current wheel speed is stored into the CWheeledEntity component. If the robot is equipped with colored LEDs, their state is stored in a component called CLEDEquippedEntity.

Entity types are organized in hierarchies. For instance, the CEmbodiedEntity is an extension of the simpler CPositionalEntity, which contains just the position and orientation of an object, but not its bounding box. These design choices (entity composition and extension) ensure flexibility, enhance code reuse and diminish information redundancy.

Entity types are indexed in efficient data structures optimized for access speed. In this way, the performance of the plug-ins that access the simulated 3D space is enhanced. For example, positional entities and their extensions are indexed in several type-specific space hashes.

See also
CSpace
CSpaceHash

Definition at line 89 of file entity.h.

Member Typedef Documentation

◆ TMap

typedef unordered_map<std::string, CEntity*> argos::CEntity::TMap

A map of entities.

Definition at line 100 of file entity.h.

◆ TMultiMap

typedef std::multimap<std::string, CEntity*> argos::CEntity::TMultiMap

A multi-map of entities.

Definition at line 103 of file entity.h.

◆ TVector

typedef std::vector<CEntity*> argos::CEntity::TVector

A vector of entities.

Definition at line 97 of file entity.h.

Constructor & Destructor Documentation

◆ CEntity() [1/2]

argos::CEntity::CEntity ( CComposableEntity pc_parent)

Class constructor.

This constructor is meant to be used with the Init() method.

Parameters
pc_parentThe parent of this entity.

Definition at line 18 of file entity.cpp.

◆ CEntity() [2/2]

argos::CEntity::CEntity ( CComposableEntity pc_parent,
const std::string &  str_id 
)

Class constructor.

This constructor is meant to be standalone. You should not call Init() after using this constructor, or memory leaks are likely to happen.

Parameters
pc_parentThe parent of this entity.
str_idThe id of this entity.

Definition at line 28 of file entity.cpp.

◆ ~CEntity()

virtual argos::CEntity::~CEntity ( )
inlinevirtual

Class destructor.

Definition at line 128 of file entity.h.

Member Function Documentation

◆ Destroy()

virtual void argos::CEntity::Destroy ( )
inlinevirtual

Destroys the entity, undoing whatever was done by Init() or by the standalone constructor.

The default implementation of this method does nothing.

Implements argos::CBaseConfigurableResource.

Reimplemented in argos::CTagEntity, argos::CRadioEntity, argos::CLEDEntity, argos::CDirectionalLEDEntity, argos::CEPuckEntity, and argos::CControllableEntity.

Definition at line 151 of file entity.h.

◆ Disable()

void argos::CEntity::Disable ( )
inline

Disables the entity.

See also
m_bEnabled
m_bCanBeEnabledIfDisabled
SetEnabled()

Definition at line 275 of file entity.h.

◆ Enable()

void argos::CEntity::Enable ( )
inline

Enables the entity.

See also
m_bEnabled
m_bCanBeEnabledIfDisabled
SetEnabled()

Definition at line 265 of file entity.h.

◆ ENABLE_VTABLE()

argos::CEntity::ENABLE_VTABLE ( )

◆ GetConfigurationNode()

TConfigurationNode* argos::CEntity::GetConfigurationNode ( )
inline

Returns a pointer to the configuration node that was used to create this entity.

The pointer is NULL if no configuration node was used.

Returns
A pointer to the configuration node that was used to create this entity.

Definition at line 292 of file entity.h.

◆ GetContext()

std::string argos::CEntity::GetContext ( ) const

Returns the context of this entity.

Returns
The context of this entity.

Definition at line 79 of file entity.cpp.

◆ GetId()

const std::string& argos::CEntity::GetId ( ) const
inline

Returns the id of this entity.

Returns
The id of this entity.

Definition at line 157 of file entity.h.

◆ GetIndex()

ssize_t argos::CEntity::GetIndex ( ) const
inline

Returns the entity index.

The entity index is used to order entities globally when necessary to ensure determinism.

When an entity index is <0, the index is considered unset and it should not be used.

Returns
The entity index.

Definition at line 234 of file entity.h.

◆ GetParent() [1/2]

CComposableEntity & argos::CEntity::GetParent ( )

Returns this entity's parent.

Returns
This entity's parent.
Exceptions
CARGoSExceptionif this entity has no parent.

Definition at line 91 of file entity.cpp.

◆ GetParent() [2/2]

const CComposableEntity & argos::CEntity::GetParent ( ) const

Returns this entity's parent.

Returns
This entity's parent.
Exceptions
CARGoSExceptionif this entity has no parent.

Definition at line 103 of file entity.cpp.

◆ GetRootEntity() [1/2]

CEntity & argos::CEntity::GetRootEntity ( )

Returns the root entity containing this entity.

Returns
The root entity containing this entity.

Definition at line 115 of file entity.cpp.

◆ GetRootEntity() [2/2]

const CEntity & argos::CEntity::GetRootEntity ( ) const

Returns the root entity containing this entity.

Returns
The root entity containing this entity.

Definition at line 127 of file entity.cpp.

◆ GetTypeDescription()

◆ HasParent()

bool argos::CEntity::HasParent ( ) const
inline

Returns true if this entity has a parent.

Returns
true if this entity has a parent.

Definition at line 171 of file entity.h.

◆ Init()

void argos::CEntity::Init ( TConfigurationNode t_tree)
virtual

Initializes the state of the entity from the XML configuration tree.

If the id of the entity has not been set yet, this method sets an id for the entity. If the entity has no parent, this method parses the passed XML tree and looks for the id attribute, setting its value as id. If, instead, this entity has a parent, the id is set as GetParent().GetId() + "." + GetTypeDescription().

Exceptions
CARGoSExceptionif a parse error occurred

Implements argos::CBaseConfigurableResource.

Reimplemented in argos::CTagEquippedEntity, argos::CTagEntity, argos::CRadioEquippedEntity, argos::CRadioEntity, argos::CRABEquippedEntity, argos::CProximitySensorEquippedEntity, argos::CPerspectiveCameraEquippedEntity, argos::COmnidirectionalCameraEquippedEntity, argos::CMagnetEquippedEntity, argos::CMagnetEntity, argos::CLightSensorEquippedEntity, argos::CLightEntity, argos::CLEDEquippedEntity, argos::CLEDEntity, argos::CGroundSensorEquippedEntity, argos::CGripperEquippedEntity, argos::CDirectionalLEDEquippedEntity, argos::CDirectionalLEDEntity, argos::CCylinderEntity, argos::CBoxEntity, argos::CBatteryEquippedEntity, argos::CSpiriEntity, argos::CPrototypeLinkEquippedEntity, argos::CPrototypeLinkEntity, argos::CPrototypeJointEquippedEntity, argos::CPrototypeJointEntity, argos::CPrototypeEntity, argos::CMiniQuadrotorEntity, argos::CFootBotTurretEntity, argos::CFootBotEntity, argos::CEyeBotEntity, argos::CEPuckEntity, argos::CPositionalEntity, argos::CFloorEntity, argos::CEmbodiedEntity, and argos::CControllableEntity.

Definition at line 40 of file entity.cpp.

◆ IsEnabled()

bool argos::CEntity::IsEnabled ( ) const
inline

Returns true if the entity is enabled.

Returns
true if the entity is enabled.
See also
m_bEnabled
m_bCanBeEnabledIfDisabled

Definition at line 255 of file entity.h.

◆ Reset()

◆ SetEnabled()

void argos::CEntity::SetEnabled ( bool  b_enabled)
virtual

Enables or disables an entity.

Parameters
b_enabledtrue if the entity is enabled, false otherwise
See also
m_bEnabled
m_bCanBeEnabledIfDisabled

Reimplemented in argos::CTagEntity, argos::CRadioEntity, argos::CRABEquippedEntity, argos::CLEDEntity, argos::CDirectionalLEDEntity, and argos::CComposableEntity.

Definition at line 139 of file entity.cpp.

◆ SetIndex()

void argos::CEntity::SetIndex ( ssize_t  n_idx)
inline

Sets the entity index.

The entity index is used to order entities globally when necessary to ensure determinism. Never call this function in your code.

Parameters
un_idxThe entity index.

Definition at line 245 of file entity.h.

◆ SetParent()

void argos::CEntity::SetParent ( CComposableEntity c_parent)
inline

Sets this entity's parent.

Parameters
c_parentThe new parent.

Definition at line 205 of file entity.h.

◆ Update()

virtual void argos::CEntity::Update ( )
inlinevirtual

Updates the state of this entity.

The default implementation of this method does nothing.

Reimplemented in argos::CRABEquippedEntity, argos::CBatteryEquippedEntity, argos::CFootBotTurretEntity, argos::CFootBotDistanceScannerEquippedEntity, and argos::CComposableEntity.

Definition at line 221 of file entity.h.