An helper class to load sampled data from file. More...
Public Member Functions | |
SampledIRDataLoader (QString filename) | |
Constructor. More... | |
~SampledIRDataLoader () | |
Destructor. More... | |
real | distanceInterval () const |
Returns the distance interval in meters. More... | |
const QString & | filename () const |
Returns the name of the file from which samples are loaded. More... | |
real | finalDistance () const |
Returns the furthest sampled distance in meters. More... | |
unsigned int | getActivation (unsigned int i, real dist, real ang) const |
Returns the activation of the given sensor at the given distance and angle. More... | |
QVector< unsigned int >::const_iterator | getActivation (real dist, real ang) const |
Returns the activation at the given distance and angle. More... | |
real | initialDistance () const |
Returns the initial distance in meters. More... | |
unsigned int | numDistances () const |
Returns the number of different distances from the object. More... | |
unsigned int | numIR () const |
Returns the number of IR sensors as read from the file. More... | |
unsigned int | numSamplingAngles () const |
Returns the number of different sampling angles. More... | |
Detailed Description
An helper class to load sampled data from file.
This class loads a .sam file, the file used by Evorobot to store sensor samplings. The file stores the recorded activations of infrared sensors when the robot is in front of an object at variuos distances and orientations. A .sam file if a text file with the following format:
- The first line contains information about the sampling process. It is made up of 5 integer values separeted by a whitespace: the number of infrared sensors of the robot, the number of different sampling angles (if e.g there are 4 angles it means the sensors are sampled when the robot is at 0°, 90°, 180° and 270° with respect to the object), the number of different distances from the object, the initial distance and the distance interval (i.e. how many millimeters are there between two subsequent positions at different distances). All lengths are in millimiters. - The file then contains a number of blocks equal to the number of different distances from the object. Each block starts with a line "TURN NN" where NN is an index starting from 0. The "TURN" line is followed by a number of lines equal to the number of different sampling angles. Each line is made up of a number of different integer values equal to the number of infrared sensors, separated by whitespaces. Each integer is the activation of the corresponding infrared sensor (range is 0-1023)
All distances are taken from the nearest point of the robot (not from the center), while orientations are relative to the robot forward direction. Angles are in radiants.
- Note
- The angles in the files are taken positive clockwise, while it is more common to take angles positive counterclockwise. This class takes care of the conversion, so positive angles are considered counterclockwise as usual
Constructor & Destructor Documentation
SampledIRDataLoader | ( | QString | filename | ) |
Constructor.
- Parameters
-
filename The name of the file with data to load
Definition at line 1269 of file sensors.cpp.
~SampledIRDataLoader | ( | ) |
Destructor.
Definition at line 1368 of file sensors.cpp.
Member Function Documentation
|
inline |
|
inline |
Returns the name of the file from which samples are loaded.
- Returns
- the name of the file from which samples are loaded
Definition at line 869 of file sensors.h.
Referenced by EpuckSampledProximityIRSensor::EpuckSampledProximityIRSensor(), KheperaSampledLightSensor::KheperaSampledLightSensor(), KheperaSampledProximityIRSensor::KheperaSampledProximityIRSensor(), MarXbotSampledProximityIRSensor::MarXbotSampledProximityIRSensor(), KheperaSampledProximityIRSensor::save(), KheperaSampledLightSensor::save(), EpuckSampledProximityIRSensor::save(), and MarXbotSampledProximityIRSensor::save().
|
inline |
Returns the activation of the given sensor at the given distance and angle.
Sensors activations range from 0 to 1023.
- Parameters
-
i the id of the sensor dist the distance from the object to the robot ang the orientation respect to the object
- Returns
- the activation of the sensor
Definition at line 1373 of file sensors.cpp.
Referenced by KheperaSampledProximityIRSensor::update(), KheperaSampledLightSensor::update(), EpuckSampledProximityIRSensor::update(), and MarXbotSampledProximityIRSensor::update().
Returns the activation at the given distance and angle.
Sensors activations range from 0 to 1023. This function returns an iterator pointing at the first sensor (i.e. the sensor with id 0) for the given distance and angle. You can then move the iterator forward to access the other sensors
- Parameters
-
dist the distance from the object to the robot ang the orientation respect to the object
- Returns
- an iterator to the first sensor for the given distance and angle
Definition at line 1381 of file sensors.cpp.
References farsa::normalizeRad02pi().
|
inline |
|
inline |
|
inline |
Returns the number of IR sensors as read from the file.
- Returns
- the number of IR sensors as read from the file
Definition at line 879 of file sensors.h.
Referenced by EpuckSampledProximityIRSensor::EpuckSampledProximityIRSensor(), KheperaSampledLightSensor::KheperaSampledLightSensor(), KheperaSampledProximityIRSensor::KheperaSampledProximityIRSensor(), and MarXbotSampledProximityIRSensor::MarXbotSampledProximityIRSensor().
|
inline |
The documentation for this class was generated from the following files:
- experiments/include/sensors.h
- experiments/src/sensors.cpp