ARGoS  3
A parallel, multi-engine simulator for swarm robotics
plugins/simulator/entities/led_equipped_entity.h
Go to the documentation of this file.
00001 
00007 #ifndef LED_EQUIPPED_ENTITY_H
00008 #define LED_EQUIPPED_ENTITY_H
00009 
00010 namespace argos {
00011    class CLEDEquippedEntity;
00012    class CLEDEntity;
00013 }
00014 
00015 #include <argos3/core/simulator/entity/composable_entity.h>
00016 #include <argos3/plugins/simulator/entities/led_entity.h>
00017 #include <map>
00018 
00019 namespace argos {
00020 
00036    class CLEDEquippedEntity : public CComposableEntity {
00037 
00038    public:
00039 
00040       ENABLE_VTABLE();
00041 
00042       typedef std::map<std::string, CLEDEquippedEntity*> TMap;
00043 
00044    public:
00045 
00051       CLEDEquippedEntity(CComposableEntity* pc_parent,
00052                          CPositionalEntity* pc_reference);
00053 
00060       CLEDEquippedEntity(CComposableEntity* pc_parent,
00061                          const std::string& str_id,
00062                          CPositionalEntity* pc_reference);
00063 
00064       virtual void Init(TConfigurationNode& t_tree);
00065 
00066       virtual void Reset();
00067 
00068       virtual void Update() {}
00069 
00076       void AddLED(const CVector3& c_position,
00077                   const CColor& c_color = CColor::BLACK);
00078 
00088       void AddLEDRing(const CVector3& c_center,
00089                       Real f_radius,
00090                       const CRadians& c_start_angle,
00091                       UInt32 un_num_leds,
00092                       const CColor& c_color = CColor::BLACK);
00093 
00100       CLEDEntity& GetLED(UInt32 un_index);
00101 
00107       inline CLEDEntity::TList& GetAllLEDs() {
00108          return m_tLEDs;
00109       }
00110 
00117       inline const CVector3& GetLEDOffsetPosition(size_t un_idx) const {
00118          ARGOS_ASSERT(un_idx < m_vecLEDOffsetPositions.size(),
00119                       "CLEDEquippedEntity::GetLEDOffsetPosition() : index " <<
00120                       un_idx <<
00121                       " out of bounds [0:" <<
00122                       m_vecLEDOffsetPositions.size()-1 <<
00123                       "]" );
00124          return m_vecLEDOffsetPositions[un_idx];
00125       }
00126 
00132       void SetLEDPosition(UInt32 un_index,
00133                           const CVector3& c_position);
00134 
00140       void SetLEDColor(UInt32 un_index,
00141                        const CColor& c_color);
00142 
00148       void SetAllLEDsColors(const CColor& c_color);
00149 
00156       void SetAllLEDsColors(const std::vector<CColor>& vec_colors);
00157 
00162       bool HasReferenceEntity() const {
00163          return m_pcReferenceEntity != NULL;
00164       }
00165 
00172       CPositionalEntity& GetReferenceEntity() {
00173          return *m_pcReferenceEntity;
00174       }
00175 
00181       void AddToMedium(CLEDMedium& c_medium);
00182 
00188       void RemoveFromMedium(CLEDMedium& c_medium);
00189 
00190       virtual std::string GetTypeDescription() const {
00191          return "leds";
00192       }
00193 
00194    protected:
00195 
00196       virtual void UpdateComponents();
00197 
00198    protected:
00199 
00201       CLEDEntity::TList m_tLEDs;
00202 
00204       std::vector<CVector3> m_vecLEDOffsetPositions;
00205 
00207       CPositionalEntity* m_pcReferenceEntity;
00208 
00209    };
00210 
00211 }
00212 
00213 #endif