icub-test
opticalEncodersDrift.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 _OPTICALENCODERSDRIFT_H_
22 #define _OPTICALENCODERSDRIFT_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/os/Bottle.h>
30 #include <yarp/sig/Matrix.h>
31 
62 class OpticalEncodersDrift : public yarp::robottestingframework::TestCase {
63 public:
65  virtual ~OpticalEncodersDrift();
66 
67  virtual bool setup(yarp::os::Property& property);
68 
69  virtual void tearDown();
70 
71  virtual void run();
72 
73  bool goHome();
74  void setMode(int desired_mode);
75  bool saveToFile(const std::string &filename, const yarp::os::Bottle &b);
76 
77 private:
78  std::string robotName;
79  std::string partName;
80  yarp::sig::Vector jointsList;
81 
82  double tolerance;
83 
84  int n_part_joints;
85 
86  yarp::dev::PolyDriver *dd;
87  yarp::dev::IPositionControl *ipos;
88  yarp::dev::IControlMode *icmd;
89  yarp::dev::IInteractionMode *iimd;
90  yarp::dev::IEncoders *ienc;
91  yarp::dev::IMotorEncoders *imot;
92 
93  yarp::sig::Vector enc_jnt;
94  yarp::sig::Vector enc_mot;
95  yarp::sig::Vector home_enc_mot;
96  yarp::sig::Vector end_enc_mot;
97  yarp::sig::Vector err_enc_mot;
98 
99  int cycles;
100  yarp::sig::Vector max;
101  yarp::sig::Vector min;
102  yarp::sig::Vector home;
103  yarp::sig::Vector speed;
104 
105  bool plot; //if true, the test runs gnuplot utility at end of test.
106 };
107 
108 #endif //_opticalEncodersDRIFT_H
This tests checks if the relative encoders measurements are consistent over time, by performing cycli...