icub-test
ControlModes.h
1 /*
2  * iCub Robot Unit Tests (Robot Testing Framework)
3  *
4  * Copyright (C) 2015-2019 Istituto Italiano di Tecnologia (IIT)
5  *
6  * This library is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Lesser General Public
8  * License as published by the Free Software Foundation; either
9  * version 2.1 of the License, or (at your option) any later version.
10  *
11  * This library is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14  * Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public
17  * License along with this library; if not, write to the Free Software
18  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19  */
20 
21 #ifndef _CONTROLMODES_H_
22 #define _CONTROLMODES_H_
23 
24 #include <string>
25 #include <yarp/robottestingframework/TestCase.h>
26 #include <yarp/dev/ControlBoardInterfaces.h>
27 #include <yarp/dev/PolyDriver.h>
28 
53 class ControlModes : public yarp::robottestingframework::TestCase {
54 public:
55  ControlModes();
56  virtual ~ControlModes();
57 
58  virtual bool setup(yarp::os::Property& property);
59 
60  virtual void tearDown();
61 
62  virtual void run();
63 
64  void goHome();
65  void executeCmd();
66  void setMode(int desired_control_mode, yarp::dev::InteractionModeEnum desired_interaction_mode);
67  void verifyMode(int desired_control_mode, yarp::dev::InteractionModeEnum desired_interaction_mode, std::string title);
68  void verifyAmplifier(int desired_amplifier_mode, std::string title);
69 
70  void zeroCurrentLimits();
71  void getOriginalCurrentLimits();
72  void resetOriginalCurrentLimits();
73  void verifyModeSingle(int joint, int desired_control_mode, yarp::dev::InteractionModeEnum desired_interaction_mode, std::string title);
74  void setModeSingle(int joint, int desired_control_mode, yarp::dev::InteractionModeEnum desired_interaction_mode);
75  void checkJointWithTorqueMode();
76  void checkControlModeWithImCompliant(int desired_control_mode, std::string title);
77 
78 private:
79  std::string robotName;
80  std::string partName;
81  int* jointsList;
82  int* jointTorqueCtrlEnabled;
83 
84  double *home_pos;
85  int n_part_joints;
86  int n_cmd_joints;
87  double tolerance;
88  enum cmd_mode_t
89  {
90  single_joint = 0,
91  all_joints = 1,
92  some_joints =2
93  } cmd_mode;
94 
95  yarp::dev::PolyDriver *dd;
96  yarp::dev::IPositionControl *ipos;
97  yarp::dev::IAmplifierControl *iamp;
98  yarp::dev::IControlMode *icmd;
99  yarp::dev::IInteractionMode *iimd;
100  yarp::dev::IEncoders *ienc;
101  yarp::dev::IPositionDirect *idir;
102  yarp::dev::IVelocityControl *ivel;
103  yarp::dev::ITorqueControl *itrq;
104  yarp::dev::IRemoteVariables *ivar;
105 
106  double cmd_single;
107  double* cmd_tot;
108  double* cmd_some;
109 
110  double prevcurr_single;
111  double* prevcurr_tot;
112  double* prevcurr_some;
113 
114  double* pos_tot;
115 };
116 
117 #endif //_CONTROLMODES_H
The test checks if the joint is able to go in all the available control/interaction modes and if tran...
Definition: ControlModes.h:53