magnets_default_actuator.cpp
Go to the documentation of this file.
1 
8 #include <argos3/plugins/simulator/entities/magnet_equipped_entity.h>
9 
10 namespace argos {
11 
12  /****************************************/
13  /****************************************/
14 
16  m_pcMagnetEquippedEntity(nullptr) {
17  }
18 
19  /****************************************/
20  /****************************************/
21 
23  try {
24  /* Get the magnet equipped entity */
26  /* Allocate memory for a control interface for each instance */
28  /* Populate the interfaces */
30  m_vecInterfaces.emplace_back(s_instance.Magnet.GetId());
31  }
32  }
33  catch(CARGoSException& ex) {
34  THROW_ARGOSEXCEPTION_NESTED("Can't set robot for the magnets default actuator", ex);
35  }
36  }
37 
38  /****************************************/
39  /****************************************/
40 
42  try {
43  /* Parent class init */
45  }
46  catch(CARGoSException& ex) {
47  THROW_ARGOSEXCEPTION_NESTED("Error initializing the magnets default actuator", ex);
48  }
49  }
50 
51 
52  /****************************************/
53  /****************************************/
54 
56  for(size_t i = 0; i < m_vecInterfaces.size(); ++i) {
58  /* Update each magnet field by setting the magnet's current */
59  cMagnet.SetCurrent(m_vecInterfaces[i].Current);
60  }
61  }
62 
63  /****************************************/
64  /****************************************/
65 
67  for(SInterface& s_interface : m_vecInterfaces) {
68  /* Set the current to zero */
69  s_interface.Current = 0.0f;
70  }
71  }
72 
73  /****************************************/
74  /****************************************/
75 
77  "magnets", "default",
78  "Michael Allwright [allsey87@gmail.com]",
79  "1.0",
80  "The (electro)magnet actuator.",
81 
82  "This actuator is used to modify the magnetic field of a magnet entity in the\n"
83  "simulation. A magnetic entity has a passive and an active field. The overall\n"
84  "field of a magnetic entity is calculated as:\n\n"
85  " field = passive_field + (current x active_field)\n\n"
86  "This actuator allows you to set the current, a scalar multiplier of the active\n"
87  "field.\n\n"
88 
89  "REQUIRED XML CONFIGURATION\n\n"
90 
91  " <controllers>\n"
92  " ...\n"
93  " <my_controller ...>\n"
94  " ...\n"
95  " <actuators>\n"
96  " ...\n"
97  " <magnets implementation=\"default\"/>\n"
98  " ...\n"
99  " </actuators>\n"
100  " ...\n"
101  " </my_controller>\n"
102  " ...\n"
103  " </controllers>\n\n"
104 
105  "OPTIONAL XML CONFIGURATION\n\n"
106 
107  "None.\n",
108 
109  "Under development"
110  );
111 
112  /****************************************/
113  /****************************************/
114 
115 }
#define THROW_ARGOSEXCEPTION_NESTED(message, nested)
This macro throws an ARGoS exception with the passed message and nesting the passed exception.
The namespace containing all the ARGoS related code.
Definition: ci_actuator.h:12
ticpp::Element TConfigurationNode
The ARGoS configuration XML node.
REGISTER_ACTUATOR(CFootBotDistanceScannerDefaultActuator, "footbot_distance_scanner", "default", "Carlo Pinciroli [ilpincy@gmail.com]", "1.0", "The foot-bot distance scanner actuator.", "This actuator controls the foot-bot distance scanner. For a complete\n" "description of its usage, refer to the ci_footbot_distance_scanner_actuator\n" "file.\n\n" "REQUIRED XML CONFIGURATION\n\n" " <controllers>\n" " ...\n" " <my_controller ...>\n" " ...\n" " <actuators>\n" " ...\n" " <footbot_distance_scanner implementation=\"default\" />\n" " ...\n" " </actuators>\n" " ...\n" " </my_controller>\n" " ...\n" " </controllers>\n\n" "OPTIONAL XML CONFIGURATION\n\n" "None for the time being.\n", "Usable")
virtual void Init(TConfigurationNode &t_node)
Initializes the actuator from the XML configuration tree.
Definition: ci_actuator.h:54
Basic class for an entity that contains other entities.
CEntity & GetComponent(const std::string &str_component)
Returns the component with the passed string label.
The exception that wraps all errors in ARGoS.
SInterface::TVector m_vecInterfaces
virtual void Reset()
Resets the actuator to the state it had just after Init().
virtual void Init(TConfigurationNode &t_tree)
Initializes the actuator from the XML configuration tree.
virtual void Update()
Updates the state of the entity associated to this actuator.
CMagnetEquippedEntity * m_pcMagnetEquippedEntity
virtual void SetRobot(CComposableEntity &c_entity)
Sets the entity associated to this actuator.
void SetCurrent(Real f_current)
Sets the current field of the magnet.
Definition: magnet_entity.h:75
A container of CMagnetEntity.
SInstance::TVector & GetInstances()
CMagnetEntity & GetMagnet(UInt32 un_index)
Returns an magnet by numeric index.