ARGoS  3
A parallel, multi-engine simulator for swarm robotics
dynamics2d_cylinder_model.cpp
Go to the documentation of this file.
1 
8 #include "dynamics2d_gripping.h"
9 #include "dynamics2d_engine.h"
10 
11 namespace argos {
12 
13  /****************************************/
14  /****************************************/
15 
17  CCylinderEntity& c_entity) :
18  CDynamics2DStretchableObjectModel(c_engine, c_entity) {
19  /* Get the radius of the entity */
20  Real fRadius = c_entity.GetRadius();
21  /* Create a circle object in the physics space */
22  const CVector3& cPosition = GetEmbodiedEntity().GetOriginAnchor().Position;
23  CRadians cXAngle, cYAngle, cZAngle;
24  GetEmbodiedEntity().GetOriginAnchor().Orientation.ToEulerAngles(cZAngle, cYAngle, cXAngle);
25  /*
26  * Create body and shapes
27  */
28  cpBody* ptBody;
29  if(GetEmbodiedEntity().IsMovable()) {
30  /* The cylinder is movable */
31  SetMass(c_entity.GetMass());
32  /* Create the body */
33  ptBody = cpSpaceAddBody(GetDynamics2DEngine().GetPhysicsSpace(),
34  cpBodyNew(GetMass(),
35  cpMomentForCircle(GetMass(),
36  0,
37  fRadius + fRadius,
38  cpvzero)));
39  ptBody->p = cpv(cPosition.GetX(), cPosition.GetY());
40  cpBodySetAngle(ptBody, cZAngle.GetValue());
41  /* Create the shape */
42  cpShape* ptShape = cpSpaceAddShape(GetDynamics2DEngine().GetPhysicsSpace(),
43  cpCircleShapeNew(ptBody, fRadius, cpvzero));
44  ptShape->e = 0.0; // no elasticity
45  ptShape->u = 0.7; // lots contact friction to help pushing
46  /* The shape is grippable */
48  ptShape));
49  /* Set the body so that the default methods work as expected */
50  SetBody(ptBody, c_entity.GetHeight());
51  /* Friction with ground */
52  SetLinearFriction(0.0f, 1.49f);
53  SetAngularFriction(0.0f, 1.49f);
54  }
55  else {
56  /* The cylinder is not movable */
57  /* Create a static body */
58  ptBody = cpBodyNewStatic();
59  ptBody->p = cpv(cPosition.GetX(), cPosition.GetY());
60  cpBodySetAngle(ptBody, cZAngle.GetValue());
61  /* Create the shape */
62  cpShape* ptShape = cpSpaceAddShape(
63  GetDynamics2DEngine().GetPhysicsSpace(),
64  cpCircleShapeNew(ptBody,
65  fRadius,
66  cpvzero));
67  ptShape->e = 0.0; // No elasticity
68  ptShape->u = 0.1; // Little contact friction to help sliding away
69  /* This shape is normal (not grippable, not gripper) */
70  ptShape->collision_type = CDynamics2DEngine::SHAPE_NORMAL;
71  /* Set the body so that the default methods work as expected */
72  SetBody(ptBody, c_entity.GetHeight());
73  }
74  }
75 
76  /****************************************/
77  /****************************************/
78 
80 
81  /****************************************/
82  /****************************************/
83 
84 }
argos::CEmbodiedEntity::GetOriginAnchor
const SAnchor & GetOriginAnchor() const
Returns a const reference to the origin anchor associated to this entity.
Definition: embodied_entity.h:119
argos::SAnchor::Orientation
CQuaternion Orientation
The orientation of the anchor wrt the global coordinate system.
Definition: physics_model.h:53
argos::CDynamics2DStretchableObjectModel
A stretchable and grippable object model for the dynamics 2D engine.
Definition: dynamics2d_stretchable_object_model.h:32
argos
The namespace containing all the ARGoS related code.
Definition: ci_actuator.h:12
argos::CVector3
A 3D vector class.
Definition: vector3.h:29
argos::CDynamics2DCylinderModel
Definition: dynamics2d_cylinder_model.h:20
argos::CDynamics2DModel::GetDynamics2DEngine
CDynamics2DEngine & GetDynamics2DEngine()
Returns the dynamics 2D engine state.
Definition: dynamics2d_model.h:48
argos::CRadians
It defines the basic type CRadians, used to store an angle value in radians.
Definition: angles.h:42
argos::CDynamics2DStretchableObjectModel::SetGrippable
void SetGrippable(CDynamics2DGrippable *pc_grippable)
Definition: dynamics2d_stretchable_object_model.h:56
argos::CDynamics2DGrippable
Definition: dynamics2d_gripping.h:84
argos::CCylinderEntity::GetHeight
Real GetHeight() const
Definition: cylinder_entity.h:84
argos::CDynamics2DEngine::SHAPE_NORMAL
@ SHAPE_NORMAL
Definition: dynamics2d_engine.h:47
argos::CDynamics2DEngine
Definition: dynamics2d_engine.h:42
argos::REGISTER_STANDARD_DYNAMICS2D_OPERATIONS_ON_ENTITY
REGISTER_STANDARD_DYNAMICS2D_OPERATIONS_ON_ENTITY(CEPuckEntity, CDynamics2DEPuckModel)
argos::CVector3::GetX
Real GetX() const
Returns the x coordinate of this vector.
Definition: vector3.h:93
argos::CDynamics2DStretchableObjectModel::SetAngularFriction
void SetAngularFriction(Real f_max_bias, Real f_max_force)
Sets the angular friction of this object.
Definition: dynamics2d_stretchable_object_model.cpp:73
argos::CRadians::GetValue
Real GetValue() const
Returns the value in radians.
Definition: angles.h:111
argos::CQuaternion::ToEulerAngles
void ToEulerAngles(CRadians &c_z_angle, CRadians &c_y_angle, CRadians &c_x_angle) const
Definition: quaternion.h:171
argos::CDynamics2DStretchableObjectModel::SetLinearFriction
void SetLinearFriction(Real f_max_bias, Real f_max_force)
Sets the linear friction of this object.
Definition: dynamics2d_stretchable_object_model.cpp:58
argos::CCylinderEntity::GetRadius
Real GetRadius() const
Definition: cylinder_entity.h:76
dynamics2d_gripping.h
dynamics2d_engine.h
dynamics2d_cylinder_model.h
argos::CCylinderEntity
Definition: cylinder_entity.h:23
argos::CDynamics2DSingleBodyObjectModel::SetBody
virtual void SetBody(cpBody *pt_body, Real f_height)
Sets the body and registers the default origin anchor method.
Definition: dynamics2d_single_body_object_model.cpp:132
argos::CCylinderEntity::GetMass
Real GetMass() const
Definition: cylinder_entity.h:92
argos::CDynamics2DStretchableObjectModel::SetMass
void SetMass(Real f_mass)
Definition: dynamics2d_stretchable_object_model.h:52
argos::CDynamics2DCylinderModel::CDynamics2DCylinderModel
CDynamics2DCylinderModel(CDynamics2DEngine &c_engine, CCylinderEntity &c_entity)
Definition: dynamics2d_cylinder_model.cpp:16
argos::CVector3::GetY
Real GetY() const
Returns the y coordinate of this vector.
Definition: vector3.h:109
argos::CDynamics2DStretchableObjectModel::GetMass
Real GetMass() const
Definition: dynamics2d_stretchable_object_model.h:48
argos::SAnchor::Position
CVector3 Position
The position of the anchor wrt the global coordinate system.
Definition: physics_model.h:51
Real
float Real
Collects all ARGoS code.
Definition: datatypes.h:39
argos::CPhysicsModel::GetEmbodiedEntity
CEmbodiedEntity & GetEmbodiedEntity()
Returns the embodied entity associated to this physics model.
Definition: physics_model.h:133