icub-test
All Data Structures Modules Pages
OpenloopConsistency.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 _OPENLOOPCONSISTENCY_H_
22 #define _OPENLOOPCONSISTENCY_H_
23 
24 #include <string>
25 #include <yarp/robottestingframework/TestCase.h>
26 #include <yarp/dev/ControlBoardInterfaces.h>
27 #include <yarp/dev/PolyDriver.h>
28 
29 class OpenLoopConsistency : public yarp::robottestingframework::TestCase {
30 public:
31  OpenLoopConsistency();
32  virtual ~OpenLoopConsistency();
33 
34  virtual bool setup(yarp::os::Property& property);
35 
36  virtual void tearDown();
37 
38  virtual void run();
39 
40  void goHome();
41  void executeCmd();
42  void setMode(int desired_control_mode, yarp::dev::InteractionModeEnum desired_interaction_mode);
43  void verifyMode(int desired_control_mode, yarp::dev::InteractionModeEnum desired_interaction_mode, std::string title);
44 
45  void setRefOpenloop(double value);
46  void verifyRefOpenloop(double value, std::string title);
47  void verifyOutputEqual(double value, std::string title);
48  void verifyOutputDiff(double value, std::string title);
49 
50 private:
51  std::string robotName;
52  std::string partName;
53  int* jointsList;
54 
55  double *home;
56  int n_part_joints;
57  int n_cmd_joints;
58  enum cmd_mode_t
59  {
60  single_joint = 0,
61  all_joints = 1,
62  some_joints =2
63  } cmd_mode;
64 
65  yarp::dev::PolyDriver *dd;
66  yarp::dev::IPositionControl *ipos;
67  yarp::dev::IAmplifierControl *iamp;
68  yarp::dev::IControlMode *icmd;
69  yarp::dev::IInteractionMode *iimd;
70  yarp::dev::IEncoders *ienc;
71  yarp::dev::IPWMControl *ipwm;
72 
73  double cmd_single;
74  double* cmd_tot;
75  double* cmd_some;
76 
77  double prevcurr_single;
78  double* prevcurr_tot;
79  double* prevcurr_some;
80 
81  double* pos_tot;
82 };
83 
84 #endif //_OPENLOOPCONSISTENCY_H_