ARGoS  3
A parallel, multi-engine simulator for swarm robotics
leds_default_actuator.cpp
Go to the documentation of this file.
1 
8 #include <argos3/core/simulator/simulator.h>
9 #include <argos3/core/utility/logging/argos_log.h>
10 #include <argos3/plugins/simulator/media/led_medium.h>
11 
12 namespace argos {
13 
14  /****************************************/
15  /****************************************/
16 
18  m_pcLEDEquippedEntity(NULL) {}
19 
20  /****************************************/
21  /****************************************/
22 
24  m_pcLEDEquippedEntity = &(c_entity.GetComponent<CLEDEquippedEntity>("leds"));
25  m_tSettings.resize(m_pcLEDEquippedEntity->GetLEDs().size());
26  }
27 
28  /****************************************/
29  /****************************************/
30 
32  try {
33  CCI_LEDsActuator::Init(t_tree);
34  std::string strMedium;
35  GetNodeAttribute(t_tree, "medium", strMedium);
36  m_pcLEDMedium = &CSimulator::GetInstance().GetMedium<CLEDMedium>(strMedium);
37  m_pcLEDEquippedEntity->AddToMedium(*m_pcLEDMedium);
38  }
39  catch(CARGoSException& ex) {
40  THROW_ARGOSEXCEPTION_NESTED("Error initializing the LEDs default actuator", ex);
41  }
42  }
43 
44  /****************************************/
45  /****************************************/
46 
48  m_pcLEDEquippedEntity->SetAllLEDsColors(m_tSettings);
49  }
50 
51  /****************************************/
52  /****************************************/
53 
56  }
57 
58  /****************************************/
59  /****************************************/
60 
62  m_pcLEDEquippedEntity->RemoveFromMedium();
63  }
64 
65  /****************************************/
66  /****************************************/
67 
68 }
69 
70 REGISTER_ACTUATOR(CLEDsDefaultActuator,
71  "leds", "default",
72  "Carlo Pinciroli [ilpincy@gmail.com]",
73  "1.0",
74  "The LEDs actuator.",
75  "This actuator controls a group of LEDs. For a complete description of its\n"
76  "usage, refer to the ci_leds_actuator.h file.\n\n"
77  "REQUIRED XML CONFIGURATION\n\n"
78  " <controllers>\n"
79  " ...\n"
80  " <my_controller ...>\n"
81  " ...\n"
82  " <actuators>\n"
83  " ...\n"
84  " <leds implementation=\"default\"\n"
85  " medium=\"leds\" />\n"
86  " ...\n"
87  " </actuators>\n"
88  " ...\n"
89  " </my_controller>\n"
90  " ...\n"
91  " </controllers>\n\n"
92  "The 'medium' attribute sets the id of the LED medium declared in the <media>\n"
93  "XML section.\n\n"
94  "OPTIONAL XML CONFIGURATION\n\n"
95  "None.\n",
96  "Usable"
97  );
98 
argos::CSimulator::GetInstance
static CSimulator & GetInstance()
Returns the instance to the CSimulator class.
Definition: simulator.cpp:87
argos
The namespace containing all the ARGoS related code.
Definition: ci_actuator.h:12
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::CComposableEntity
Basic class for an entity that contains other entities.
Definition: composable_entity.h:32
argos::CARGoSException
The exception that wraps all errors in ARGoS.
Definition: argos_exception.h:61
argos::CComposableEntity::GetComponent
CEntity & GetComponent(const std::string &str_component)
Returns the component with the passed string label.
Definition: composable_entity.cpp:109
argos::CLEDsDefaultActuator::CLEDsDefaultActuator
CLEDsDefaultActuator()
Definition: leds_default_actuator.cpp:17
argos::CLEDsDefaultActuator::Update
virtual void Update()
Updates the state of the entity associated to this actuator.
Definition: leds_default_actuator.cpp:47
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
THROW_ARGOSEXCEPTION_NESTED
#define THROW_ARGOSEXCEPTION_NESTED(message, nested)
This macro throws an ARGoS exception with the passed message and nesting the passed exception.
Definition: argos_exception.h:115
argos::CLEDsDefaultActuator::Destroy
virtual void Destroy()
Destroys the actuator.
Definition: leds_default_actuator.cpp:61
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
REGISTER_ACTUATOR
REGISTER_ACTUATOR(CLEDsDefaultActuator, "leds", "default", "Carlo Pinciroli [ilpincy@gmail.com]", "1.0", "The LEDs actuator.", "This actuator controls a group of LEDs. For a complete description of its\n" "usage, refer to the ci_leds_actuator.h file.\n\n" "REQUIRED XML CONFIGURATION\n\n" " <controllers>\n" " ...\n" " <my_controller ...>\n" " ...\n" " <actuators>\n" " ...\n" " <leds implementation=\"default\"\n" " medium=\"leds\" />\n" " ...\n" " </actuators>\n" " ...\n" " </my_controller>\n" " ...\n" " </controllers>\n\n" "The 'medium' attribute sets the id of the LED medium declared in the <media>\n" "XML section.\n\n" "OPTIONAL XML CONFIGURATION\n\n" "None.\n", "Usable")
argos::GetNodeAttribute
void GetNodeAttribute(TConfigurationNode &t_node, const std::string &str_attribute, T &t_buffer)
Returns the value of a node's attribute.
Definition: argos_configuration.h:208
argos::CColor::BLACK
static CColor BLACK
Definition: color.h:29
argos::CCI_LEDsActuator::SetAllColors
virtual void SetAllColors(const CColor &c_color)
Sets the color of the whole LED ring.
Definition: ci_leds_actuator.cpp:116
argos::CCI_LEDsActuator::m_tSettings
TSettings m_tSettings
Definition: ci_leds_actuator.h:93
leds_default_actuator.h
argos::CLEDsDefaultActuator::SetRobot
virtual void SetRobot(CComposableEntity &c_entity)
Sets the entity associated to this actuator.
Definition: leds_default_actuator.cpp:23
argos::CLEDsDefaultActuator::Reset
virtual void Reset()
Resets the actuator to the state it had just after Init().
Definition: leds_default_actuator.cpp:54
argos::CCI_Actuator::Init
virtual void Init(TConfigurationNode &t_node)
Initializes the actuator from the XML configuration tree.
Definition: ci_actuator.h:54
argos::CSimulator::GetMedium
T & GetMedium(const std::string &str_id)
Returns a reference to a medium.
Definition: simulator.h:129
argos::CLEDEquippedEntity::RemoveFromMedium
void RemoveFromMedium()
Removes the LEDs from the associated LED medium.
Definition: led_equipped_entity.cpp:266
argos::CLEDsDefaultActuator::Init
virtual void Init(TConfigurationNode &t_tree)
Initializes the actuator from the XML configuration tree.
Definition: leds_default_actuator.cpp:31