8 #include <argos3/core/simulator/simulator.h>
9 #include <argos3/core/simulator/space/space.h>
10 #include <argos3/core/simulator/space/positional_indices/grid.h>
11 #include <argos3/core/utility/configuration/argos_exception.h>
12 #include <argos3/core/utility/logging/argos_log.h>
23 std::string strPosIndexMethod(
"grid");
32 if(strPosIndexMethod ==
"grid") {
33 size_t punGridSize[3];
35 punGridSize[0] =
static_cast<UInt32>(cArenaSize.
GetX());
36 punGridSize[1] =
static_cast<UInt32>(cArenaSize.
GetY());
37 punGridSize[2] =
static_cast<UInt32>(cArenaSize.
GetZ());
40 std::string strPosGridSize;
42 ParseValues<size_t>(strPosGridSize, 3, punGridSize,
',');
45 cArenaCenter - cArenaSize * 0.5f, cArenaCenter + cArenaSize * 0.5f,
46 punGridSize[0], punGridSize[1], punGridSize[2]);
49 m_pcDirectionalLEDEntityIndex = pcGrid;
52 THROW_ARGOSEXCEPTION(
"Unknown method \"" << strPosIndexMethod <<
"\" for the positional index.");
71 m_pcDirectionalLEDEntityIndex->Reset();
78 delete m_pcDirectionalLEDEntityIndex;
79 if(m_pcDirectionalLEDEntityGridUpdateOperation !=
nullptr) {
80 delete m_pcDirectionalLEDEntityGridUpdateOperation;
88 m_pcDirectionalLEDEntityIndex->Update();
95 m_pcDirectionalLEDEntityIndex->AddEntity(c_entity);
96 m_pcDirectionalLEDEntityIndex->Update();
103 m_pcDirectionalLEDEntityIndex->RemoveEntity(c_entity);
104 m_pcDirectionalLEDEntityIndex->Update();
112 "Michael Allwright [allsey87@gmail.com]",
114 "Manages directional LED entities.",
115 "This medium is required to manage the directional LED entities, so that\n"
116 "the associated camera sensors can find them. If you use a camera sensor,\n"
117 "you must add this medium the sensors XML configuration.\n\n"
118 "REQUIRED XML CONFIGURATION\n\n"
119 "<directional_led id=\"led\" />\n\n"
120 "OPTIONAL XML CONFIGURATION\n\n"
121 "None for the time being\n",
#define THROW_ARGOSEXCEPTION_NESTED(message, nested)
This macro throws an ARGoS exception with the passed message and nesting the passed exception.
#define THROW_ARGOSEXCEPTION(message)
This macro throws an ARGoS exception with the passed message.
unsigned int UInt32
32-bit unsigned integer.
The namespace containing all the ARGoS related code.
REGISTER_MEDIUM(CDirectionalLEDMedium, "directional_led", "Michael Allwright [allsey87@gmail.com]", "1.0", "Manages directional LED entities.", "This medium is required to manage the directional LED entities, so that\n" "the associated camera sensors can find them. If you use a camera sensor,\n" "you must add this medium the sensors XML configuration.\n\n" "REQUIRED XML CONFIGURATION\n\n" "<directional_led id=\"led\" />\n\n" "OPTIONAL XML CONFIGURATION\n\n" "None for the time being\n", "Under development")
TConfigurationNode & GetNode(TConfigurationNode &t_node, const std::string &str_tag)
Given a tree root node, returns the first of its child nodes with the wanted name.
bool NodeAttributeExists(TConfigurationNode &t_node, const std::string &str_attribute)
Returns true if the specified attribute of a node exists.
void GetNodeAttributeOrDefault(TConfigurationNode &t_node, const std::string &str_attribute, T &t_buffer, const T &t_default)
Returns the value of a node's attribute, or the passed default value.
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_tree)
Initialized the medium.
static CSimulator & GetInstance()
Returns the instance to the CSimulator class.
void SetUpdateEntityOperation(CEntityOperation *pc_operation)
The exception that wraps all errors in ARGoS.
Real GetX() const
Returns the x coordinate of this vector.
Real GetY() const
Returns the y coordinate of this vector.
Real GetZ() const
Returns the z coordinate of this vector.
virtual void PostSpaceInit()
Executes extra initialization activities after the space has been initialized.
virtual void Reset()
Resets the resource.
void RemoveEntity(CDirectionalLEDEntity &c_entity)
Removes the specified entity from the list of managed entities.
virtual void Init(TConfigurationNode &t_tree)
Initialized the medium.
virtual void Destroy()
Undoes whatever was done by Init().
virtual void Update()
Updates the state of this medium.
void AddEntity(CDirectionalLEDEntity &c_entity)
Adds the specified entity to the list of managed entities.