Warning: include(php/utility.php): Failed to open stream: No such file or directory in /home/argos/argos3/doc/api/embedded/a00780_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/a00780_source.php on line 2
The ARGoS Website

rotor_equipped_entity.cpp
Go to the documentation of this file.
1 
8 #include <argos3/core/simulator/space/space.h>
9 
10 namespace argos {
11 
12  /****************************************/
13  /****************************************/
14 
16  size_t un_num_rotors) :
17  CEntity(pc_parent),
18  m_unNumRotors(un_num_rotors) {
19  m_pcRotorPositions = new CVector3[m_unNumRotors];
20  ::memset(m_pcRotorPositions, 0, m_unNumRotors * sizeof(CVector3));
21  m_pfRotorVelocities = new Real[m_unNumRotors];
22  ::memset(m_pfRotorVelocities, 0, m_unNumRotors * sizeof(Real));
23  Disable();
24  }
25 
26  /****************************************/
27  /****************************************/
28 
30  const std::string& str_id,
31  size_t un_num_rotors) :
32  CEntity(pc_parent, str_id),
33  m_unNumRotors(un_num_rotors) {
34  m_pcRotorPositions = new CVector3[m_unNumRotors];
35  ::memset(m_pcRotorPositions, 0, m_unNumRotors * sizeof(CVector3));
36  m_pfRotorVelocities = new Real[m_unNumRotors];
37  ::memset(m_pfRotorVelocities, 0, m_unNumRotors * sizeof(Real));
38  Disable();
39  }
40 
41  /****************************************/
42  /****************************************/
43 
45  delete[] m_pcRotorPositions;
46  delete[] m_pfRotorVelocities;
47  }
48 
49  /****************************************/
50  /****************************************/
51 
53  ::memset(m_pfRotorVelocities, 0, m_unNumRotors * sizeof(Real));
54  }
55 
56  /****************************************/
57  /****************************************/
58 
60  const CVector3& c_position) {
61  if(un_index < m_unNumRotors) {
62  m_pcRotorPositions[un_index] = c_position;
63  }
64  else {
65  THROW_ARGOSEXCEPTION("CRotorEquippedEntity::SetRotor() : index " << un_index << " out of bounds (allowed [0:" << m_unNumRotors << "])");
66  }
67  }
68 
69  /****************************************/
70  /****************************************/
71 
72  const CVector3& CRotorEquippedEntity::GetRotorPosition(size_t un_index) const {
73  if(un_index < m_unNumRotors) {
74  return m_pcRotorPositions[un_index];
75  }
76  else {
77  THROW_ARGOSEXCEPTION("CRotorEquippedEntity::GetRotorPosition() : index " << un_index << " out of bounds (allowed [0:" << m_unNumRotors << "])");
78  }
79  }
80 
81  /****************************************/
82  /****************************************/
83 
85  if(un_index < m_unNumRotors) {
86  return m_pfRotorVelocities[un_index];
87  }
88  else {
89  THROW_ARGOSEXCEPTION("CRotorEquippedEntity::GetRotorVelocity() : index " << un_index << " out of bounds (allowed [0:" << m_unNumRotors << "])");
90  }
91  }
92 
93  /****************************************/
94  /****************************************/
95 
97  ::memcpy(m_pfRotorVelocities, pf_velocities, m_unNumRotors * sizeof(Real));
98  }
99 
100  /****************************************/
101  /****************************************/
102 
104 
105  /****************************************/
106  /****************************************/
107 
108 }
A 3D vector class.
Definition: vector3.h:29
virtual void Reset()
Resets the state of the entity to whatever it was after Init() or the standalone constructor was call...
void SetVelocities(Real *pf_velocities)
float Real
Collects all ARGoS code.
Definition: datatypes.h:39
#define THROW_ARGOSEXCEPTION(message)
This macro throws an ARGoS exception with the passed message.
The basic entity type.
Definition: entity.h:89
unsigned int UInt32
32-bit unsigned integer.
Definition: datatypes.h:97
Basic class for an entity that contains other entities.
Real GetRotorVelocity(size_t un_index) const
const CVector3 & GetRotorPosition(size_t un_index) const
void Disable()
Disables the entity.
Definition: entity.h:275
REGISTER_STANDARD_SPACE_OPERATIONS_ON_ENTITY(CEntity)
CRotorEquippedEntity(CComposableEntity *pc_parent, size_t un_num_rotors)
void SetRotor(UInt32 un_index, const CVector3 &c_position)
The namespace containing all the ARGoS related code.
Definition: ci_actuator.h:12