8 #include <argos3/core/utility/string_utilities.h>
9 #include <argos3/core/simulator/simulator.h>
10 #include <argos3/core/simulator/space/space.h>
11 #include <argos3/core/simulator/entity/composable_entity.h>
12 #include <argos3/core/simulator/entity/embodied_entity.h>
13 #include <argos3/plugins/simulator/media/rab_medium.h>
33 const std::string& str_id,
42 m_psAnchor(&s_anchor),
43 m_cPosOffset(c_pos_offset),
44 m_cRotOffset(c_rot_offset),
47 m_pcEntityBody(&c_entity_body),
73 std::string strRotOffset;
75 if(strRotOffset !=
"") {
83 std::string strAnchorId;
187 for(
SInt32 i = 0; i <= nRangeI; ++i) {
195 for(
SInt32 j = 0; j <= nRangeJ; ++j) {
203 for(
SInt32 k = 0; k <= nRangeK; ++k) {
219 c_space_hash.
UpdateCell(m_nCenterI + i, m_nCenterJ + j, m_nCenterK + k, c_element);
220 c_space_hash.
UpdateCell(m_nCenterI + i, m_nCenterJ + j, m_nCenterK - k, c_element);
221 c_space_hash.
UpdateCell(m_nCenterI + i, m_nCenterJ - j, m_nCenterK + k, c_element);
222 c_space_hash.
UpdateCell(m_nCenterI + i, m_nCenterJ - j, m_nCenterK - k, c_element);
223 c_space_hash.
UpdateCell(m_nCenterI - i, m_nCenterJ + j, m_nCenterK + k, c_element);
224 c_space_hash.
UpdateCell(m_nCenterI - i, m_nCenterJ + j, m_nCenterK - k, c_element);
225 c_space_hash.
UpdateCell(m_nCenterI - i, m_nCenterJ - j, m_nCenterK + k, c_element);
226 c_space_hash.
UpdateCell(m_nCenterI - i, m_nCenterJ - j, m_nCenterK - k, c_element);
234 c_space_hash.
UpdateCell(m_nCenterI + i, m_nCenterJ + j, m_nCenterK, c_element);
235 c_space_hash.
UpdateCell(m_nCenterI + i, m_nCenterJ - j, m_nCenterK, c_element);
236 c_space_hash.
UpdateCell(m_nCenterI - i, m_nCenterJ + j, m_nCenterK, c_element);
237 c_space_hash.
UpdateCell(m_nCenterI - i, m_nCenterJ - j, m_nCenterK, c_element);
251 c_space_hash.
UpdateCell(m_nCenterI + i, m_nCenterJ, m_nCenterK + k, c_element);
252 c_space_hash.
UpdateCell(m_nCenterI + i, m_nCenterJ, m_nCenterK - k, c_element);
253 c_space_hash.
UpdateCell(m_nCenterI - i, m_nCenterJ, m_nCenterK + k, c_element);
254 c_space_hash.
UpdateCell(m_nCenterI - i, m_nCenterJ, m_nCenterK - k, c_element);
262 c_space_hash.
UpdateCell(m_nCenterI + i, m_nCenterJ, m_nCenterK, c_element);
263 c_space_hash.
UpdateCell(m_nCenterI - i, m_nCenterJ, m_nCenterK, c_element);
282 c_space_hash.
UpdateCell(m_nCenterI, m_nCenterJ + j, m_nCenterK + k, c_element);
283 c_space_hash.
UpdateCell(m_nCenterI, m_nCenterJ + j, m_nCenterK - k, c_element);
284 c_space_hash.
UpdateCell(m_nCenterI, m_nCenterJ - j, m_nCenterK + k, c_element);
285 c_space_hash.
UpdateCell(m_nCenterI, m_nCenterJ - j, m_nCenterK - k, c_element);
293 c_space_hash.
UpdateCell(m_nCenterI, m_nCenterJ + j, m_nCenterK, c_element);
294 c_space_hash.
UpdateCell(m_nCenterI, m_nCenterJ - j, m_nCenterK, c_element);
308 c_space_hash.
UpdateCell(m_nCenterI, m_nCenterJ, m_nCenterK + k, c_element);
309 c_space_hash.
UpdateCell(m_nCenterI, m_nCenterJ, m_nCenterK - k, c_element);
317 c_space_hash.
UpdateCell(m_nCenterI, m_nCenterJ, m_nCenterK, c_element);
366 m_cGrid.UpdateCell(n_i, n_j, n_k, *m_pcEntity);
372 m_pcEntity = &c_entity;
377 m_cCellUpdater(c_grid) {}
virtual void SetEnabled(bool b_enabled)
Enables or disables an entity.
void SetData(const CByteArray &c_data)
T Square(const T &t_v)
Returns the square of the value of the passed argument.
CRABEquippedEntityGridEntityUpdater(CGrid< CRABEquippedEntity > &c_grid)
signed int SInt32
32-bit signed integer.
void AddEntity(ENTITY &c_entity)
Adds an entity of the given type.
virtual bool operator()(CRABEquippedEntity &c_entity)
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.
virtual void SetEnabled(bool b_enabled)
Enables or disables an entity.
size_t Size() const
Returns the current size of the byte array.
float Real
Collects all ARGoS code.
void RemoveEntity(ENTITY &c_entity)
Removes an entity of the given type.
#define THROW_ARGOSEXCEPTION(message)
This macro throws an ARGoS exception with the passed message.
CVector3 & Rotate(const CQuaternion &c_quaternion)
Rotates this vector by the given quaternion.
void ParseValues(std::istream &str_input, UInt32 un_num_fields, T *pt_field_buffer, const char ch_delimiter= '\n')
The abstract definition of a space hash.
void RemoveEntity(CRABEquippedEntity &c_entity)
Removes the specified entity from the list of managed entities.
void Resize(size_t un_size, UInt8 un_value=0)
Resizes the byte array to the wanted size.
virtual void Init(TConfigurationNode &t_tree)
Initializes the state of the entity from the XML configuration tree.
const CQuaternion & GetOrientation() const
CQuaternion Orientation
The orientation of the anchor wrt the global coordinate system.
ticpp::Element TConfigurationNode
The ARGoS configuration XML node.
const CQuaternion & GetInitOrientation() const
This entity is a link to a body in the physics engine.
#define THROW_ARGOSEXCEPTION_NESTED(message, nested)
This macro throws an ARGoS exception with the passed message and nesting the passed exception...
It defines the basic type CDegrees, used to store an angle value in degrees.
virtual void Update()
Updates the state of this entity.
const CVector3 & GetPosition() const
REGISTER_SPACE_OPERATION(CSpaceOperationAddEntity, CSpaceOperationAddCFloorEntity, CFloorEntity)
void SetInitOrientation(const CQuaternion c_orientation)
CQuaternion & FromEulerAngles(const CRadians &c_z_angle, const CRadians &c_y_angle, const CRadians &c_x_angle)
void SetEntity(CRABEquippedEntity &c_entity)
void Enable()
Enables this anchor.
void SetInitPosition(const CVector3 &c_position)
Basic class for an entity that contains other entities.
CRABEquippedEntity(CComposableEntity *pc_parent)
An anchor related to the body of an entity.
ssize_t GetIndex() const
Returns the entity index.
void ApplyTo(CSpace &c_space, CRABEquippedEntity &c_entity)
void Zero()
Sets the contents of the byte array to all zeros.
void AddEntity(CRABEquippedEntity &c_entity)
Adds the specified entity to the list of managed entities.
virtual void operator()(CAbstractSpaceHash< CRABEquippedEntity > &c_space_hash, CRABEquippedEntity &c_element)
Updates the necessary cells of a space hash.
virtual bool operator()(SInt32 n_i, SInt32 n_j, SInt32 n_k, CGrid< CRABEquippedEntity >::SCell &s_cell)
virtual Real HashTableToSpace(SInt32 n_coord, UInt32 un_axis)
Converts a single space hash cell coordinate into a space coordinate.
bool IsEnabled() const
Returns true if the entity is enabled.
CEmbodiedEntity * m_pcEntityBody
virtual SInt32 SpaceToHashTable(Real f_coord, UInt32 un_axis)
Converts a single space coordinate into a space hash cell coordinate.
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.
virtual void UpdateCell(SInt32 n_x, SInt32 n_y, SInt32 n_z, ENTITY &c_entity)=0
Adds an entity to a cell of the space hash.
virtual void Init(TConfigurationNode &t_tree)
Initializes the state of the entity from the XML configuration tree.
void Disable()
Disables the entity.
Byte array utility class.
void SetOrientation(const CQuaternion c_orientation)
void Disable()
Disables this anchor.
CVector3 Position
The position of the anchor wrt the global coordinate system.
virtual void Reset()
Resets the state of the entity to whatever it was after Init() or the standalone constructor was call...
CRABEquippedEntityGridCellUpdater(CGrid< CRABEquippedEntity > &c_grid)
const SAnchor & GetAnchor(const std::string &str_id) const
Returns the wanted anchor as a const reference.
const std::string & GetId() const
Returns the id of this entity.
CRadians ToRadians(const CDegrees &c_degrees)
Converts CDegrees to CRadians.
CComposableEntity & GetParent()
Returns this entity's parent.
void ApplyTo(CSpace &c_space, CRABEquippedEntity &c_entity)
The namespace containing all the ARGoS related code.
std::string GetContext() const
Returns the context of this entity.
void SetPosition(const CVector3 &c_position)
CEntity & GetComponent(const std::string &str_component)
Returns the component with the passed string label.