icub-test
All Data Structures Modules Pages
MotorStiction.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 _MOTORSTICTION_H_
22 #define _MOTORSTICTION_H_
23 
24 #include <string>
25 #include <vector>
26 #include <yarp/robottestingframework/TestCase.h>
27 #include <yarp/dev/ControlBoardInterfaces.h>
28 #include <yarp/dev/PolyDriver.h>
29 #include <yarp/sig/Vector.h>
30 #include <yarp/os/Bottle.h>
31 #include <yarp/sig/Matrix.h>
32 
33 class stiction_data
34 {
35  public:
36  int jnt;
37  int cycle;
38  bool pos_test_passed;
39  bool neg_test_passed;
40  double pos_opl;
41  double neg_opl;
42 
43  public:
44  stiction_data() {jnt=0; cycle=0; pos_test_passed=false; neg_test_passed=false; pos_opl=0; neg_opl=0;}
45 };
46 
47 class MotorStiction : public yarp::robottestingframework::TestCase
48 {
49 public:
50  MotorStiction();
51  virtual ~MotorStiction();
52 
53  virtual bool setup(yarp::os::Property& property);
54 
55  virtual void tearDown();
56 
57  virtual void run();
58 
59  void goHome();
60  void setMode(int desired_control_mode, yarp::dev::InteractionModeEnum desired_interaction_mode);
61  void setModeSingle(int i, int desired_control_mode, yarp::dev::InteractionModeEnum desired_interaction_mode);
62  void verifyMode(int desired_control_mode, yarp::dev::InteractionModeEnum desired_interaction_mode, std::string title);
63  void saveToFile(std::string filename, yarp::os::Bottle &b);
64 
65  //ok if the joints moves of 5 degrees
66  void OplExecute(int i, std::vector<yarp::os::Bottle>& dataToPlotList, stiction_data& current_test, bool positive_sign);
67 
68  //ok if the joint reaches the hardware limit
69  void OplExecute2(int i, std::vector<yarp::os::Bottle>& dataToPlotList, stiction_data& current_test, bool positive_sign);
70 
71 private:
72  std::string robotName;
73  std::string partName;
74  int repeat;
75  std::vector<stiction_data> stiction_data_list;
76  yarp::sig::Vector jointsList;
77  yarp::sig::Vector home;
78  yarp::sig::Vector opl_step;
79  yarp::sig::Vector opl_max;
80  yarp::sig::Vector opl_delay;
81  yarp::sig::Vector movement_threshold;
82  yarp::sig::Vector max_lims;
83  yarp::sig::Vector min_lims;
84 
85  int n_part_joints;
86 
87  yarp::dev::PolyDriver *dd;
88  yarp::dev::IPositionControl *ipos;
89  yarp::dev::IAmplifierControl *iamp;
90  yarp::dev::IControlMode *icmd;
91  yarp::dev::IInteractionMode *iimd;
92  yarp::dev::IEncoders *ienc;
93  yarp::dev::IPWMControl *ipwm;
94  yarp::dev::IControlLimits *ilim;
95 };
96 
97 #endif //_MOTORSTICTION_H_