Warning: include(php/utility.php): Failed to open stream: No such file or directory in /home/argos/argos3/doc/api/embedded/a02042.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/a02042.php on line 2
The ARGoS Website

This entity is a link to a body in the physics engine. More...

#include <embodied_entity.h>

Inheritance diagram for argos::CEmbodiedEntity:
Collaboration diagram for argos::CEmbodiedEntity:

Public Member Functions

 ENABLE_VTABLE ()
 
 CEmbodiedEntity (CComposableEntity *pc_parent)
 Class constructor. More...
 
 CEmbodiedEntity (CComposableEntity *pc_parent, const std::string &str_id, const CVector3 &c_position=CVector3(), const CQuaternion &c_orientation=CQuaternion(), bool b_movable=true)
 Class constructor. More...
 
virtual ~CEmbodiedEntity ()
 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...
 
bool IsMovable () const
 Returns true if the entity is movable. More...
 
void SetMovable (bool b_movable)
 Sets whether this entity is movable or not. More...
 
const SAnchorGetOriginAnchor () const
 Returns a const reference to the origin anchor associated to this entity. More...
 
SAnchorGetOriginAnchor ()
 Returns a non-const reference to the origin anchor associated to this entity. More...
 
SAnchorAddAnchor (const std::string &str_id, const CVector3 &c_rel_position=CVector3(), const CQuaternion &c_rel_orientation=CQuaternion())
 Adds an anchor to the embodied entity. More...
 
void EnableAnchor (const std::string &str_id)
 Enables an anchor. More...
 
void DisableAnchor (const std::string &str_id)
 Disables an anchor. More...
 
const SAnchorGetAnchor (const std::string &str_id) const
 Returns the wanted anchor as a const reference. More...
 
SAnchorGetAnchor (const std::string &str_id)
 Returns the wanted anchor as a non-const reference. More...
 
std::map< std::string, SAnchor * > & GetAnchors ()
 Returns a map of anchors associated to this embodied entity. More...
 
std::vector< SAnchor * > & GetEnabledAnchors ()
 Returns a vector of enabled anchors for fast looping. More...
 
bool IsAnchorEnabled (const std::string &str_id)
 Returns true if the given anchor is enabled, false otherwise. More...
 
const SBoundingBoxGetBoundingBox () const
 Returns the bounding box of this embodied entity. More...
 
UInt32 GetPhysicsModelsNum () const
 Returns the number of physics models associated to this entity. More...
 
virtual void AddPhysicsModel (const std::string &str_engine_id, CPhysicsModel &c_physics_model)
 Adds a new physics model to this embodied entity. More...
 
void RemovePhysicsModel (const std::string &str_engine_id)
 Removes a physics model from this embodied entity. More...
 
const CPhysicsModelGetPhysicsModel (size_t un_idx) const
 Returns a physics model associated to this entity. More...
 
CPhysicsModelGetPhysicsModel (size_t un_idx)
 Returns a physics model associated to this entity. More...
 
const CPhysicsModelGetPhysicsModel (const std::string &str_engine_id) const
 Returns a physics model associated to this entity. More...
 
CPhysicsModelGetPhysicsModel (const std::string &str_engine_id)
 Returns a physics model associated to this entity. More...
 
virtual bool MoveTo (const CVector3 &c_position, const CQuaternion &c_orientation, bool b_check_only=false)
 Moves the entity to the wanted position and orientation. More...
 
virtual bool IsCollidingWithSomething () const
 Returns true if this entity is colliding with another object. More...
 
virtual std::string GetTypeDescription () const
 Returns a string label for this class. More...
 
- Public Member Functions inherited from argos::CEntity
 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 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 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
 

Protected Member Functions

void CalculateBoundingBox ()
 Calculates the bounding box of this entity. More...
 

Protected Attributes

bool m_bMovable
 
CPhysicsModel::TMap m_tPhysicsModelMap
 
CPhysicsModel::TVector m_tPhysicsModelVector
 
SBoundingBoxm_sBoundingBox
 
SAnchorm_psOriginAnchor
 
std::map< std::string, SAnchor * > m_mapAnchors
 
std::vector< SAnchor * > m_vecEnabledAnchors
 
CVector3 m_cInitOriginPosition
 
CQuaternion m_cInitOriginOrientation
 

Additional Inherited Members

- Public Types inherited from argos::CEntity
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...
 

Detailed Description

This entity is a link to a body in the physics engine.

The embodied entity can either be a root entity (i.e., parentless), or a component.

Its main purpose is to serve as an interface to the actual body in the physics engine. Sensors can use embodied entities to know the position and orientations of the objects in the arena, and can perform ray-cast queries to test for occlusions. In addition, the method MoveTo() allows one to move an entity and/or rotate it.

Embodied entities can be either movable or non-movable. Movable entities are typically self-propelled objects such as mobile robots, or passive objects that can be grasped and moved around. A movable entity can only be associated to a single physics engine per time. Non-movable embodied entities are typically the structural elements of the environments (walls, columns, etc.) and can be associated to multiple physics engines.

See also
CPhysicsEngine
CPhysicsModel

Definition at line 48 of file embodied_entity.h.

Constructor & Destructor Documentation

◆ CEmbodiedEntity() [1/2]

argos::CEmbodiedEntity::CEmbodiedEntity ( 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 19 of file embodied_entity.cpp.

◆ CEmbodiedEntity() [2/2]

argos::CEmbodiedEntity::CEmbodiedEntity ( CComposableEntity pc_parent,
const std::string &  str_id,
const CVector3 c_position = CVector3(),
const CQuaternion c_orientation = CQuaternion(),
bool  b_movable = true 
)

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.
c_positionThe initial entity position
c_orientationThe initial entity orientation
b_movableIf set to true, this entity is movable.

Definition at line 28 of file embodied_entity.cpp.

◆ ~CEmbodiedEntity()

argos::CEmbodiedEntity::~CEmbodiedEntity ( )
virtual

Class destructor.

Definition at line 53 of file embodied_entity.cpp.

Member Function Documentation

◆ AddAnchor()

SAnchor & argos::CEmbodiedEntity::AddAnchor ( const std::string &  str_id,
const CVector3 c_rel_position = CVector3(),
const CQuaternion c_rel_orientation = CQuaternion() 
)

Adds an anchor to the embodied entity.

The anchor is initially disabled. To enable it you must call EnableAnchor().

Parameters
str_idThe id of the anchor.
c_rel_positionThe position of the anchor wrt the body coordinate system.
c_rel_orientationThe orientation of the anchor wrt the body coordinate system.
Returns
A reference to the newly created anchor.
Exceptions
CARGoSExceptionif an anchor with the passed id already exists in this embodied entity.
See also
SAnchor
EnableAnchor

Definition at line 121 of file embodied_entity.cpp.

◆ AddPhysicsModel()

void argos::CEmbodiedEntity::AddPhysicsModel ( const std::string &  str_engine_id,
CPhysicsModel c_physics_model 
)
virtual

Adds a new physics model to this embodied entity.

Internally it calls CalculateBoundingBox().

Parameters
str_engine_idThe id of the engine to which the physics model belongs.
c_physics_modelThe physics model to add.
See also
CPhysicsModel

Definition at line 250 of file embodied_entity.cpp.

◆ CalculateBoundingBox()

void argos::CEmbodiedEntity::CalculateBoundingBox ( )
protected

Calculates the bounding box of this entity.

In case of association to multiple models, the resulting bounding box is the largest that contains all the bounding boxes of each model.

See also
CPhysicsModel::CalculateBoundingBox()

Definition at line 380 of file embodied_entity.cpp.

◆ DisableAnchor()

void argos::CEmbodiedEntity::DisableAnchor ( const std::string &  str_id)

Disables an anchor.

Parameters
str_idThe id of the anchor.
Exceptions
CARGoSExceptionif an enabled anchor with the passed id does not exist in this embodied entity.
See also
SAnchor
DisableAnchor

Definition at line 169 of file embodied_entity.cpp.

◆ ENABLE_VTABLE()

argos::CEmbodiedEntity::ENABLE_VTABLE ( )

◆ EnableAnchor()

void argos::CEmbodiedEntity::EnableAnchor ( const std::string &  str_id)

Enables an anchor.

Parameters
str_idThe id of the anchor.
Exceptions
CARGoSExceptionif an anchor with the passed id does not exist in this embodied entity.
See also
SAnchor
DisableAnchor

Definition at line 150 of file embodied_entity.cpp.

◆ GetAnchor() [1/2]

const SAnchor & argos::CEmbodiedEntity::GetAnchor ( const std::string &  str_id) const

Returns the wanted anchor as a const reference.

Parameters
str_idThe id of the anchor.
Returns
The wanted anchor.
Exceptions
CARGoSExceptionif the anchor was not found.
See also
SAnchor
EnableAnchor
DisableAnchor

Definition at line 190 of file embodied_entity.cpp.

◆ GetAnchor() [2/2]

SAnchor & argos::CEmbodiedEntity::GetAnchor ( const std::string &  str_id)

Returns the wanted anchor as a non-const reference.

Parameters
str_idThe id of the anchor.
Returns
The wanted anchor.
Exceptions
CARGoSExceptionif the anchor was not found.
See also
SAnchor
EnableAnchor
DisableAnchor

Definition at line 204 of file embodied_entity.cpp.

◆ GetAnchors()

std::map<std::string, SAnchor*>& argos::CEmbodiedEntity::GetAnchors ( )
inline

Returns a map of anchors associated to this embodied entity.

The map has the id as key and a pointer to the anchor as value.

Returns
The map of anchors.
See also
SAnchor
AddAnchor

Definition at line 193 of file embodied_entity.h.

◆ GetBoundingBox()

const SBoundingBox & argos::CEmbodiedEntity::GetBoundingBox ( ) const

Returns the bounding box of this embodied entity.

The bounding box is calculated by the physics engine. In case multiple physics engines are associated to this entity, the resulting bounding box is the largest bounding box that includes all the bounding boxes of each physics engine.

Returns
The bounding box of this embodied entity.
See also
SBoundingBox

Definition at line 232 of file embodied_entity.cpp.

◆ GetEnabledAnchors()

std::vector<SAnchor*>& argos::CEmbodiedEntity::GetEnabledAnchors ( )
inline

Returns a vector of enabled anchors for fast looping.

This method is mainly intended for use in a physics engine when anchors are updated.

Returns
The vector of currently enabled anchors.
See also
EnableAnchor
DisableAnchor

Definition at line 205 of file embodied_entity.h.

◆ GetOriginAnchor() [1/2]

const SAnchor& argos::CEmbodiedEntity::GetOriginAnchor ( ) const
inline

Returns a const reference to the origin anchor associated to this entity.

Returns
A const reference to the origin anchor associated to this entity.

Definition at line 119 of file embodied_entity.h.

◆ GetOriginAnchor() [2/2]

SAnchor& argos::CEmbodiedEntity::GetOriginAnchor ( )
inline

Returns a non-const reference to the origin anchor associated to this entity.

Returns
A non-const reference to the origin anchor associated to this entity.

Definition at line 127 of file embodied_entity.h.

◆ GetPhysicsModel() [1/4]

const CPhysicsModel & argos::CEmbodiedEntity::GetPhysicsModel ( size_t  un_idx) const

Returns a physics model associated to this entity.

Parameters
un_idxThe index of the wanted physics model.
Returns
a physics model associated to this entity.
Exceptions
CARGoSExceptionif the index is out of bounds.

Definition at line 279 of file embodied_entity.cpp.

◆ GetPhysicsModel() [2/4]

CPhysicsModel & argos::CEmbodiedEntity::GetPhysicsModel ( size_t  un_idx)

Returns a physics model associated to this entity.

Parameters
un_idxThe index of the wanted physics model.
Returns
a physics model associated to this entity.
Exceptions
CARGoSExceptionif the index is out of bounds.

Definition at line 289 of file embodied_entity.cpp.

◆ GetPhysicsModel() [3/4]

const CPhysicsModel & argos::CEmbodiedEntity::GetPhysicsModel ( const std::string &  str_engine_id) const

Returns a physics model associated to this entity.

Parameters
str_engine_idThe id of the engine to which the physics model belongs.
Returns
a physics model associated to this entity.
Exceptions
CARGoSExceptionif the engine id is not found.

Definition at line 299 of file embodied_entity.cpp.

◆ GetPhysicsModel() [4/4]

CPhysicsModel & argos::CEmbodiedEntity::GetPhysicsModel ( const std::string &  str_engine_id)

Returns a physics model associated to this entity.

Parameters
str_engine_idThe id of the engine to which the physics model belongs.
Returns
a physics model associated to this entity.
Exceptions
CARGoSExceptionif the engine id is not found.

Definition at line 310 of file embodied_entity.cpp.

◆ GetPhysicsModelsNum()

UInt32 argos::CEmbodiedEntity::GetPhysicsModelsNum ( ) const

Returns the number of physics models associated to this entity.

Returns
The number of physics models associated to this entity.

Definition at line 243 of file embodied_entity.cpp.

◆ GetTypeDescription()

virtual std::string argos::CEmbodiedEntity::GetTypeDescription ( ) const
inlinevirtual

Returns a string label for this class.

Returns
A string label for this class.

Reimplemented from argos::CEntity.

Definition at line 305 of file embodied_entity.h.

◆ Init()

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

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

Internally, this entity calls CPositionalEntity::Init() and sets m_bMovable to true.

Exceptions
CARGoSExceptionif a parse error occurred
See also
CPositionalEntity::Init()
m_bMovable

Reimplemented from argos::CEntity.

Definition at line 68 of file embodied_entity.cpp.

◆ IsAnchorEnabled()

bool argos::CEmbodiedEntity::IsAnchorEnabled ( const std::string &  str_id)

Returns true if the given anchor is enabled, false otherwise.

Returns
true if the given anchor is enabled, false otherwise.
See also
EnableAnchor
DisableAnchor

Definition at line 218 of file embodied_entity.cpp.

◆ IsCollidingWithSomething()

bool argos::CEmbodiedEntity::IsCollidingWithSomething ( ) const
virtual

Returns true if this entity is colliding with another object.

Returns
true if this entity is colliding with another object.

Definition at line 421 of file embodied_entity.cpp.

◆ IsMovable()

bool argos::CEmbodiedEntity::IsMovable ( ) const
inline

Returns true if the entity is movable.

Returns
true if the entity is movable.

Definition at line 101 of file embodied_entity.h.

◆ MoveTo()

bool argos::CEmbodiedEntity::MoveTo ( const CVector3 c_position,
const CQuaternion c_orientation,
bool  b_check_only = false 
)
virtual

Moves the entity to the wanted position and orientation.

The movement is allowed only if the object does not collide with anything once in the new position. In case of multiple models associated to this entity, all the engines are checked.

Parameters
c_positionThe wanted position.
c_orientationThe wanted orientation.
b_check_onlyIf false, the movement is executed; otherwise, the object is not actually moved.
Returns
true if no collisions were detected, false otherwise.
See also
CPhysicsModel::MoveTo()

Definition at line 321 of file embodied_entity.cpp.

◆ RemovePhysicsModel()

void argos::CEmbodiedEntity::RemovePhysicsModel ( const std::string &  str_engine_id)

Removes a physics model from this embodied entity.

Internally it calls CalculateBoundingBox().

Parameters
str_engine_idThe id of the engine to which the physics model belongs.
Exceptions
CARGoSExceptionif the engine id is not found.

Definition at line 263 of file embodied_entity.cpp.

◆ Reset()

void argos::CEmbodiedEntity::Reset ( )
virtual

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.

Reimplemented from argos::CEntity.

Definition at line 98 of file embodied_entity.cpp.

◆ SetMovable()

void argos::CEmbodiedEntity::SetMovable ( bool  b_movable)
inline

Sets whether this entity is movable or not.

This flag cannot be changed during an experiment, because the results are undefined.

Parameters
b_movabletrue if the entity is movable.

Definition at line 111 of file embodied_entity.h.

Member Data Documentation

◆ m_bMovable

bool argos::CEmbodiedEntity::m_bMovable
protected

Definition at line 321 of file embodied_entity.h.

◆ m_cInitOriginOrientation

CQuaternion argos::CEmbodiedEntity::m_cInitOriginOrientation
protected

Definition at line 329 of file embodied_entity.h.

◆ m_cInitOriginPosition

CVector3 argos::CEmbodiedEntity::m_cInitOriginPosition
protected

Definition at line 328 of file embodied_entity.h.

◆ m_mapAnchors

std::map<std::string, SAnchor*> argos::CEmbodiedEntity::m_mapAnchors
protected

Definition at line 326 of file embodied_entity.h.

◆ m_psOriginAnchor

SAnchor* argos::CEmbodiedEntity::m_psOriginAnchor
protected

Definition at line 325 of file embodied_entity.h.

◆ m_sBoundingBox

SBoundingBox* argos::CEmbodiedEntity::m_sBoundingBox
protected

Definition at line 324 of file embodied_entity.h.

◆ m_tPhysicsModelMap

CPhysicsModel::TMap argos::CEmbodiedEntity::m_tPhysicsModelMap
protected

Definition at line 322 of file embodied_entity.h.

◆ m_tPhysicsModelVector

CPhysicsModel::TVector argos::CEmbodiedEntity::m_tPhysicsModelVector
protected

Definition at line 323 of file embodied_entity.h.

◆ m_vecEnabledAnchors

std::vector<SAnchor*> argos::CEmbodiedEntity::m_vecEnabledAnchors
protected

Definition at line 327 of file embodied_entity.h.