ARGoS
3
A parallel, multi-engine simulator for swarm robotics
|
Go to the documentation of this file.
8 #include <argos3/core/simulator/simulator.h>
9 #include <argos3/core/simulator/entity/composable_entity.h>
10 #include <argos3/core/simulator/entity/controllable_entity.h>
11 #include <argos3/plugins/simulator/entities/rab_equipped_entity.h>
12 #include <argos3/plugins/simulator/media/rab_medium.h>
25 m_pcRangeAndBearingEquippedEntity(NULL),
26 m_fDistanceNoiseStdDev(0.0f),
27 m_fPacketDropProb(0.0f),
29 m_cSpace(
CSimulator::GetInstance().GetSpace()),
39 m_pcRangeAndBearingEquippedEntity->
Enable();
56 if((m_fPacketDropProb > 0.0f) ||
57 (m_fDistanceNoiseStdDev > 0.0f)) {
61 std::string strMedium;
65 m_pcRangeAndBearingMedium->
AddEntity(*m_pcRangeAndBearingEquippedEntity);
87 it != setRABs.
end(); ++it) {
90 !(m_fPacketDropProb > 0.0f &&
103 cVectorRobotToMessage -= m_pcRangeAndBearingEquippedEntity->
GetPosition();
105 if(m_pcRNG && m_fDistanceNoiseStdDev > 0.0f) {
107 m_pcRNG->
Gaussian(m_fDistanceNoiseStdDev),
123 sPacket.
Range *= 100.0f;
156 m_pcRangeAndBearingMedium->
RemoveEntity(*m_pcRangeAndBearingEquippedEntity);
163 "range_and_bearing",
"medium",
164 "Carlo Pinciroli [ilpincy@gmail.com]",
166 "The range-and-bearing sensor.",
167 "This sensor allows robots to perform situated communication, i.e., a form of\n"
168 "wireless communication whereby the receiver also knows the location of the\n"
169 "sender with respect to its own frame of reference.\n"
170 "This implementation of the range-and-bearing sensor is associated to the\n"
171 "range-and-bearing medium. To be able to use this sensor, you must add a\n"
172 "range-and-bearing medium to the <media> section.\n"
173 "This sensor allows a robot to receive messages. To send messages, you need the\n"
174 "range-and-bearing actuator.\n"
175 "To use this sensor, in controllers you must include the\n"
176 "ci_range_and_bearing_sensor.h header.\n\n"
177 "REQUIRED XML CONFIGURATION\n\n"
180 " <my_controller ...>\n"
184 " <range_and_bearing implementation=\"medium\"\n"
185 " medium=\"rab\" />\n"
189 " </my_controller>\n"
191 " </controllers>\n\n"
192 "The 'medium' attribute must be set to the id of the range-and-bearing medium\n"
193 "declared in the <media> section.\n\n"
194 "OPTIONAL XML CONFIGURATION\n\n"
195 "It is possible to draw the rays shot by the range-and-bearing sensor in the\n"
196 "OpenGL visualization. This can be useful for sensor debugging but also to\n"
197 "understand what's wrong in your controller. In OpenGL, the rays are drawn in\n"
198 "cyan when two robots are communicating.\n"
199 "To turn this functionality on, add the attribute \"show_rays\" as in this\n"
203 " <my_controller ...>\n"
207 " <range_and_bearing implementation=\"medium\"\n"
209 " show_rays=\"true\" />\n"
213 " </my_controller>\n"
215 " </controllers>\n\n"
216 "It is possible to add noise to the readings, thus matching the characteristics\n"
217 "of a real robot better. Noise is implemented as a random vector added to the\n"
218 "vector joining two communicating robots. For the random vector, the inclination\n"
219 "and azimuth are chosen uniformly in the range [0:PI] and [0:2PI], respectively,\n"
220 "and the length is drawn from a Gaussian distribution. The standard deviation of\n"
221 "the Gaussian distribution is expressed in meters and set by the user through\n"
222 "the attribute 'noise_std_dev' as shown in this example:\n\n"
225 " <my_controller ...>\n"
229 " <range_and_bearing implementation=\"medium\"\n"
231 " noise_std_dev=\"0.1\" />\n"
235 " </my_controller>\n"
237 " </controllers>\n\n"
238 "In addition, it is possible to specify the probability that a packet gets lost\n"
239 "even though the robot should have received it (i.e., packet dropping). To set\n"
240 "this probability, use the attribute 'packet_drop_prob' as shown in the example:\n"
243 " <my_controller ...>\n"
247 " <range_and_bearing implementation=\"medium\"\n"
249 " packet_drop_prob=\"0.1\" />\n"
253 " </my_controller>\n"
255 " </controllers>\n" ,
virtual void SetRobot(CComposableEntity &c_entity)
Sets the entity associated to this sensor.
Real Gaussian(Real f_std_dev, Real f_mean=0.0f)
Returns a random value from a Gaussian distribution.
#define ARGOS_PI
To be used when initializing static variables.
CRadians Uniform(const CRange< CRadians > &c_range)
Returns a random value from a uniform distribution.
static CSimulator & GetInstance()
Returns the instance to the CSimulator class.
The namespace containing all the ARGoS related code.
Basic class for an entity that contains other entities.
The exception that wraps all errors in ARGoS.
static const CRadians PI_OVER_TWO
Set to PI / 2.
CEntity & GetComponent(const std::string &str_component)
Returns the component with the passed string label.
CQuaternion Inverse() const
CRadians & SignedNormalize()
Normalizes the value in the range [-PI:PI].
virtual void Reset()
Resets the sensor to the state it had just after Init().
void ToSphericalCoords(Real &f_radius, CRadians &c_inclination, CRadians &c_azimuth) const
Returns the vector contents as spherical coordinates.
ticpp::Element TConfigurationNode
The ARGoS configuration XML node.
bool Bernoulli(Real f_true=0.5)
Returns a random value from a Bernoulli distribution.
void AddCheckedRay(bool b_obstructed, const CRay3 &c_ray)
Adds a ray to the list of checked rays.
iterator end() const
Returns an invalid iterator.
CRange< CRadians > INCLINATION_RANGE(CRadians(0), CRadians(ARGOS_PI))
const CVector3 & GetPosition() const
#define THROW_ARGOSEXCEPTION_NESTED(message, nested)
This macro throws an ARGoS exception with the passed message and nesting the passed exception.
CRangeAndBearingMediumSensor()
static const CRange< CRadians > UNSIGNED_RANGE
The unsigned normalization range [0:TWO_PI].
virtual void Destroy()
Destroys the sensor.
REGISTER_SENSOR(CEyeBotLightRotZOnlySensor, "eyebot_light", "rot_z_only", "Carlo Pinciroli [ilpincy@gmail.com]", "1.0", "The eye-bot light sensor (optimized for 2D).", "This sensor accesses a set of light sensors. The sensors all return a value\n" "between 0 and 1, where 0 means nothing within range and 1 means the perceived\n" "light saturates the sensor. Values between 0 and 1 depend on the distance of\n" "the perceived light. Each reading R is calculated with R=(I/x)^2, where x is the\n" "distance between a sensor and the light, and I is the reference intensity of the\n" "perceived light. The reference intensity corresponds to the minimum distance at\n" "which the light saturates a sensor. The reference intensity depends on the\n" "individual light, and it is set with the \"intensity\" attribute of the light\n" "entity. In case multiple lights are present in the environment, each sensor\n" "reading is calculated as the sum of the individual readings due to each light.\n" "In other words, light wave interference is not taken into account. In\n" "controllers, you must include the ci_light_sensor.h header.\n\n" "REQUIRED XML CONFIGURATION\n\n" " <controllers>\n" " ...\n" " <my_controller ...>\n" " ...\n" " <sensors>\n" " ...\n" " <eyebot_light implementation=\"rot_z_only\" />\n" " ...\n" " </sensors>\n" " ...\n" " </my_controller>\n" " ...\n" " </controllers>\n\n" "OPTIONAL XML CONFIGURATION\n\n" "It is possible to draw the rays shot by the light sensor in the OpenGL\n" "visualization. This can be useful for sensor debugging but also to understand\n" "what's wrong in your controller. In OpenGL, the rays are drawn in cyan when\n" "they are not obstructed and in purple when they are. In case a ray is\n" "obstructed, a black dot is drawn where the intersection occurred.\n" "To turn this functionality on, add the attribute \"show_rays\" as in this\n" "example:\n\n" " <controllers>\n" " ...\n" " <my_controller ...>\n" " ...\n" " <sensors>\n" " ...\n" " <eyebot_light implementation=\"rot_z_only\"\n" " show_rays=\"true\" />\n" " ...\n" " </sensors>\n" " ...\n" " </my_controller>\n" " ...\n" " </controllers>\n\n" "It is possible to add uniform noise to the sensors, thus matching the\n" "characteristics of a real robot better. This can be done with the attribute\n" "\"noise_level\", whose allowed range is in [-1,1] and is added to the calculated\n" "reading. The final sensor reading is always normalized in the [0-1] range.\n\n" " <controllers>\n" " ...\n" " <my_controller ...>\n" " ...\n" " <sensors>\n" " ...\n" " <eyebot_light implementation=\"rot_z_only\"\n" " noise_level=\"0.1\" />\n" " ...\n" " </sensors>\n" " ...\n" " </my_controller>\n" " ...\n" " </controllers>\n\n" "OPTIONAL XML CONFIGURATION\n\n" "None.\n", "Usable")
const CQuaternion & GetOrientation() const
CRadians HorizontalBearing
const CSet< CRABEquippedEntity * > & GetRABsCommunicatingWith(CRABEquippedEntity &c_entity) const
Returns an immutable vector of RAB entities that can communicated with the given entity.
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.
void AddEntity(CRABEquippedEntity &c_entity)
Adds the specified entity to the list of managed entities.
virtual void Init(TConfigurationNode &t_tree)
Initializes the sensor from the XML configuration tree.
void GetNodeAttribute(TConfigurationNode &t_node, const std::string &str_attribute, T &t_buffer)
Returns the value of a node's attribute.
CRadians VerticalBearing
The vertical bearing is defined as the angle between the local robot XY plane and the message source ...
iterator begin() const
Returns an iterator to the first element.
static CRNG * CreateRNG(const std::string &str_category)
Creates a new RNG inside the given category.
CVector3 & Rotate(const CQuaternion &c_quaternion)
Rotates this vector by the given quaternion.
An entity that contains a pointer to the user-defined controller.
virtual void Update()
Updates the state of the entity associated to this sensor.
virtual void Init(TConfigurationNode &t_node)
Initializes the sensor from the XML configuration tree.
void RemoveEntity(CRABEquippedEntity &c_entity)
Removes the specified entity from the list of managed entities.
Defines a very simple double-linked list that stores unique elements.
T & GetMedium(const std::string &str_id)
Returns a reference to a medium.