ARGoS  3
A parallel, multi-engine simulator for swarm robotics
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 AddToMedium(CLEDMedium& c_medium);
184 
189  void RemoveFromMedium();
190 
191  virtual std::string GetTypeDescription() const {
192  return "leds";
193  }
194 
195  protected:
196 
197  virtual void UpdateComponents();
198 
199  protected:
200 
203  };
204 
205 }
206 
207 #endif
argos::CLEDEquippedEntity::AddLEDRing
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.
Definition: led_equipped_entity.cpp:144
argos::CLEDEquippedEntity::GetLED
CLEDEntity & GetLED(UInt32 un_index)
Returns an LED by numeric index.
Definition: led_equipped_entity.cpp:166
argos::CLEDEquippedEntity::CLEDEquippedEntity
CLEDEquippedEntity(CComposableEntity *pc_parent)
Class constructor.
Definition: led_equipped_entity.cpp:27
argos
The namespace containing all the ARGoS related code.
Definition: ci_actuator.h:12
argos::CVector3
A 3D vector class.
Definition: vector3.h:29
argos::CLEDEquippedEntity::m_tLEDs
SActuator::TList m_tLEDs
List of the LEDs managed by this entity.
Definition: led_equipped_entity.h:202
argos::CLEDEquippedEntity::SetAllLEDsColors
void SetAllLEDsColors(const CColor &c_color)
Sets the color of all the LEDs to the same value.
Definition: led_equipped_entity.cpp:210
argos::CLEDEntity
Definition: led_entity.h:24
argos::CRadians
It defines the basic type CRadians, used to store an angle value in radians.
Definition: angles.h:42
argos::CLEDEquippedEntity::SActuator::LED
CLEDEntity & LED
Definition: led_equipped_entity.h:49
argos::CComposableEntity
Basic class for an entity that contains other entities.
Definition: composable_entity.h:32
argos::CLEDEquippedEntity::Reset
virtual void Reset()
Resets the state of the entity to whatever it was after Init() or the standalone constructor was call...
Definition: led_equipped_entity.cpp:97
argos::CLEDEquippedEntity::SActuator
Definition: led_equipped_entity.h:46
argos::CLEDEquippedEntity::SActuator::Anchor
SAnchor & Anchor
Definition: led_equipped_entity.h:51
argos::TConfigurationNode
ticpp::Element TConfigurationNode
The ARGoS configuration XML node.
Definition: argos_configuration.h:27
argos::CLEDMedium
Definition: led_medium.h:15
argos::CLEDEquippedEntity
A container of CLEDEntity.
Definition: led_equipped_entity.h:36
argos::CLEDEquippedEntity::TMap
std::map< std::string, CLEDEquippedEntity * > TMap
Definition: led_equipped_entity.h:42
argos::CLEDEquippedEntity::ENABLE_VTABLE
ENABLE_VTABLE()
argos::CLEDEquippedEntity::SActuator::SActuator
SActuator(CLEDEntity &c_led, const CVector3 &c_offset, SAnchor &s_anchor)
Definition: led_equipped_entity.cpp:17
argos::SAnchor
An anchor related to the body of an entity.
Definition: physics_model.h:38
argos::CLEDEquippedEntity::~CLEDEquippedEntity
~CLEDEquippedEntity()
Class destructor.
Definition: led_equipped_entity.cpp:44
argos::CLEDEquippedEntity::AddToMedium
void AddToMedium(CLEDMedium &c_medium)
Adds the LEDs to the wanted LED medium.
Definition: led_equipped_entity.cpp:256
argos::CLEDEquippedEntity::GetLEDs
SActuator::TList & GetLEDs()
Returns all the LEDs.
Definition: led_equipped_entity.h:126
argos::CLEDEquippedEntity::SActuator::TList
std::vector< SActuator * > TList
Definition: led_equipped_entity.h:47
argos::CLEDEquippedEntity::SetLEDColor
void SetLEDColor(UInt32 un_index, const CColor &c_color)
Sets the color of an LED.
Definition: led_equipped_entity.cpp:195
argos::CLEDEquippedEntity::Enable
virtual void Enable()
Definition: led_equipped_entity.cpp:108
argos::CLEDEquippedEntity::UpdateComponents
virtual void UpdateComponents()
Calls the Update() method on all the components.
Definition: led_equipped_entity.cpp:240
argos::CLEDEquippedEntity::GetLEDOffset
const CVector3 & GetLEDOffset(size_t un_idx) const
Returns the offset position of the given LED.
Definition: led_equipped_entity.h:136
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::CLEDEquippedEntity::SetLEDOffset
void SetLEDOffset(UInt32 un_index, const CVector3 &c_offset)
Sets the position of an LED.
Definition: led_equipped_entity.cpp:180
argos::CLEDEquippedEntity::SActuator::Offset
CVector3 Offset
Definition: led_equipped_entity.h:50
argos::CLEDEquippedEntity::Disable
virtual void Disable()
Definition: led_equipped_entity.cpp:118
UInt32
unsigned int UInt32
32-bit unsigned integer.
Definition: datatypes.h:97
argos::CLEDEquippedEntity::Init
virtual void Init(TConfigurationNode &t_tree)
Initializes the state of the entity from the XML configuration tree.
Definition: led_equipped_entity.cpp:54
argos::CColor
The basic color type.
Definition: color.h:25
argos::CColor::BLACK
static CColor BLACK
Definition: color.h:29
Real
float Real
Collects all ARGoS code.
Definition: datatypes.h:39
argos::CLEDEquippedEntity::GetTypeDescription
virtual std::string GetTypeDescription() const
Returns a string label for this class.
Definition: led_equipped_entity.h:191
argos::CLEDEquippedEntity::AddLED
void AddLED(const CVector3 &c_offset, SAnchor &s_anchor, const CColor &c_color=CColor::BLACK)
Adds an LED to this entity.
Definition: led_equipped_entity.cpp:128
argos::CLEDEquippedEntity::RemoveFromMedium
void RemoveFromMedium()
Removes the LEDs from the associated LED medium.
Definition: led_equipped_entity.cpp:266