argos::CPhysicsModel Class Referenceabstract

#include <physics_model.h>

Inheritance diagram for argos::CPhysicsModel:

Public Types

typedef std::map< std::string, CPhysicsModel * > TMap
 
typedef std::vector< CPhysicsModel * > TVector
 

Public Member Functions

 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...
 
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 void UpdatePhysics ()
 Performs extra work just before the physics update takes place. More...
 
virtual void MoveTo (const CVector3 &c_position, const CQuaternion &c_orientation)=0
 
const SBoundingBoxGetBoundingBox () const
 Returns an axis-aligned box that contains the physics model. More...
 
virtual void CalculateBoundingBox ()=0
 Calculates the axis-aligned box that contains the entire physics model. More...
 
virtual void CalculateAnchors ()
 Calculates the anchors associated to this model. More...
 
virtual bool IsCollidingWithSomething () const =0
 Returns true if this model is colliding with another 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...
 

Detailed Description

Definition at line 102 of file physics_model.h.

Member Typedef Documentation

◆ TMap

typedef std::map<std::string, CPhysicsModel*> argos::CPhysicsModel::TMap

Definition at line 106 of file physics_model.h.

◆ TVector

Definition at line 107 of file physics_model.h.

Constructor & Destructor Documentation

◆ CPhysicsModel()

argos::CPhysicsModel::CPhysicsModel ( CPhysicsEngine c_engine,
CEmbodiedEntity c_entity 
)

Definition at line 44 of file physics_model.cpp.

◆ ~CPhysicsModel()

virtual argos::CPhysicsModel::~CPhysicsModel ( )
inlinevirtual

Definition at line 114 of file physics_model.h.

Member Function Documentation

◆ CalculateAnchors()

void argos::CPhysicsModel::CalculateAnchors ( )
virtual

Calculates the anchors associated to this model.

The default implementation of this method should fit all possible use cases. There's usually no need to override it.

Definition at line 77 of file physics_model.cpp.

◆ CalculateBoundingBox()

virtual void argos::CPhysicsModel::CalculateBoundingBox ( )
pure virtual

◆ GetBoundingBox() [1/2]

SBoundingBox& argos::CPhysicsModel::GetBoundingBox ( )
inline

Returns an axis-aligned box that contains the physics model.

The bounding box is often called AABB.

Returns
The bounding box as a modifiable struct.

Definition at line 242 of file physics_model.h.

◆ GetBoundingBox() [2/2]

const SBoundingBox& argos::CPhysicsModel::GetBoundingBox ( ) const
inline

Returns an axis-aligned box that contains the physics model.

The bounding box is often called AABB.

Returns
The bounding box as a const struct.

Definition at line 214 of file physics_model.h.

◆ GetEmbodiedEntity() [1/2]

CEmbodiedEntity& argos::CPhysicsModel::GetEmbodiedEntity ( )
inline

Returns the embodied entity associated to this physics model.

Returns
The embodied entity associated to this physics model.

Definition at line 133 of file physics_model.h.

◆ GetEmbodiedEntity() [2/2]

const CEmbodiedEntity& argos::CPhysicsModel::GetEmbodiedEntity ( ) const
inline

Returns the embodied entity associated to this physics model.

Returns
The embodied entity associated to this physics model.

Definition at line 141 of file physics_model.h.

◆ GetEngine()

CPhysicsEngine& argos::CPhysicsModel::GetEngine ( )
inline

Returns the physics engine associated to this physics model.

Returns
The physics engine associated to this physics model.

Definition at line 125 of file physics_model.h.

◆ IsCollidingWithSomething()

virtual bool argos::CPhysicsModel::IsCollidingWithSomething ( ) const
pure virtual

Returns true if this model is colliding with another model.

Returns
true if this model is colliding with another model.

Implemented in argos::CPointMass3DModel, argos::CDynamics3DModel, argos::CDynamics2DSingleBodyObjectModel, and argos::CDynamics2DMultiBodyObjectModel.

◆ MoveTo()

virtual void argos::CPhysicsModel::MoveTo ( const CVector3 c_position,
const CQuaternion c_orientation 
)
pure 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.

Implemented in argos::CPointMass3DModel, argos::CDynamics3DSingleBodyObjectModel, argos::CDynamics3DMultiBodyObjectModel, argos::CDynamics2DStretchableObjectModel, argos::CDynamics2DSingleBodyObjectModel, argos::CDynamics2DMultiBodyObjectModel, and argos::CDynamics2DFootBotModel.

◆ RegisterAnchorMethod()

template<typename MODEL >
void argos::CPhysicsModel::RegisterAnchorMethod ( const SAnchor s_anchor,
void(MODEL::*)(SAnchor &)  pt_method 
)

Registers an anchor method.

Parameters
MODELA user-defined subclass of CPhysicsModel.
s_anchorThe anchor to pass as a parameter to the anchor method.
pt_methodThe actual user-defined pointer-to-method.

Definition at line 341 of file physics_model.h.

◆ UpdateEntityStatus()

void argos::CPhysicsModel::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 in argos::CPointMass3DBoxModel, argos::CDynamics3DModel, argos::CDynamics2DSingleBodyObjectModel, argos::CDynamics3DPrototypeModel, and argos::CDynamics3DEPuckModel.

Definition at line 55 of file physics_model.cpp.

◆ UpdateFromEntityStatus()

virtual void argos::CPhysicsModel::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.

Implemented in argos::CPointMass3DModel, argos::CDynamics2DSingleBodyObjectModel, argos::CDynamics2DMultiBodyObjectModel, argos::CPointMass3DQuadRotorModel, argos::CPointMass3DCylinderModel, argos::CPointMass3DBoxModel, argos::CDynamics3DModel, argos::CDynamics2DStretchableObjectModel, argos::CDynamics3DPrototypeModel, argos::CPointMass3DFootBotModel, argos::CDynamics2DFootBotModel, argos::CDynamics3DEPuckModel, and argos::CDynamics2DEPuckModel.

◆ UpdatePhysics()

virtual void argos::CPhysicsModel::UpdatePhysics ( )
inlinevirtual

Performs extra work just before the physics update takes place.

This method is called as many times as the physics update itself, that is GetIteration() times every control step.

You can use this method to implement a PID controller, or to calculate high-frequency physics effects.

By default this method does nothing.

Definition at line 184 of file physics_model.h.