ARGoS  3
A parallel, multi-engine simulator for swarm robotics
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 
argos::CRandom::CRNG::Gaussian
Real Gaussian(Real f_std_dev, Real f_mean=0.0f)
Returns a random value from a Gaussian distribution.
Definition: rng.cpp:131
argos::CEntity::GetId
const std::string & GetId() const
Returns the id of this entity.
Definition: entity.h:157
argos
The namespace containing all the ARGoS related code.
Definition: ci_actuator.h:12
argos::CComposableEntity
Basic class for an entity that contains other entities.
Definition: composable_entity.h:32
argos::CCI_MiniQuadrotorRotorActuator::SVelocities
Definition: ci_miniquadrotor_rotor_actuator.h:22
argos::CARGoSException
The exception that wraps all errors in ARGoS.
Definition: argos_exception.h:61
argos::CComposableEntity::GetComponent
CEntity & GetComponent(const std::string &str_component)
Returns the component with the passed string label.
Definition: composable_entity.cpp:109
argos::CMiniQuadrotorRotorDefaultActuator::Reset
virtual void Reset()
Resets the actuator to the state it had just after Init().
Definition: miniquadrotor_rotor_default_actuator.cpp:76
argos::CMiniQuadrotorRotorDefaultActuator::m_fNoiseStdDeviation
Real m_fNoiseStdDeviation
Noise parameters, at the moment noise is Gaussian.
Definition: miniquadrotor_rotor_default_actuator.h:67
argos::CMiniQuadrotorRotorDefaultActuator::SetRotorVelocities
virtual void SetRotorVelocities(const CCI_MiniQuadrotorRotorActuator::SVelocities &s_velocities)
Definition: miniquadrotor_rotor_default_actuator.cpp:57
argos::CCI_MiniQuadrotorRotorActuator::SVelocities::Velocities
Real Velocities[4]
Definition: ci_miniquadrotor_rotor_actuator.h:23
argos::CRotorEquippedEntity::GetNumRotors
size_t GetNumRotors() const
Definition: rotor_equipped_entity.h:34
argos::TConfigurationNode
ticpp::Element TConfigurationNode
The ARGoS configuration XML node.
Definition: argos_configuration.h:27
REGISTER_ACTUATOR
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")
argos::CMiniQuadrotorRotorDefaultActuator::AddGaussianNoise
virtual void AddGaussianNoise()
Adds noise to the rotor velocity.
Definition: miniquadrotor_rotor_default_actuator.cpp:83
argos::CMiniQuadrotorRotorDefaultActuator::SetRobot
virtual void SetRobot(CComposableEntity &c_entity)
Sets the entity associated to this actuator.
Definition: miniquadrotor_rotor_default_actuator.cpp:26
THROW_ARGOSEXCEPTION_NESTED
#define THROW_ARGOSEXCEPTION_NESTED(message, nested)
This macro throws an ARGoS exception with the passed message and nesting the passed exception.
Definition: argos_exception.h:115
THROW_ARGOSEXCEPTION
#define THROW_ARGOSEXCEPTION(message)
This macro throws an ARGoS exception with the passed message.
Definition: argos_exception.h:111
argos::CMiniQuadrotorRotorDefaultActuator::m_pcRNG
CRandom::CRNG * m_pcRNG
Random number generator.
Definition: miniquadrotor_rotor_default_actuator.h:64
argos::CRotorEquippedEntity::SetVelocities
void SetVelocities(Real *pf_velocities)
Definition: rotor_equipped_entity.cpp:96
argos::CMiniQuadrotorRotorDefaultActuator::m_pcRotorEquippedEntity
CRotorEquippedEntity * m_pcRotorEquippedEntity
The rotor equipped entity.
Definition: miniquadrotor_rotor_default_actuator.h:61
argos::CMiniQuadrotorRotorDefaultActuator::CMiniQuadrotorRotorDefaultActuator
CMiniQuadrotorRotorDefaultActuator()
Definition: miniquadrotor_rotor_default_actuator.cpp:17
miniquadrotor_rotor_default_actuator.h
argos::CRotorEquippedEntity
Definition: rotor_equipped_entity.h:15
argos::CRandom::CreateRNG
static CRNG * CreateRNG(const std::string &str_category)
Creates a new RNG inside the given category.
Definition: rng.cpp:326
argos::CMiniQuadrotorRotorDefaultActuator::Init
virtual void Init(TConfigurationNode &t_tree)
Initializes the actuator from the XML configuration tree.
Definition: miniquadrotor_rotor_default_actuator.cpp:41
argos::CCI_MiniQuadrotorRotorActuator::m_sCurrentVelocities
SVelocities m_sCurrentVelocities
Definition: ci_miniquadrotor_rotor_actuator.h:46
argos::CMiniQuadrotorRotorDefaultActuator::Update
virtual void Update()
Updates the state of the entity associated to this actuator.
Definition: miniquadrotor_rotor_default_actuator.cpp:69
argos::CCI_Actuator::Init
virtual void Init(TConfigurationNode &t_node)
Initializes the actuator from the XML configuration tree.
Definition: ci_actuator.h:54