Warning: include(php/utility.php): Failed to open stream: No such file or directory in /home/argos/argos3/doc/api/embedded/a00802_source.php on line 2

Warning: include(): Failed opening 'php/utility.php' for inclusion (include_path='.:/usr/lib64/php') in /home/argos/argos3/doc/api/embedded/a00802_source.php on line 2
The ARGoS Website

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 */
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 }
A 3D vector class.
Definition: vector3.h:29
void SetAngularFriction(Real f_max_bias, Real f_max_force)
Sets the angular friction of this object.
float Real
Collects all ARGoS code.
Definition: datatypes.h:39
Real GetX() const
Returns the x coordinate of this vector.
Definition: vector3.h:93
A stretchable and grippable object model for the dynamics 2D engine.
Real GetY() const
Returns the y coordinate of this vector.
Definition: vector3.h:109
virtual void SetBody(cpBody *pt_body, Real f_height)
Sets the body and registers the default origin anchor method.
CQuaternion Orientation
The orientation of the anchor wrt the global coordinate system.
Definition: physics_model.h:53
cpFloat GetCylinderAngularFriction() const
It defines the basic type CRadians, used to store an angle value in radians.
Definition: angles.h:42
CDynamics2DCylinderModel(CDynamics2DEngine &c_engine, CCylinderEntity &c_entity)
CDynamics2DEngine & GetDynamics2DEngine()
Returns the dynamics 2D engine state.
void ToEulerAngles(CRadians &c_z_angle, CRadians &c_y_angle, CRadians &c_x_angle) const
Definition: quaternion.h:172
CEmbodiedEntity & GetEmbodiedEntity()
Returns the embodied entity associated to this physics model.
cpFloat GetCylinderLinearFriction() const
Real GetValue() const
Returns the value in radians.
Definition: angles.h:111
CVector3 Position
The position of the anchor wrt the global coordinate system.
Definition: physics_model.h:51
void SetLinearFriction(Real f_max_bias, Real f_max_force)
Sets the linear friction of this object.
The namespace containing all the ARGoS related code.
Definition: ci_actuator.h:12
REGISTER_STANDARD_DYNAMICS2D_OPERATIONS_ON_ENTITY(CEPuckEntity, CDynamics2DEPuckModel)
void SetGrippable(CDynamics2DGrippable *pc_grippable)
const SAnchor & GetOriginAnchor() const
Returns a const reference to the origin anchor associated to this entity.