epucksensors.cpp
39 m_epuckResource = actualResourceNameForMultirobot(ConfigurationHelper::getString(params, prefix + "epuck", m_epuckResource));
40 m_neuronsIteratorResource = actualResourceNameForMultirobot(ConfigurationHelper::getString(params, prefix + "neuronsIterator", m_neuronsIteratorResource));
69 d.describeString("epuck").def("robot").help("the name of the resource associated with the e-puck robot to use (default is \"robot\")");
70 d.describeString("neuronsIterator").def("neuronsIterator").help("the name of the resource associated with the neural network iterator (default is \"neuronsIterator\")");
86 EpuckProximityIRSensor::EpuckProximityIRSensor(ConfigurationParameters& params, QString prefix) :
113 Descriptor d = addTypeDescription(type, "The infrared proximity sensors of the e-puck robot", "The infrared proximity sensors of the e-puck robot. These are the very short range IR sensors all around the base");
126 m_neuronsIterator->setInput(applyNoise(m_robot->proximityIRSensorController()->activation(i), 0.0, 1.0));
135 void EpuckProximityIRSensor::resourceChanged(QString resourceName, ResourceChangeType changeType)
190 Descriptor d = addTypeDescription(type, "The infrared ground sensors of the e-puck robot", "The infrared ground sensors of the e-puck robot. These are the three ground sensors in the frontal part of the robot.");
204 const wVector sensorPosition = m_robot->matrix().transformVector(m_robot->groundIRSensorController()->sensors()[i].getPosition());
245 EpuckLinearCameraSensor::EpuckLinearCameraSensor(ConfigurationParameters& params, QString prefix) :
282 Descriptor d = addTypeDescription(type, "The linear camera sensor of the e-puck robot", "This is a linear camera with configurable aperture");
283 d.describeInt("numReceptors").def(8).limits(1, MaxInteger).help("The number of receptors of the sensor", "Each receptor returns three values, one for each of the three colors (red, green, blue). This means that the size returned by this sensor is 3 * numReceptors (default is 8)");
284 d.describeReal("aperture").def(360.0f).limits(0.0f, 360.0f).help("The aperture of the camera in degrees", "The real e-puck has a camera with an aperture of 36 degrees, but here you can use any value up to 360° (default is 36)");
286 d.describeBool("ignoreWalls").def(false).help("whether to perceive walls or not (default is false)");
318 void EpuckLinearCameraSensor::resourceChanged(QString resourceName, ResourceChangeType changeType)
342 m_camera = new LinearCamera(m_robot, mtr, toRad(m_aperture), m_numReceptors, std::numeric_limits<double>::infinity(), Qt::black);
353 m_neuronsIterator->setGraphicProperties("lr" + QString::number(i % m_numReceptors), 0.0, 1.0, Qt::red);
356 m_neuronsIterator->setGraphicProperties("lg" + QString::number(i % m_numReceptors), 0.0, 1.0, Qt::red);
359 m_neuronsIterator->setGraphicProperties("lb" + QString::number(i % m_numReceptors), 0.0, 1.0, Qt::red);
366 EpuckSampledProximityIRSensor::EpuckSampledProximityIRSensor(ConfigurationParameters& params, QString prefix) :
377 ConfigurationHelper::throwUserConfigError(prefix + "roundSamples", m_roundSamples.filename(), "The file has samples for the wrong number of sensors, expected 8, got " + QString::number(m_roundSamples.numIR()));
380 ConfigurationHelper::throwUserConfigError(prefix + "smallSamples", m_smallSamples.filename(), "The file has samples for the wrong number of sensors, expected 8, got " + QString::number(m_smallSamples.numIR()));
383 ConfigurationHelper::throwUserConfigError(prefix + "wallSamples", m_wallSamples.filename(), "The file has samples for the wrong number of sensors, expected 8, got " + QString::number(m_wallSamples.numIR()));
413 Descriptor d = addTypeDescription(type, "The sampled proximity infrared sensors of the e-puck", "This is the sampled version of the proximity infrared sensors of the e-puck. This sensor only works with objects created using the Arena");
414 d.describeString("roundSamples").def("round.sam").help("The name of the file with samples for big round objects");
415 d.describeString("smallSamples").def("small.sam").help("The name of the file with samples for small round objects");
416 d.describeString("wallSamples").def("wall.sam").help("The name of the file with samples for walls");
433 // Cycling through the list of objects. We first need to get the current position and orientation of the robot
437 // Computing angle and distance. We don't need to remove the robot to which this sensor belongs because
443 if (!obj->computeDistanceAndOrientationFromRobot(*(m_arena->getRobotWrapper(m_epuckResource)), distance, angle)) {
461 //Logger::warning("The sampled infrared sensor only works with Small Cylinders, Big Cylinders, Walls and other Robots");
483 void EpuckSampledProximityIRSensor::resourceChanged(QString resourceName, ResourceChangeType changeType)
void usableResources(QStringList resources)
FARSA_UTIL_TEMPLATE real toRad(real x)
virtual int size()
Returns the number of neurons required by this sensor.
Definition: epucksensors.cpp:130
QString m_epuckResource
The name of the resource associated with the e-puck robot.
Definition: epucksensors.h:110
double applyNoise(double v, double minValue, double maxValue) const
Adds noise to the value.
Definition: neuroninterfaces.cpp:96
virtual void update()
Performs the sensor update. This also modifies the activation of input neurons.
Definition: epucksensors.cpp:289
virtual int size()
Returns the number of neurons required by this sensor.
Definition: epucksensors.cpp:212
QString actualResourceNameForMultirobot(QString resourceName) const
Returns the actual resource name to use.
Definition: neuroninterfaces.cpp:185
EpuckLinearCameraSensor(ConfigurationParameters ¶ms, QString prefix)
Constructor.
Definition: epucksensors.cpp:245
static QString getString(ConfigurationParameters ¶ms, QString paramPath, QString def=QString())
void addUsableResource(QString resource)
virtual int size()
Returns the number of neurons required by this sensor.
Definition: epucksensors.cpp:313
EpuckProximityIRSensor(ConfigurationParameters ¶ms, QString prefix)
Constructor.
Definition: epucksensors.cpp:86
static void describe(QString type)
Generates a description of this class and its parameters.
Definition: epucksensors.cpp:184
const WheeledRobot2DWrapper * getRobotWrapper(QString robotName) const
Returns a pointer to the wrapper of a robot given the robot resource name.
Definition: arena.cpp:217
EpuckSensor(ConfigurationParameters ¶ms, QString prefix)
Constructor.
Definition: epucksensors.cpp:33
virtual bool nextNeuron()=0
Go to the next neuron of the current block.
virtual bool setCurrentBlock(QString blockName)=0
Set the current blocks of neurons to iterate.
const QVector< SingleIR > & sensors() const
virtual void update()
Performs the sensor update. This also modifies the activation of input neurons.
Definition: epucksensors.cpp:419
virtual void shareResourcesWith(ResourcesUser *buddy)
static void describe(QString type)
Describe all the parameter for configuring the Sensor.
Definition: neuroninterfaces.cpp:148
static wMatrix roll(real ang)
virtual void resourceChanged(QString resourceName, ResourceChangeType changeType)
The function called when a resource used here is changed.
Definition: epucksensors.cpp:73
virtual void resourceChanged(QString name, ResourceChangeType changeType)
static void throwUserConfigError(QString paramName, QString paramValue, QString description)
virtual void update()
Performs the sensor update. This also modifies the activation of input neurons.
Definition: epucksensors.cpp:116
const QColor & colorForReceptor(int i) const
Returns the color perceived by the i-th receptor.
Definition: sensors.h:268
const wMatrix & matrix() const
void setEnabled(bool b)
const QVector< PhyObject2DWrapper * > & getObjects() const
Returns the list of 2D objects.
Definition: arena.h:136
unsigned int numIR() const
Returns the number of IR sensors as read from the file.
Definition: sensors.h:879
virtual int size()
Returns the number of neurons required by this sensor.
Definition: epucksensors.cpp:478
static void info(QString msg)
SimulatedIRGroundSensorController * groundIRSensorController()
A class wrapping a PhyObject to add methods suitable for wheeled robots simulations.
Definition: wheeledexperimenthelper.h:51
void resetNeededResourcesCheck()
Resets the check on needed resources so that the next call to checkAllNeededResourcesExist() will per...
Definition: neuroninterfaces.cpp:180
static void describe(QString type)
Generates a description of this class and its parameters.
Definition: epucksensors.cpp:276
bool startObjectParameters(QString groupPath, QString typeName, ParameterSettable *object)
EpuckSampledProximityIRSensor(ConfigurationParameters ¶ms, QString prefix)
Constructor.
Definition: epucksensors.cpp:366
static Descriptor addTypeDescription(QString type, QString shortHelp, QString longHelp=QString(""))
unsigned int getActivation(unsigned int i, real dist, real ang) const
Returns the activation of the given sensor at the given distance and angle.
Definition: sensors.cpp:1373
float real
virtual void save(ConfigurationParameters ¶ms, QString prefix)
Saves current parameters into the given ConfigurationParameters object.
Definition: epucksensors.cpp:175
virtual void setInput(double value)=0
Set the input of the current neuron.
virtual void save(ConfigurationParameters ¶ms, QString prefix)
Saves current parameters into the given ConfigurationParameters object.
Definition: epucksensors.cpp:263
static const int MaxInteger
FARSA_UTIL_TEMPLATE const T min(const T &t1, const U &t2)
virtual void save(ConfigurationParameters ¶ms, QString prefix)
Saves the parameters of the sensor into the ConfigurationParameters object.
Definition: epucksensors.cpp:51
virtual bool computeDistanceAndOrientationFromRobot(const WheeledRobot2DWrapper &robot, double &distance, double &angle) const =0
Computes the distance and orientation of this object respect to the given robot.
virtual void setGraphicProperties(QString label, double minValue, double maxValue, QColor color)=0
Set the graphic properties for the current neuron (in case it will be visualized on a GUI) ...
double activation(int i) const
void save(ConfigurationParameters ¶ms, QString prefix)
Save the parameters into the ConfigurationParameters.
Definition: neuroninterfaces.cpp:134
void checkAllNeededResourcesExist()
Checks whether all resources we need are existing and throws an exception if they aren't...
Definition: neuroninterfaces.cpp:165
wVector transformVector(const wVector &v) const
virtual void save(ConfigurationParameters ¶ms, QString prefix)
Saves current parameters into the given ConfigurationParameters object.
Definition: epucksensors.cpp:98
virtual void update()
Performs the sensor update. This also modifies the activation of input neurons.
Definition: epucksensors.cpp:193
static void describe(QString type)
Generates a description of this class and its parameters.
Definition: epucksensors.cpp:107
EpuckGroundIRSensor(ConfigurationParameters ¶ms, QString prefix)
Constructor.
Definition: epucksensors.cpp:160
SimulatedIRProximitySensorController * proximityIRSensorController()
void createParameter(QString groupPath, QString parameter)
QString m_neuronsIteratorResource
The name of th resource associated with the neural network iterator.
Definition: epucksensors.h:116
const QString & filename() const
Returns the name of the file from which samples are loaded.
Definition: sensors.h:869
static void describe(QString type)
Describes all the parameters for this sensor.
Definition: epucksensors.cpp:62
virtual void save(ConfigurationParameters ¶ms, QString prefix)
Saves current parameters into the given ConfigurationParameters object.
Definition: epucksensors.cpp:395
ResourceChangeType
static void describe(QString type)
Generates a description of this class and its parameters.
Definition: epucksensors.cpp:407