8 #include <argos3/core/simulator/simulator.h>
9 #include <argos3/core/simulator/space/space.h>
10 #include <argos3/plugins/simulator/media/led_medium.h>
36 const std::string& str_id) :
62 for(itLED = itLED.begin(&t_tree);
72 std::string strAnchorId;
98 for(SActuator::TList::iterator it =
m_tLEDs.begin();
112 for(
size_t i = 0; i <
m_tLEDs.size(); ++i) {
124 for(
size_t i = 0; i <
m_tLEDs.size(); ++i) {
157 for(
UInt32 i = 0; i < un_num_leds; ++i) {
158 cAngle = c_start_angle + i * cLEDSpacing;
160 cOffset.
Set(f_radius, 0.0f, 0.0f);
163 AddLED(cOffset, s_anchor, c_color);
172 "CLEDEquippedEntity::GetLED(), id=\"" <<
174 "\": index out of bounds: un_index = " <<
176 ", m_tLEDs.size() = " <<
187 "CLEDEquippedEntity::SetLEDPosition(), id=\"" <<
189 "\": index out of bounds: un_index = " <<
191 ", m_tLEDs.size() = " <<
193 m_tLEDs[un_index]->Offset = c_offset;
202 "CLEDEquippedEntity::SetLEDColor(), id=\"" <<
204 "\": index out of bounds: un_index = " <<
206 ", m_tLEDs.size() = " <<
208 m_tLEDs[un_index]->LED.SetColor(c_color);
216 m_tLEDs[i]->LED.SetColor(c_color);
224 if(vec_colors.size() ==
m_tLEDs.size()) {
225 for(
UInt32 i = 0; i < vec_colors.size(); ++i) {
226 m_tLEDs[i]->LED.SetColor(vec_colors[i]);
231 "CLEDEquippedEntity::SetAllLEDsColors(), id=\"" <<
233 "\": number of LEDs (" <<
235 ") is lower than the passed color vector size (" <<
248 if(
m_tLEDs[i]->LED.IsEnabled()) {
249 cLEDPosition =
m_tLEDs[i]->Offset;
251 cLEDPosition +=
m_tLEDs[i]->Anchor.Position;
252 m_tLEDs[i]->LED.SetPosition(cLEDPosition);
262 m_tLEDs[i]->LED.SetMedium(c_medium);
CLEDEntity & GetLED(UInt32 un_index)
Returns an LED by numeric index.
CVector3 & RotateZ(const CRadians &c_angle)
Rotates this vector wrt the z axis.
virtual void Init(TConfigurationNode &t_tree)
Initializes the state of the entity from the XML configuration tree.
void Enable()
Enables the entity.
float Real
Collects all ARGoS code.
void AddLED(const CVector3 &c_offset, SAnchor &s_anchor, const CColor &c_color=CColor::BLACK)
Adds an LED to this entity.
#define THROW_ARGOSEXCEPTION(message)
This macro throws an ARGoS exception with the passed message.
CRadians & SignedNormalize()
Normalizes the value in the range [-PI:PI].
CVector3 & Rotate(const CQuaternion &c_quaternion)
Rotates this vector by the given quaternion.
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.
static const CRadians TWO_PI
Set to PI * 2.
virtual void Init(TConfigurationNode &t_tree)
Initializes the state of the entity from the XML configuration tree.
ticpp::Element TConfigurationNode
The ARGoS configuration XML node.
This entity is a link to a body in the physics engine.
#define THROW_ARGOSEXCEPTION_NESTED(message, nested)
This macro throws an ARGoS exception with the passed message and nesting the passed exception...
It defines the basic type CRadians, used to store an angle value in radians.
void SetMedium(CLEDMedium &c_medium)
Sets the medium associated to this entity.
~CLEDEquippedEntity()
Class destructor.
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.
A container of CLEDEntity.
void Set(const Real f_x, const Real f_y, const Real f_z)
Sets the vector contents from Cartesian coordinates.
Basic class for an entity that contains other entities.
An anchor related to the body of an entity.
void AddComponent(CEntity &c_component)
Adds a component to this composable entity.
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.
ticpp::Iterator< ticpp::Element > TConfigurationNodeIterator
The iterator for the ARGoS configuration XML node.
std::string ToString(const T &t_value)
Converts the given parameter to a std::string.
void GetNodeAttribute(TConfigurationNode &t_node, const std::string &str_attribute, T &t_buffer)
Returns the value of a node's attribute.
CLEDEquippedEntity(CComposableEntity *pc_parent)
Class constructor.
The exception that wraps all errors in ARGoS.
virtual void Init(TConfigurationNode &t_tree)
Initializes the state of the entity from the XML configuration tree.
void Disable()
Disables the entity.
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.
const SAnchor & GetAnchor(const std::string &str_id) const
Returns the wanted anchor as a const reference.
const std::string & GetId() const
Returns the id of this entity.
CComposableEntity & GetParent()
Returns this entity's parent.
REGISTER_STANDARD_SPACE_OPERATIONS_ON_COMPOSABLE(CComposableEntity)
The namespace containing all the ARGoS related code.
SActuator(CLEDEntity &c_led, const CVector3 &c_offset, SAnchor &s_anchor)
CEntity & GetComponent(const std::string &str_component)
Returns the component with the passed string label.