ARGoS
3
A parallel, multi-engine simulator for swarm robotics
|
00001 00007 #ifndef FLOOR_ENTITY_H 00008 #define FLOOR_ENTITY_H 00009 00010 namespace argos { 00011 class CFloorEntity; 00012 } 00013 00014 #include <argos3/core/simulator/entity/entity.h> 00015 #include <argos3/core/utility/math/vector2.h> 00016 #include <argos3/core/utility/math/vector3.h> 00017 #include <argos3/core/utility/datatypes/color.h> 00018 00019 namespace argos { 00020 00021 class CFloorEntity : public CEntity { 00022 00023 public: 00024 00025 class CFloorColorSource { 00026 00027 public: 00028 00029 virtual ~CFloorColorSource() {} 00030 00031 virtual void Reset() {} 00032 00033 virtual CColor GetColorAtPoint(Real f_x, 00034 Real f_y) = 0; 00035 00036 virtual void SaveAsImage(const std::string& str_path) = 0; 00037 00038 }; 00039 00040 public: 00041 00042 ENABLE_VTABLE(); 00043 00044 enum EColorSource { 00045 UNSET = 0, 00046 FROM_IMAGE, 00047 FROM_LOOP_FUNCTIONS 00048 }; 00049 00050 public: 00051 00056 CFloorEntity(); 00057 00064 CFloorEntity(const std::string& str_id, 00065 const std::string& str_file_name); 00066 00071 CFloorEntity(const std::string& str_id, 00072 UInt32 un_pixels_per_meter); 00073 00077 virtual ~CFloorEntity(); 00078 00082 virtual void Init(TConfigurationNode& t_tree); 00083 00087 virtual void Reset(); 00088 00095 inline CColor GetColorAtPoint(Real f_x, 00096 Real f_y) { 00097 ARGOS_ASSERT(m_pcColorSource != NULL, 00098 "The floor entity \"" << 00099 GetId() << 00100 "\" has no associated color source."); 00101 return m_pcColorSource->GetColorAtPoint(f_x, f_y); 00102 } 00103 00109 inline bool HasChanged() const { 00110 return m_bHasChanged; 00111 } 00112 00117 inline void SetChanged() { 00118 m_bHasChanged = true; 00119 } 00120 00125 inline void ClearChanged() { 00126 m_bHasChanged = false; 00127 } 00128 00135 inline void SaveAsImage(const std::string& str_path) { 00136 m_pcColorSource->SaveAsImage(str_path); 00137 } 00138 00139 virtual std::string GetTypeDescription() const { 00140 return "floor"; 00141 } 00142 00143 private: 00144 00148 EColorSource m_eColorSource; 00149 00153 CFloorColorSource* m_pcColorSource; 00154 00158 bool m_bHasChanged; 00159 }; 00160 } 00161 00162 #endif