icubmotors.h
1 /********************************************************************************
2  * FARSA Experimentes Library *
3  * Copyright (C) 2007-2012 *
4  * Gianluca Massera <emmegian@yahoo.it> *
5  * Stefano Nolfi <stefano.nolfi@istc.cnr.it> *
6  * Tomassino Ferrauto <tomassino.ferrauto@istc.cnr.it> *
7  * Onofrio Gigliotta <onofrio.gigliotta@istc.cnr.it> *
8  * *
9  * This program is free software; you can redistribute it and/or modify *
10  * it under the terms of the GNU General Public License as published by *
11  * the Free Software Foundation; either version 2 of the License, or *
12  * (at your option) any later version. *
13  * *
14  * This program is distributed in the hope that it will be useful, *
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of *
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
17  * GNU General Public License for more details. *
18  * *
19  * You should have received a copy of the GNU General Public License *
20  * along with this program; if not, write to the Free Software *
21  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
22  ********************************************************************************/
23 
24 #ifndef ICUBMOTORS_H
25 #define ICUBMOTORS_H
26 
27 #ifdef FARSA_USE_YARP_AND_ICUB
28 
29 #include "experimentsconfig.h"
30 #include "neuroninterfaces.h"
31 #include "musclepair.h"
32 #include "robots.h"
33 #include "motors.h"
34 
35 namespace farsa {
36 
37 class MultiMotorController;
38 
57 class iCubMotor : public Motor
58 {
59 public:
70  iCubMotor(ConfigurationParameters& params, QString prefix);
71 
75  virtual ~iCubMotor();
76 
85  virtual void save(ConfigurationParameters& params, QString prefix);
86 
93  static void describe(QString type);
94 
95 protected:
103  virtual void resourceChanged(QString resourceName, ResourceChangeType changeType);
104 
108  QString icubResource;
109 
115 };
116 
122 class FARSA_EXPERIMENTS_API iCubArmRandomMotor : public iCubMotor {
123 public:
128  iCubArmRandomMotor( ConfigurationParameters& params, QString prefix );
135  void save( ConfigurationParameters& params, QString prefix );
137  static void describe( QString type );
139  void update();
141  int size();
142 protected:
148  void resourceChanged(QString resourceName, ResourceChangeType changeType);
150  QString icubArm;
157 };
158 
166 class FARSA_EXPERIMENTS_API iCubArmPosToPostureMotor : public iCubMotor {
167 public:
172  iCubArmPosToPostureMotor( ConfigurationParameters& params, QString prefix );
179  void save( ConfigurationParameters& params, QString prefix );
181  static void describe( QString type );
183  void update();
185  int size();
186 protected:
192  void resourceChanged(QString resourceName, ResourceChangeType changeType);
194  QString icubArm;
202  bool is7Dof;
203 };
204 
212 class FARSA_EXPERIMENTS_API iCubTorsoPosToPostureMotor : public iCubMotor {
213 public:
218  iCubTorsoPosToPostureMotor( ConfigurationParameters& params, QString prefix );
225  void save( ConfigurationParameters& params, QString prefix );
227  static void describe( QString type );
229  void update();
231  int size();
232 protected:
238  void resourceChanged(QString resourceName, ResourceChangeType changeType);
244  bool torsoDofs[3];
245 };
246 
251 class FARSA_EXPERIMENTS_API iCubArmMusclesMotor : public iCubMotor {
252 public:
257  iCubArmMusclesMotor( ConfigurationParameters& params, QString prefix );
264  void save( ConfigurationParameters& params, QString prefix );
266  static void describe( QString type );
268  void update();
270  int size();
271 protected:
277  void resourceChanged(QString resourceName, ResourceChangeType changeType);
281  QString icubArm;
286 };
287 
292 class FARSA_EXPERIMENTS_API iCubHandMusclesMotor : public iCubMotor {
293 public:
298  iCubHandMusclesMotor( ConfigurationParameters& params, QString prefix );
305  void save( ConfigurationParameters& params, QString prefix );
307  static void describe( QString type );
309  void update();
311  int size();
312 protected:
318  void resourceChanged(QString resourceName, ResourceChangeType changeType);
322  QString icubHand;
327 };
328 
333 class FARSA_EXPERIMENTS_API iCubTorsoMusclesMotor : public iCubMotor {
334 public:
339  iCubTorsoMusclesMotor( ConfigurationParameters& params, QString prefix );
346  void save( ConfigurationParameters& params, QString prefix );
348  static void describe( QString type );
350  void update();
352  int size();
353 protected:
359  void resourceChanged(QString resourceName, ResourceChangeType changeType);
366 };
367 
372 class FARSA_EXPERIMENTS_API iCubHeadMusclesMotor : public iCubMotor {
373 public:
378  iCubHeadMusclesMotor( ConfigurationParameters& params, QString prefix );
385  void save( ConfigurationParameters& params, QString prefix );
387  static void describe( QString type );
389  void update();
391  int size();
392 protected:
398  void resourceChanged(QString resourceName, ResourceChangeType changeType);
405 };
406 
411 class FARSA_EXPERIMENTS_API iCubArmPosToVelMotor : public iCubMotor {
412 public:
417  iCubArmPosToVelMotor( ConfigurationParameters& params, QString prefix );
424  void save( ConfigurationParameters& params, QString prefix );
426  static void describe( QString type );
428  void update();
430  int size();
431 protected:
437  void resourceChanged(QString resourceName, ResourceChangeType changeType);
439  QString icubArm;
446 };
447 
452 class FARSA_EXPERIMENTS_API iCubTorsoPosToVelMotor : public iCubMotor {
453 public:
458  iCubTorsoPosToVelMotor( ConfigurationParameters& params, QString prefix );
465  void save( ConfigurationParameters& params, QString prefix );
467  static void describe( QString type );
469  void update();
471  int size();
472 protected:
478  void resourceChanged(QString resourceName, ResourceChangeType changeType);
485 };
486 
491 class FARSA_EXPERIMENTS_API iCubHeadPosToVelMotor : public iCubMotor {
492 public:
497  iCubHeadPosToVelMotor( ConfigurationParameters& params, QString prefix );
504  void save( ConfigurationParameters& params, QString prefix );
506  static void describe( QString type );
508  void update();
510  int size();
511 protected:
517  void resourceChanged(QString resourceName, ResourceChangeType changeType);
524 };
525 
530 class FARSA_EXPERIMENTS_API iCubHandPosToVelMotor : public iCubMotor {
531 public:
536  iCubHandPosToVelMotor( ConfigurationParameters& params, QString prefix );
543  void save( ConfigurationParameters& params, QString prefix );
545  static void describe( QString type );
547  void update();
549  int size();
550 protected:
556  void resourceChanged(QString resourceName, ResourceChangeType changeType);
558  QString icubHand;
565 };
566 
607 class FARSA_EXPERIMENTS_API iCubConfigurableHandPosToVelMotor : public iCubMotor
608 {
609 public:
618 
623 
632  virtual void save(ConfigurationParameters& params, QString prefix);
633 
639  static void describe(QString type);
640 
645  virtual void update();
646 
652  virtual int size();
653 
654 private:
662  virtual void resourceChanged(QString resourceName, ResourceChangeType changeType);
663 
667  QString m_icubHand;
668 
675  QVector<QVector<int> > m_jointsGroups;
676 
683  double m_maxClosure;
684 
688  MultiMotorController* m_armController;
689 
694  ProportionalController m_pcontrol;
695 };
696 
712 class FARSA_EXPERIMENTS_API iCubHeadVelocityMotor : public iCubMotor
713 {
714 public:
722  iCubHeadVelocityMotor(ConfigurationParameters& params, QString prefix);
723 
728 
737  virtual void save(ConfigurationParameters& params, QString prefix);
738 
744  static void describe(QString type);
745 
750  virtual void update();
751 
757  virtual int size();
758 
759 private:
768  virtual void resourceChanged(QString resourceName, ResourceChangeType changeType);
769 
773  MultiMotorController* m_headNeckController;
774 };
775 
781 class FARSA_EXPERIMENTS_API iCubArmVelocityMotor : public iCubMotor {
782 public:
787  iCubArmVelocityMotor( ConfigurationParameters& params, QString prefix );
794  void save( ConfigurationParameters& params, QString prefix );
796  static void describe( QString type );
798  void update();
800  int size();
801 protected:
807  void resourceChanged(QString resourceName, ResourceChangeType changeType);
809  QString icubArm;
817  bool is7Dof;
819  double maxVelocity;
820 };
821 
827 class FARSA_EXPERIMENTS_API iCubTorsoVelocityMotor : public iCubMotor {
828 public:
833  iCubTorsoVelocityMotor( ConfigurationParameters& params, QString prefix );
840  void save( ConfigurationParameters& params, QString prefix );
842  static void describe( QString type );
844  void update();
846  int size();
847 protected:
853  void resourceChanged(QString resourceName, ResourceChangeType changeType);
859  bool torsoDofs[3];
861  double maxVelocity;
862 };
863 
864 } // end namespace farsa
865 
866 #endif
867 
868 #endif