magnet_entity.cpp
Go to the documentation of this file.
1 
7 #include "magnet_entity.h"
8 #include <argos3/core/simulator/space/space.h>
9 
10 namespace argos {
11 
12  /****************************************/
13  /****************************************/
14 
16  CEntity(pc_parent),
17  m_cField(CVector3::ZERO),
18  m_cPassiveField(CVector3::ZERO),
19  m_cActiveField(CVector3::ZERO) {}
20 
21  /****************************************/
22  /****************************************/
23 
25  const std::string& str_id,
26  const CVector3& c_passive_field,
27  const CVector3& c_active_field) :
28  CEntity(pc_parent, str_id),
29  m_cField(c_passive_field),
30  m_cPassiveField(c_passive_field),
31  m_cActiveField(c_active_field) {}
32 
33  /****************************************/
34  /****************************************/
35 
37  try {
38  /* Parse XML */
39  CEntity::Init(t_tree);
40  GetNodeAttribute(t_tree, "passive_field", m_cPassiveField);
42  /* m_cField is updated by SetCurrent which sums the product of the current with
43  m_cActiveField and m_cPassiveField to evalaute m_cField */
45  }
46  catch(CARGoSException& ex) {
47  THROW_ARGOSEXCEPTION_NESTED("Error while initializing magnet entity", ex);
48  }
49  }
50 
51  /****************************************/
52  /****************************************/
53 
56  }
57 
58  /****************************************/
59  /****************************************/
60 
62 
63  /****************************************/
64  /****************************************/
65 
66 }
A 3D vector class.
Definition: vector3.h:29
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 Reset()
Resets the state of the entity to whatever it was after Init() or the standalone constructor was call...
The basic entity type.
Definition: entity.h:89
ticpp::Element TConfigurationNode
The ARGoS configuration XML node.
#define THROW_ARGOSEXCEPTION_NESTED(message, nested)
This macro throws an ARGoS exception with the passed message and nesting the passed exception...
Basic class for an entity that contains other entities.
virtual void Init(TConfigurationNode &t_tree)
Initializes the state of the entity from the XML configuration tree.
CMagnetEntity(CComposableEntity *pc_parent)
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 Init(TConfigurationNode &t_tree)
Initializes the state of the entity from the XML configuration tree.
Definition: entity.cpp:40
REGISTER_STANDARD_SPACE_OPERATIONS_ON_ENTITY(CEntity)
The namespace containing all the ARGoS related code.
Definition: ci_actuator.h:12