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

wheeled_entity.cpp
Go to the documentation of this file.
1 
7 #include "wheeled_entity.h"
8 #include <argos3/core/simulator/space/space.h>
9 
10 namespace argos {
11 
12  /****************************************/
13  /****************************************/
14 
16  size_t un_num_wheels) :
17  CEntity(pc_parent),
18  m_unNumWheels(un_num_wheels) {
19  m_pcWheelPositions = new CVector3[m_unNumWheels];
20  ::memset(m_pcWheelPositions, 0, m_unNumWheels * sizeof(CVector3));
21  m_pfWheelRadia = new Real[m_unNumWheels];
22  ::memset(m_pfWheelRadia, 0, m_unNumWheels * sizeof(Real));
23  m_pfWheelVelocities = new Real[m_unNumWheels];
24  ::memset(m_pfWheelVelocities, 0, m_unNumWheels * sizeof(Real));
25  Disable();
26  }
27 
28  /****************************************/
29  /****************************************/
30 
32  const std::string& str_id,
33  size_t un_num_wheels) :
34  CEntity(pc_parent, str_id),
35  m_unNumWheels(un_num_wheels) {
36  m_pcWheelPositions = new CVector3[m_unNumWheels];
37  ::memset(m_pcWheelPositions, 0, m_unNumWheels * sizeof(CVector3));
38  m_pfWheelRadia = new Real[m_unNumWheels];
39  ::memset(m_pfWheelRadia, 0, m_unNumWheels * sizeof(Real));
40  m_pfWheelVelocities = new Real[m_unNumWheels];
41  ::memset(m_pfWheelVelocities, 0, m_unNumWheels * sizeof(Real));
42  Disable();
43  }
44 
45  /****************************************/
46  /****************************************/
47 
49  delete[] m_pcWheelPositions;
50  delete[] m_pfWheelRadia;
51  delete[] m_pfWheelVelocities;
52  }
53 
54  /****************************************/
55  /****************************************/
56 
58  ::memset(m_pfWheelVelocities, 0, m_unNumWheels * sizeof(Real));
59  }
60 
61  /****************************************/
62  /****************************************/
63 
65  const CVector3& c_position,
66  Real f_radius) {
67  if(un_index < m_unNumWheels) {
68  m_pcWheelPositions[un_index] = c_position;
69  m_pfWheelRadia[un_index] = f_radius;
70  }
71  else {
72  THROW_ARGOSEXCEPTION("CWheeledEntity::SetWheel() : index " << un_index << " out of bounds (allowed [0:" << m_unNumWheels << "])");
73  }
74  }
75 
76  /****************************************/
77  /****************************************/
78 
79  const CVector3& CWheeledEntity::GetWheelPosition(size_t un_index) const {
80  if(un_index < m_unNumWheels) {
81  return m_pcWheelPositions[un_index];
82  }
83  else {
84  THROW_ARGOSEXCEPTION("CWheeledEntity::GetWheelPosition() : index " << un_index << " out of bounds (allowed [0:" << m_unNumWheels << "])");
85  }
86  }
87 
88  /****************************************/
89  /****************************************/
90 
91  Real CWheeledEntity::GetWheelRadius(size_t un_index) const {
92  if(un_index < m_unNumWheels) {
93  return m_pfWheelRadia[un_index];
94  }
95  else {
96  THROW_ARGOSEXCEPTION("CWheeledEntity::GetWheelRadius() : index " << un_index << " out of bounds (allowed [0:" << m_unNumWheels << "])");
97  }
98  }
99 
100  /****************************************/
101  /****************************************/
102 
103  Real CWheeledEntity::GetWheelVelocity(size_t un_index) const {
104  if(un_index < m_unNumWheels) {
105  return m_pfWheelVelocities[un_index];
106  }
107  else {
108  THROW_ARGOSEXCEPTION("CWheeledEntity::GetWheelVelocity() : index " << un_index << " out of bounds (allowed [0:" << m_unNumWheels << "])");
109  }
110  }
111 
112  /****************************************/
113  /****************************************/
114 
115  void CWheeledEntity::SetVelocities(Real* pf_velocities) {
116  ::memcpy(m_pfWheelVelocities, pf_velocities, m_unNumWheels * sizeof(Real));
117  }
118 
119  /****************************************/
120  /****************************************/
121 
123 
124  /****************************************/
125  /****************************************/
126 
127 }
A 3D vector class.
Definition: vector3.h:29
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
void SetWheel(UInt32 un_index, const CVector3 &c_position, Real f_radius)
Real GetWheelRadius(size_t un_index) const
virtual void Reset()
Resets the state of the entity to whatever it was after Init() or the standalone constructor was call...
unsigned int UInt32
32-bit unsigned integer.
Definition: datatypes.h:97
CWheeledEntity(CComposableEntity *pc_parent, size_t un_num_wheels)
Real GetWheelVelocity(size_t un_index) const
Basic class for an entity that contains other entities.
void Disable()
Disables the entity.
Definition: entity.h:275
REGISTER_STANDARD_SPACE_OPERATIONS_ON_ENTITY(CEntity)
The namespace containing all the ARGoS related code.
Definition: ci_actuator.h:12
const CVector3 & GetWheelPosition(size_t un_index) const
void SetVelocities(Real *pf_velocities)