ARGoS  3
A parallel, multi-engine simulator for swarm robotics
argos::CLEDEquippedEntity Class Reference

A container of CLEDEntity. More...

#include <led_equipped_entity.h>

+ Inheritance diagram for argos::CLEDEquippedEntity:

List of all members.

Public Types

typedef std::map< std::string,
CLEDEquippedEntity * > 
TMap
 A map of entities.

Public Member Functions

 ENABLE_VTABLE ()
 CLEDEquippedEntity (CComposableEntity *pc_parent, CPositionalEntity *pc_reference)
 Class constructor.
 CLEDEquippedEntity (CComposableEntity *pc_parent, const std::string &str_id, CPositionalEntity *pc_reference)
 Class constructor.
virtual void Init (TConfigurationNode &t_tree)
 Initializes the state of the entity from the XML configuration tree.
virtual void Reset ()
 Resets the state of the entity to whatever it was after Init() or the standalone constructor was called.
virtual void Update ()
 Updates the status of this entity.
void AddLED (const CVector3 &c_position, const CColor &c_color=CColor::BLACK)
 Adds an LED to this entity.
void AddLEDRing (const CVector3 &c_center, Real f_radius, const CRadians &c_start_angle, UInt32 un_num_leds, const CColor &c_color=CColor::BLACK)
 Adds a ring of LEDs to this entity.
CLEDEntityGetLED (UInt32 un_index)
 Returns an LED by numeric index.
CLEDEntity::TListGetAllLEDs ()
 Returns all the LEDs.
const CVector3GetLEDOffsetPosition (size_t un_idx) const
 Returns the offset position of the given LED.
void SetLEDPosition (UInt32 un_index, const CVector3 &c_position)
 Sets the position of an LED.
void SetLEDColor (UInt32 un_index, const CColor &c_color)
 Sets the color of an LED.
void SetAllLEDsColors (const CColor &c_color)
 Sets the color of all the LEDs to the same value.
void SetAllLEDsColors (const std::vector< CColor > &vec_colors)
 Sets the color of all the LEDs to the given setting.
bool HasReferenceEntity () const
 Returns true if this entity has a reference.
CPositionalEntityGetReferenceEntity ()
 Returns the reference of this entity.
void AddToMedium (CLEDMedium &c_medium)
 Adds the LEDs to the wanted LED medium.
void RemoveFromMedium (CLEDMedium &c_medium)
 Removes the LEDs from the wanted LED medium.
virtual std::string GetTypeDescription () const
 Returns a string label for this class.

Protected Member Functions

virtual void UpdateComponents ()
 Calls the Update() method on all the components.

Protected Attributes

CLEDEntity::TList m_tLEDs
 A list of the LEDs contained in this entity.
std::vector< CVector3m_vecLEDOffsetPositions
 The offsets of the LEDs.
CPositionalEntitym_pcReferenceEntity
 The positional reference of this entity.

Detailed Description

A container of CLEDEntity.

This is a convenience class that acts a container of CLEDEntity objects. It is mostly useful when a robot is equipped with a number of LEDs, and you want to manage them comfortably.

You can define a positional entity as the reference of this entity. In this way, if the reference entity moves, this entity will follow automatically. The contained LEDs will also move accordingly. If you don't define a reference entity, the LEDs won't move.

See also:
CLEDEntity

Definition at line 36 of file led_equipped_entity.h.


Member Typedef Documentation

typedef std::map<std::string, CLEDEquippedEntity*> argos::CLEDEquippedEntity::TMap

A map of entities.

Reimplemented from argos::CEntity.

Definition at line 42 of file led_equipped_entity.h.


Constructor & Destructor Documentation

Class constructor.

Parameters:
pc_parentThe parent entity.
pc_referenceThe positional entity to which this entity refers for its position.

Definition at line 17 of file led_equipped_entity.cpp.

argos::CLEDEquippedEntity::CLEDEquippedEntity ( CComposableEntity pc_parent,
const std::string &  str_id,
CPositionalEntity pc_reference 
)

Class constructor.

Parameters:
pc_parentThe parent entity.
str_idThe id of this entity.
pc_referenceThe positional entity to which this entity refers for its position.

Definition at line 26 of file led_equipped_entity.cpp.


Member Function Documentation

void argos::CLEDEquippedEntity::AddLED ( const CVector3 c_position,
const CColor c_color = CColor::BLACK 
)

Adds an LED to this entity.

Parameters:
c_positionThe position of the LED wrt the reference entity.
c_colorThe color of the LED.
See also:
GetReferenceEntity()

Definition at line 76 of file led_equipped_entity.cpp.

void argos::CLEDEquippedEntity::AddLEDRing ( const CVector3 c_center,
Real  f_radius,
const CRadians c_start_angle,
UInt32  un_num_leds,
const CColor c_color = CColor::BLACK 
)

Adds a ring of LEDs to this entity.

Parameters:
c_centerThe position of LED ring center wrt the reference entity.
f_radiusThe radius of the LED ring.
c_start_angleThe angle at which the first LED must be placed. Expressed wrt the local entity x-axis.
un_num_ledsThe number of LEDs to place along the ring.
c_colorThe color of the LEDs.
See also:
GetReferenceEntity()

Definition at line 91 of file led_equipped_entity.cpp.

Adds the LEDs to the wanted LED medium.

Parameters:
c_mediumThe LED medium.
See also:
CLEDMedium

Definition at line 202 of file led_equipped_entity.cpp.

Returns all the LEDs.

Returns:
All the LEDs.
See also:
GetLED()

Definition at line 107 of file led_equipped_entity.h.

Returns an LED by numeric index.

Parameters:
un_indexThe index of the wanted LED.
Returns:
An LED by numeric index.
See also:
GetAllLEDs()

Definition at line 112 of file led_equipped_entity.cpp.

const CVector3& argos::CLEDEquippedEntity::GetLEDOffsetPosition ( size_t  un_idx) const [inline]

Returns the offset position of the given LED.

The actual position of an LED is calculated as the sum of the offset position and the position of the reference.

Returns:
The offset position of the given LED.

Definition at line 117 of file led_equipped_entity.h.

Returns the reference of this entity.

Make sure this entity has a reference using HasReferenceEntity(), or segfault may occur.

Returns:
The reference of this entity.
See also:
HasReferenceEntity()

Definition at line 172 of file led_equipped_entity.h.

virtual std::string argos::CLEDEquippedEntity::GetTypeDescription ( ) const [inline, virtual]

Returns a string label for this class.

Returns:
A string label for this class.

Reimplemented from argos::CComposableEntity.

Definition at line 190 of file led_equipped_entity.h.

Returns true if this entity has a reference.

Returns:
true if this entity has a reference.

Definition at line 162 of file led_equipped_entity.h.

Initializes the state of the entity from the XML configuration tree.

If the id of the entity has not been set yet, this method sets an id for the entity. If the entity has no parent, this method parses the passed XML tree and looks for the id attribute, setting its value as id. If, instead, this entity has a parent, the id is set as GetParent().GetId() + "." + GetTypeDescription().

Exceptions:
CARGoSExceptionif a parse error occurred

Reimplemented from argos::CEntity.

Definition at line 36 of file led_equipped_entity.cpp.

Removes the LEDs from the wanted LED medium.

Parameters:
c_mediumThe LED medium.
See also:
CLEDMedium

Definition at line 211 of file led_equipped_entity.cpp.

Resets the state of the entity to whatever it was after Init() or the standalone constructor was called.

Internally calls Reset() for all the component entities.

Reimplemented from argos::CComposableEntity.

Definition at line 65 of file led_equipped_entity.cpp.

Sets the color of all the LEDs to the same value.

Parameters:
c_colorThe color of the LEDs.
See also:
SetAllLEDsColors()

Definition at line 156 of file led_equipped_entity.cpp.

void argos::CLEDEquippedEntity::SetAllLEDsColors ( const std::vector< CColor > &  vec_colors)

Sets the color of all the LEDs to the given setting.

Parameters:
vec_colorsA vector containing the colors of the LEDs.
See also:
SetAllLEDsColors()
Exceptions:
CARGoSExceptionif the size of the passed vector is different from the number of LEDs.

Definition at line 165 of file led_equipped_entity.cpp.

void argos::CLEDEquippedEntity::SetLEDColor ( UInt32  un_index,
const CColor c_color 
)

Sets the color of an LED.

Parameters:
un_indexThe index of the wanted LED.
c_colorThe color of the LED.

Definition at line 141 of file led_equipped_entity.cpp.

void argos::CLEDEquippedEntity::SetLEDPosition ( UInt32  un_index,
const CVector3 c_position 
)

Sets the position of an LED.

Parameters:
un_indexThe index of the wanted LED.
c_positionThe position of the LED wrt the reference entity.

Definition at line 126 of file led_equipped_entity.cpp.

virtual void argos::CLEDEquippedEntity::Update ( ) [inline, virtual]

Updates the status of this entity.

Internally calls UpdateComponents(). If you plan to overload this method, don't forget to call CComposableEntity::Update() or UpdateComponents() in your code.

See also:
UpdateComponents()

Reimplemented from argos::CComposableEntity.

Definition at line 68 of file led_equipped_entity.h.

void argos::CLEDEquippedEntity::UpdateComponents ( ) [protected, virtual]

Calls the Update() method on all the components.

See also:
Update()

Reimplemented from argos::CComposableEntity.

Definition at line 186 of file led_equipped_entity.cpp.


Member Data Documentation

The positional reference of this entity.

Definition at line 207 of file led_equipped_entity.h.

A list of the LEDs contained in this entity.

Definition at line 201 of file led_equipped_entity.h.

The offsets of the LEDs.

Definition at line 204 of file led_equipped_entity.h.


The documentation for this class was generated from the following files: