led_equipped_entity.h
Go to the documentation of this file.
1 
7 #ifndef LED_EQUIPPED_ENTITY_H
8 #define LED_EQUIPPED_ENTITY_H
9 
10 namespace argos {
11  class CLEDEquippedEntity;
12  class CLEDEntity;
13 }
14 
15 #include <argos3/core/simulator/entity/composable_entity.h>
16 #include <argos3/plugins/simulator/entities/led_entity.h>
17 #include <map>
18 
19 namespace argos {
20 
37 
38  public:
39 
40  ENABLE_VTABLE();
41 
42  typedef std::map<std::string, CLEDEquippedEntity*> TMap;
43 
44  public:
45 
46  struct SActuator {
47  typedef std::vector<SActuator*> TList;
48 
52 
53  SActuator(CLEDEntity& c_led,
54  const CVector3& c_offset,
55  SAnchor& s_anchor);
56  };
57 
58  public:
59 
65 
72  const std::string& str_id);
73 
78 
79  virtual void Init(TConfigurationNode& t_tree);
80 
81  virtual void Reset();
82 
83  virtual void Enable();
84 
85  virtual void Disable();
86 
93  void AddLED(const CVector3& c_offset,
94  SAnchor& s_anchor,
95  const CColor& c_color = CColor::BLACK);
96 
106  void AddLEDRing(const CVector3& c_center,
107  Real f_radius,
108  const CRadians& c_start_angle,
109  UInt32 un_num_leds,
110  SAnchor& s_anchor,
111  const CColor& c_color = CColor::BLACK);
112 
119  CLEDEntity& GetLED(UInt32 un_index);
120 
127  return m_tLEDs;
128  }
129 
136  inline const CVector3& GetLEDOffset(size_t un_idx) const {
137  ARGOS_ASSERT(un_idx < m_tLEDs.size(),
138  "CLEDEquippedEntity::GetLEDOffset() : index " <<
139  un_idx <<
140  " out of bounds [0:" <<
141  m_tLEDs.size()-1 <<
142  "]" );
143  return m_tLEDs[un_idx]->Offset;
144  }
145 
151  void SetLEDOffset(UInt32 un_index,
152  const CVector3& c_offset);
153 
159  void SetLEDColor(UInt32 un_index,
160  const CColor& c_color);
161 
167  void SetAllLEDsColors(const CColor& c_color);
168 
176  void SetAllLEDsColors(const std::vector<CColor>& vec_colors);
177 
183  void SetMedium(CLEDMedium& c_medium);
184 
185  virtual std::string GetTypeDescription() const {
186  return "leds";
187  }
188 
189  protected:
190 
191  virtual void UpdateComponents();
192 
193  protected:
194 
197  };
198 
199 }
200 
201 #endif
CLEDEntity & GetLED(UInt32 un_index)
Returns an LED by numeric index.
A 3D vector class.
Definition: vector3.h:29
static CColor BLACK
Definition: color.h:29
virtual void Init(TConfigurationNode &t_tree)
Initializes the state of the entity from the XML configuration tree.
float Real
Collects all ARGoS code.
Definition: datatypes.h:39
void AddLED(const CVector3 &c_offset, SAnchor &s_anchor, const CColor &c_color=CColor::BLACK)
Adds an LED to this entity.
virtual std::string GetTypeDescription() const
Returns a string label for this class.
void AddLEDRing(const CVector3 &c_center, Real f_radius, const CRadians &c_start_angle, UInt32 un_num_leds, SAnchor &s_anchor, const CColor &c_color=CColor::BLACK)
Adds a ring of LEDs to this entity.
ticpp::Element TConfigurationNode
The ARGoS configuration XML node.
It defines the basic type CRadians, used to store an angle value in radians.
Definition: angles.h:42
void SetMedium(CLEDMedium &c_medium)
Sets the medium associated to this entity.
~CLEDEquippedEntity()
Class destructor.
std::map< std::string, CLEDEquippedEntity * > TMap
virtual void UpdateComponents()
Calls the Update() method on all the components.
#define ARGOS_ASSERT(condition, message)
When code is compiled in debug, this macro throws an ARGoS exception with the passed message if the s...
unsigned int UInt32
32-bit unsigned integer.
Definition: datatypes.h:97
A container of CLEDEntity.
Basic class for an entity that contains other entities.
An anchor related to the body of an entity.
Definition: physics_model.h:38
const CVector3 & GetLEDOffset(size_t un_idx) const
Returns the offset position of the given LED.
virtual void Reset()
Resets the state of the entity to whatever it was after Init() or the standalone constructor was call...
void SetLEDOffset(UInt32 un_index, const CVector3 &c_offset)
Sets the position of an LED.
CLEDEquippedEntity(CComposableEntity *pc_parent)
Class constructor.
SActuator::TList & GetLEDs()
Returns all the LEDs.
The basic color type.
Definition: color.h:25
void SetLEDColor(UInt32 un_index, const CColor &c_color)
Sets the color of an LED.
SActuator::TList m_tLEDs
List of the LEDs managed by this entity.
void SetAllLEDsColors(const CColor &c_color)
Sets the color of all the LEDs to the same value.
The namespace containing all the ARGoS related code.
Definition: ci_actuator.h:12
SActuator(CLEDEntity &c_led, const CVector3 &c_offset, SAnchor &s_anchor)