ARGoS 3
A parallel, multi-engine simulator for swarm robotics
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
10namespace 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
57
58 /****************************************/
59 /****************************************/
60
62
63 /****************************************/
64 /****************************************/
65
66}
#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.
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.
The basic entity type.
Definition entity.h:90
virtual void Init(TConfigurationNode &t_tree)
Initializes the state of the entity from the XML configuration tree.
Definition entity.cpp:40
The exception that wraps all errors in ARGoS.
A 3D vector class.
Definition vector3.h:31
virtual void Reset()
Resets the state of the entity to whatever it was after Init() or the standalone constructor was call...
CMagnetEntity(CComposableEntity *pc_parent)
virtual void Init(TConfigurationNode &t_tree)
Initializes the state of the entity from the XML configuration tree.