ARGoS
3
A parallel, multi-engine simulator for swarm robotics
|
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. | |
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. | |
virtual | ~CEmbodiedEntity () |
Class destructor. | |
virtual void | Init (TConfigurationNode &t_tree) |
Initializes the state of the entity from the XML configuration tree. | |
bool | IsMovable () const |
Returns true if the entity is movable. | |
void | SetMovable (bool b_movable) |
Sets whether this entity is movable or not. | |
const SBoundingBox & | GetBoundingBox () const |
Returns the bounding box of this embodied entity. | |
UInt32 | GetPhysicsModelsNum () const |
Returns the number of physics models associated to this entity. | |
virtual void | AddPhysicsModel (const std::string &str_engine_id, CPhysicsModel &c_physics_model) |
Adds a new physics model to this embodied entity. | |
void | RemovePhysicsModel (const std::string &str_engine_id) |
Removes a physics model from this embodied entity. | |
const CPhysicsModel & | GetPhysicsModel (size_t un_idx) const |
Returns a physics model associated to this entity. | |
CPhysicsModel & | GetPhysicsModel (size_t un_idx) |
Returns a physics model associated to this entity. | |
const CPhysicsModel & | GetPhysicsModel (const std::string &str_engine_id) const |
Returns a physics model associated to this entity. | |
CPhysicsModel & | GetPhysicsModel (const std::string &str_engine_id) |
Returns a physics model associated to this entity. | |
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. | |
virtual bool | IsCollidingWithSomething () const |
Returns true if this entity is colliding with another object. | |
virtual std::string | GetTypeDescription () const |
Returns a string label for this class. | |
Protected Member Functions | |
void | CalculateBoundingBox () |
Calculates the bounding box of this entity. | |
Protected Attributes | |
bool | m_bMovable |
CPhysicsModel::TMap | m_tPhysicsModelMap |
CPhysicsModel::TVector | m_tPhysicsModelVector |
SBoundingBox * | m_sBoundingBox |
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 49 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 27 of file embodied_entity.cpp.
argos::CEmbodiedEntity::~CEmbodiedEntity | ( | ) | [virtual] |
Class destructor.
Definition at line 42 of file embodied_entity.cpp.
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().
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 82 of file embodied_entity.cpp.
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.
Definition at line 200 of file embodied_entity.cpp.
Reimplemented from argos::CPositionalEntity.
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 64 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 111 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 121 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 131 of file embodied_entity.cpp.
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 142 of file embodied_entity.cpp.
Returns the number of physics models associated to this entity.
Definition at line 75 of file embodied_entity.cpp.
virtual std::string argos::CEmbodiedEntity::GetTypeDescription | ( | ) | const [inline, virtual] |
Returns a string label for this class.
Reimplemented from argos::CPositionalEntity.
Definition at line 202 of file embodied_entity.h.
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
.
CARGoSException | if a parse error occurred |
Reimplemented from argos::CPositionalEntity.
Definition at line 51 of file embodied_entity.cpp.
bool argos::CEmbodiedEntity::IsCollidingWithSomething | ( | ) | const [virtual] |
Returns true
if this entity is colliding with another object.
true
if this entity is colliding with another object. Definition at line 241 of file embodied_entity.cpp.
bool argos::CEmbodiedEntity::IsMovable | ( | ) | const [inline] |
Returns true
if the entity is movable.
true
if the entity is movable. Definition at line 100 of file embodied_entity.h.
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.
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. |
true
if no collisions were detected, false
otherwise. Reimplemented from argos::CPositionalEntity.
Definition at line 153 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 95 of file embodied_entity.cpp.
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.
b_movable | true if the entity is movable. |
Definition at line 110 of file embodied_entity.h.
bool argos::CEmbodiedEntity::m_bMovable [protected] |
Definition at line 218 of file embodied_entity.h.
SBoundingBox* argos::CEmbodiedEntity::m_sBoundingBox [protected] |
Definition at line 221 of file embodied_entity.h.
Definition at line 219 of file embodied_entity.h.
Definition at line 220 of file embodied_entity.h.