experiments/src/robots.cpp

00001 /********************************************************************************
00002  *  FARSA Experiments Library                                                   *
00003  *  Copyright (C) 2007-2012                                                     *
00004  *  Tomassino Ferrauto <tomassino.ferrauto@istc.cnr.it>                         *
00005  *  Stefano Nolfi <stefano.nolfi@istc.cnr.it>                                   *
00006  *  Onofrio Gigliotta <onofrio.gigliotta@istc.cnr.it>                           *
00007  *  Gianluca Massera <emmegian@yahoo.it>                                        *
00008  *                                                                              *
00009  *  This program is free software; you can redistribute it and/or modify        *
00010  *  it under the terms of the GNU General Public License as published by        *
00011  *  the Free Software Foundation; either version 2 of the License, or           *
00012  *  (at your option) any later version.                                         *
00013  *                                                                              *
00014  *  This program is distributed in the hope that it will be useful,             *
00015  *  but WITHOUT ANY WARRANTY; without even the implied warranty of              *
00016  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the               *
00017  *  GNU General Public License for more details.                                *
00018  *                                                                              *
00019  *  You should have received a copy of the GNU General Public License           *
00020  *  along with this program; if not, write to the Free Software                 *
00021  *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA  *
00022  ********************************************************************************/
00023 
00024 #include "robots.h"
00025 #include "configurationhelper.h"
00026 #include "logger.h"
00027 #include "mathutils.h"
00028 #include <QStringList>
00029 #include <QRegExp>
00030 
00031 namespace farsa {
00032 
00033 #ifdef FARSA_USE_YARP_AND_ICUB
00034 namespace {
00035     // This anonymous namespace contains helper functions to extract from the ConfigurationParameters
00036     // object information needed by the PhyXxxx robot constructors
00037 
00038     World* extractWorld(ConfigurationParameters& params)
00039     {
00040         SimpleResourcesUser* r = params.getResourcesUserForResource("world");
00041 
00042         if (r == NULL) {
00043             ConfigurationHelper::throwUserMissingResourceError("world", "We need a world to create the iCub robot!");
00044         }
00045 
00046         return r->getResource<World>("world");
00047     }
00048 
00049     QString extractRobotName(ConfigurationParameters& params, QString prefix)
00050     {
00051         return ConfigurationHelper::getString(params, prefix + "name", "iCub");
00052     }
00053 
00054     wMatrix extractRobotTranformation(ConfigurationParameters& params, QString prefix)
00055     {
00056         QString value = ConfigurationHelper::getString(params, prefix + "transformation", QString());
00057 
00058         if (value.isEmpty()) {
00059             return wMatrix::identity();
00060         }
00061 
00062         // The values on the same row are separated by spaces, rows are separated by semicolons
00063         QStringList rows = value.split(";");
00064         if (rows.size() != 4) {
00065             ConfigurationHelper::throwUserConfigError(prefix + "transformation", value, "The transformation matrix must have 4 rows. The format is: a11 a12 a13 a14; a21 a22 a23 a24; a31 a32 a33 a34; a41 a42 a43 a44");
00066         }
00067 
00068         wMatrix mtr;
00069         for (int i = 0; i < rows.size(); i++) {
00070             QStringList elements = rows[i].split(QRegExp("\\s+"));
00071             if (elements.size() != 4) {
00072                 ConfigurationHelper::throwUserConfigError(prefix + "transformation", value, "The transformation matrix must have 4 columns. The format is: a11 a12 a13 a14; a21 a22 a23 a24; a31 a32 a33 a34; a41 a42 a43 a44");
00073             }
00074             for (int j = 0; j < elements.size(); j++) {
00075                 bool ok;
00076                 mtr[i][j] = elements[j].toDouble(&ok);
00077                 if (!ok) {
00078                     ConfigurationHelper::throwUserConfigError(prefix + "transformation", value, "The transformation matrix elements must be numbers");
00079                 }
00080             }
00081         }
00082 
00083         return mtr;
00084     }
00085 
00086     bool extractCreateServerControlBoard(ConfigurationParameters& params, QString prefix)
00087     {
00088         return ConfigurationHelper::getBool(params, prefix + "createServerControlBoards", false);
00089     }
00090 }
00091 
00092 iCubRobot::iCubRobot(ConfigurationParameters& params, QString prefix) :
00093     Robot(params, prefix),
00094     PhyiCub(extractWorld(params), extractRobotName(params, prefix), extractRobotTranformation(params, prefix), extractCreateServerControlBoard(params, prefix))
00095 {
00096     // Reading all configuration parameters (they are quite a lot...)
00097     doKinematicSimulation(ConfigurationHelper::getBool(params, prefix + "kinematiciCub", false), ConfigurationHelper::getBool(params, prefix + "kinematiciCubWithDynamicLeftHand", false), ConfigurationHelper::getBool(params, prefix + "kinematiciCubWithDynamicRightHand", false));
00098 
00099     enableLeftKinematicHand(ConfigurationHelper::getBool(params, prefix + "kinematiciCubKinematicLeftHand", false));
00100     enableRightKinematicHand(ConfigurationHelper::getBool(params, prefix + "kinematiciCubKinematicRightHand", false));
00101 
00102     enableLeftLeg(ConfigurationHelper::getBool(params, prefix + "enableLeftLeg", true));
00103     enableRightLeg(ConfigurationHelper::getBool(params, prefix + "enableRightLeg", true));
00104     enableTorso(ConfigurationHelper::getBool(params, prefix + "enableTorso", true));
00105     enableCameras(false /*ConfigurationHelper::getBool(params, prefix + "enableCameras", true)*/); // Cameras don't work with multithreaded applications, disabling them
00106     enableHead(ConfigurationHelper::getBool(params, prefix + "enableHead", true));
00107     enableLeftArm(ConfigurationHelper::getBool(params, prefix + "enableLeftArm", true));
00108     enableRightArm(ConfigurationHelper::getBool(params, prefix + "enableRightArm", true));
00109 
00110     blockTorso0(ConfigurationHelper::getBool(params, prefix + "blockTorso0", true));
00111 
00112     // Setting initial posture
00113     QMap<int, real> posture;
00114 
00115     if (ConfigurationHelper::hasParameter(params, prefix, "init_torso_yaw")) {
00116         posture[PhyiCub::torso_yaw] = ConfigurationHelper::getDouble(params, prefix + "init_torso_yaw");
00117     }
00118     if (ConfigurationHelper::hasParameter(params, prefix, "init_torso_roll")) {
00119         posture[PhyiCub::torso_roll] = ConfigurationHelper::getDouble(params, prefix + "init_torso_roll");
00120     }
00121     if (ConfigurationHelper::hasParameter(params, prefix, "init_torso_pitch")) {
00122         posture[PhyiCub::torso_pitch] = ConfigurationHelper::getDouble(params, prefix + "init_torso_pitch");
00123     }
00124     if (ConfigurationHelper::hasParameter(params, prefix, "init_left_shoulder_pitch")) {
00125         posture[PhyiCub::left_shoulder_pitch] = ConfigurationHelper::getDouble(params, prefix + "init_left_shoulder_pitch");
00126     }
00127     if (ConfigurationHelper::hasParameter(params, prefix, "init_left_shoulder_roll")) {
00128         posture[PhyiCub::left_shoulder_roll] = ConfigurationHelper::getDouble(params, prefix + "init_left_shoulder_roll");
00129     }
00130     if (ConfigurationHelper::hasParameter(params, prefix, "init_left_shoulder_yaw")) {
00131         posture[PhyiCub::left_shoulder_yaw] = ConfigurationHelper::getDouble(params, prefix + "init_left_shoulder_yaw");
00132     }
00133     if (ConfigurationHelper::hasParameter(params, prefix, "init_left_elbow")) {
00134         posture[PhyiCub::left_elbow] = ConfigurationHelper::getDouble(params, prefix + "init_left_elbow");
00135     }
00136     if (ConfigurationHelper::hasParameter(params, prefix, "init_left_wrist_prosup")) {
00137         posture[PhyiCub::left_wrist_prosup] = ConfigurationHelper::getDouble(params, prefix + "init_left_wrist_prosup");
00138     }
00139     if (ConfigurationHelper::hasParameter(params, prefix, "init_left_wrist_pitch")) {
00140         posture[PhyiCub::left_wrist_pitch] = ConfigurationHelper::getDouble(params, prefix + "init_left_wrist_pitch");
00141     }
00142     if (ConfigurationHelper::hasParameter(params, prefix, "init_left_wrist_yaw")) {
00143         posture[PhyiCub::left_wrist_yaw] = ConfigurationHelper::getDouble(params, prefix + "init_left_wrist_yaw");
00144     }
00145     if (ConfigurationHelper::hasParameter(params, prefix, "init_left_hand_finger")) {
00146         posture[PhyiCub::left_hand_finger] = ConfigurationHelper::getDouble(params, prefix + "init_left_hand_finger");
00147     }
00148     if (ConfigurationHelper::hasParameter(params, prefix, "init_left_thumb_oppose")) {
00149         posture[PhyiCub::left_thumb_oppose] = ConfigurationHelper::getDouble(params, prefix + "init_left_thumb_oppose");
00150     }
00151     if (ConfigurationHelper::hasParameter(params, prefix, "init_left_thumb_proximal")) {
00152         posture[PhyiCub::left_thumb_proximal] = ConfigurationHelper::getDouble(params, prefix + "init_left_thumb_proximal");
00153     }
00154     if (ConfigurationHelper::hasParameter(params, prefix, "init_left_thumb_distal")) {
00155         posture[PhyiCub::left_thumb_distal] = ConfigurationHelper::getDouble(params, prefix + "init_left_thumb_distal");
00156     }
00157     if (ConfigurationHelper::hasParameter(params, prefix, "init_left_index_proximal")) {
00158         posture[PhyiCub::left_index_proximal] = ConfigurationHelper::getDouble(params, prefix + "init_left_index_proximal");
00159     }
00160     if (ConfigurationHelper::hasParameter(params, prefix, "init_left_index_distal")) {
00161         posture[PhyiCub::left_index_distal] = ConfigurationHelper::getDouble(params, prefix + "init_left_index_distal");
00162     }
00163     if (ConfigurationHelper::hasParameter(params, prefix, "init_left_middle_proximal")) {
00164         posture[PhyiCub::left_middle_proximal] = ConfigurationHelper::getDouble(params, prefix + "init_left_middle_proximal");
00165     }
00166     if (ConfigurationHelper::hasParameter(params, prefix, "init_left_middle_distal")) {
00167         posture[PhyiCub::left_middle_distal] = ConfigurationHelper::getDouble(params, prefix + "init_left_middle_distal");
00168     }
00169     if (ConfigurationHelper::hasParameter(params, prefix, "init_left_pinky")) {
00170         posture[PhyiCub::left_pinky] = ConfigurationHelper::getDouble(params, prefix + "init_left_pinky");
00171     }
00172     if (ConfigurationHelper::hasParameter(params, prefix, "init_right_shoulder_pitch")) {
00173         posture[PhyiCub::right_shoulder_pitch] = ConfigurationHelper::getDouble(params, prefix + "init_right_shoulder_pitch");
00174     }
00175     if (ConfigurationHelper::hasParameter(params, prefix, "init_right_shoulder_roll")) {
00176         posture[PhyiCub::right_shoulder_roll] = ConfigurationHelper::getDouble(params, prefix + "init_right_shoulder_roll");
00177     }
00178     if (ConfigurationHelper::hasParameter(params, prefix, "init_right_shoulder_yaw")) {
00179         posture[PhyiCub::right_shoulder_yaw] = ConfigurationHelper::getDouble(params, prefix + "init_right_shoulder_yaw");
00180     }
00181     if (ConfigurationHelper::hasParameter(params, prefix, "init_right_elbow")) {
00182         posture[PhyiCub::right_elbow] = ConfigurationHelper::getDouble(params, prefix + "init_right_elbow");
00183     }
00184     if (ConfigurationHelper::hasParameter(params, prefix, "init_right_wrist_prosup")) {
00185         posture[PhyiCub::right_wrist_prosup] = ConfigurationHelper::getDouble(params, prefix + "init_right_wrist_prosup");
00186     }
00187     if (ConfigurationHelper::hasParameter(params, prefix, "init_right_wrist_pitch")) {
00188         posture[PhyiCub::right_wrist_pitch] = ConfigurationHelper::getDouble(params, prefix + "init_right_wrist_pitch");
00189     }
00190     if (ConfigurationHelper::hasParameter(params, prefix, "init_right_wrist_yaw")) {
00191         posture[PhyiCub::right_wrist_yaw] = ConfigurationHelper::getDouble(params, prefix + "init_right_wrist_yaw");
00192     }
00193     if (ConfigurationHelper::hasParameter(params, prefix, "init_right_hand_finger")) {
00194         posture[PhyiCub::right_hand_finger] = ConfigurationHelper::getDouble(params, prefix + "init_right_hand_finger");
00195     }
00196     if (ConfigurationHelper::hasParameter(params, prefix, "init_right_thumb_oppose")) {
00197         posture[PhyiCub::right_thumb_oppose] = ConfigurationHelper::getDouble(params, prefix + "init_right_thumb_oppose");
00198     }
00199     if (ConfigurationHelper::hasParameter(params, prefix, "init_right_thumb_proximal")) {
00200         posture[PhyiCub::right_thumb_proximal] = ConfigurationHelper::getDouble(params, prefix + "init_right_thumb_proximal");
00201     }
00202     if (ConfigurationHelper::hasParameter(params, prefix, "init_right_thumb_distal")) {
00203         posture[PhyiCub::right_thumb_distal] = ConfigurationHelper::getDouble(params, prefix + "init_right_thumb_distal");
00204     }
00205     if (ConfigurationHelper::hasParameter(params, prefix, "init_right_index_proximal")) {
00206         posture[PhyiCub::right_index_proximal] = ConfigurationHelper::getDouble(params, prefix + "init_right_index_proximal");
00207     }
00208     if (ConfigurationHelper::hasParameter(params, prefix, "init_right_index_distal")) {
00209         posture[PhyiCub::right_index_distal] = ConfigurationHelper::getDouble(params, prefix + "init_right_index_distal");
00210     }
00211     if (ConfigurationHelper::hasParameter(params, prefix, "init_right_middle_proximal")) {
00212         posture[PhyiCub::right_middle_proximal] = ConfigurationHelper::getDouble(params, prefix + "init_right_middle_proximal");
00213     }
00214     if (ConfigurationHelper::hasParameter(params, prefix, "init_right_middle_distal")) {
00215         posture[PhyiCub::right_middle_distal] = ConfigurationHelper::getDouble(params, prefix + "init_right_middle_distal");
00216     }
00217     if (ConfigurationHelper::hasParameter(params, prefix, "init_right_pinky")) {
00218         posture[PhyiCub::right_pinky] = ConfigurationHelper::getDouble(params, prefix + "init_right_pinky");
00219     }
00220     if (ConfigurationHelper::hasParameter(params, prefix, "init_neck_pitch")) {
00221         posture[PhyiCub::neck_pitch] = ConfigurationHelper::getDouble(params, prefix + "init_neck_pitch");
00222     }
00223     if (ConfigurationHelper::hasParameter(params, prefix, "init_neck_roll")) {
00224         posture[PhyiCub::neck_roll] = ConfigurationHelper::getDouble(params, prefix + "init_neck_roll");
00225     }
00226     if (ConfigurationHelper::hasParameter(params, prefix, "init_neck_yaw")) {
00227         posture[PhyiCub::neck_yaw] = ConfigurationHelper::getDouble(params, prefix + "init_neck_yaw");
00228     }
00229     if (ConfigurationHelper::hasParameter(params, prefix, "init_eyes_tilt")) {
00230         posture[PhyiCub::eyes_tilt] = ConfigurationHelper::getDouble(params, prefix + "init_eyes_tilt");
00231     }
00232     if (ConfigurationHelper::hasParameter(params, prefix, "init_eyes_version")) {
00233         posture[PhyiCub::eyes_version] = ConfigurationHelper::getDouble(params, prefix + "init_eyes_version");
00234     }
00235     if (ConfigurationHelper::hasParameter(params, prefix, "init_eyes_vergence")) {
00236         posture[PhyiCub::eyes_vergence] = ConfigurationHelper::getDouble(params, prefix + "init_eyes_vergence");
00237     }
00238     if (ConfigurationHelper::hasParameter(params, prefix, "init_left_hip_pitch")) {
00239         posture[PhyiCub::left_hip_pitch] = ConfigurationHelper::getDouble(params, prefix + "init_left_hip_pitch");
00240     }
00241     if (ConfigurationHelper::hasParameter(params, prefix, "init_left_hip_roll")) {
00242         posture[PhyiCub::left_hip_roll] = ConfigurationHelper::getDouble(params, prefix + "init_left_hip_roll");
00243     }
00244     if (ConfigurationHelper::hasParameter(params, prefix, "init_left_hip_yaw")) {
00245         posture[PhyiCub::left_hip_yaw] = ConfigurationHelper::getDouble(params, prefix + "init_left_hip_yaw");
00246     }
00247     if (ConfigurationHelper::hasParameter(params, prefix, "init_left_knee")) {
00248         posture[PhyiCub::left_knee] = ConfigurationHelper::getDouble(params, prefix + "init_left_knee");
00249     }
00250     if (ConfigurationHelper::hasParameter(params, prefix, "init_left_ankle_pitch")) {
00251         posture[PhyiCub::left_ankle_pitch] = ConfigurationHelper::getDouble(params, prefix + "init_left_ankle_pitch");
00252     }
00253     if (ConfigurationHelper::hasParameter(params, prefix, "init_left_ankle_roll")) {
00254         posture[PhyiCub::left_ankle_roll] = ConfigurationHelper::getDouble(params, prefix + "init_left_ankle_roll");
00255     }
00256     if (ConfigurationHelper::hasParameter(params, prefix, "init_right_hip_pitch")) {
00257         posture[PhyiCub::right_hip_pitch] = ConfigurationHelper::getDouble(params, prefix + "init_right_hip_pitch");
00258     }
00259     if (ConfigurationHelper::hasParameter(params, prefix, "init_right_hip_roll")) {
00260         posture[PhyiCub::right_hip_roll] = ConfigurationHelper::getDouble(params, prefix + "init_right_hip_roll");
00261     }
00262     if (ConfigurationHelper::hasParameter(params, prefix, "init_right_hip_yaw")) {
00263         posture[PhyiCub::right_hip_yaw] = ConfigurationHelper::getDouble(params, prefix + "init_right_hip_yaw");
00264     }
00265     if (ConfigurationHelper::hasParameter(params, prefix, "init_right_knee")) {
00266         posture[PhyiCub::right_knee] = ConfigurationHelper::getDouble(params, prefix + "init_right_knee");
00267     }
00268     if (ConfigurationHelper::hasParameter(params, prefix, "init_right_ankle_pitch")) {
00269         posture[PhyiCub::right_ankle_pitch] = ConfigurationHelper::getDouble(params, prefix + "init_right_ankle_pitch");
00270     }
00271     if (ConfigurationHelper::hasParameter(params, prefix, "init_right_ankle_roll")) {
00272         posture[PhyiCub::right_ankle_roll] = ConfigurationHelper::getDouble(params, prefix + "init_right_ankle_roll");
00273     }
00274 
00275     if (posture.size() != 0) {
00276         configurePosture(posture);
00277     }
00278 }
00279 
00280 void iCubRobot::save(ConfigurationParameters& params, QString prefix)
00281 {
00282     Logger::error("NOT IMPLEMENTED (iCubRobot::save)");
00283     abort();
00284 }
00285 
00286 void iCubRobot::describe(QString type)
00287 {
00288     Robot::describe(type);
00289 
00290     Descriptor d = addTypeDescription(type, "The simulated iCub robot in a physical world", "This type models the iCub robot in a physical world. Note that to create a robot we need a resource named \"world\" with a valid World instance");
00291     
00292     d.describeString("name").def("iCub").help("The name of the iCub robot", "The name of the iCub robot");
00293     
00294     d.describeString("transformation").def("").help("The initial transformation matrix for the robot", "The transformation matrix must be a 4x4 matrix. The format is: a11 a12 a13 a14; a21 a22 a23 a24; a31 a32 a33 a34; a41 a42 a43 a44");
00295     
00296     d.describeBool("createServerControlBoards").def(false).help("Whether to create server control boards or not", "The server control boards are neede to control the robot through YARP. You can avoid creating them if you just plan to control the robot programmatically");
00297     
00298     d.describeBool("kinematiciCub").def(false).help("If true only the kinematic of the iCub robot will simulated", "When this parameter is true, the iCub is not physically simulated and will not collide with any object in the world. This modality, however, is a lot faster than normal simulation");
00299     
00300     d.describeBool("kinematiciCubWithDynamicLeftHand").def(false).help("If true the left hand will be dynamic even in kinematic modality", "If the iCub is kinematic and this parameter is set to true, the left hand will be dynamic. Collision of the left hand with other world objects will be simulated. Note however that this doesn't work very well");
00301     
00302     d.describeBool("kinematiciCubWithDynamicRightHand").def(false).help("If true the right hand will be dynamic even in kinematic modality", "If the iCub is kinematic and this parameter is set to true, the right hand will be dynamic. Collision of the right hand with other world objects will be simulated. Note however that this doesn't work very well");
00303 
00304     d.describeBool("kinematiciCubKinematicLeftHand").def(true).help("If true the kinematic of the left hand is simulated in kinematic mode", "When set to false the left hand kinematic is not computed. This can speed up a bit simulations that only need the arm kinematic. Note that there is no \"official\" hand kinematic for the iCub, so the results can be slightly inaccurate");
00305 
00306     d.describeBool("kinematiciCubKinematicRightHand").def(true).help("If true the kinematic of the right hand is simulated in kinematic mode", "When set to false the right hand kinematic is not computed. This can speed up a bit simulations that only need the arm kinematic. Note that there is no \"official\" hand kinematic for the iCub, so the results can be slightly inaccurate");
00307 
00308     d.describeBool("enableLeftLeg").def(true).help("If true enables simulation of the left leg", "When set to false the left leg is not simulated, making the simulation of the remaining robot parts a bit faster. To increase simulation speed try to enable only the needed parts of the robot");
00309 
00310     d.describeBool("enableRightLeg").def(true).help("If true enables simulation of the right leg", "When set to false the right leg is not simulated, making the simulation of the remaining robot parts a bit faster. To increase simulation speed try to enable only the needed parts of the robot");
00311 
00312     d.describeBool("enableTorso").def(true).help("If true enables simulation of the torso", "When set to false the torso is not simulated, making the simulation of the remaining robot parts a bit faster. To increase simulation speed try to enable only the needed parts of the robot");
00313 
00314     d.describeBool("enableHead").def(true).help("If true enables simulation of the head and neck", "When set to false the head and neck are not simulated, making the simulation of the remaining robot parts a bit faster. To increase simulation speed try to enable only the needed parts of the robot");
00315 
00316     // An enableCameras parameter is not present because the current multithread implentation of total99 is incompatible with camera simulation
00317 
00318     d.describeBool("enableLeftArm").def(true).help("If true enables simulation of the left arm", "When set to false the left arm is not simulated, making the simulation of the remaining robot parts a bit faster. To increase simulation speed try to enable only the needed parts of the robot");
00319 
00320     d.describeBool("enableRightArm").def(true).help("If true enables simulation of the right arm", "When set to false the right arm is not simulated, making the simulation of the remaining robot parts a bit faster. To increase simulation speed try to enable only the needed parts of the robot");
00321 
00322     d.describeBool("blockTorso0").def(true).help("If true the first element of the robot torso is blocked", "When set to true the first element of the robot torso is a static object. This way the robot cannot move or fall, just as if it was connected to a wall or floor with a fixed link");
00323 
00324     d.describeReal("init_torso_yaw").def(0.0).help("The initial angle for the torso_yaw joint", "This is the initial angle for the torso_yaw joint. Please note that we do not enforce joint limits, so be careful what you set.");
00325 
00326     d.describeReal("init_torso_roll").def(0.0).help("The initial angle for the torso_roll joint", "This is the initial angle for the torso_roll joint. Please note that we do not enforce joint limits, so be careful what you set.");
00327 
00328     d.describeReal("init_torso_pitch").def(0.0).help("The initial angle for the torso_pitch joint", "This is the initial angle for the torso_pitch joint. Please note that we do not enforce joint limits, so be careful what you set.");
00329 
00330     d.describeReal("init_left_shoulder_pitch").def(0.0).help("The initial angle for the left_shoulder_pitch joint", "This is the initial angle for the left_shoulder_pitch joint. Please note that we do not enforce joint limits, so be careful what you set.");
00331 
00332     d.describeReal("init_left_shoulder_roll").def(0.0).help("The initial angle for the left_shoulder_roll joint", "This is the initial angle for the left_shoulder_roll joint. Please note that we do not enforce joint limits, so be careful what you set.");
00333 
00334     d.describeReal("init_left_shoulder_yaw").def(0.0).help("The initial angle for the left_shoulder_yaw joint", "This is the initial angle for the left_shoulder_yaw joint. Please note that we do not enforce joint limits, so be careful what you set.");
00335 
00336     d.describeReal("init_left_elbow").def(0.0).help("The initial angle for the left_elbow joint", "This is the initial angle for the left_elbow joint. Please note that we do not enforce joint limits, so be careful what you set.");
00337 
00338     d.describeReal("init_left_wrist_prosup").def(0.0).help("The initial angle for the left_wrist_prosup joint", "This is the initial angle for the left_wrist_prosup joint. Please note that we do not enforce joint limits, so be careful what you set.");
00339 
00340     d.describeReal("init_left_wrist_pitch").def(0.0).help("The initial angle for the left_wrist_pitch joint", "This is the initial angle for the left_wrist_pitch joint. Please note that we do not enforce joint limits, so be careful what you set.");
00341 
00342     d.describeReal("init_left_wrist_yaw").def(0.0).help("The initial angle for the left_wrist_yaw joint", "This is the initial angle for the left_wrist_yaw joint. Please note that we do not enforce joint limits, so be careful what you set.");
00343 
00344     d.describeReal("init_left_hand_finger").def(0.0).help("The initial angle for the left_hand_finger joint", "This is the initial angle for the left_hand_finger joint. Please note that we do not enforce joint limits, so be careful what you set.");
00345 
00346     d.describeReal("init_left_thumb_oppose").def(0.0).help("The initial angle for the left_thumb_oppose joint", "This is the initial angle for the left_thumb_oppose joint. Please note that we do not enforce joint limits, so be careful what you set.");
00347 
00348     d.describeReal("init_left_thumb_proximal").def(0.0).help("The initial angle for the left_thumb_proximal joint", "This is the initial angle for the left_thumb_proximal joint. Please note that we do not enforce joint limits, so be careful what you set.");
00349 
00350     d.describeReal("init_left_thumb_distal").def(0.0).help("The initial angle for the left_thumb_distal joint", "This is the initial angle for the left_thumb_distal joint. Please note that we do not enforce joint limits, so be careful what you set.");
00351 
00352     d.describeReal("init_left_index_proximal").def(0.0).help("The initial angle for the left_index_proximal joint", "This is the initial angle for the left_index_proximal joint. Please note that we do not enforce joint limits, so be careful what you set.");
00353 
00354     d.describeReal("init_left_index_distal").def(0.0).help("The initial angle for the left_index_distal joint", "This is the initial angle for the left_index_distal joint. Please note that we do not enforce joint limits, so be careful what you set.");
00355 
00356     d.describeReal("init_left_middle_proximal").def(0.0).help("The initial angle for the left_middle_proximal joint", "This is the initial angle for the left_middle_proximal joint. Please note that we do not enforce joint limits, so be careful what you set.");
00357 
00358     d.describeReal("init_left_middle_distal").def(0.0).help("The initial angle for the left_middle_distal joint", "This is the initial angle for the left_middle_distal joint. Please note that we do not enforce joint limits, so be careful what you set.");
00359 
00360     d.describeReal("init_left_pinky").def(0.0).help("The initial angle for the left_pinky joint", "This is the initial angle for the left_pinky joint. Please note that we do not enforce joint limits, so be careful what you set.");
00361 
00362     d.describeReal("init_right_shoulder_pitch").def(0.0).help("The initial angle for the right_shoulder_pitch joint", "This is the initial angle for the right_shoulder_pitch joint. Please note that we do not enforce joint limits, so be careful what you set.");
00363 
00364     d.describeReal("init_right_shoulder_roll").def(0.0).help("The initial angle for the right_shoulder_roll joint", "This is the initial angle for the right_shoulder_roll joint. Please note that we do not enforce joint limits, so be careful what you set.");
00365 
00366     d.describeReal("init_right_shoulder_yaw").def(0.0).help("The initial angle for the right_shoulder_yaw joint", "This is the initial angle for the right_shoulder_yaw joint. Please note that we do not enforce joint limits, so be careful what you set.");
00367 
00368     d.describeReal("init_right_elbow").def(0.0).help("The initial angle for the right_elbow joint", "This is the initial angle for the right_elbow joint. Please note that we do not enforce joint limits, so be careful what you set.");
00369 
00370     d.describeReal("init_right_wrist_prosup").def(0.0).help("The initial angle for the right_wrist_prosup joint", "This is the initial angle for the right_wrist_prosup joint. Please note that we do not enforce joint limits, so be careful what you set.");
00371 
00372     d.describeReal("init_right_wrist_pitch").def(0.0).help("The initial angle for the right_wrist_pitch joint", "This is the initial angle for the right_wrist_pitch joint. Please note that we do not enforce joint limits, so be careful what you set.");
00373 
00374     d.describeReal("init_right_wrist_yaw").def(0.0).help("The initial angle for the right_wrist_yaw joint", "This is the initial angle for the right_wrist_yaw joint. Please note that we do not enforce joint limits, so be careful what you set.");
00375 
00376     d.describeReal("init_right_hand_finger").def(0.0).help("The initial angle for the right_hand_finger joint", "This is the initial angle for the right_hand_finger joint. Please note that we do not enforce joint limits, so be careful what you set.");
00377 
00378     d.describeReal("init_right_thumb_oppose").def(0.0).help("The initial angle for the right_thumb_oppose joint", "This is the initial angle for the right_thumb_oppose joint. Please note that we do not enforce joint limits, so be careful what you set.");
00379 
00380     d.describeReal("init_right_thumb_proximal").def(0.0).help("The initial angle for the right_thumb_proximal joint", "This is the initial angle for the right_thumb_proximal joint. Please note that we do not enforce joint limits, so be careful what you set.");
00381 
00382     d.describeReal("init_right_thumb_distal").def(0.0).help("The initial angle for the right_thumb_distal joint", "This is the initial angle for the right_thumb_distal joint. Please note that we do not enforce joint limits, so be careful what you set.");
00383 
00384     d.describeReal("init_right_index_proximal").def(0.0).help("The initial angle for the right_index_proximal joint", "This is the initial angle for the right_index_proximal joint. Please note that we do not enforce joint limits, so be careful what you set.");
00385 
00386     d.describeReal("init_right_index_distal").def(0.0).help("The initial angle for the right_index_distal joint", "This is the initial angle for the right_index_distal joint. Please note that we do not enforce joint limits, so be careful what you set.");
00387 
00388     d.describeReal("init_right_middle_proximal").def(0.0).help("The initial angle for the right_middle_proximal joint", "This is the initial angle for the right_middle_proximal joint. Please note that we do not enforce joint limits, so be careful what you set.");
00389 
00390     d.describeReal("init_right_middle_distal").def(0.0).help("The initial angle for the right_middle_distal joint", "This is the initial angle for the right_middle_distal joint. Please note that we do not enforce joint limits, so be careful what you set.");
00391 
00392     d.describeReal("init_right_pinky").def(0.0).help("The initial angle for the right_pinky joint", "This is the initial angle for the right_pinky joint. Please note that we do not enforce joint limits, so be careful what you set.");
00393 
00394     d.describeReal("init_neck_pitch").def(0.0).help("The initial angle for the neck_pitch joint", "This is the initial angle for the neck_pitch joint. Please note that we do not enforce joint limits, so be careful what you set.");
00395 
00396     d.describeReal("init_neck_roll").def(0.0).help("The initial angle for the neck_roll joint", "This is the initial angle for the neck_roll joint. Please note that we do not enforce joint limits, so be careful what you set.");
00397 
00398     d.describeReal("init_neck_yaw").def(0.0).help("The initial angle for the neck_yaw joint", "This is the initial angle for the neck_yaw joint. Please note that we do not enforce joint limits, so be careful what you set.");
00399 
00400     d.describeReal("init_eyes_tilt").def(0.0).help("The initial angle for the eyes_tilt joint", "This is the initial angle for the eyes_tilt joint. Please note that we do not enforce joint limits, so be careful what you set.");
00401 
00402     d.describeReal("init_eyes_version").def(0.0).help("The initial angle for the eyes_version joint", "This is the initial angle for the eyes_version joint. Please note that we do not enforce joint limits, so be careful what you set.");
00403 
00404     d.describeReal("init_eyes_vergence").def(0.0).help("The initial angle for the eyes_vergence joint", "This is the initial angle for the eyes_vergence joint. Please note that we do not enforce joint limits, so be careful what you set.");
00405 
00406     d.describeReal("init_left_hip_pitch").def(0.0).help("The initial angle for the left_hip_pitch joint", "This is the initial angle for the left_hip_pitch joint. Please note that we do not enforce joint limits, so be careful what you set.");
00407 
00408     d.describeReal("init_left_hip_roll").def(0.0).help("The initial angle for the left_hip_roll joint", "This is the initial angle for the left_hip_roll joint. Please note that we do not enforce joint limits, so be careful what you set.");
00409 
00410     d.describeReal("init_left_hip_yaw").def(0.0).help("The initial angle for the left_hip_yaw joint", "This is the initial angle for the left_hip_yaw joint. Please note that we do not enforce joint limits, so be careful what you set.");
00411 
00412     d.describeReal("init_left_knee").def(0.0).help("The initial angle for the left_knee joint", "This is the initial angle for the left_knee joint. Please note that we do not enforce joint limits, so be careful what you set.");
00413 
00414     d.describeReal("init_left_ankle_pitch").def(0.0).help("The initial angle for the left_ankle_pitch joint", "This is the initial angle for the left_ankle_pitch joint. Please note that we do not enforce joint limits, so be careful what you set.");
00415 
00416     d.describeReal("init_left_ankle_roll").def(0.0).help("The initial angle for the left_ankle_roll joint", "This is the initial angle for the left_ankle_roll joint. Please note that we do not enforce joint limits, so be careful what you set.");
00417 
00418     d.describeReal("init_right_hip_pitch").def(0.0).help("The initial angle for the right_hip_pitch joint", "This is the initial angle for the right_hip_pitch joint. Please note that we do not enforce joint limits, so be careful what you set.");
00419 
00420     d.describeReal("init_right_hip_roll").def(0.0).help("The initial angle for the right_hip_roll joint", "This is the initial angle for the right_hip_roll joint. Please note that we do not enforce joint limits, so be careful what you set.");
00421 
00422     d.describeReal("init_right_hip_yaw").def(0.0).help("The initial angle for the right_hip_yaw joint", "This is the initial angle for the right_hip_yaw joint. Please note that we do not enforce joint limits, so be careful what you set.");
00423 
00424     d.describeReal("init_right_knee").def(0.0).help("The initial angle for the right_knee joint", "This is the initial angle for the right_knee joint. Please note that we do not enforce joint limits, so be careful what you set.");
00425 
00426     d.describeReal("init_right_ankle_pitch").def(0.0).help("The initial angle for the right_ankle_pitch joint", "This is the initial angle for the right_ankle_pitch joint. Please note that we do not enforce joint limits, so be careful what you set.");
00427 
00428     d.describeReal("init_right_ankle_roll").def(0.0).help("The initial angle for the right_ankle_roll joint", "This is the initial angle for the right_ankle_roll joint. Please note that we do not enforce joint limits, so be careful what you set.");
00429 }
00430 
00431 iCubRobot::~iCubRobot()
00432 {
00433     // Nothing to do here
00434 }
00435 
00436 #endif // FARSA_USE_YARP_AND_ICUB
00437 
00438 MarXbot::MarXbot(ConfigurationParameters& params, QString prefix) :
00439     Robot(params, prefix),
00440     PhyMarXbot(extractWorld(params), extractRobotName(params, prefix), extractRobotTranformation(params, prefix))
00441 {
00442     const bool enableWheels = ConfigurationHelper::getBool(params, prefix + "enableWheels", true);
00443     const bool enableProximityIR = ConfigurationHelper::getBool(params, prefix + "enableProximityIR", true);
00444     const bool enableGroundBottomIR = ConfigurationHelper::getBool(params, prefix + "enableGroundBottomIR", true);
00445     const bool enableGroundAroundIR = ConfigurationHelper::getBool(params, prefix + "enableGroundAroundIR", true);
00446     const bool drawIRRays =ConfigurationHelper::getBool(params, prefix + "drawIRRays", true);
00447     const bool drawIRRaysRange = ConfigurationHelper::getBool(params, prefix + "drawIRRaysRange", true);
00448     
00449     wheelsController()->setEnabled(enableWheels);
00450     proximityIRSensorController()->setEnabled(enableProximityIR);
00451     setProximityIRSensorsGraphicalProperties(enableProximityIR, drawIRRays, drawIRRaysRange);
00452     groundBottomIRSensorController()->setEnabled(enableGroundBottomIR);
00453     setGroundBottomIRSensorsGraphicalProperties(enableGroundBottomIR, drawIRRays, drawIRRaysRange);
00454     groundAroundIRSensorController()->setEnabled(enableGroundAroundIR);
00455     setGroundAroundIRSensorsGraphicalProperties(enableGroundAroundIR, drawIRRays, drawIRRaysRange);
00456 }
00457 
00458 void MarXbot::save(ConfigurationParameters& params, QString prefix) {
00459     Logger::error("NOT IMPLEMENTED (MarXBot::save)");
00460     abort();
00461 }
00462 
00463 void MarXbot::describe(QString type) {
00464     Robot::describe(type);
00465 
00466     Descriptor d = addTypeDescription(type, "The simulated wheeled MarXBot robot in a physical world", "This type models the wheeled MarXBot robot in a physical world. Note that to create a robot we need a resource named \"world\" with a valid World instance");
00467     
00468     d.describeString("name").def("marXbot").help("The name of the MarXBot robot", "The name of the MarXBot robot");
00469     
00470     d.describeString("transformation").def("").help("The initial transformation matrix for the robot", "The transformation matrix must be a 4x4 matrix. The format is: a11 a12 a13 a14; a21 a22 a23 a24; a31 a32 a33 a34; a41 a42 a43 a44");
00471 
00472     d.describeBool("enableWheels").def(true).help("If true enables the wheel motors", "When set to false the wheel motors are not enabled, so the robot cannot move by itself");
00473 
00474     d.describeBool("enableProximityIR").def(true).help("If true enables the proximity IR sensors", "When set to false the proximity infrared sensors are not enabled, thus making simulation a bit faster. To increase simulation speed try to enable only the needed parts of the robot");
00475 
00476     d.describeBool("enableGroundBottomIR").def(true).help("If true enables the bottom ground IR sensors", "When set to false the ground infrared sensors below the battery pack are not enabled, thus making simulation a bit faster. To increase simulation speed try to enable only the needed parts of the robot");
00477 
00478     d.describeBool("enableGroundAroundIR").def(true).help("If true enables the around ground IR sensors", "When set to false the ground infrared sensors on the bottom part of the base (just above the wheels) are not enabled, thus making simulation a bit faster. To increase simulation speed try to enable only the needed parts of the robot");
00479 
00480     d.describeBool("drawIRRays").def(true).help("If true draws rays of enabled IR sensors", "When set to true rays of the enabled IR sensors (i.e. proximity, ground bottom and ground around infrared sensors) are drawn");
00481 
00482     d.describeBool("drawIRRaysRange").def(true).help("If true rays of enabled IR sensors are shown in their real range", "When drawIRRays is true, this parameter sets whether rays are drawn in their real range (the parameter is true) or instead only their direction is shown (the parameter is false)");
00483     
00484 }
00485 
00486 MarXbot::~MarXbot() {
00487     // Nothing to do here
00488 }
00489 
00490 } //end namespace farsa