icubsensors.cpp
41 icubResource = actualResourceNameForMultirobot(ConfigurationHelper::getString(params, prefix + "icub", icubResource));
42 neuronsIteratorResource = actualResourceNameForMultirobot(ConfigurationHelper::getString(params, prefix + "neuronsIterator", neuronsIteratorResource));
71 d.describeString("icub").def("robot").help("the name of the resource associated with the iCub robot to use (default is \"robot\")");
72 d.describeString("neuronsIterator").def("neuronsIterator").help("the name of the resource associated with the neural network iterator (default is \"neuronsIterator\")");
108 Descriptor d = addTypeDescription( type, "Sensor for reading the joint angles of an iCub arm" );
109 d.describeEnum( "arm" ).def( "right" ).values( QStringList()<<"right"<<"left" ).props( IsMandatory ).help( "The arm from which the joint angles are read" );
141 void iCubArmJointsSensor::resourceChanged(QString resourceName, ResourceChangeType changeType) {
438 iCubPalmTargetDistSensor::iCubPalmTargetDistSensor(ConfigurationParameters ¶ms, QString prefix) :
451 Logger::warning( QString("iCubPalmTargetDistSensor %1 - bbMin and/or bbMax parameters are not well specified; they will be ignored").arg(name()) );
462 Logger::warning( QString("iCubPalmTargetDistSensor %1 - palmOffset parameter is not well specified; It will be ignored").arg(name()) );
481 params.createParameter( prefix, "bbMin", QString("%1 %2 %3").arg(bbMin[0]).arg(bbMin[1]).arg(bbMin[2]) );
482 params.createParameter( prefix, "bbMax", QString("%1 %2 %3").arg(bbMax[0]).arg(bbMax[1]).arg(bbMax[2]) );
488 Descriptor d = addTypeDescription( type, "Sensor for reading the distance between right or left palm and a specified target" );
489 d.describeEnum( "palm" ).def( "right" ).values( QStringList()<<"right"<<"left" ).props( IsMandatory ).help( "The palm from which the distance to the target is computed" );
490 d.describeString( "target" ).def( "target" ).help( "The name of the resource associated with the target object" );
491 d.describeReal( "bbMin" ).props( IsList ).help( "The minimum 3D point used for linearize the object position into [-1,1]" );
492 d.describeReal( "bbMax" ).props( IsList ).help( "The maximum 3D point used for linearize the object position into [-1,1]" );
493 d.describeReal( "palmOffset" ).props( IsList ).help( "The offset respect to the palm on which the distance will be computed" );
539 void iCubPalmTargetDistSensor::resourceChanged(QString resourceName, ResourceChangeType changeType) {
579 usableResources( QStringList() << icubResource << "world" << "objects" << neuronsIteratorResource );
584 Descriptor d = addTypeDescription( type, "Sensor for reading right or left palm touch sensor" );
585 d.describeEnum( "palm" ).def( "right" ).values( QStringList()<<"right"<<"left" ).props( IsMandatory ).help( "The palm from which the touch sensor is read" );
628 void iCubPalmTouchSensor::resourceChanged(QString resourceName, ResourceChangeType changeType) {
676 usableResources( QStringList() << icubResource << "world" << "objects" << neuronsIteratorResource );
689 params.createParameter(prefix, "checkAllObjects", m_checkAllObjects ? QString("true") : QString("false"));
695 Descriptor d = addTypeDescription(type, "Hand touch sensor", "The touch sensor of the iCub hand. There are six sensors: one on the palm and one for each figertip");
696 d.describeEnum("hand").def("right").values(QStringList() << "right" << "left").props(IsMandatory).help("The hand to use", "The hand whose distance from the object should be returned. Choose between \"right\" and \"left\"");
697 d.describeBool("checkAllObjects").def(true).help("Wheter to check collisions with all objects or not", "If true, the collision of the hand touch sensors with all objects in the world is checked, otherwise only those in the objects vector are taken into account. Note that if the iCub is kinematic, only collisions with objects in the objects vector are checked regardless of the value of this parameter.");
821 Descriptor d = addTypeDescription( type, "Sensor for reading right or left palm touch sensor" );
854 void iCubTorsoJointsSensor::resourceChanged(QString resourceName, ResourceChangeType changeType) {
940 void iCubHeadJointsSensor::resourceChanged(QString resourceName, ResourceChangeType changeType) {
967 iCubPCHeadJointsSensor::iCubPCHeadJointsSensor(ConfigurationParameters ¶ms, QString prefix) :
1006 d.describeBool("disableNeckPitch").def(false).help("Disables proprioception of the #0 joint of the head: Neck Pitch");
1007 d.describeBool("disableNeckRoll").def(false).help("Disables proprioception of the #1 joint of the head: Neck Roll");
1008 d.describeBool("disableNeckYaw").def(false).help("Disables proprioception of the #2 joint of the head: Neck Yaw");
1009 d.describeBool("disableEyesTilt").def(false).help("Disables proprioception of the #3 joint of the head: Eyes tilt");
1010 d.describeBool("disableEyesVersion").def(false).help("Disables proprioception of the #4 joint of the head: Eyes version");
1011 d.describeBool("disableEyesVergence").def(false).help("Disables proprioception of the #5 joint of the head: Eyes vergence");
1070 void iCubPCHeadJointsSensor::resourceChanged(QString resourceName, ResourceChangeType changeType) {
1088 evonetIt->setGraphicProperties( QString("n")+QString::number(i)+QString("-")+QString::number(n), 0, 1, Qt::red ); //n stands for neck
1103 iCubHandJointsSensor::iCubHandJointsSensor( ConfigurationParameters& params, QString prefix ) :
1123 Descriptor d = addTypeDescription( type, "Sensor for reading the joint angles of an iCub hand" );
1124 d.describeEnum( "hand" ).def( "right" ).values( QStringList()<<"right"<<"left" ).props( IsMandatory ).help( "The hand from which the joint angles are read" );
1156 void iCubHandJointsSensor::resourceChanged(QString resourceName, ResourceChangeType changeType) {
1181 evonetIt->setGraphicProperties( label+QString("f")+QString::number(i), 0.0, 1.0, Qt::red ); //f stands for fingers
1247 FingertipTouchSensorGraphic(PhyObject *handPiece, double alpha, double h, bool isRight, bool isThumb, QString name = "unamed") :
1332 glVertex3f(epsilon, adjustedRadius * sin(effectiveNextAngle), adjustedRadius * cos(effectiveNextAngle));
1344 // To compute the normal we take two vectors along two adiacent sides of the quad, compute the cross
1346 const wVector v1(0.0, sin(angle) - sin(angle + m_angularIncrement), cos(angle) - cos(angle + m_angularIncrement));
1352 glVertex3f(epsilon, adjustedRadius * sin(effectiveNextAngle), adjustedRadius * cos(effectiveNextAngle));
1353 glVertex3f(-m_h, adjustedRadius * sin(effectiveNextAngle), adjustedRadius * cos(effectiveNextAngle));
1472 PalmPatchesTouchSensorGraphic(PhyObject *handPalm, const QVector<iCubPalmPatchesTouchSensor::Triangle>& patches, bool isRight, QString name = "unamed") :
1619 iCubFingertipsTouchSensor::iCubFingertipsTouchSensor(ConfigurationParameters& params, QString prefix) :
1639 ConfigurationHelper::throwUserConfigError(prefix + "hand", m_icubHand, "The hand parameter must be either \"right\" or \"left\" (case insensitive)");
1641 m_checkAllObjects = ConfigurationHelper::getBool(params, prefix + "checkAllObjects", m_checkAllObjects);
1647 usableResources(QStringList() << icubResource << neuronsIteratorResource << "objects" << "world");
1660 params.createParameter(prefix, "checkAllObjects", m_checkAllObjects ? QString("true") : QString("false"));
1663 params.createParameter(prefix, "drawSensor", m_drawSensor ? QString("true") : QString("false"));
1669 Descriptor d = addTypeDescription(type, "Hand fingertips touch sensor", "The touch sensor of the iCub fingertips. There are five sensors, one for each figertip");
1670 d.describeEnum("hand").def("right").values(QStringList() << "right" << "left").props(IsMandatory).help("The hand to use", "The hand whose distance from the object should be returned. Choose between \"right\" and \"left\"");
1671 d.describeBool("checkAllObjects").def(true).help("Wheter to check collisions with all objects or not", "If true, the collision of the hand touch sensors with all objects in the world is checked, otherwise only those in the objects vector are taken into account. Note that if the iCub is kinematic, only collisions with objects in the objects vector are checked regardless of the value of this parameter.");
1672 d.describeReal("alpha").def(45.0).help("The aperture of the sensor surface", "The aperture angle of the sensor surface in degrees (see the \"Fingertip Touch Sensor.png\" image for a graphical representation of sensor surface dimensions)");
1673 d.describeReal("h").def(0.01).help("The height of the sensor surface", "The height of the sensor surface (see the \"Fingertip Touch Sensor.png\" image for a graphical representation of sensor surface dimensions)");
1674 d.describeBool("drawSensor").def(true).help("Whether to draw sensor areas", "If true areas corresponding to the touch sensor surface are drawn on the fingertips when doing graphical simulations");
1708 void iCubFingertipsTouchSensor::resourceChanged(QString resourceName, ResourceChangeType changeType)
1724 // Checking if we have to draw the sensors. This is here because it requires a pointer to icub parts
1728 // Creating graphical objects representing the touch sensors areas. They will set the finger piece as
1730 m_graphicalTouchSensors.append(new FingertipTouchSensorGraphic(m_icubArm[19], m_alpha, m_h, m_isRight, false)); // Index
1731 m_graphicalTouchSensors.append(new FingertipTouchSensorGraphic(m_icubArm[20], m_alpha, m_h, m_isRight, false)); // Middle
1732 m_graphicalTouchSensors.append(new FingertipTouchSensorGraphic(m_icubArm[21], m_alpha, m_h, m_isRight, false)); // Ring
1733 m_graphicalTouchSensors.append(new FingertipTouchSensorGraphic(m_icubArm[22], m_alpha, m_h, m_isRight, false)); // Little
1734 m_graphicalTouchSensors.append(new FingertipTouchSensorGraphic(m_icubArm[26], m_alpha, m_h, m_isRight, true)); // Thumb
1771 if ((obj != NULL) && (m_world->smartCheckContacts(handPiece, (PhyObject*) m_objects->at(i), maxNumContacts, &contacts))) {
1797 bool iCubFingertipsTouchSensor::goodCollisionPoint(PhyObject* handPiece, const wVector& collisionPoint, bool isThumb) const
1799 // The various fingertips have frame of references with different orientations, so the direction towards
1807 // Here we calculate the angle on the yz plane, but the 0 angle is on different axes depending on the
1821 const float distFromFingertip = (dynamic_cast<PhyCylinder*>(handPiece))->height() / 2.0 - collisionPoint.x;
1831 iCubPalmPatchesTouchSensor::iCubPalmPatchesTouchSensor(ConfigurationParameters& params, QString prefix) :
1851 ConfigurationHelper::throwUserConfigError(prefix + "hand", m_icubHand, "The hand parameter must be either \"right\" or \"left\" (case insensitive)");
1853 m_checkAllObjects = ConfigurationHelper::getBool(params, prefix + "checkAllObjects", m_checkAllObjects);
1857 usableResources(QStringList() << icubResource << neuronsIteratorResource << "objects" << "world");
1870 params.createParameter(prefix, "checkAllObjects", m_checkAllObjects ? QString("true") : QString("false"));
1871 params.createParameter(prefix, "drawSensor", m_drawSensor ? QString("true") : QString("false"));
1877 Descriptor d = addTypeDescription(type, "Hand palm touch sensor", "The touch sensor of the iCub hand palm. There are four sensors, roughly in the same positions of the four patches on the real iCub hand");
1878 d.describeEnum("hand").def("right").values(QStringList() << "right" << "left").props(IsMandatory).help("The hand to use", "The hand whose distance from the object should be returned. Choose between \"right\" and \"left\"");
1879 d.describeBool("checkAllObjects").def(true).help("Wheter to check collisions with all objects or not", "If true, the collision of the hand touch sensors with all objects in the world is checked, otherwise only those in the objects vector are taken into account. Note that if the iCub is kinematic, only collisions with objects in the objects vector are checked regardless of the value of this parameter.");
1880 d.describeBool("drawSensor").def(true).help("Whether to draw sensor areas", "If true areas corresponding to the touch sensor surface are drawn on the fingertips when doing graphical simulations");
1902 m_world->smartCheckContacts(m_handPalm, (PhyObject*) m_objects->at(i), maxNumContacts, &contactsWithObj);
1915 // Now we have to check each contact point for each triangle. We also save activations into a QVector
1946 void iCubPalmPatchesTouchSensor::resourceChanged(QString resourceName, ResourceChangeType changeType)
1964 // left hand have different frame of references: in the right hand the palm is towards +z, while
1965 // in the left hand it is towards -z. The patches center is not in the middle of the palm along
1970 const float triangleHeight = sqrt((triangleSide * triangleSide) - (triangleHalfSide * triangleHalfSide));
2026 bool iCubPalmPatchesTouchSensor::pointInPalmTriangle(const wVector& point, const Triangle& triangle) const
2033 // The algorithm used here uses Barycentric Coordinates to check if a point is inside a triangle or not.
2037 // The version implemented here is directly taken from the second link (an offline version is in the
2038 // documentation). We discard the z coordinate (and do computations in 2D) because the check on z has
2065 HandObjectVisualOffsetSensor::HandObjectVisualOffsetSensor(ConfigurationParameters& params, QString prefix) :
2076 usableResources(QStringList() << icubResource << neuronsIteratorResource << "objects" << "world");
2094 Descriptor d = addTypeDescription(type, "Visual offset between the hand and the object", "This sensor computes the distance between the hand and the first object in the visual field of the robot. Returns the distances on the vertical and horizontal axes");
2095 d.describeEnum("hand").def("right").values(QStringList() << "right" << "left").props(IsMandatory).help("The hand to use", "The hand whose distance from the object should be returned. Choose between \"right\" and \"left\"");
2106 // We get this here because we are not notified if the vector changes (i.e. elemets are added or deleted),