ARGoS 3
A parallel, multi-engine simulator for swarm robotics
light_entity.cpp
Go to the documentation of this file.
1
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>
11
12namespace argos {
13
14 /****************************************/
15 /****************************************/
16
18 CLEDEntity(nullptr),
19 m_fIntensity(1.0f) {}
20
21 /****************************************/
22 /****************************************/
23
24 CLightEntity::CLightEntity(const std::string& str_id,
25 const CVector3& c_position,
26 const CColor& c_color,
27 Real f_intensity) :
28 CLEDEntity(nullptr,
29 str_id,
30 c_position,
31 c_color),
32 m_fIntensity(f_intensity) {}
33
34 /****************************************/
35 /****************************************/
36
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 auto& 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 }
52
53 /****************************************/
54 /****************************************/
55
57 "light",
58 "Carlo Pinciroli [ilpincy@gmail.com]",
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"
67 "REQUIRED XML CONFIGURATION\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"
92 "OPTIONAL XML CONFIGURATION\n\n"
93 "None.\n",
94 "Usable"
95 );
96
97 /****************************************/
98 /****************************************/
99
101
102 /****************************************/
103 /****************************************/
104
105}
float Real
Collects all ARGoS code.
Definition datatypes.h:39
#define THROW_ARGOSEXCEPTION_NESTED(message, nested)
This macro throws an ARGoS exception with the passed message and nesting the passed exception.
#define REGISTER_STANDARD_SPACE_OPERATIONS_ON_ENTITY(ENTITY)
Definition space.h:564
#define REGISTER_ENTITY(CLASSNAME, LABEL, AUTHOR, VERSION, BRIEF_DESCRIPTION, LONG_DESCRIPTION, STATUS)
Definition entity.h:432
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.
static CSimulator & GetInstance()
Returns the instance to the CSimulator class.
Definition simulator.cpp:78
T & GetMedium(const std::string &str_id)
Returns a reference to a medium.
Definition simulator.h:129
The exception that wraps all errors in ARGoS.
The basic color type.
Definition color.h:25
A 3D vector class.
Definition vector3.h:31
virtual void Init(TConfigurationNode &t_tree)
Initializes the state of the entity from the XML configuration tree.
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.