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>
24 m_pcEntityBody(nullptr),
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) {}
#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.
signed int SInt32
32-bit signed integer.
float Real
Collects all ARGoS code.
The namespace containing all the ARGoS related code.
T Square(const T &t_v)
Returns the square of the value of the passed argument.
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.
REGISTER_SPACE_OPERATION(CSpaceOperationAddEntity, CSpaceOperationAddCFloorEntity, CFloorEntity)
CRadians ToRadians(const CDegrees &c_degrees)
Converts CDegrees to CRadians.
void GetNodeAttribute(TConfigurationNode &t_node, const std::string &str_attribute, T &t_buffer)
Returns the value of a node's attribute.
Basic class for an entity that contains other entities.
CEntity & GetComponent(const std::string &str_component)
Returns the component with the passed string label.
This entity is a link to a body in the physics engine.
const SAnchor & GetAnchor(const std::string &str_id) const
Returns the wanted anchor as a const reference.
void Disable()
Disables the entity.
const std::string & GetId() const
Returns the id of this entity.
std::string GetContext() const
Returns the context of this entity.
bool IsEnabled() const
Returns true if the entity is enabled.
CComposableEntity & GetParent()
Returns this entity's parent.
virtual void SetEnabled(bool b_enabled)
Enables or disables an entity.
ssize_t GetIndex() const
Returns the entity index.
virtual void Init(TConfigurationNode &t_tree)
Initializes the state of the entity from the XML configuration tree.
const CQuaternion & GetOrientation() const
const CVector3 & GetPosition() const
void SetOrientation(const CQuaternion c_orientation)
void SetPosition(const CVector3 &c_position)
void SetInitPosition(const CVector3 &c_position)
const CQuaternion & GetInitOrientation() const
void SetInitOrientation(const CQuaternion c_orientation)
An anchor related to the body of an entity.
CQuaternion Orientation
The orientation of the anchor wrt the global coordinate system.
void Disable()
Disables this anchor.
CVector3 Position
The position of the anchor wrt the global coordinate system.
void Enable()
Enables this anchor.
The abstract definition of a space hash.
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 Real HashTableToSpace(SInt32 n_coord, UInt32 un_axis)
Converts a single space hash cell coordinate into a space coordinate.
virtual SInt32 SpaceToHashTable(Real f_coord, UInt32 un_axis)
Converts a single space coordinate into a space hash cell coordinate.
void AddEntity(ENTITY &c_entity)
Adds an entity of the given type.
void RemoveEntity(ENTITY &c_entity)
Removes an entity of the given type.
The exception that wraps all errors in ARGoS.
Byte array utility class.
void Zero()
Sets the contents of the byte array to all zeros.
size_t Size() const
Returns the current size of the byte array.
void Resize(size_t un_size, UInt8 un_value=0)
Resizes the byte array to the wanted size.
It defines the basic type CDegrees, used to store an angle value in degrees.
CQuaternion & FromEulerAngles(const CRadians &c_z_angle, const CRadians &c_y_angle, const CRadians &c_x_angle)
CVector3 & Rotate(const CQuaternion &c_quaternion)
Rotates this vector by the given quaternion.
void ApplyTo(CSpace &c_space, CRABEquippedEntity &c_entity)
void ApplyTo(CSpace &c_space, CRABEquippedEntity &c_entity)
void SetData(const CByteArray &c_data)
virtual void Update()
Updates the state of this entity.
CRABEquippedEntity(CComposableEntity *pc_parent)
virtual void SetEnabled(bool b_enabled)
Enables or disables an entity.
virtual void Reset()
Resets the state of the entity to whatever it was after Init() or the standalone constructor was call...
CEmbodiedEntity * m_pcEntityBody
virtual void Init(TConfigurationNode &t_tree)
Initializes the state of the entity from the XML configuration tree.
virtual void operator()(CAbstractSpaceHash< CRABEquippedEntity > &c_space_hash, CRABEquippedEntity &c_element)
Updates the necessary cells of a space hash.
void SetEntity(CRABEquippedEntity &c_entity)
virtual bool operator()(SInt32 n_i, SInt32 n_j, SInt32 n_k, CGrid< CRABEquippedEntity >::SCell &s_cell)
CRABEquippedEntityGridCellUpdater(CGrid< CRABEquippedEntity > &c_grid)
CRABEquippedEntityGridEntityUpdater(CGrid< CRABEquippedEntity > &c_grid)
virtual bool operator()(CRABEquippedEntity &c_entity)
void AddEntity(CRABEquippedEntity &c_entity)
Adds the specified entity to the list of managed entities.
void RemoveEntity(CRABEquippedEntity &c_entity)
Removes the specified entity from the list of managed entities.