miniquadrotor_rotor_default_actuator.cpp
Go to the documentation of this file.
1 
8 #include <argos3/plugins/simulator/entities/rotor_equipped_entity.h>
9 #include <argos3/core/utility/logging/argos_log.h>
10 #include <argos3/core/utility/plugins/factory.h>
11 
12 namespace argos {
13 
14  /****************************************/
15  /****************************************/
16 
18  m_pcRotorEquippedEntity(NULL),
19  m_pcRNG(NULL),
20  m_fNoiseStdDeviation(0.0f) {
21  }
22 
23  /****************************************/
24  /****************************************/
25 
27  try {
30  THROW_ARGOSEXCEPTION("The mini-quadrotor rotor actuator can be associated only to a mini-quadrotor");
31  }
32  }
33  catch(CARGoSException& ex) {
34  THROW_ARGOSEXCEPTION_NESTED("Error setting mini-quadrotor rotor actuator to entity \"" << c_entity.GetId() << "\"", ex);
35  }
36  }
37 
38  /****************************************/
39  /****************************************/
40 
42  try {
44  GetNodeAttributeOrDefault<Real>(t_tree, "noise_std_dev", m_fNoiseStdDeviation, 0.0f);
45  if(m_fNoiseStdDeviation > 0.0f) {
46  m_pcRNG = CRandom::CreateRNG("argos");
47  }
48  }
49  catch(CARGoSException& ex) {
50  THROW_ARGOSEXCEPTION_NESTED("Initialization error in mini-quadrotor rotor actuator.", ex);
51  }
52  }
53 
54  /****************************************/
55  /****************************************/
56 
58  /* Set velocities */
59  m_sCurrentVelocities = s_velocities;
60  /* Apply noise */
61  if(m_fNoiseStdDeviation > 0.0f) {
63  }
64  }
65 
66  /****************************************/
67  /****************************************/
68 
71  }
72 
73  /****************************************/
74  /****************************************/
75 
78  }
79 
80  /****************************************/
81  /****************************************/
82 
88  }
89 
90  /****************************************/
91  /****************************************/
92 
93 }
94 
95 REGISTER_ACTUATOR(CMiniQuadrotorRotorDefaultActuator,
96  "miniquadrotor_rotor", "default",
97  "Carlo Pinciroli [ilpincy@gmail.com]",
98  "1.0",
99  "The mini-quadrotor rotor actuator.",
100  "This actuator controls the four rotors of a mini-quadrotor robot. For a\n"
101  "complete description of its usage, refer to the\n"
102  "ci_miniquadrotor_rotor_actuator.h file.\n\n"
103  "REQUIRED XML CONFIGURATION\n\n"
104  " <controllers>\n"
105  " ...\n"
106  " <my_controller ...>\n"
107  " ...\n"
108  " <actuators>\n"
109  " ...\n"
110  " <miniquadrotor_rotor implementation=\"default\" />\n"
111  " ...\n"
112  " </actuators>\n"
113  " ...\n"
114  " </my_controller>\n"
115  " ...\n"
116  " </controllers>\n\n"
117  "OPTIONAL XML CONFIGURATION\n\n"
118  "It is possible to specify noisy speed in order to match the characteristics\n"
119  "of the real robot. This can be done with the attribute: 'noise_std_dev',\n"
120  "which indicates the standard deviation of a gaussian noise applied to the\n"
121  "desired velocity of the rotor:\n\n"
122  " <controllers>\n"
123  " ...\n"
124  " <my_controller ...>\n"
125  " ...\n"
126  " <actuators>\n"
127  " ...\n"
128  " <miniquadrotor_rotor implementation=\"default\"\n"
129  " noise_std_dev=\"1\" />\n"
130  " ...\n"
131  " </actuators>\n"
132  " ...\n"
133  " </my_controller>\n"
134  " ...\n"
135  " </controllers>\n",
136  "Usable"
137  );
138 
void SetVelocities(Real *pf_velocities)
#define THROW_ARGOSEXCEPTION(message)
This macro throws an ARGoS exception with the passed message.
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...
virtual void Init(TConfigurationNode &t_node)
Initializes the actuator from the XML configuration tree.
Definition: ci_actuator.h:54
REGISTER_ACTUATOR(CMiniQuadrotorRotorDefaultActuator,"miniquadrotor_rotor","default","Carlo Pinciroli [ilpincy@gmail.com]","1.0","The mini-quadrotor rotor actuator.","This actuator controls the four rotors of a mini-quadrotor robot. For a\n""complete description of its usage, refer to the\n""ci_miniquadrotor_rotor_actuator.h file.\n\n""REQUIRED XML CONFIGURATION\n\n"" <controllers>\n"" ...\n"" <my_controller ...>\n"" ...\n"" <actuators>\n"" ...\n"" <miniquadrotor_rotor implementation=\"default\" />\n"" ...\n"" </actuators>\n"" ...\n"" </my_controller>\n"" ...\n"" </controllers>\n\n""OPTIONAL XML CONFIGURATION\n\n""It is possible to specify noisy speed in order to match the characteristics\n""of the real robot. This can be done with the attribute: 'noise_std_dev',\n""which indicates the standard deviation of a gaussian noise applied to the\n""desired velocity of the rotor:\n\n"" <controllers>\n"" ...\n"" <my_controller ...>\n"" ...\n"" <actuators>\n"" ...\n"" <miniquadrotor_rotor implementation=\"default\"\n"" noise_std_dev=\"1\" />\n"" ...\n"" </actuators>\n"" ...\n"" </my_controller>\n"" ...\n"" </controllers>\n","Usable")
Basic class for an entity that contains other entities.
virtual void SetRobot(CComposableEntity &c_entity)
Sets the entity associated to this actuator.
The exception that wraps all errors in ARGoS.
Real Gaussian(Real f_std_dev, Real f_mean=0.0f)
Returns a random value from a Gaussian distribution.
Definition: rng.cpp:131
static CRNG * CreateRNG(const std::string &str_category)
Creates a new RNG inside the given category.
Definition: rng.cpp:326
CRotorEquippedEntity * m_pcRotorEquippedEntity
The rotor equipped entity.
const std::string & GetId() const
Returns the id of this entity.
Definition: entity.h:157
Real m_fNoiseStdDeviation
Noise parameters, at the moment noise is Gaussian.
The namespace containing all the ARGoS related code.
Definition: ci_actuator.h:12
virtual void AddGaussianNoise()
Adds noise to the rotor velocity.
virtual void Reset()
Resets the actuator to the state it had just after Init().
virtual void Update()
Updates the state of the entity associated to this actuator.
virtual void SetRotorVelocities(const CCI_MiniQuadrotorRotorActuator::SVelocities &s_velocities)
virtual void Init(TConfigurationNode &t_tree)
Initializes the actuator from the XML configuration tree.
CEntity & GetComponent(const std::string &str_component)
Returns the component with the passed string label.