8 #include <argos3/core/utility/logging/argos_log.h>
9 #include <argos3/core/utility/plugins/factory.h>
17 m_pcWheeledEntity(nullptr),
36 THROW_ARGOSEXCEPTION(
"The differential steering actuator can be associated only to a robot with 2 wheels");
48 #define CHECK_ATTRIBUTE(ATTR) \
49 (NodeAttributeExists(t_tree, ATTR) || \
50 NodeAttributeExists(t_tree, ATTR "_left") || \
51 NodeAttributeExists(t_tree, ATTR "_right"))
53 #define PARSE_ATTRIBUTES(ATTR, VAR) \
54 GetNodeAttributeOrDefault<Real>(t_tree, ATTR, VAR[LEFT_WHEEL], VAR[LEFT_WHEEL]); \
55 VAR[RIGHT_WHEEL] = VAR[LEFT_WHEEL]; \
56 GetNodeAttributeOrDefault<Real>(t_tree, ATTR "_left", VAR[LEFT_WHEEL], VAR[LEFT_WHEEL]); \
57 GetNodeAttributeOrDefault<Real>(t_tree, ATTR "_right", VAR[RIGHT_WHEEL], VAR[RIGHT_WHEEL]);
59 #define PICK_BIAS(LRW) m_fNoiseBias[LRW ## _WHEEL] = m_pcRNG->Gaussian(fNoiseBiasStdDev[LRW ## _WHEEL], fNoiseBiasAvg[LRW ## _WHEEL])
75 Real fNoiseBiasAvg[2];
76 Real fNoiseBiasStdDev[2];
94 #define ADD_GAUSSIAN(LRW) \
95 (m_fNoiseFactorStdDev[LRW ## _WHEEL] > 0.0 ? \
96 m_pcRNG->Gaussian(m_fNoiseFactorStdDev[LRW ## _WHEEL], \
97 m_fNoiseFactorAvg[LRW ## _WHEEL]) : \
98 m_fNoiseFactorAvg[LRW ## _WHEEL])
100 #define ADD_NOISE(LRW) \
101 m_fCurrentVelocity[LRW ## _WHEEL] = \
104 (m_fCurrentVelocity[LRW ## _WHEEL] + \
105 m_fNoiseBias[LRW ## _WHEEL]);
108 Real f_right_velocity) {
114 ((f_left_velocity != 0) ||
115 (f_right_velocity != 0) )) {
151 "differential_steering",
"default",
152 "Carlo Pinciroli [ilpincy@gmail.com]",
154 "The differential steering actuator.",
156 "This actuator controls the two wheels a differential steering robot. For a\n"
157 "complete description of its usage, refer to the\n"
158 "ci_differential_steering_actuator.h file.\n\n"
160 "REQUIRED XML CONFIGURATION\n\n"
163 " <my_controller ...>\n"
167 " <differential_steering implementation=\"default\" />\n"
171 " </my_controller>\n"
173 " </controllers>\n\n"
175 "OPTIONAL XML CONFIGURATION\n\n"
177 "It is possible to specify noisy speed in order to match the characteristics\n"
178 "of the real robot. For each wheel, the noise model is as follows:\n\n"
179 "w = ideal wheel actuation (as set in the controller)\n"
180 "b = random bias from a Gaussian distribution\n"
181 "f = random factor from a Gaussian distribution\n"
182 "a = actual actuated value\n\n"
183 "a = f * (w + b)\n\n"
184 "You can configure the average and stddev of both the bias and the factor. This\n"
185 "can be done with the optional attributes: 'bias_avg', 'bias_stddev',\n"
186 "'factor_avg', and 'factor_stddev'. Bias attributes are expressed in m/s, while\n"
187 "factor attributes are dimensionless. If none of these attributed is specified,\n"
188 "no noise is added. If at least one of these attributed is specified, noise is\n"
189 "added and, for the non-specified attributes, the default value of 1 is used for\n"
190 "the '*_avg' attributes, while 0 is used for '*_stddev' attributes. Examples:\n\n"
194 " <my_controller ...>\n"
198 " <!-- Only the stddev of the bias\n"
199 " Noise is on, other attributes are default -->\n"
200 " <differential_steering implementation=\"default\"\n"
201 " bias_stddev=\"2\" />\n"
202 " <!-- Only the stddev of the factor\n"
203 " Noise is on, other attributes are default -->\n"
204 " <differential_steering implementation=\"default\"\n"
205 " factor_stddev=\"4\" />\n"
206 " <!-- All attributes set\n"
207 " Noise is on, specified values are set -->\n"
208 " <differential_steering implementation=\"default\"\n"
210 " bias_stddev=\"2\"\n"
211 " factor_avg=\"3\"\n"
212 " factor_stddev=\"4\" />\n"
216 " </my_controller>\n"
218 " </controllers>\n\n"
220 "The above examples set the same noise for both wheels. If you want to set\n"
221 "different noise parameters for each wheel, append '_left' and '_right' to the\n"
222 "attribute names:\n\n"
226 " <my_controller ...>\n"
230 " <!-- Mix of wheel-specific attributes set\n"
231 " Noise is on, specified values are set -->\n"
232 " <differential_steering implementation=\"default\"\n"
233 " bias_avg_left=\"1\"\n"
234 " bias_stddev_right=\"2\"\n"
235 " factor_avg_left=\"3\"\n"
236 " factor_stddev_right=\"4\" />\n"
240 " </my_controller>\n"
242 " </controllers>\n\n"
244 "Wheel-specific attributes overwrite the values of non-wheel specific attributes.\n"
245 "So, if you set 'bias_avg' = 2 and then 'bias_avg_left' = 3, the left wheel will\n"
246 "use 3 and the right wheel will use 2.\n\n"
247 "Physics-engine-specific attributes that affect this actuator might also be\n"
248 "available. Check the documentation of the physics engine you're using for more\n"
#define THROW_ARGOSEXCEPTION_NESTED(message, nested)
This macro throws an ARGoS exception with the passed message and nesting the passed exception.
#define THROW_ARGOSEXCEPTION(message)
This macro throws an ARGoS exception with the passed message.
float Real
Collects all ARGoS code.
#define CHECK_ATTRIBUTE(ATTR)
#define PARSE_ATTRIBUTES(ATTR, VAR)
REGISTER_ACTUATOR(CDifferentialSteeringDefaultActuator, "differential_steering", "default", "Carlo Pinciroli [ilpincy@gmail.com]", "1.0", "The differential steering actuator.", "This actuator controls the two wheels a differential steering robot. For a\n" "complete description of its usage, refer to the\n" "ci_differential_steering_actuator.h file.\n\n" "REQUIRED XML CONFIGURATION\n\n" " <controllers>\n" " ...\n" " <my_controller ...>\n" " ...\n" " <actuators>\n" " ...\n" " <differential_steering 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. For each wheel, the noise model is as follows:\n\n" "w = ideal wheel actuation (as set in the controller)\n" "b = random bias from a Gaussian distribution\n" "f = random factor from a Gaussian distribution\n" "a = actual actuated value\n\n" "a = f * (w + b)\n\n" "You can configure the average and stddev of both the bias and the factor. This\n" "can be done with the optional attributes: 'bias_avg', 'bias_stddev',\n" "'factor_avg', and 'factor_stddev'. Bias attributes are expressed in m/s, while\n" "factor attributes are dimensionless. If none of these attributed is specified,\n" "no noise is added. If at least one of these attributed is specified, noise is\n" "added and, for the non-specified attributes, the default value of 1 is used for\n" "the '*_avg' attributes, while 0 is used for '*_stddev' attributes. Examples:\n\n" " <controllers>\n" " ...\n" " <my_controller ...>\n" " ...\n" " <actuators>\n" " ...\n" " <!-- Only the stddev of the bias\n" " Noise is on, other attributes are default -->\n" " <differential_steering implementation=\"default\"\n" " bias_stddev=\"2\" />\n" " <!-- Only the stddev of the factor\n" " Noise is on, other attributes are default -->\n" " <differential_steering implementation=\"default\"\n" " factor_stddev=\"4\" />\n" " <!-- All attributes set\n" " Noise is on, specified values are set -->\n" " <differential_steering implementation=\"default\"\n" " bias_avg=\"1\"\n" " bias_stddev=\"2\"\n" " factor_avg=\"3\"\n" " factor_stddev=\"4\" />\n" " ...\n" " </actuators>\n" " ...\n" " </my_controller>\n" " ...\n" " </controllers>\n\n" "The above examples set the same noise for both wheels. If you want to set\n" "different noise parameters for each wheel, append '_left' and '_right' to the\n" "attribute names:\n\n" " <controllers>\n" " ...\n" " <my_controller ...>\n" " ...\n" " <actuators>\n" " ...\n" " <!-- Mix of wheel-specific attributes set\n" " Noise is on, specified values are set -->\n" " <differential_steering implementation=\"default\"\n" " bias_avg_left=\"1\"\n" " bias_stddev_right=\"2\"\n" " factor_avg_left=\"3\"\n" " factor_stddev_right=\"4\" />\n" " ...\n" " </actuators>\n" " ...\n" " </my_controller>\n" " ...\n" " </controllers>\n\n" "Wheel-specific attributes overwrite the values of non-wheel specific attributes.\n" "So, if you set 'bias_avg' = 2 and then 'bias_avg_left' = 3, the left wheel will\n" "use 3 and the right wheel will use 2.\n\n" "Physics-engine-specific attributes that affect this actuator might also be\n" "available. Check the documentation of the physics engine you're using for more\n" "information.", "Usable")
The namespace containing all the ARGoS related code.
ticpp::Element TConfigurationNode
The ARGoS configuration XML node.
virtual void Init(TConfigurationNode &t_node)
Initializes the actuator from the XML configuration tree.
Basic class for an entity that contains other entities.
CEntity & GetComponent(const std::string &str_component)
Returns the component with the passed string label.
const std::string & GetId() const
Returns the id of this entity.
void Enable()
Enables the entity.
The exception that wraps all errors in ARGoS.
static CRNG * CreateRNG(const std::string &str_category)
Creates a new RNG inside the given category.
Real Gaussian(Real f_std_dev, Real f_mean=0.0f)
Returns a random value from a Gaussian distribution.
Real m_fCurrentVelocity[2]
virtual void SetRobot(CComposableEntity &c_entity)
Sets the entity associated to this actuator.
virtual void Reset()
Resets the actuator to the state it had just after Init().
Real m_fNoiseBias[2]
Noise bias for each wheel.
CRandom::CRNG * m_pcRNG
Random number generator.
CDifferentialSteeringDefaultActuator()
Constructor.
virtual void SetLinearVelocity(Real f_left_velocity, Real f_right_velocity)
Sets the linear velocity of the two steering.
virtual void Update()
Updates the state of the entity associated to this actuator.
Real m_fNoiseFactorAvg[2]
Noise factor average (Gaussian model) for each wheel
virtual void Init(TConfigurationNode &t_tree)
Initializes the actuator from the XML configuration tree.
Real m_fNoiseFactorStdDev[2]
Noise factor stddev (Gaussian model) for each wheel
CWheeledEntity * m_pcWheeledEntity
void SetVelocities(Real *pf_velocities)
size_t GetNumWheels() const