eyebot_proximity_default_sensor.cpp
Go to the documentation of this file.
1 
7 #include <argos3/core/simulator/entity/embodied_entity.h>
8 #include <argos3/core/simulator/entity/composable_entity.h>
9 #include <argos3/core/simulator/simulator.h>
10 
12 
13 namespace argos {
14 
15  /****************************************/
16  /****************************************/
17 
19 
20  public:
21 
22  virtual Real CalculateReading(Real f_distance) {
23  if(f_distance < 0.009889556) {
24  return 1.0;
25  }
26  else {
27  return 0.0100527 / (f_distance + 0.000163144);
28  }
29  }
30 
31  };
32 
33  /****************************************/
34  /****************************************/
35 
37  m_pcProximityImpl(new CProximitySensorImpl()) {}
38 
39  /****************************************/
40  /****************************************/
41 
43  delete m_pcProximityImpl;
44  }
45 
46  /****************************************/
47  /****************************************/
48 
50  try {
51  m_pcProximityImpl->SetRobot(c_entity);
52  }
53  catch(CARGoSException& ex) {
54  THROW_ARGOSEXCEPTION_NESTED("Can't set robot for the eye-bot proximity default sensor", ex);
55  }
56  }
57 
58  /****************************************/
59  /****************************************/
60 
62  m_pcProximityImpl->Init(t_tree);
63  }
64 
65  /****************************************/
66  /****************************************/
67 
69  m_pcProximityImpl->Update();
70  for(size_t i = 0; i < 24; ++i) {
71  m_tReadings[i].Value = m_pcProximityImpl->GetReadings()[i];
72  }
73  }
74 
75  /****************************************/
76  /****************************************/
77 
79  m_pcProximityImpl->Reset();
80  }
81 
82  /****************************************/
83  /****************************************/
84 
86  "eyebot_proximity", "default",
87  "Carlo Pinciroli [ilpincy@gmail.com]",
88  "1.0",
89  "The eye-bot proximity sensor.",
90  "This sensor accesses the eye-bot proximity sensor. For a complete description\n"
91  "of its usage, refer to the ci_eyebot_proximity_sensor.h interface. For the XML\n"
92  "configuration, refer to the default proximity sensor.\n",
93  "Usable"
94  );
95 
96 }
virtual Real CalculateReading(Real f_distance)
Calculates the proximity reading when the closest occluding object is located as the given distance...
virtual void Init(TConfigurationNode &t_tree)
Initializes the sensor from the XML configuration tree.
float Real
Collects all ARGoS code.
Definition: datatypes.h:39
ticpp::Element TConfigurationNode
The ARGoS configuration XML node.
virtual void Reset()
Resets the sensor to the state it had just after Init().
#define THROW_ARGOSEXCEPTION_NESTED(message, nested)
This macro throws an ARGoS exception with the passed message and nesting the passed exception...
virtual void Reset()
Resets the sensor to the state it had just after Init().
virtual void SetRobot(CComposableEntity &c_entity)
Sets the entity associated to this sensor.
const std::vector< Real > & GetReadings() const
virtual void Init(TConfigurationNode &t_tree)
Initializes the sensor from the XML configuration tree.
Basic class for an entity that contains other entities.
virtual void Update()
Updates the state of the entity associated to this sensor.
The exception that wraps all errors in ARGoS.
virtual void SetRobot(CComposableEntity &c_entity)
Sets the entity associated to this sensor.
The namespace containing all the ARGoS related code.
Definition: ci_actuator.h:12
virtual void Update()
Updates the state of the entity associated to this 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")