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(nullptr) {}
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->SetMedium(*m_pcLEDMedium);
38  m_pcLEDEquippedEntity->Enable();
39  }
40  catch(CARGoSException& ex) {
41  THROW_ARGOSEXCEPTION_NESTED("Error initializing the LEDs default actuator", ex);
42  }
43  }
44 
45  /****************************************/
46  /****************************************/
47 
49  m_pcLEDEquippedEntity->SetAllLEDsColors(m_tSettings);
50  }
51 
52  /****************************************/
53  /****************************************/
54 
57  }
58 
59  /****************************************/
60  /****************************************/
61 
63  m_pcLEDEquippedEntity->Disable();
64  }
65 
66  /****************************************/
67  /****************************************/
68 
69 }
70 
71 REGISTER_ACTUATOR(CLEDsDefaultActuator,
72  "leds", "default",
73  "Carlo Pinciroli [ilpincy@gmail.com]",
74  "1.0",
75  "The LEDs actuator.",
76 
77  "This actuator controls a group of LEDs. For a complete description of its\n"
78  "usage, refer to the ci_leds_actuator.h file.\n\n"
79 
80  "REQUIRED XML CONFIGURATION\n\n"
81 
82  " <controllers>\n"
83  " ...\n"
84  " <my_controller ...>\n"
85  " ...\n"
86  " <actuators>\n"
87  " ...\n"
88  " <leds implementation=\"default\"\n"
89  " medium=\"leds\" />\n"
90  " ...\n"
91  " </actuators>\n"
92  " ...\n"
93  " </my_controller>\n"
94  " ...\n"
95  " </controllers>\n\n"
96 
97  "The 'medium' attribute sets the id of the LED medium declared in the <media>\n"
98  "XML section.\n\n"
99 
100  "OPTIONAL XML CONFIGURATION\n\n"
101 
102  "None.\n",
103 
104  "Usable"
105  );
106 
#define THROW_ARGOSEXCEPTION_NESTED(message, nested)
This macro throws an ARGoS exception with the passed message and nesting the passed exception.
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")
The namespace containing all the ARGoS related code.
Definition: ci_actuator.h:12
ticpp::Element TConfigurationNode
The ARGoS configuration XML node.
void GetNodeAttribute(TConfigurationNode &t_node, const std::string &str_attribute, T &t_buffer)
Returns the value of a node's attribute.
virtual void Init(TConfigurationNode &t_node)
Initializes the actuator from the XML configuration tree.
Definition: ci_actuator.h:54
Basic class for an entity that contains other entities.
CEntity & GetComponent(const std::string &str_component)
Returns the component with the passed string label.
T & GetMedium(const std::string &str_id)
Returns a reference to a medium.
Definition: simulator.h:129
static CSimulator & GetInstance()
Returns the instance to the CSimulator class.
Definition: simulator.cpp:78
The exception that wraps all errors in ARGoS.
static CColor BLACK
Definition: color.h:29
virtual void SetAllColors(const CColor &c_color)
Sets the color of the whole LED ring.
virtual void Init(TConfigurationNode &t_tree)
Initializes the actuator from the XML configuration tree.
virtual void Reset()
Resets the actuator to the state it had just after Init().
virtual void Update()
Updates the state of the entity associated to this actuator.
virtual void SetRobot(CComposableEntity &c_entity)
Sets the entity associated to this actuator.
virtual void Destroy()
Destroys the actuator.
A container of CLEDEntity.
void SetAllLEDsColors(const CColor &c_color)
Sets the color of all the LEDs to the same value.
void SetMedium(CLEDMedium &c_medium)
Sets the medium associated to this entity.
SActuator::TList & GetLEDs()
Returns all the LEDs.