7 #include <argos3/core/simulator/simulator.h>
8 #include <argos3/core/simulator/entity/composable_entity.h>
9 #include <argos3/core/simulator/entity/embodied_entity.h>
10 #include <argos3/core/simulator/entity/floor_entity.h>
11 #include <argos3/plugins/simulator/entities/ground_sensor_equipped_entity.h>
20 static CRange<Real> UNIT(0.0f, 1.0f);
26 m_pcEmbodiedEntity(nullptr),
27 m_pcFloorEntity(nullptr),
28 m_pcGroundSensorEntity(nullptr),
31 m_cSpace(
CSimulator::GetInstance().GetSpace()) {}
50 Real fNoiseLevel = 0.0f;
52 if(fNoiseLevel < 0.0f) {
55 else if(fNoiseLevel > 0.0f) {
95 cSensorPos += cCenterPos;
130 "ground",
"rot_z_only",
131 "Carlo Pinciroli [ilpincy@gmail.com]",
133 "A generic ground sensor (optimized for 2D).",
135 "This sensor accesses a set of ground sensors. The sensors all return a value\n"
136 "between 0 and 1, where 0 means black and 1 means white. Depending on the type\n"
137 "of ground sensor, readings can either take 0 or 1 as value (bw sensors) or a\n"
138 "value in between (grayscale sensors). In controllers, you must include the\n"
139 "ci_ground_sensor.h header.\n\n"
141 "This sensor is enabled by default.\n\n"
143 "REQUIRED XML CONFIGURATION\n\n"
146 " <my_controller ...>\n"
150 " <ground implementation=\"rot_z_only\" />\n"
154 " </my_controller>\n"
156 " </controllers>\n\n"
158 "OPTIONAL XML CONFIGURATION\n\n"
160 "It is possible to add uniform noise to the sensors, thus matching the\n"
161 "characteristics of a real robot better. This can be done with the attribute\n"
162 "\"noise_level\", whose allowed range is in [-1,1] and is added to the calculated\n"
163 "reading. The final sensor reading is always normalized in the [0-1] range.\n\n"
166 " <my_controller ...>\n"
170 " <ground implementation=\"rot_z_only\"\n"
171 " noise_level=\"0.1\" />\n"
175 " </my_controller>\n"
177 " </controllers>\n\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.
unsigned int UInt32
32-bit unsigned integer.
float Real
Collects all ARGoS code.
The namespace containing all the ARGoS related code.
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.
REGISTER_SENSOR(CEPuckProximityDefaultSensor, "epuck_proximity", "default", "Danesh Tarapore [daneshtarapore@gmail.com]", "1.0", "The E-Puck proximity sensor.", "This sensor accesses the epuck proximity sensor. For a complete description\n" "of its usage, refer to the ci_epuck_proximity_sensor.h interface. For the XML\n" "configuration, refer to the default proximity sensor.\n", "Usable")
ticpp::Element TConfigurationNode
The ARGoS configuration XML node.
virtual void Enable()
Enables updating of sensor information in the event loop.
virtual void Init(TConfigurationNode &t_node)
Initializes the sensor 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.
This entity is a link to a body in the physics engine.
CColor GetColorAtPoint(Real f_x, Real f_y)
Returns the color at the given point.
CQuaternion Orientation
The orientation of the anchor wrt the global coordinate system.
CVector3 Position
The position of the anchor wrt the global coordinate system.
CFloorEntity & GetFloorEntity()
Returns the floor entity.
The exception that wraps all errors in ARGoS.
Real ToGrayScale() const
Returns the color in grayscale.
It defines the basic type CRadians, used to store an angle value in radians.
void ToEulerAngles(CRadians &c_z_angle, CRadians &c_y_angle, CRadians &c_x_angle) const
void TruncValue(T &t_value) const
void Set(const T &t_min, const T &t_max)
static CRNG * CreateRNG(const std::string &str_category)
Creates a new RNG inside the given category.
CRadians Uniform(const CRange< CRadians > &c_range)
Returns a random value from a uniform distribution.
Real GetY() const
Returns the y coordinate of this vector.
CVector2 & Rotate(const CRadians &c_angle)
Rotates this vector by the wanted angle.
void Set(Real f_x, Real f_y)
Sets the vector contents from Cartesian coordinates.
Real GetX() const
Returns the x coordinate of this vector.
Real GetX() const
Returns the x coordinate of this vector.
Real GetY() const
Returns the y coordinate of this vector.
std::vector< Real > m_tReadings
const std::vector< Real > & GetReadings() const
CRandom::CRNG * m_pcRNG
Random number generator.
virtual void SetRobot(CComposableEntity &c_entity)
Sets the entity associated to this sensor.
CEmbodiedEntity * m_pcEmbodiedEntity
Reference to embodied entity associated to this sensor.
virtual void Reset()
Resets the sensor to the state it had just after Init().
CGroundSensorEquippedEntity * m_pcGroundSensorEntity
Reference to ground sensor equipped entity associated to this sensor.
virtual void Update()
Updates the state of the entity associated to this sensor, if the sensor is currently enabled.
virtual void Init(TConfigurationNode &t_tree)
Initializes the sensor from the XML configuration tree.
CFloorEntity * m_pcFloorEntity
Reference to floor entity.
bool m_bAddNoise
Whether to add noise or not.
CSpace & m_cSpace
Reference to the space.
CRange< Real > m_cNoiseRange
Noise range.
size_t GetNumSensors() const
SSensor & GetSensor(size_t un_idx)