ARGoS 3
A parallel, multi-engine simulator for swarm robotics
positional_entity.cpp
Go to the documentation of this file.
1
7#include "positional_entity.h"
8#include "composable_entity.h"
9#include <argos3/core/simulator/space/space.h>
10#include <argos3/core/simulator/simulator.h>
11#include <argos3/core/utility/string_utilities.h>
12
13namespace argos {
14
15 /****************************************/
16 /****************************************/
17
20
21 /****************************************/
22 /****************************************/
23
25 const std::string& str_id,
26 const CVector3& c_position,
27 const CQuaternion& c_orientation) :
28 CEntity(pc_parent, str_id),
29 m_cPosition(c_position),
30 m_cInitPosition(c_position),
31 m_cOrientation(c_orientation),
32 m_cInitOrientation(c_orientation) {}
33
34 /****************************************/
35 /****************************************/
36
38 try {
39 /* Initialize base entity */
40 CEntity::Init(t_tree);
41 /* Get the position of the entity */
42 GetNodeAttributeOrDefault(t_tree, "position", m_cPosition, CVector3());
43 /* Get the orientation of the entity */
44 GetNodeAttributeOrDefault(t_tree, "orientation", m_cOrientation, CQuaternion());
45 m_cInitPosition = m_cPosition;
46 m_cInitOrientation = m_cOrientation;
47 }
48 catch(CARGoSException& ex) {
49 THROW_ARGOSEXCEPTION_NESTED("Failed to initialize positional entity \"" << GetId() << "\".", ex);
50 }
51 }
52
53 /****************************************/
54 /****************************************/
55
57 /* Reset the entity's initial position and orientation */
58 SetPosition(m_cInitPosition);
59 SetOrientation(m_cInitOrientation);
60 }
61
62 /****************************************/
63 /****************************************/
64
65 void CPositionalEntity::MoveTo(const CVector3& c_position,
66 const CQuaternion& c_orientation) {
67 SetPosition(c_position);
68 SetOrientation(c_orientation);
69 }
70
71 /****************************************/
72 /****************************************/
73
75
76 /****************************************/
77 /****************************************/
78
79}
#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
The namespace containing all the ARGoS related code.
Definition ci_actuator.h:12
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.
Basic class for an entity that contains other entities.
The basic entity type.
Definition entity.h:90
const std::string & GetId() const
Returns the id of this entity.
Definition entity.h:157
virtual void Init(TConfigurationNode &t_tree)
Initializes the state of the entity from the XML configuration tree.
Definition entity.cpp:40
virtual void Reset()
Resets the state of the entity to whatever it was after Init() or the standalone constructor was call...
virtual void MoveTo(const CVector3 &c_position, const CQuaternion &c_orientation)
void SetOrientation(const CQuaternion c_orientation)
void SetPosition(const CVector3 &c_position)
virtual void Init(TConfigurationNode &t_tree)
Initializes the state of the entity from the XML configuration tree.
CPositionalEntity(CComposableEntity *pc_parent)
The exception that wraps all errors in ARGoS.
A 3D vector class.
Definition vector3.h:31