ARGoS
3
A parallel, multi-engine simulator for swarm robotics
|
00001 00007 #include "leds_default_actuator.h" 00008 #include <argos3/core/simulator/simulator.h> 00009 #include <argos3/core/utility/logging/argos_log.h> 00010 #include <argos3/plugins/simulator/media/led_medium.h> 00011 00012 namespace argos { 00013 00014 /****************************************/ 00015 /****************************************/ 00016 00017 CLEDsDefaultActuator::CLEDsDefaultActuator() : 00018 m_pcLEDEquippedEntity(NULL) {} 00019 00020 /****************************************/ 00021 /****************************************/ 00022 00023 void CLEDsDefaultActuator::SetRobot(CComposableEntity& c_entity) { 00024 m_pcLEDEquippedEntity = &(c_entity.GetComponent<CLEDEquippedEntity>("leds")); 00025 m_tSettings.resize(m_pcLEDEquippedEntity->GetAllLEDs().size()); 00026 m_pcLEDEquippedEntity->SetCanBeEnabledIfDisabled(true); 00027 m_pcLEDEquippedEntity->Enable(); 00028 } 00029 00030 /****************************************/ 00031 /****************************************/ 00032 00033 void CLEDsDefaultActuator::Init(TConfigurationNode& t_tree) { 00034 try { 00035 CCI_LEDsActuator::Init(t_tree); 00036 std::string strMedium; 00037 GetNodeAttribute(t_tree, "medium", strMedium); 00038 m_pcLEDMedium = &CSimulator::GetInstance().GetMedium<CLEDMedium>(strMedium); 00039 m_pcLEDEquippedEntity->AddToMedium(*m_pcLEDMedium); 00040 } 00041 catch(CARGoSException& ex) { 00042 THROW_ARGOSEXCEPTION_NESTED("Error initializing the LEDs default actuator", ex); 00043 } 00044 } 00045 00046 /****************************************/ 00047 /****************************************/ 00048 00049 void CLEDsDefaultActuator::Update() { 00050 m_pcLEDEquippedEntity->SetAllLEDsColors(m_tSettings); 00051 } 00052 00053 /****************************************/ 00054 /****************************************/ 00055 00056 void CLEDsDefaultActuator::Reset() { 00057 SetAllColors(CColor::BLACK); 00058 } 00059 00060 /****************************************/ 00061 /****************************************/ 00062 00063 void CLEDsDefaultActuator::Destroy() { 00064 m_pcLEDEquippedEntity->RemoveFromMedium(*m_pcLEDMedium); 00065 } 00066 00067 /****************************************/ 00068 /****************************************/ 00069 00070 } 00071 00072 REGISTER_ACTUATOR(CLEDsDefaultActuator, 00073 "leds", "default", 00074 "Carlo Pinciroli [ilpincy@gmail.com]", 00075 "1.0", 00076 "The LEDs actuator.", 00077 "This actuator controls a group of LEDs. For a complete description of its\n" 00078 "usage, refer to the ci_leds_actuator.h file.\n\n" 00079 "REQUIRED XML CONFIGURATION\n\n" 00080 " <controllers>\n" 00081 " ...\n" 00082 " <my_controller ...>\n" 00083 " ...\n" 00084 " <actuators>\n" 00085 " ...\n" 00086 " <leds implementation=\"default\"\n" 00087 " medium=\"leds\" />\n" 00088 " ...\n" 00089 " </actuators>\n" 00090 " ...\n" 00091 " </my_controller>\n" 00092 " ...\n" 00093 " </controllers>\n\n" 00094 "The 'medium' attribute sets the id of the LED medium declared in the <media>\n" 00095 "XML section.\n\n" 00096 "OPTIONAL XML CONFIGURATION\n\n" 00097 "None.\n", 00098 "Usable" 00099 ); 00100