kheperasensors.cpp
40 m_kheperaResource = actualResourceNameForMultirobot(ConfigurationHelper::getString(params, prefix + "khepera", m_kheperaResource));
41 m_neuronsIteratorResource = actualResourceNameForMultirobot(ConfigurationHelper::getString(params, prefix + "neuronsIterator", m_neuronsIteratorResource));
70 d.describeString("khepera").def("robot").help("the name of the resource associated with the khepera robot to use (default is \"robot\")");
71 d.describeString("neuronsIterator").def("neuronsIterator").help("the name of the resource associated with the neural network iterator (default is \"neuronsIterator\")");
87 KheperaProximityIRSensor::KheperaProximityIRSensor(ConfigurationParameters& params, QString prefix) :
114 Descriptor d = addTypeDescription(type, "The infrared proximity sensors of the Khepera robot", "The infrared proximity sensors of the Khepera II robot. These are the very short range IR sensors all around the base");
127 m_neuronsIterator->setInput(applyNoise(m_robot->proximityIRSensorController()->activation(i), 0.0, 1.0));
136 void KheperaProximityIRSensor::resourceChanged(QString resourceName, ResourceChangeType changeType)
162 KheperaSampledProximityIRSensor::KheperaSampledProximityIRSensor(ConfigurationParameters& params, QString prefix) :
167 m_activeSensors(ConfigurationHelper::getBoolVector(params, prefix + "activeSensors", "11111111")),
174 ConfigurationHelper::throwUserConfigError(prefix + "activeSensors", params.getValue(prefix + "activeSensors"), "The parameter must be a list of exactly 8 elements either equal to 1 or to 0 (do not use any space to separate elements, just put them directly one after the other)");
179 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()));
182 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()));
185 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()));
220 Descriptor d = addTypeDescription(type, "The sampled proximity infrared sensors of the Khepera", "This is the sampled version of the proximity infrared sensors of the Khepera. This sensor only works with objects created using the Arena");
221 d.describeString("activeSensors").def("11111111").help("Which IR sensors of the robot are actually enabled", "This is a string of exactly 8 elements. Each element can be either \"0\" or \"1\" to respectively disable/enable the corresponding proximity IR sensor. The first sensor is the one on the left side of the robot and the others follow counterclockwise (i.e. left, back, right, front)");
222 d.describeString("roundSamples").def("round.sam").help("The name of the file with samples for big round objects");
223 d.describeString("smallSamples").def("small.sam").help("The name of the file with samples for small round objects");
224 d.describeString("wallSamples").def("wall.sam").help("The name of the file with samples for walls");
241 // Cycling through the list of objects. We first need to get the current position and orientation of the robot
245 // Computing angle and distance. We don't need to remove the robot to which this sensor belongs because
251 if (!obj->computeDistanceAndOrientationFromRobot(*(m_arena->getRobotWrapper(m_kheperaResource)), distance, angle)) {
271 //Logger::warning("The sampled infrared sensor only works with Small Cylinders, Big Cylinders, Walls and other Robots");
296 void KheperaSampledProximityIRSensor::resourceChanged(QString resourceName, ResourceChangeType changeType)
329 KheperaSampledLightSensor::KheperaSampledLightSensor(ConfigurationParameters& params, QString prefix) :
334 m_activeSensors(ConfigurationHelper::getBoolVector(params, prefix + "activeSensors", "11111111")),
339 ConfigurationHelper::throwUserConfigError(prefix + "activeSensors", params.getValue(prefix + "activeSensors"), "The parameter must be a list of exactly 8 elements either equal to 1 or to 0 (do not use any space to separate elements, just put them directly one after the other)");
344 ConfigurationHelper::throwUserConfigError(prefix + "lightSamples", m_lightSamples.filename(), "The file has samples for the wrong number of sensors, expected 8, got " + QString::number(m_lightSamples.numIR()));
377 Descriptor d = addTypeDescription(type, "The sampled light sensors of the Khepera", "This is the sampled version of the light sensors of the Khepera. This sensor only works with objects created using the Arena");
378 d.describeString("activeSensors").def("11111111").help("Which light sensors of the robot are actually enabled", "This is a string of exactly 8 elements. Each element can be either \"0\" or \"1\" to respectively disable/enable the corresponding light sensor. The first sensor is the one on the left side of the robot and the others follow counterclockwise (i.e. left, back, right, front)");
379 d.describeString("lightSamples").def("light.sam").help("The name of the file with samples for light sensors");
396 // Cycling through the list of objects. We first need to get the current position and orientation of the robot
410 if (!obj->computeDistanceAndOrientationFromRobot(*(m_arena->getRobotWrapper(m_kheperaResource)), distance, angle)) {
438 void KheperaSampledLightSensor::resourceChanged(QString resourceName, ResourceChangeType changeType)
500 Descriptor d = addTypeDescription(type, "The ground sensor of the khepera robot", "The ground sensors of the khepera robot. It is an infrared sensor that can be mounted on the bottom part of the robot.");
588 KheperaWheelSpeedsSensor::KheperaWheelSpeedsSensor(ConfigurationParameters& params, QString prefix) :
595 ConfigurationHelper::throwUserConfigError(prefix + "mode", params.getValue(prefix + "mode"), "The parameter must be one of \"Absolute\" or \"Delta\" (case insensitive)");
620 Descriptor d = addTypeDescription(type, "The sensor reporting the actual velocity of the wheels of the Khepera", "This sensor have three modalities, see the mode parameter");
621 d.describeEnum("mode").def("Absolute").values(QStringList() << "Absolute" << "Delta").help("The modality of the sensor", "The possible modalities are: \"Absolute\" meaning that the senors returns the current velocity of the wheels (scaled between -1 and 1) and \"Delta\", meaning that the sensor returns the absolute value of the difference between the desired velocity and the current velocity. The default value is \"Absolute\"");
679 void KheperaWheelSpeedsSensor::resourceChanged(QString resourceName, ResourceChangeType changeType)
virtual void save(ConfigurationParameters ¶ms, QString prefix)
Saves current parameters into the given ConfigurationParameters object.
Definition: kheperasensors.cpp:197
void usableResources(QStringList resources)
FARSA_UTIL_TEMPLATE float linearMap(float x, float min=-10, float max=10, float outMin=-1, float outMax=1)
double applyNoise(double v, double minValue, double maxValue) const
Adds noise to the value.
Definition: neuroninterfaces.cpp:96
static void describe(QString type)
Generates a description of this class and its parameters.
Definition: kheperasensors.cpp:214
QString m_neuronsIteratorResource
The name of th resource associated with the neural network iterator.
Definition: kheperasensors.h:116
QString actualResourceNameForMultirobot(QString resourceName) const
Returns the actual resource name to use.
Definition: neuroninterfaces.cpp:185
static QString getString(ConfigurationParameters ¶ms, QString paramPath, QString def=QString())
void addUsableResource(QString resource)
virtual void save(ConfigurationParameters ¶ms, QString prefix)
Saves current parameters into the given ConfigurationParameters object.
Definition: kheperasensors.cpp:99
SimulatedIRProximitySensorController * proximityIRSensorController()
const WheeledRobot2DWrapper * getRobotWrapper(QString robotName) const
Returns a pointer to the wrapper of a robot given the robot resource name.
Definition: arena.cpp:217
virtual void update()
Performs the sensor update. This also modifies the activation of input neurons.
Definition: kheperasensors.cpp:382
KheperaGroundSensor(ConfigurationParameters ¶ms, QString prefix)
Constructor.
Definition: kheperasensors.cpp:468
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.
static void describe(QString type)
Generates a description of this class and its parameters.
Definition: kheperasensors.cpp:108
WheelMotorController * wheelsController()
static void describe(QString type)
Describe all the parameter for configuring the Sensor.
Definition: neuroninterfaces.cpp:148
virtual void resourceChanged(QString name, ResourceChangeType changeType)
static void throwUserConfigError(QString paramName, QString paramValue, QString description)
static void describe(QString type)
Generates a description of this class and its parameters.
Definition: kheperasensors.cpp:371
virtual int size()
Returns the number of neurons required by this sensor.
Definition: kheperasensors.cpp:291
void setEnabled(bool b)
const QVector< PhyObject2DWrapper * > & getObjects() const
Returns the list of 2D objects.
Definition: arena.h:136
static QString modeToString(Mode mode)
Returns the string representation of the given modality.
Definition: kheperasensors.cpp:558
unsigned int numIR() const
Returns the number of IR sensors as read from the file.
Definition: sensors.h:879
KheperaSensor(ConfigurationParameters ¶ms, QString prefix)
Constructor.
Definition: kheperasensors.cpp:34
void getSpeeds(QVector< double > &speeds) const
static Mode stringToMode(QString mode)
Converts the given string to a modality.
Definition: kheperasensors.cpp:573
void FARSA_UTIL_TEMPLATE throwUserRuntimeError(QString reason)
void getSpeedLimits(QVector< double > &minSpeeds, QVector< double > &maxSpeeds) const
virtual void update()
Performs the sensor update. This also modifies the activation of input neurons.
Definition: kheperasensors.cpp:227
static void info(QString msg)
QString m_kheperaResource
The name of the resource associated with the e-puck robot.
Definition: kheperasensors.h:110
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
virtual int size()
Returns the number of neurons required by this sensor.
Definition: kheperasensors.cpp:131
virtual void update()
Performs the sensor update. This also modifies the activation of input neurons.
Definition: kheperasensors.cpp:503
static void describe(QString type)
Generates a description of this class and its parameters.
Definition: kheperasensors.cpp:494
bool startObjectParameters(QString groupPath, QString typeName, ParameterSettable *object)
void getDesiredSpeeds(QVector< double > &speeds) const
virtual void update()
Performs the sensor update. This also modifies the activation of input neurons.
Definition: kheperasensors.cpp:624
static Descriptor addTypeDescription(QString type, QString shortHelp, QString longHelp=QString(""))
QString getValue(QString path, bool alsoMatchParents=false) const
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 update()
Performs the sensor update. This also modifies the activation of input neurons.
Definition: kheperasensors.cpp:117
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: kheperasensors.cpp:356
KheperaProximityIRSensor(ConfigurationParameters ¶ms, QString prefix)
Constructor.
Definition: kheperasensors.cpp:87
KheperaWheelSpeedsSensor(ConfigurationParameters ¶ms, QString prefix)
Constructor.
Definition: kheperasensors.cpp:588
virtual int size()
Returns the number of neurons required by this sensor.
Definition: kheperasensors.cpp:674
static void describe(QString type)
Describes all the parameters for this sensor.
Definition: kheperasensors.cpp:63
FARSA_UTIL_TEMPLATE const T min(const T &t1, const U &t2)
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
virtual void save(ConfigurationParameters ¶ms, QString prefix)
Saves current parameters into the given ConfigurationParameters object.
Definition: kheperasensors.cpp:484
virtual int size()
Returns the number of neurons required by this sensor.
Definition: kheperasensors.cpp:433
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
static void describe(QString type)
Generates a description of this class and its parameters.
Definition: kheperasensors.cpp:614
KheperaSampledProximityIRSensor(ConfigurationParameters ¶ms, QString prefix)
Constructor.
Definition: kheperasensors.cpp:162
virtual int size()
Returns the number of neurons required by this sensor.
Definition: kheperasensors.cpp:523
virtual void save(ConfigurationParameters ¶ms, QString prefix)
Saves current parameters into the given ConfigurationParameters object.
Definition: kheperasensors.cpp:604
void createParameter(QString groupPath, QString parameter)
const QString & filename() const
Returns the name of the file from which samples are loaded.
Definition: sensors.h:869
virtual void save(ConfigurationParameters ¶ms, QString prefix)
Saves the parameters of the sensor into the ConfigurationParameters object.
Definition: kheperasensors.cpp:52
ResourceChangeType
KheperaSampledLightSensor(ConfigurationParameters ¶ms, QString prefix)
Constructor.
Definition: kheperasensors.cpp:329
virtual void resourceChanged(QString resourceName, ResourceChangeType changeType)
The function called when a resource used here is changed.
Definition: kheperasensors.cpp:74