SampledIRDataLoader Class Reference

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

Definition at line 849 of file sensors.h.

Constructor & Destructor Documentation

SampledIRDataLoader ( QString  filename)

Constructor.

Parameters
filenameThe name of the file with data to load

Definition at line 1269 of file sensors.cpp.

Destructor.

Definition at line 1368 of file sensors.cpp.

Member Function Documentation

real distanceInterval ( ) const
inline

Returns the distance interval in meters.

Returns
the distance interval in meters

Definition at line 919 of file sensors.h.

real finalDistance ( ) const
inline

Returns the furthest sampled distance in meters.

Returns
the furthest sampled distance in meters

Definition at line 929 of file sensors.h.

unsigned int getActivation ( unsigned int  i,
real  dist,
real  ang 
) const

Returns the activation of the given sensor at the given distance and angle.

Sensors activations range from 0 to 1023.

Parameters
ithe id of the sensor
distthe distance from the object to the robot
angthe 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().

QVector< unsigned int >::const_iterator getActivation ( real  dist,
real  ang 
) const

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
distthe distance from the object to the robot
angthe 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().

real initialDistance ( ) const
inline

Returns the initial distance in meters.

Returns
the initial distance in meters

Definition at line 909 of file sensors.h.

unsigned int numDistances ( ) const
inline

Returns the number of different distances from the object.

Returns
the number of different distances from the object

Definition at line 899 of file sensors.h.

unsigned int numIR ( ) const
inline
unsigned int numSamplingAngles ( ) const
inline

Returns the number of different sampling angles.

Returns
the number of different sampling angles

Definition at line 889 of file sensors.h.


The documentation for this class was generated from the following files: