icub-test
motorEncodersConsistency.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 _OPTICALENCODERSCONSISTENCY_H_
22 #define _OPTICALENCODERSCONSISTENCY_H_
23 
24 #include <string>
25 #include <yarp/robottestingframework/TestCase.h>
26 #include <yarp/dev/ControlBoardInterfaces.h>
27 #include <yarp/dev/PolyDriver.h>
28 #include <yarp/sig/Vector.h>
29 #include <yarp/sig/Matrix.h>
30 
80 class OpticalEncodersConsistency : public yarp::robottestingframework::TestCase {
81 public:
83  virtual ~OpticalEncodersConsistency();
84 
85  virtual bool setup(yarp::os::Property& property);
86 
87  virtual void tearDown();
88 
89  virtual void run();
90 
91  void goHome();
92  void setMode(int desired_mode);
93  void saveToFile(std::string filename, yarp::os::Bottle &b);
94 
95 private:
96  std::string getPath(const std::string& str);
97  std::string robotName;
98  std::string partName;
99  std::string plotString1;
100  std::string plotString2;
101  std::string plotString3;
102  std::string plotString4;
103 
104  yarp::sig::Vector jointsList;
105 
106  double tolerance;
107  bool plot_enabled;
108 
109  int n_part_joints;
110  int cycles;
111 
112  yarp::dev::PolyDriver *dd;
113  yarp::dev::IPositionControl *ipos;
114  yarp::dev::IControlMode *icmd;
115  yarp::dev::IInteractionMode *iimd;
116  yarp::dev::IEncoders *ienc;
117  yarp::dev::IMotorEncoders *imotenc;
118  yarp::dev::IMotor *imot;
119  yarp::dev::IRemoteVariables *ivar;
120 
121  yarp::sig::Vector zero_vector;
122  yarp::sig::Vector enc_jnt;
123  yarp::sig::Vector enc_jnt2mot;
124  yarp::sig::Vector enc_mot;
125  yarp::sig::Vector enc_mot2jnt;
126  yarp::sig::Vector vel_jnt;
127  yarp::sig::Vector vel_jnt2mot;
128  yarp::sig::Vector vel_mot;
129  yarp::sig::Vector vel_mot2jnt;
130  yarp::sig::Vector acc_jnt;
131  yarp::sig::Vector acc_jnt2mot;
132  yarp::sig::Vector acc_mot;
133  yarp::sig::Vector acc_mot2jnt;
134 
135  yarp::sig::Vector prev_enc_jnt;
136  yarp::sig::Vector prev_enc_jnt2mot;
137  yarp::sig::Vector prev_enc_mot;
138  yarp::sig::Vector prev_enc_mot2jnt;
139  yarp::sig::Vector prev_vel_jnt;
140  yarp::sig::Vector prev_vel_jnt2mot;
141  yarp::sig::Vector prev_vel_mot;
142  yarp::sig::Vector prev_vel_mot2jnt;
143  yarp::sig::Vector prev_acc_jnt;
144  yarp::sig::Vector prev_acc_jnt2mot;
145  yarp::sig::Vector prev_acc_mot;
146  yarp::sig::Vector prev_acc_mot2jnt;
147 
148  yarp::sig::Vector diff_enc_jnt;
149  yarp::sig::Vector diff_enc_jnt2mot;
150  yarp::sig::Vector diff_enc_mot;
151  yarp::sig::Vector diff_enc_mot2jnt;
152  yarp::sig::Vector diff_vel_jnt;
153  yarp::sig::Vector diff_vel_jnt2mot;
154  yarp::sig::Vector diff_vel_mot;
155  yarp::sig::Vector diff_vel_mot2jnt;
156  yarp::sig::Vector diff_acc_jnt;
157  yarp::sig::Vector diff_acc_jnt2mot;
158  yarp::sig::Vector diff_acc_mot;
159  yarp::sig::Vector diff_acc_mot2jnt;
160 
161  yarp::sig::Vector max;
162  yarp::sig::Vector min;
163  yarp::sig::Vector home;
164  yarp::sig::Vector speed;
165  yarp::sig::Vector gearbox;
166 
167  yarp::sig::Matrix matrix_arms;
168  yarp::sig::Matrix matrix_torso;
169  yarp::sig::Matrix matrix_legs;
170  yarp::sig::Matrix matrix_head;
171 
172  yarp::sig::Matrix matrix;
173  yarp::sig::Matrix inv_matrix;
174  yarp::sig::Matrix trasp_matrix;
175  yarp::sig::Matrix inv_trasp_matrix;
176 };
177 
178 #endif //_opticalEncoders_H
This tests checks if the motor encoder reading are consistent with the joint encoder readings.