ARGoS  3
A parallel, multi-engine simulator for swarm robotics
footbot_turret_entity.cpp
Go to the documentation of this file.
1 
8 #include <argos3/core/utility/math/angles.h>
9 #include <argos3/core/simulator/physics_engine/physics_engine.h>
10 #include <argos3/core/simulator/space/space.h>
11 
12 namespace argos {
13 
14  /****************************************/
15  /****************************************/
16 
18  CEntity(pc_parent),
19  m_psAnchor(NULL) {
20  Reset();
21  Disable();
22  }
23 
24  /****************************************/
25  /****************************************/
26 
28  const std::string& str_id,
29  SAnchor& s_anchor) :
30  CEntity(pc_parent, str_id),
31  m_psAnchor(&s_anchor) {
32  Reset();
33  Disable();
34  }
35 
36  /****************************************/
37  /****************************************/
38 
40  }
41 
42  /****************************************/
43  /****************************************/
44 
46  m_unMode = MODE_OFF;
47  m_cDesRot = CRadians::ZERO;
48  m_cOldRot = CRadians::ZERO;
49  m_fDesRotSpeed = 0.0;
50  m_fCurRotSpeed = 0.0;
51  if (m_psAnchor) {
52  m_psAnchor->OffsetOrientation = CQuaternion();
53  }
54  }
55 
56  /****************************************/
57  /****************************************/
58 
60  /* Calculate rotation speed */
61  CRadians cZAngle, cYAngle, cXAngle;
62  m_psAnchor->OffsetOrientation.ToEulerAngles(cZAngle, cYAngle, cXAngle);
63  m_fCurRotSpeed =
64  NormalizedDifference(cZAngle, m_cOldRot).GetValue() *
66  /* Save rotation for next time */
67  m_cOldRot = cZAngle;
68  }
69 
70  /****************************************/
71  /****************************************/
72 
74  CRadians cZAngle, cYAngle, cXAngle;
75  m_psAnchor->OffsetOrientation.ToEulerAngles(cZAngle, cYAngle, cXAngle);
76  return cZAngle;
77  }
78 
79  /****************************************/
80  /****************************************/
81 
83  return m_fCurRotSpeed;
84  }
85 
86  /****************************************/
87  /****************************************/
88 
90  return m_cDesRot;
91  }
92 
93  /****************************************/
94  /****************************************/
95 
97  return m_fDesRotSpeed;
98  }
99 
100  /****************************************/
101  /****************************************/
102 
104  m_cDesRot = c_rotation;
105  m_cDesRot.SignedNormalize();
106  }
107 
108  /****************************************/
109  /****************************************/
110 
112  m_fDesRotSpeed = f_speed;
113  }
114 
115  /****************************************/
116  /****************************************/
117 
119 
120  /****************************************/
121  /****************************************/
122 
123 }
footbot_turret_entity.h
argos
The namespace containing all the ARGoS related code.
Definition: ci_actuator.h:12
argos::CFootBotTurretEntity::MODE_OFF
@ MODE_OFF
Definition: footbot_turret_entity.h:27
argos::CFootBotTurretEntity::SetDesiredRotation
void SetDesiredRotation(const CRadians &c_rotation)
Definition: footbot_turret_entity.cpp:103
argos::CRadians
It defines the basic type CRadians, used to store an angle value in radians.
Definition: angles.h:42
argos::CComposableEntity
Basic class for an entity that contains other entities.
Definition: composable_entity.h:32
argos::CFootBotTurretEntity::GetRotationSpeed
Real GetRotationSpeed() const
Definition: footbot_turret_entity.cpp:82
argos::CFootBotTurretEntity::GetRotation
CRadians GetRotation() const
Definition: footbot_turret_entity.cpp:73
argos::CFootBotTurretEntity::SetDesiredRotationSpeed
void SetDesiredRotationSpeed(Real f_speed)
Definition: footbot_turret_entity.cpp:111
argos::CRadians::SignedNormalize
CRadians & SignedNormalize()
Normalizes the value in the range [-PI:PI].
Definition: angles.h:137
argos::CFootBotTurretEntity::GetDesiredRotationSpeed
Real GetDesiredRotationSpeed() const
Definition: footbot_turret_entity.cpp:96
argos::REGISTER_STANDARD_SPACE_OPERATIONS_ON_ENTITY
REGISTER_STANDARD_SPACE_OPERATIONS_ON_ENTITY(CEntity)
argos::TConfigurationNode
ticpp::Element TConfigurationNode
The ARGoS configuration XML node.
Definition: argos_configuration.h:27
argos::SAnchor::OffsetOrientation
CQuaternion OffsetOrientation
The initial orientation of the anchor wrt the body coordinate system.
Definition: physics_model.h:49
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::CQuaternion
Definition: quaternion.h:14
argos::CFootBotTurretEntity::GetDesiredRotation
const CRadians & GetDesiredRotation() const
Definition: footbot_turret_entity.cpp:89
argos::SAnchor
An anchor related to the body of an entity.
Definition: physics_model.h:38
argos::CEntity
The basic entity type.
Definition: entity.h:89
argos::CFootBotTurretEntity
Definition: footbot_turret_entity.h:20
argos::CFootBotTurretEntity::Update
virtual void Update()
Updates the state of this entity.
Definition: footbot_turret_entity.cpp:59
argos::CFootBotTurretEntity::Reset
virtual void Reset()
Resets the state of the entity to whatever it was after Init() or the standalone constructor was call...
Definition: footbot_turret_entity.cpp:45
argos::CEntity::Disable
void Disable()
Disables the entity.
Definition: entity.h:249
argos::CFootBotTurretEntity::CFootBotTurretEntity
CFootBotTurretEntity(CComposableEntity *pc_parent)
Definition: footbot_turret_entity.cpp:17
argos::CPhysicsEngine::GetInverseSimulationClockTick
static Real GetInverseSimulationClockTick()
Returns the inverse of GetSimulationClockTick().
Definition: physics_engine.cpp:271
Real
float Real
Collects all ARGoS code.
Definition: datatypes.h:39
argos::NormalizedDifference
CRadians NormalizedDifference(const CRadians &c_angle1, const CRadians &c_angle2)
Calculates the normalized difference between the given angles.
Definition: angles.h:510
argos::CFootBotTurretEntity::Init
virtual void Init(TConfigurationNode &t_tree)
Initializes the state of the entity from the XML configuration tree.
Definition: footbot_turret_entity.cpp:39
argos::CRadians::ZERO
static const CRadians ZERO
Set to zero radians.
Definition: angles.h:79