The basic entity type. More...
#include <entity.h>
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... | |
CEntity & | GetRootEntity () |
Returns the root entity containing this entity. More... | |
const CEntity & | GetRootEntity () const |
Returns the root entity containing this entity. More... | |
CComposableEntity & | GetParent () |
Returns this entity's parent. More... | |
const CComposableEntity & | GetParent () 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... | |
TConfigurationNode * | GetConfigurationNode () |
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 |
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.
typedef unordered_map<std::string, CEntity*> argos::CEntity::TMap |
typedef std::multimap<std::string, CEntity*> argos::CEntity::TMultiMap |
typedef std::vector<CEntity*> argos::CEntity::TVector |
argos::CEntity::CEntity | ( | CComposableEntity * | pc_parent | ) |
Class constructor.
This constructor is meant to be used with the Init() method.
pc_parent | The parent of this entity. |
Definition at line 18 of file entity.cpp.
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.
pc_parent | The parent of this entity. |
str_id | The id of this entity. |
Definition at line 28 of file entity.cpp.
|
inlinevirtual |
|
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.
|
inline |
Disables the entity.
|
inline |
Enables the entity.
argos::CEntity::ENABLE_VTABLE | ( | ) |
|
inline |
std::string argos::CEntity::GetContext | ( | ) | const |
Returns the context of this entity.
Definition at line 79 of file entity.cpp.
|
inline |
|
inline |
CComposableEntity & argos::CEntity::GetParent | ( | ) |
Returns this entity's parent.
CARGoSException | if this entity has no parent. |
Definition at line 91 of file entity.cpp.
const CComposableEntity & argos::CEntity::GetParent | ( | ) | const |
Returns this entity's parent.
CARGoSException | if this entity has no parent. |
Definition at line 103 of file entity.cpp.
CEntity & argos::CEntity::GetRootEntity | ( | ) |
Returns the root entity containing this entity.
Definition at line 115 of file entity.cpp.
const CEntity & argos::CEntity::GetRootEntity | ( | ) | const |
Returns the root entity containing this entity.
Definition at line 127 of file entity.cpp.
|
inlinevirtual |
Returns a string label for this class.
Reimplemented in argos::CWiFiEquippedEntity, argos::CWheeledEntity, argos::CTagEquippedEntity, argos::CTagEntity, argos::CRotorEquippedEntity, argos::CRadioEquippedEntity, argos::CRadioEntity, argos::CRABEquippedEntity, argos::CQuadRotorEntity, 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::CFootBotDistanceScannerEquippedEntity, argos::CEyeBotEntity, argos::CEPuckEntity, argos::CPositionalEntity, argos::CFloorEntity, argos::CEmbodiedEntity, argos::CControllableEntity, and argos::CComposableEntity.
|
inline |
|
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()
.
CARGoSException | if 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.
|
inline |
|
inlinevirtual |
Resets the state of the entity to whatever it was after Init() or the standalone constructor was called.
The default implementation of this method does nothing.
Implements argos::CBaseConfigurableResource.
Reimplemented in argos::CWheeledEntity, argos::CTagEntity, argos::CRotorEquippedEntity, argos::CRadioEntity, argos::CRABEquippedEntity, argos::CQuadRotorEntity, argos::CMagnetEntity, argos::CLEDEquippedEntity, argos::CLEDEntity, argos::CGripperEquippedEntity, argos::CDirectionalLEDEntity, argos::CCylinderEntity, argos::CBoxEntity, argos::CSpiriEntity, argos::CFootBotTurretEntity, argos::CFootBotEntity, argos::CFootBotDistanceScannerEquippedEntity, argos::CEyeBotEntity, argos::CEPuckEntity, argos::CPositionalEntity, argos::CFloorEntity, argos::CEmbodiedEntity, argos::CControllableEntity, and argos::CComposableEntity.
|
virtual |
Enables or disables an entity.
b_enabled | true if the entity is enabled, false otherwise |
Reimplemented in argos::CTagEntity, argos::CRadioEntity, argos::CRABEquippedEntity, argos::CLEDEntity, argos::CDirectionalLEDEntity, and argos::CComposableEntity.
Definition at line 139 of file entity.cpp.
|
inline |
|
inline |
|
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.