Go to the documentation of this file.
7 #include "light_entity.h"
8 #include <argos3/core/simulator/simulator.h>
9 #include <argos3/core/simulator/space/space.h>
10 #include <argos3/plugins/simulator/media/led_medium.h>
12 namespace argos {
14  /****************************************/
15  /****************************************/
18  CLEDEntity(NULL),
19  m_fIntensity(1.0f) {}
21  /****************************************/
22  /****************************************/
24  CLightEntity::CLightEntity(const std::string& str_id,
25  const CVector3& c_position,
26  const CColor& c_color,
27  Real f_intensity) :
28  CLEDEntity(NULL,
29  str_id,
30  c_position,
31  c_color),
32  m_fIntensity(f_intensity) {}
34  /****************************************/
35  /****************************************/
38  try {
39  /* Init parent */
40  CLEDEntity::Init(t_tree);
41  /* Parse XML */
42  GetNodeAttribute(t_tree, "intensity", m_fIntensity);
43  std::string strMedium;
44  GetNodeAttribute(t_tree, "medium", strMedium);
45  CLEDMedium& cLEDMedium = CSimulator::GetInstance().GetMedium<CLEDMedium>(strMedium);
46  cLEDMedium.AddEntity(*this);
47  }
48  catch(CARGoSException& ex) {
49  THROW_ARGOSEXCEPTION_NESTED("Error while initializing light entity", ex);
50  }
51  }
53  /****************************************/
54  /****************************************/
57  "light",
58  "Carlo Pinciroli []",
59  "1.0",
60  "A colored light.",
61  "The light entity is an entity that emits a light detectable by a robot camera\n"
62  "(as a normal LED) or by light sensors. A light is bodyless, therefore it must\n"
63  "not be added to physics engines.\n"
64  "A light is characterized by a color and an intensity. The color of the light\n"
65  "is perceived by cameras. The intensity modifies the reading of the light\n"
66  "sensors. The higher the intensity, the closer the light is perceived.\n\n"
68  " <arena ...>\n"
69  " ...\n"
70  " <light id=\"light0\"\n"
71  " position=\"0.4,2.3,0.25\"\n"
72  " orientation=\"0,0,0\"\n"
73  " color=\"yellow\"\n"
74  " intensity=\"1.0\"\n"
75  " medium=\"leds\"/>\n"
76  " ...\n"
77  " </arena>\n\n"
78  "The 'id' attribute is necessary and must be unique among the entities. If two\n"
79  "entities share the same id, initialization aborts.\n"
80  "The 'position' attribute specifies the position of the center of the light.\n"
81  "The attribute values are in the X,Y,Z order.\n"
82  "The 'orientation' attribute specifies the orientation of the light. At the\n"
83  "moment this attribute is mandatory but its value is ignored. In the future,\n"
84  "it will be used to implement a directional light.\n"
85  "The 'color' attribute specifies the color of the light.\n"
86  "The 'intensity' attribute sets the intensity of the light. When the value is\n"
87  "1.0, the light emits a normal amount of light. When it is 0.5 the amount of\n"
88  "light is half, and when the value is 2.0 the emission is doubled. The\n"
89  "intensity of the light affects the readings of the light sensors but not\n"
90  "those of the cameras.\n"
91  "The 'medium' attribute is used to add the light the corresponding LED medium.\n\n"
93  "None.\n",
94  "Usable"
95  );
97  /****************************************/
98  /****************************************/
102  /****************************************/
103  /****************************************/
105 }
A 3D vector class.
Definition: vector3.h:29
float Real
Collects all ARGoS code.
Definition: datatypes.h:39
virtual void Init(TConfigurationNode &t_tree)
Initializes the state of the entity from the XML configuration tree.
Definition: led_entity.cpp:40
ticpp::Element TConfigurationNode
The ARGoS configuration XML node.
REGISTER_ENTITY(CFloorEntity,"floor","Carlo Pinciroli []","1.0","It contains the properties of the arena floor.","The floor entity contains the properties of the arena floor. In the current\n""implementation, it contains only the color of the floor. The floor color is\n""detected by the robots' ground sensors.\n\n""REQUIRED XML CONFIGURATION\n\n"" <arena ...>\n"" ...\n"" <floor id=\"floor\"\n"" source=\"SOURCE\" />\n"" ...\n"" </arena>\n\n""The 'id' attribute is necessary and must be unique among the entities. If two\n""entities share the same id, initialization aborts.\n""The 'source' attribute specifies where to get the color of the floor from. Its\n""value, here denoted as SOURCE, can assume the following values:\n\n"" image The color is calculated from the passed image file\n"" loop_functions The color is calculated calling the loop functions\n\n""When 'source' is set to 'image', as showed in the following example, you have\n""to specify the image path in the additional attribute 'path':\n\n"" <arena ...>\n"" ...\n"" <floor id=\"floor\"\n"" source=\"image\"\n"" path=\"/path/to/imagefile.ext\" />\n"" ...\n"" </arena>\n\n""Many image formats are available, such as PNG, JPG, BMP, GIF and many more.\n""Refer to the FreeImage webpage for a complete list of supported image formats\n""(\n\n""When 'source' is set to 'loop_functions', as showed in the following example,\n""an image is implicitly created to be used as texture for graphical\n""visualizations. The algorithm that creates the texture needs to convert from\n""meters (in the arena) to pixels (of the texture). You control how many pixels\n""per meter are used with the attribute 'pixels_per_meter'. Clearly, the higher\n""value, the higher the quality, but also the slower the algorithm and the bigger\n""the texture. The algorithm is called only once at init time, so the fact that\n""it is slow is not so important. However, the image size is limited by OpenGL.\n""Every implementation has its own limit, and you should check yours if any\n""texture-related problem arises. Now for the example:\n\n"" <arena ...>\n"" ...\n"" <floor id=\"floor\"\n"" source=\"loop_functions\"\n"" pixels_per_meter=\"100\" />\n"" ...\n"" </arena>\n\n""OPTIONAL XML CONFIGURATION\n\n""None for the time being.\n","Usable")
#define THROW_ARGOSEXCEPTION_NESTED(message, nested)
This macro throws an ARGoS exception with the passed message and nesting the passed exception...
void GetNodeAttribute(TConfigurationNode &t_node, const std::string &str_attribute, T &t_buffer)
Returns the value of a node's attribute.
The exception that wraps all errors in ARGoS.
The basic color type.
Definition: color.h:25
T & GetMedium(const std::string &str_id)
Returns a reference to a medium.
Definition: simulator.h:129
virtual void Init(TConfigurationNode &t_tree)
Initializes the state of the entity from the XML configuration tree.
void AddEntity(CLEDEntity &c_entity)
Adds the specified entity to the list of managed entities.
Definition: led_medium.cpp:100
The namespace containing all the ARGoS related code.
Definition: ci_actuator.h:12
static CSimulator & GetInstance()
Returns the instance to the CSimulator class.
Definition: simulator.cpp:78