ARGoS  3
A parallel, multi-engine simulator for swarm robotics
floor_entity.h
Go to the documentation of this file.
1 
7 #ifndef FLOOR_ENTITY_H
8 #define FLOOR_ENTITY_H
9 
10 namespace argos {
11  class CFloorEntity;
12 }
13 
14 #include <argos3/core/simulator/entity/entity.h>
15 #include <argos3/core/utility/math/vector2.h>
16 #include <argos3/core/utility/math/vector3.h>
17 #include <argos3/core/utility/datatypes/color.h>
18 
19 namespace argos {
20 
21  class CFloorEntity : public CEntity {
22 
23  public:
24 
26 
27  public:
28 
29  virtual ~CFloorColorSource() {}
30 
31  virtual void Reset() {}
32 
33  virtual CColor GetColorAtPoint(Real f_x,
34  Real f_y) = 0;
35 
36 #ifdef ARGOS_WITH_FREEIMAGE
37  virtual void SaveAsImage(const std::string& str_path) = 0;
38 #endif
39 
40  };
41 
42  public:
43 
44  ENABLE_VTABLE();
45 
46  enum EColorSource {
47  UNSET = 0,
50  };
51 
52  public:
53 
58  CFloorEntity();
59 
66 #ifdef ARGOS_WITH_FREEIMAGE
67  CFloorEntity(const std::string& str_id,
68  const std::string& str_file_name);
69 #endif
70 
75  CFloorEntity(const std::string& str_id,
76  UInt32 un_pixels_per_meter);
77 
81  virtual ~CFloorEntity();
82 
86  virtual void Init(TConfigurationNode& t_tree);
87 
91  virtual void Reset();
92 
100  Real f_y) {
101  ARGOS_ASSERT(m_pcColorSource != NULL,
102  "The floor entity \"" <<
103  GetId() <<
104  "\" has no associated color source.");
105  return m_pcColorSource->GetColorAtPoint(f_x, f_y);
106  }
107 
113  inline bool HasChanged() const {
114  return m_bHasChanged;
115  }
116 
121  inline void SetChanged() {
122  m_bHasChanged = true;
123  }
124 
129  inline void ClearChanged() {
130  m_bHasChanged = false;
131  }
132 
139 #ifdef ARGOS_WITH_FREEIMAGE
140  void SaveAsImage(const std::string& str_path);
141 #endif
142 
143  virtual std::string GetTypeDescription() const {
144  return "floor";
145  }
146 
147  private:
148 
152  EColorSource m_eColorSource;
153 
157  CFloorColorSource* m_pcColorSource;
158 
162  bool m_bHasChanged;
163  };
164 }
165 
166 #endif
argos::CEntity::GetId
const std::string & GetId() const
Returns the id of this entity.
Definition: entity.h:157
argos::CFloorEntity::Init
virtual void Init(TConfigurationNode &t_tree)
Initializes the entity from an XML tree.
Definition: floor_entity.cpp:214
argos
The namespace containing all the ARGoS related code.
Definition: ci_actuator.h:12
argos::CFloorEntity::HasChanged
bool HasChanged() const
Returns true if the floor color has changed.
Definition: floor_entity.h:113
argos::CFloorEntity::GetTypeDescription
virtual std::string GetTypeDescription() const
Saves the current floor color to the given file.
Definition: floor_entity.h:143
argos::CFloorEntity::EColorSource
EColorSource
Definition: floor_entity.h:46
argos::CFloorEntity::GetColorAtPoint
CColor GetColorAtPoint(Real f_x, Real f_y)
Returns the color at the given point.
Definition: floor_entity.h:99
argos::TConfigurationNode
ticpp::Element TConfigurationNode
The ARGoS configuration XML node.
Definition: argos_configuration.h:27
argos::CFloorEntity
Definition: floor_entity.h:21
argos::CFloorEntity::Reset
virtual void Reset()
Restores the initial state of the floor.
Definition: floor_entity.cpp:251
argos::CFloorEntity::FROM_IMAGE
@ FROM_IMAGE
Definition: floor_entity.h:48
argos::CFloorEntity::CFloorColorSource::GetColorAtPoint
virtual CColor GetColorAtPoint(Real f_x, Real f_y)=0
argos::CFloorEntity::CFloorColorSource::Reset
virtual void Reset()
Definition: floor_entity.h:31
argos::CFloorEntity::~CFloorEntity
virtual ~CFloorEntity()
Class destructor.
Definition: floor_entity.cpp:205
argos::CFloorEntity::UNSET
@ UNSET
Definition: floor_entity.h:47
argos::CFloorEntity::FROM_LOOP_FUNCTIONS
@ FROM_LOOP_FUNCTIONS
Definition: floor_entity.h:49
argos::CFloorEntity::ClearChanged
void ClearChanged()
Marks the floor color as not changed.
Definition: floor_entity.h:129
argos::CFloorEntity::ENABLE_VTABLE
ENABLE_VTABLE()
argos::CEntity
The basic entity type.
Definition: entity.h:89
ARGOS_ASSERT
#define ARGOS_ASSERT(condition, message)
When code is compiled in debug, this macro throws an ARGoS exception with the passed message if the s...
Definition: argos_exception.h:122
argos::CFloorEntity::CFloorEntity
CFloorEntity()
Class constructor.
Definition: floor_entity.cpp:170
UInt32
unsigned int UInt32
32-bit unsigned integer.
Definition: datatypes.h:97
argos::CFloorEntity::CFloorColorSource
Definition: floor_entity.h:25
argos::CColor
The basic color type.
Definition: color.h:25
argos::CFloorEntity::CFloorColorSource::~CFloorColorSource
virtual ~CFloorColorSource()
Definition: floor_entity.h:29
Real
float Real
Collects all ARGoS code.
Definition: datatypes.h:39
argos::CFloorEntity::SetChanged
void SetChanged()
Marks the floor color as changed.
Definition: floor_entity.h:121