experiments/include/icubmotors.h

00001 /********************************************************************************
00002  *  FARSA Experimentes Library                                                  *
00003  *  Copyright (C) 2007-2012                                                     *
00004  *  Gianluca Massera <emmegian@yahoo.it>                                        *
00005  *  Stefano Nolfi <stefano.nolfi@istc.cnr.it>                                   *
00006  *  Tomassino Ferrauto <tomassino.ferrauto@istc.cnr.it>                         *
00007  *  Onofrio Gigliotta <onofrio.gigliotta@istc.cnr.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 #ifndef ICUBMOTORS_H
00025 #define ICUBMOTORS_H
00026 
00027 #ifdef FARSA_USE_YARP_AND_ICUB
00028 
00029 #include "experimentsconfig.h"
00030 #include "neuroninterfaces.h"
00031 #include "musclepair.h"
00032 #include "robots.h"
00033 #include "motors.h"
00034 
00035 namespace farsa {
00036 
00037 class MultiMotorController;
00038 
00057 class iCubMotor : public Motor
00058 {
00059 public:
00070     iCubMotor(ConfigurationParameters& params, QString prefix);
00071 
00075     virtual ~iCubMotor();
00076 
00085     virtual void save(ConfigurationParameters& params, QString prefix);
00086 
00093     static void describe(QString type);
00094 
00095 protected:
00103     virtual void resourceChanged(QString resourceName, ResourceChangeType changeType);
00104 
00108     QString icubResource;
00109 
00114     QString neuronsIteratorResource;
00115 };
00116 
00122 class FARSA_EXPERIMENTS_API iCubArmRandomMotor : public iCubMotor {
00123 public:
00128     iCubArmRandomMotor( ConfigurationParameters& params, QString prefix );
00130     ~iCubArmRandomMotor();
00135     void save( ConfigurationParameters& params, QString prefix );
00137     static void describe( QString type );
00139     void update();
00141     int size();
00142 protected:
00148     void resourceChanged(QString resourceName, ResourceChangeType changeType);
00150     QString icubArm;
00152     iCubRobot* icub;
00154     MultiMotorController* icubMotors;
00156     int startJointId;
00157 };
00158 
00166 class FARSA_EXPERIMENTS_API iCubArmPosToPostureMotor : public iCubMotor {
00167 public:
00172     iCubArmPosToPostureMotor( ConfigurationParameters& params, QString prefix );
00174     ~iCubArmPosToPostureMotor();
00179     void save( ConfigurationParameters& params, QString prefix );
00181     static void describe( QString type );
00183     void update();
00185     int size();
00186 protected:
00192     void resourceChanged(QString resourceName, ResourceChangeType changeType);
00194     QString icubArm;
00196     iCubRobot* icub;
00198     MultiMotorController* icubMotors;
00200     int startJointId;
00202     bool is7Dof;
00203 };
00204 
00212 class FARSA_EXPERIMENTS_API iCubTorsoPosToPostureMotor : public iCubMotor {
00213 public:
00218     iCubTorsoPosToPostureMotor( ConfigurationParameters& params, QString prefix );
00220     ~iCubTorsoPosToPostureMotor();
00225     void save( ConfigurationParameters& params, QString prefix );
00227     static void describe( QString type );
00229     void update();
00231     int size();
00232 protected:
00238     void resourceChanged(QString resourceName, ResourceChangeType changeType);
00240     iCubRobot* icub;
00242     MultiMotorController* icubMotors;
00244     bool torsoDofs[3];
00245 };
00246 
00251 class FARSA_EXPERIMENTS_API iCubArmMusclesMotor : public iCubMotor {
00252 public:
00257     iCubArmMusclesMotor( ConfigurationParameters& params, QString prefix );
00259     ~iCubArmMusclesMotor();
00264     void save( ConfigurationParameters& params, QString prefix );
00266     static void describe( QString type );
00268     void update();
00270     int size();
00271 protected:
00277     void resourceChanged(QString resourceName, ResourceChangeType changeType);
00279     MusclePair **musclePairs;
00281     QString icubArm;
00283     iCubRobot* icub;
00285     MultiMotorController* icubMotors;
00286 };
00287 
00292 class FARSA_EXPERIMENTS_API iCubHandMusclesMotor : public iCubMotor {
00293 public:
00298     iCubHandMusclesMotor( ConfigurationParameters& params, QString prefix );
00300     ~iCubHandMusclesMotor();
00305     void save( ConfigurationParameters& params, QString prefix );
00307     static void describe( QString type );
00309     void update();
00311     int size();
00312 protected:
00318     void resourceChanged(QString resourceName, ResourceChangeType changeType);
00320     MusclePair **musclePairs;
00322     QString icubHand;
00324     iCubRobot* icub;
00326     MultiMotorController* icubMotors;
00327 };
00328 
00333 class FARSA_EXPERIMENTS_API iCubTorsoMusclesMotor : public iCubMotor {
00334 public:
00339     iCubTorsoMusclesMotor( ConfigurationParameters& params, QString prefix );
00341     ~iCubTorsoMusclesMotor();
00346     void save( ConfigurationParameters& params, QString prefix );
00348     static void describe( QString type );
00350     void update();
00352     int size();
00353 protected:
00359     void resourceChanged(QString resourceName, ResourceChangeType changeType);
00361     MusclePair **musclePairs;
00363     iCubRobot* icub;
00365     MultiMotorController* icubMotors;
00366 };
00367 
00372 class FARSA_EXPERIMENTS_API iCubHeadMusclesMotor : public iCubMotor {
00373 public:
00378     iCubHeadMusclesMotor( ConfigurationParameters& params, QString prefix );
00380     ~iCubHeadMusclesMotor();
00385     void save( ConfigurationParameters& params, QString prefix );
00387     static void describe( QString type );
00389     void update();
00391     int size();
00392 protected:
00398     void resourceChanged(QString resourceName, ResourceChangeType changeType);
00400     MusclePair **musclePairs;
00402     iCubRobot* icub;
00404     MultiMotorController* icubMotors;
00405 };
00406 
00411 class FARSA_EXPERIMENTS_API iCubArmPosToVelMotor : public iCubMotor {
00412 public:
00417     iCubArmPosToVelMotor( ConfigurationParameters& params, QString prefix );
00419     ~iCubArmPosToVelMotor();
00424     void save( ConfigurationParameters& params, QString prefix );
00426     static void describe( QString type );
00428     void update();
00430     int size();
00431 protected:
00437     void resourceChanged(QString resourceName, ResourceChangeType changeType);
00439     QString icubArm;
00441     iCubRobot* icub;
00443     MultiMotorController* icubMotors;
00445     ProportionalController pcontrol;
00446 };
00447 
00452 class FARSA_EXPERIMENTS_API iCubTorsoPosToVelMotor : public iCubMotor {
00453 public:
00458     iCubTorsoPosToVelMotor( ConfigurationParameters& params, QString prefix );
00460     ~iCubTorsoPosToVelMotor();
00465     void save( ConfigurationParameters& params, QString prefix );
00467     static void describe( QString type );
00469     void update();
00471     int size();
00472 protected:
00478     void resourceChanged(QString resourceName, ResourceChangeType changeType);
00480     iCubRobot* icub;
00482     MultiMotorController* icubMotors;
00484     ProportionalController pcontrol;
00485 };
00486 
00491 class FARSA_EXPERIMENTS_API iCubHeadPosToVelMotor : public iCubMotor {
00492 public:
00497     iCubHeadPosToVelMotor( ConfigurationParameters& params, QString prefix );
00499     ~iCubHeadPosToVelMotor();
00504     void save( ConfigurationParameters& params, QString prefix );
00506     static void describe( QString type );
00508     void update();
00510     int size();
00511 protected:
00517     void resourceChanged(QString resourceName, ResourceChangeType changeType);
00519     iCubRobot* icub;
00521     MultiMotorController* icubMotors;
00523     ProportionalController pcontrol;
00524 };
00525 
00530 class FARSA_EXPERIMENTS_API iCubHandPosToVelMotor : public iCubMotor {
00531 public:
00536     iCubHandPosToVelMotor( ConfigurationParameters& params, QString prefix );
00538     ~iCubHandPosToVelMotor();
00543     void save( ConfigurationParameters& params, QString prefix );
00545     static void describe( QString type );
00547     void update();
00549     int size();
00550 protected:
00556     void resourceChanged(QString resourceName, ResourceChangeType changeType);
00558     QString icubHand;
00560     iCubRobot* icub;
00562     MultiMotorController* icubMotors;
00564     ProportionalController pcontrol;
00565 };
00566 
00607 class FARSA_EXPERIMENTS_API iCubConfigurableHandPosToVelMotor : public iCubMotor
00608 {
00609 public:
00617     iCubConfigurableHandPosToVelMotor(ConfigurationParameters& params, QString prefix);
00618 
00622     ~iCubConfigurableHandPosToVelMotor();
00623 
00632     virtual void save(ConfigurationParameters& params, QString prefix);
00633 
00639     static void describe(QString type);
00640 
00645     virtual void update();
00646 
00652     virtual int size();
00653 
00654 private:
00662     virtual void resourceChanged(QString resourceName, ResourceChangeType changeType);
00663 
00667     QString m_icubHand;
00668 
00675     QVector<QVector<int> > m_jointsGroups;
00676 
00683     double m_maxClosure;
00684 
00688     MultiMotorController* m_armController;
00689 
00694     ProportionalController m_pcontrol;
00695 };
00696 
00712 class FARSA_EXPERIMENTS_API iCubHeadVelocityMotor : public iCubMotor
00713 {
00714 public:
00722     iCubHeadVelocityMotor(ConfigurationParameters& params, QString prefix);
00723 
00727     ~iCubHeadVelocityMotor();
00728 
00737     virtual void save(ConfigurationParameters& params, QString prefix);
00738 
00744     static void describe(QString type);
00745 
00750     virtual void update();
00751 
00757     virtual int size();
00758 
00759 private:
00768     virtual void resourceChanged(QString resourceName, ResourceChangeType changeType);
00769 
00773     MultiMotorController* m_headNeckController;
00774 };
00775 
00781 class FARSA_EXPERIMENTS_API iCubArmVelocityMotor : public iCubMotor {
00782 public:
00787     iCubArmVelocityMotor( ConfigurationParameters& params, QString prefix );
00789     ~iCubArmVelocityMotor();
00794     void save( ConfigurationParameters& params, QString prefix );
00796     static void describe( QString type );
00798     void update();
00800     int size();
00801 protected:
00807     void resourceChanged(QString resourceName, ResourceChangeType changeType);
00809     QString icubArm;
00811     iCubRobot* icub;
00813     MultiMotorController* icubMotors;
00815     int startJointId;
00817     bool is7Dof;
00819     double maxVelocity;
00820 };
00821 
00827 class FARSA_EXPERIMENTS_API iCubTorsoVelocityMotor : public iCubMotor {
00828 public:
00833     iCubTorsoVelocityMotor( ConfigurationParameters& params, QString prefix );
00835     ~iCubTorsoVelocityMotor();
00840     void save( ConfigurationParameters& params, QString prefix );
00842     static void describe( QString type );
00844     void update();
00846     int size();
00847 protected:
00853     void resourceChanged(QString resourceName, ResourceChangeType changeType);
00855     iCubRobot* icub;
00857     MultiMotorController* icubMotors;
00859     bool torsoDofs[3];
00861     double maxVelocity;
00862 };
00863 
00864 } // end namespace farsa
00865 
00866 #endif
00867 
00868 #endif