2#include <argos3/core/simulator/simulator.h>
3#include <argos3/core/simulator/space/space.h>
4#include <argos3/core/simulator/space/positional_indices/grid.h>
5#include <argos3/core/utility/configuration/argos_exception.h>
6#include <argos3/core/utility/logging/argos_log.h>
29 std::string strPosIndexMethod(
"grid");
38 if(strPosIndexMethod ==
"grid") {
39 size_t punGridSize[3];
41 punGridSize[0] =
static_cast<UInt32>(cArenaSize.
GetX());
42 punGridSize[1] =
static_cast<UInt32>(cArenaSize.
GetY());
43 punGridSize[2] =
static_cast<UInt32>(cArenaSize.
GetZ());
46 std::string strPosGridSize;
51 cArenaCenter - cArenaSize * 0.5f, cArenaCenter + cArenaSize * 0.5f,
52 punGridSize[0], punGridSize[1], punGridSize[2]);
55 m_pcLEDEntityIndex = pcGrid;
58 THROW_ARGOSEXCEPTION(
"Unknown method \"" << strPosIndexMethod <<
"\" for the positional index.");
77 m_pcLEDEntityIndex->Reset();
84 delete m_pcLEDEntityIndex;
85 if(m_pcLEDEntityGridUpdateOperation !=
nullptr) {
86 delete m_pcLEDEntityGridUpdateOperation;
94 m_pcLEDEntityIndex->Update();
101 m_pcLEDEntityIndex->AddEntity(c_entity);
102 m_pcLEDEntityIndex->Update();
109 m_pcLEDEntityIndex->RemoveEntity(c_entity);
110 m_pcLEDEntityIndex->Update();
118 "Carlo Pinciroli [ilpincy@gmail.com]",
121 "This medium is required to manage the LED entities, thus allowing the\n"
122 "associated camera sensors to work properly. If you intend to use a camera\n"
123 "sensor that detects colored blobs, you must add this medium to the XML\n"
124 "configuration file.\n\n"
125 "REQUIRED XML CONFIGURATION\n\n"
126 "<led id=\"led\" />\n\n"
127 "OPTIONAL XML CONFIGURATION\n\n"
128 "None for the time being\n",
unsigned int UInt32
32-bit unsigned integer.
#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.
#define REGISTER_MEDIUM(CLASSNAME, LABEL, AUTHOR, VERSION, BRIEF_DESCRIPTION, LONG_DESCRIPTION, STATUS)
The namespace containing all the ARGoS related code.
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.
void ParseValues(std::istream &str_input, UInt32 un_num_fields, T *pt_field_buffer, const char ch_delimiter='\n')
ticpp::Element TConfigurationNode
The ARGoS configuration XML node.
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.
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 Reset()
Resets the resource.
virtual ~CLEDMedium()
Class destructor.
virtual void Init(TConfigurationNode &t_tree)
Initialized the medium.
virtual void Update()
Updates the state of this medium.
virtual void PostSpaceInit()
Executes extra initialization activities after the space has been initialized.
void RemoveEntity(CLEDEntity &c_entity)
Removes the specified entity from the list of managed entities.
CLEDMedium()
Class constructor.
void AddEntity(CLEDEntity &c_entity)
Adds the specified entity to the list of managed entities.
virtual void Destroy()
Undoes whatever was done by Init().