ARGoS 3
A parallel, multi-engine simulator for swarm robotics
radio_entity.h
Go to the documentation of this file.
1
7#ifndef RADIO_ENTITY_H
8#define RADIO_ENTITY_H
9
10namespace argos {
11 class CRadioEntity;
12 class CRadioMedium;
13}
14
15#include <argos3/core/simulator/entity/positional_entity.h>
16#include <argos3/core/utility/datatypes/set.h>
17#include <argos3/core/utility/math/vector3.h>
18#include <argos3/core/utility/datatypes/byte_array.h>
19#include <argos3/core/simulator/space/positional_indices/space_hash.h>
20#include <argos3/core/simulator/space/positional_indices/grid.h>
21
22namespace argos {
23
25
26 public:
27
29
30 public:
31
32 typedef std::vector<CRadioEntity*> TList;
33
34 public:
35
37
39 const std::string& str_id,
40 Real f_transmit_range);
41
42 virtual ~CRadioEntity() {}
43
44 virtual void Init(TConfigurationNode& t_tree);
45
46 virtual void Reset();
47
48 virtual void Destroy();
49
50 virtual void SetEnabled(bool b_enabled);
51
57 inline const std::vector<std::pair<CVector3, CByteArray> >& GetData() const {
58 return m_vecData;
59 }
60
66 inline std::vector<std::pair<CVector3, CByteArray> >& GetData() {
67 return m_vecData;
68 }
69
75 inline void ReceiveData(const CVector3& c_tx_location, const CByteArray& c_tx_data) {
76 m_vecData.emplace_back(c_tx_location, c_tx_data);
77 }
78
85 inline bool HasData() const {
86 return !m_vecData.empty();
87 }
88
94 inline Real GetRange() const {
95 return m_fRange;
96 }
97
103 inline void SetRange(Real f_range) {
104 m_fRange = f_range;
105 }
106
107 virtual std::string GetTypeDescription() const {
108 return "radio";
109 }
110
116 inline bool HasMedium() const {
117 return m_pcMedium != nullptr;
118 }
119
125 CRadioMedium& GetMedium() const;
126
132 void SetMedium(CRadioMedium& c_medium);
133
134 protected:
135
137 std::vector<std::pair<CVector3, CByteArray> > m_vecData;
139
140 };
141
142 /****************************************/
143 /****************************************/
144
145 class CRadioEntitySpaceHashUpdater : public CSpaceHashUpdater<CRadioEntity> {
146
147 public:
148
149 virtual void operator()(CAbstractSpaceHash<CRadioEntity>& c_space_hash,
150 CRadioEntity& c_element);
151
152 private:
153
154 SInt32 m_nI, m_nJ, m_nK;
155
156 };
157
158 /****************************************/
159 /****************************************/
160
161 class CRadioEntityGridUpdater : public CGrid<CRadioEntity>::COperation {
162
163 public:
164
166 virtual bool operator()(CRadioEntity& c_entity);
167
168 private:
169
170 CGrid<CRadioEntity>& m_cGrid;
171 SInt32 m_nI, m_nJ, m_nK;
172
173 };
174
175 /****************************************/
176 /****************************************/
177
178}
179
180#endif
signed int SInt32
32-bit signed integer.
Definition datatypes.h:93
float Real
Collects all ARGoS code.
Definition datatypes.h:39
The namespace containing all the ARGoS related code.
Definition ci_actuator.h:12
ticpp::Element TConfigurationNode
The ARGoS configuration XML node.
Basic class for an entity that contains other entities.
The abstract definition of a space hash.
Definition space_hash.h:34
Defines the basic cell updater of the space hash.
Definition space_hash.h:269
Byte array utility class.
Definition byte_array.h:28
A 3D vector class.
Definition vector3.h:31
void SetRange(Real f_range)
Sets the tranmission range of the radio.
std::vector< std::pair< CVector3, CByteArray > > & GetData()
Returns a reference to the received data.
void SetMedium(CRadioMedium &c_medium)
Sets the medium associated to this entity.
CRadioMedium & GetMedium() const
Returns the medium associated to this radio.
std::vector< CRadioEntity * > TList
virtual void SetEnabled(bool b_enabled)
Enables or disables an entity.
CRadioMedium * m_pcMedium
std::vector< std::pair< CVector3, CByteArray > > m_vecData
virtual std::string GetTypeDescription() const
Returns a string label for this class.
virtual void Init(TConfigurationNode &t_tree)
Initializes the state of the entity from the XML configuration tree.
virtual void Reset()
Resets the state of the entity to whatever it was after Init() or the standalone constructor was call...
virtual void Destroy()
Destroys the entity, undoing whatever was done by Init() or by the standalone constructor.
virtual ~CRadioEntity()
bool HasMedium() const
Returns true if this radio is associated to a medium.
void ReceiveData(const CVector3 &c_tx_location, const CByteArray &c_tx_data)
Adds data received by the radio.
CRadioEntity(CComposableEntity *pc_parent)
const std::vector< std::pair< CVector3, CByteArray > > & GetData() const
Returns a constant reference to the received data.
bool HasData() const
Checks if there has been data received by the radio.
Real GetRange() const
Returns the transmission range of the radio.
virtual void operator()(CAbstractSpaceHash< CRadioEntity > &c_space_hash, CRadioEntity &c_element)
Updates the necessary cells of a space hash.
CRadioEntityGridUpdater(CGrid< CRadioEntity > &c_grid)
virtual bool operator()(CRadioEntity &c_entity)