icubmotors.h
1 /********************************************************************************
2  * FARSA Experimentes Library *
3  * Copyright (C) 2007-2013 *
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);
486  bool torsoDofs[3];
487 };
488 
493 class FARSA_EXPERIMENTS_API iCubHeadPosToVelMotor : public iCubMotor {
494 public:
499  iCubHeadPosToVelMotor( ConfigurationParameters& params, QString prefix );
506  void save( ConfigurationParameters& params, QString prefix );
508  static void describe( QString type );
510  void update();
512  int size();
513 protected:
519  void resourceChanged(QString resourceName, ResourceChangeType changeType);
527  bool headDofs[6];
528 
529 };
530 
535 class FARSA_EXPERIMENTS_API iCubHandPosToVelMotor : public iCubMotor {
536 public:
541  iCubHandPosToVelMotor( ConfigurationParameters& params, QString prefix );
548  void save( ConfigurationParameters& params, QString prefix );
550  static void describe( QString type );
552  void update();
554  int size();
555 protected:
561  void resourceChanged(QString resourceName, ResourceChangeType changeType);
563  QString icubHand;
570 };
571 
612 class FARSA_EXPERIMENTS_API iCubConfigurableHandPosToVelMotor : public iCubMotor
613 {
614 public:
623 
628 
637  virtual void save(ConfigurationParameters& params, QString prefix);
638 
644  static void describe(QString type);
645 
650  virtual void update();
651 
657  virtual int size();
658 
659 private:
667  virtual void resourceChanged(QString resourceName, ResourceChangeType changeType);
668 
672  QString m_icubHand;
673 
680  QVector<QVector<int> > m_jointsGroups;
681 
688  double m_maxClosure;
689 
693  MultiMotorController* m_armController;
694 
699  ProportionalController m_pcontrol;
700 };
701 
717 class FARSA_EXPERIMENTS_API iCubHeadVelocityMotor : public iCubMotor
718 {
719 public:
727  iCubHeadVelocityMotor(ConfigurationParameters& params, QString prefix);
728 
733 
742  virtual void save(ConfigurationParameters& params, QString prefix);
743 
749  static void describe(QString type);
750 
755  virtual void update();
756 
762  virtual int size();
763 
764 private:
773  virtual void resourceChanged(QString resourceName, ResourceChangeType changeType);
774 
778  MultiMotorController* m_headNeckController;
779 };
780 
786 class FARSA_EXPERIMENTS_API iCubArmVelocityMotor : public iCubMotor {
787 public:
792  iCubArmVelocityMotor( ConfigurationParameters& params, QString prefix );
799  void save( ConfigurationParameters& params, QString prefix );
801  static void describe( QString type );
803  void update();
805  int size();
806 protected:
812  void resourceChanged(QString resourceName, ResourceChangeType changeType);
814  QString icubArm;
822  bool is7Dof;
824  double maxVelocity;
825 };
826 
832 class FARSA_EXPERIMENTS_API iCubTorsoVelocityMotor : public iCubMotor {
833 public:
838  iCubTorsoVelocityMotor( ConfigurationParameters& params, QString prefix );
845  void save( ConfigurationParameters& params, QString prefix );
847  static void describe( QString type );
849  void update();
851  int size();
852 protected:
858  void resourceChanged(QString resourceName, ResourceChangeType changeType);
864  bool torsoDofs[3];
866  double maxVelocity;
867 };
868 
869 } // end namespace farsa
870 
871 #endif
872 
873 #endif