This entity is a link to a body in the physics engine. More...
#include <embodied_entity.h>
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 SAnchor & | GetOriginAnchor () const |
Returns a const reference to the origin anchor associated to this entity. More... | |
SAnchor & | GetOriginAnchor () |
Returns a non-const reference to the origin anchor associated to this entity. More... | |
SAnchor & | 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. More... | |
void | EnableAnchor (const std::string &str_id) |
Enables an anchor. More... | |
void | DisableAnchor (const std::string &str_id) |
Disables an anchor. More... | |
const SAnchor & | GetAnchor (const std::string &str_id) const |
Returns the wanted anchor as a const reference. More... | |
SAnchor & | GetAnchor (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 SBoundingBox & | GetBoundingBox () 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 CPhysicsModel & | GetPhysicsModel (size_t un_idx) const |
Returns a physics model associated to this entity. More... | |
CPhysicsModel & | GetPhysicsModel (size_t un_idx) |
Returns a physics model associated to this entity. More... | |
const CPhysicsModel & | GetPhysicsModel (const std::string &str_engine_id) const |
Returns a physics model associated to this entity. More... | |
CPhysicsModel & | GetPhysicsModel (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, bool b_ignore_collisions=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... | |
void | CalculateBoundingBox () |
Calculates the bounding box of this entity. 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... | |
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 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 |
Protected Attributes | |
bool | m_bMovable |
CPhysicsModel::TMap | m_tPhysicsModelMap |
CPhysicsModel::TVector | m_tPhysicsModelVector |
SBoundingBox * | m_sBoundingBox |
SAnchor * | m_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... | |
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.
Definition at line 48 of file embodied_entity.h.
argos::CEmbodiedEntity::CEmbodiedEntity | ( | 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 19 of file embodied_entity.cpp.
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.
pc_parent | The parent of this entity. |
str_id | The id of this entity. |
c_position | The initial entity position |
c_orientation | The initial entity orientation |
b_movable | If set to true , this entity is movable. |
Definition at line 28 of file embodied_entity.cpp.
|
virtual |
Class destructor.
Definition at line 53 of file embodied_entity.cpp.
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().
str_id | The id of the anchor. |
c_rel_position | The position of the anchor wrt the body coordinate system. |
c_rel_orientation | The orientation of the anchor wrt the body coordinate system. |
CARGoSException | if an anchor with the passed id already exists in this embodied entity. |
Definition at line 121 of file embodied_entity.cpp.
|
virtual |
Adds a new physics model to this embodied entity.
Internally it calls CalculateBoundingBox().
str_engine_id | The id of the engine to which the physics model belongs. |
c_physics_model | The physics model to add. |
Definition at line 250 of file embodied_entity.cpp.
void argos::CEmbodiedEntity::CalculateBoundingBox | ( | ) |
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.
Definition at line 381 of file embodied_entity.cpp.
void argos::CEmbodiedEntity::DisableAnchor | ( | const std::string & | str_id | ) |
Disables an anchor.
str_id | The id of the anchor. |
CARGoSException | if an enabled anchor with the passed id does not exist in this embodied entity. |
Definition at line 169 of file embodied_entity.cpp.
argos::CEmbodiedEntity::ENABLE_VTABLE | ( | ) |
void argos::CEmbodiedEntity::EnableAnchor | ( | const std::string & | str_id | ) |
Enables an anchor.
str_id | The id of the anchor. |
CARGoSException | if an anchor with the passed id does not exist in this embodied entity. |
Definition at line 150 of file embodied_entity.cpp.
SAnchor & argos::CEmbodiedEntity::GetAnchor | ( | const std::string & | str_id | ) |
Returns the wanted anchor as a non-const reference.
str_id | The id of the anchor. |
CARGoSException | if the anchor was not found. |
Definition at line 204 of file embodied_entity.cpp.
const SAnchor & argos::CEmbodiedEntity::GetAnchor | ( | const std::string & | str_id | ) | const |
Returns the wanted anchor as a const reference.
str_id | The id of the anchor. |
CARGoSException | if the anchor was not found. |
Definition at line 190 of file embodied_entity.cpp.
|
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.
Definition at line 193 of file embodied_entity.h.
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.
Definition at line 232 of file embodied_entity.cpp.
|
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.
Definition at line 205 of file embodied_entity.h.
|
inline |
Returns a non-const reference to the origin anchor associated to this entity.
Definition at line 127 of file embodied_entity.h.
|
inline |
Returns a const reference to the origin anchor associated to this entity.
Definition at line 119 of file embodied_entity.h.
CPhysicsModel & argos::CEmbodiedEntity::GetPhysicsModel | ( | const std::string & | str_engine_id | ) |
Returns a physics model associated to this entity.
str_engine_id | The id of the engine to which the physics model belongs. |
CARGoSException | if the engine id is not found. |
Definition at line 310 of file embodied_entity.cpp.
const CPhysicsModel & argos::CEmbodiedEntity::GetPhysicsModel | ( | const std::string & | str_engine_id | ) | const |
Returns a physics model associated to this entity.
str_engine_id | The id of the engine to which the physics model belongs. |
CARGoSException | if the engine id is not found. |
Definition at line 299 of file embodied_entity.cpp.
CPhysicsModel & argos::CEmbodiedEntity::GetPhysicsModel | ( | size_t | un_idx | ) |
Returns a physics model associated to this entity.
un_idx | The index of the wanted physics model. |
CARGoSException | if the index is out of bounds. |
Definition at line 289 of file embodied_entity.cpp.
const CPhysicsModel & argos::CEmbodiedEntity::GetPhysicsModel | ( | size_t | un_idx | ) | const |
Returns a physics model associated to this entity.
un_idx | The index of the wanted physics model. |
CARGoSException | if the index is out of bounds. |
Definition at line 279 of file embodied_entity.cpp.
UInt32 argos::CEmbodiedEntity::GetPhysicsModelsNum | ( | ) | const |
Returns the number of physics models associated to this entity.
Definition at line 243 of file embodied_entity.cpp.
|
inlinevirtual |
Returns a string label for this class.
Reimplemented from argos::CEntity.
Definition at line 307 of file embodied_entity.h.
|
virtual |
Initializes the state of the entity from the XML configuration tree.
Internally, this entity calls CPositionalEntity::Init() and sets m_bMovable to true
.
CARGoSException | if a parse error occurred |
Reimplemented from argos::CEntity.
Definition at line 68 of file embodied_entity.cpp.
bool argos::CEmbodiedEntity::IsAnchorEnabled | ( | const std::string & | str_id | ) |
Returns true
if the given anchor is enabled, false
otherwise.
true
if the given anchor is enabled, false
otherwise. Definition at line 218 of file embodied_entity.cpp.
|
virtual |
Returns true
if this entity is colliding with another object.
true
if this entity is colliding with another object. Definition at line 422 of file embodied_entity.cpp.
|
inline |
Returns true
if the entity is movable.
true
if the entity is movable. Definition at line 101 of file embodied_entity.h.
|
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.
c_position | The wanted position. |
c_orientation | The wanted orientation. |
b_check_only | If false , the movement is executed; otherwise, the object is not actually moved. |
b_ignore_collisions | If false , collisions are considered; if true , collisions are ignored |
true
if no collisions were detected, false
otherwise. Definition at line 321 of file embodied_entity.cpp.
void argos::CEmbodiedEntity::RemovePhysicsModel | ( | const std::string & | str_engine_id | ) |
Removes a physics model from this embodied entity.
Internally it calls CalculateBoundingBox().
str_engine_id | The id of the engine to which the physics model belongs. |
CARGoSException | if the engine id is not found. |
Definition at line 263 of file embodied_entity.cpp.
|
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.
|
inline |
Sets whether this entity is movable or not.
This flag cannot be changed during an experiment, because the results are undefined.
b_movable | true if the entity is movable. |
Definition at line 111 of file embodied_entity.h.
|
protected |
Definition at line 321 of file embodied_entity.h.
|
protected |
Definition at line 329 of file embodied_entity.h.
|
protected |
Definition at line 328 of file embodied_entity.h.
|
protected |
Definition at line 326 of file embodied_entity.h.
|
protected |
Definition at line 325 of file embodied_entity.h.
|
protected |
Definition at line 324 of file embodied_entity.h.
|
protected |
Definition at line 322 of file embodied_entity.h.
|
protected |
Definition at line 323 of file embodied_entity.h.
|
protected |
Definition at line 327 of file embodied_entity.h.