argos::CDynamics2DSingleBodyObjectModel Class Referenceabstract

Base class for object models with a single body. More...

#include <dynamics2d_single_body_object_model.h>

Inheritance diagram for argos::CDynamics2DSingleBodyObjectModel:
Collaboration diagram for argos::CDynamics2DSingleBodyObjectModel:

Public Member Functions

 CDynamics2DSingleBodyObjectModel (CDynamics2DEngine &c_engine, CComposableEntity &c_entity)
 Class constructor. More...
 
virtual ~CDynamics2DSingleBodyObjectModel ()
 Class destructor. More...
 
CComposableEntityGetComposableEntity ()
 Returns the associated composable entity as a non-const reference. More...
 
const CComposableEntityGetComposableEntity () const
 Returns the associated composable entity as a const reference. More...
 
cpBody * GetBody ()
 Returns the body as non-const pointer. More...
 
const cpBody * GetBody () const
 Returns the body as const pointer. More...
 
virtual void Reset ()
 
virtual void MoveTo (const CVector3 &c_position, const CQuaternion &c_orientation)
 
virtual void CalculateBoundingBox ()
 Calculates the axis-aligned box that contains the entire physics model. More...
 
virtual void UpdateEntityStatus ()
 Updates the status of the associated entity. More...
 
virtual void UpdateFromEntityStatus ()=0
 Updates the state of this model from the status of the associated entity. More...
 
virtual bool IsCollidingWithSomething () const
 Returns true if this model is colliding with another model. More...
 
virtual void SetBody (cpBody *pt_body, Real f_height)
 Sets the body and registers the default origin anchor method. More...
 
void UpdateOriginAnchor (SAnchor &s_anchor)
 Updates the origin anchor associated to the embodied entity. More...
 
- Public Member Functions inherited from argos::CDynamics2DModel
 CDynamics2DModel (CDynamics2DEngine &c_engine, CEmbodiedEntity &c_entity)
 
virtual ~CDynamics2DModel ()
 
CDynamics2DEngineGetDynamics2DEngine ()
 Returns the dynamics 2D engine state. More...
 
const CDynamics2DEngineGetDynamics2DEngine () const
 Returns the dynamics 2D engine state as a const reference. More...
 
- Public Member Functions inherited from argos::CPhysicsModel
 CPhysicsModel (CPhysicsEngine &c_engine, CEmbodiedEntity &c_entity)
 
virtual ~CPhysicsModel ()
 
CPhysicsEngineGetEngine ()
 Returns the physics engine associated to this physics model. More...
 
CEmbodiedEntityGetEmbodiedEntity ()
 Returns the embodied entity associated to this physics model. More...
 
const CEmbodiedEntityGetEmbodiedEntity () const
 Returns the embodied entity associated to this physics model. More...
 
const SBoundingBoxGetBoundingBox () const
 Returns an axis-aligned box that contains the physics model. More...
 
virtual void CalculateAnchors ()
 Calculates the anchors associated to this model. More...
 
SBoundingBoxGetBoundingBox ()
 Returns an axis-aligned box that contains the physics model. More...
 
template<typename MODEL >
void RegisterAnchorMethod (const SAnchor &s_anchor, void(MODEL::*pt_method)(SAnchor &))
 Registers an anchor method. More...
 

Additional Inherited Members

- Public Types inherited from argos::CDynamics2DModel
typedef std::map< std::string, CDynamics2DModel * > TMap
 
- Public Types inherited from argos::CPhysicsModel
typedef std::map< std::string, CPhysicsModel * > TMap
 
typedef std::vector< CPhysicsModel * > TVector
 

Detailed Description

Base class for object models with a single body.

This class offers all the basic functionality to manage models composed of a single body. These models, while having only a single body, can have multiple associated shapes.

Single-body objects are often passive objects such as boxes and cylinders, and simple robots with no moving parts, such as the e-puck.

To use this class, simply create a class that inherits from it. The default implementations for Reset(), MoveTo(), etc. should be already OK for your needs.

In the constructor of your class, be sure to call the method SetBody() when you have created the body and associated the shapes to it. If this method is not called, the default implementations will have segfaults.

This class retains ownership for the body and shapes you created once you call SetBody(). In other words, you don't need to free these objects because ~CDynamics2DSingleBodyObjectModel() does it for you.

Definition at line 47 of file dynamics2d_single_body_object_model.h.

Constructor & Destructor Documentation

argos::CDynamics2DSingleBodyObjectModel::CDynamics2DSingleBodyObjectModel ( CDynamics2DEngine c_engine,
CComposableEntity c_entity 
)

Class constructor.

Parameters
c_engineThe dynamics 2D engine that manages this model.
c_entityThe composable entity associated to this model.
Exceptions
CARGoSExceptionif c_entity does not contain an embodied entity.

Definition at line 9 of file dynamics2d_single_body_object_model.cpp.

argos::CDynamics2DSingleBodyObjectModel::~CDynamics2DSingleBodyObjectModel ( )
virtual

Class destructor.

Disposes of the object body and its shapes.

Definition at line 18 of file dynamics2d_single_body_object_model.cpp.

Member Function Documentation

void argos::CDynamics2DSingleBodyObjectModel::CalculateBoundingBox ( )
virtual

Calculates the axis-aligned box that contains the entire physics model.

The bounding box is often called AABB.

Implements argos::CPhysicsModel.

Definition at line 85 of file dynamics2d_single_body_object_model.cpp.

cpBody* argos::CDynamics2DSingleBodyObjectModel::GetBody ( )
inline

Returns the body as non-const pointer.

Returns
The body as non-const pointer.

Definition at line 86 of file dynamics2d_single_body_object_model.h.

const cpBody* argos::CDynamics2DSingleBodyObjectModel::GetBody ( ) const
inline

Returns the body as const pointer.

Returns
The body as const pointer.

Definition at line 94 of file dynamics2d_single_body_object_model.h.

CComposableEntity& argos::CDynamics2DSingleBodyObjectModel::GetComposableEntity ( )
inline

Returns the associated composable entity as a non-const reference.

Returns
The associated composable entity as a non-const reference.

Definition at line 70 of file dynamics2d_single_body_object_model.h.

const CComposableEntity& argos::CDynamics2DSingleBodyObjectModel::GetComposableEntity ( ) const
inline

Returns the associated composable entity as a const reference.

Returns
The associated composable entity as a const reference.

Definition at line 78 of file dynamics2d_single_body_object_model.h.

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

Returns true if this model is colliding with another model.

Returns
true if this model is colliding with another model.

Implements argos::CPhysicsModel.

Definition at line 115 of file dynamics2d_single_body_object_model.cpp.

void argos::CDynamics2DSingleBodyObjectModel::MoveTo ( const CVector3 c_position,
const CQuaternion c_orientation 
)
virtual

Moves the entity to the wanted position and orientation within this engine. When you create a new model, you must implement this method. Don't forget to call UpdateEntityStatus() after you've changed the position.

This method should never be called directly from user code. It is called internally by CEmbodiedEntity::MoveTo(), which is meant to be called from user code.

CEmbodiedEntity::MoveTo() never calls this method if the embodied entity is static. This is because static entities cannot be moved around. Thus, there's no need in your code to check whether the associated entity is static.

Parameters
c_positionThe wanted position.
c_orientationThe wanted orientation.

Implements argos::CPhysicsModel.

Reimplemented in argos::CDynamics2DStretchableObjectModel.

Definition at line 40 of file dynamics2d_single_body_object_model.cpp.

void argos::CDynamics2DSingleBodyObjectModel::Reset ( )
virtual
void argos::CDynamics2DSingleBodyObjectModel::SetBody ( cpBody *  pt_body,
Real  f_height 
)
virtual

Sets the body and registers the default origin anchor method.

You must call this method for this class' methods to work.

This class retains ownership of the passed body, so you don't need to explicitly delete anything.

Internally, this method also sets pt_body->data to point to this, which is a requirement for ray cast queries to work properly.

Finally, this method also calculates the initial bounding box of the object.

Parameters
pt_bodyThe object body.
f_heightThe object height.

Definition at line 132 of file dynamics2d_single_body_object_model.cpp.

void argos::CDynamics2DSingleBodyObjectModel::UpdateEntityStatus ( )
virtual

Updates the status of the associated entity.

This method performs all the calculations to update the status of the entity associated to this model. In particular, it is in this method that anchors get updated and transfer to other engines is scheduled. This method internally calls:

See also
CalculateBoundingBox()
CalculateAnchors()
CComposableEntity::UpdateComponents()

Reimplemented from argos::CPhysicsModel.

Definition at line 105 of file dynamics2d_single_body_object_model.cpp.

virtual void argos::CDynamics2DSingleBodyObjectModel::UpdateFromEntityStatus ( )
pure virtual

Updates the state of this model from the status of the associated entity.

This method takes the current state of the associated entity (e.g., desired wheel speed, turret rotationss, etc.) and updates the state of this model. Typically, in this method you apply forces and set speeds.

Implements argos::CPhysicsModel.

Implemented in argos::CDynamics2DStretchableObjectModel, and argos::CDynamics2DEPuckModel.

void argos::CDynamics2DSingleBodyObjectModel::UpdateOriginAnchor ( SAnchor s_anchor)

Updates the origin anchor associated to the embodied entity.

Definition at line 149 of file dynamics2d_single_body_object_model.cpp.