icub-test
PositionControlAccuracy.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 _POSITIONACCURACY_H_
22 #define _POSITIONACCURACY_H_
23 
24 #include <string>
25 #include <yarp/robottestingframework/TestCase.h>
26 #include <yarp/dev/ControlBoardInterfaces.h>
27 #include <yarp/dev/PolyDriver.h>
28 
55 class PositionControlAccuracy : public yarp::robottestingframework::TestCase {
56 public:
58  virtual ~PositionControlAccuracy();
59 
60  virtual bool setup(yarp::os::Property& property);
61 
62  virtual void tearDown();
63 
64  virtual void run();
65 
66  bool goHome();
67  void executeCmd();
68  void setMode(int desired_mode);
69  void saveToFile(std::string filename, yarp::os::Bottle &b);
70 
71 private:
72  std::string m_robotName;
73  std::string m_partName;
74  int* m_jointsList;
75  int m_cycles;
76  double m_sampleTime;
77  double* m_zeros;
78  double m_step;
79  int m_n_part_joints;
80  int m_n_cmd_joints;
81  yarp::os::Bottle m_dataToSave;
82 
83  yarp::dev::PolyDriver *dd;
84  yarp::dev::IPositionControl *ipos;
85  yarp::dev::IControlMode *icmd;
86  yarp::dev::IInteractionMode *iimd;
87  yarp::dev::IEncoders *ienc;
88  yarp::dev::IPositionDirect *idir;
89  yarp::dev::IPidControl *ipid;
90 
91  double m_cmd_single;
92  double* m_encoders;
93  std::string m_requested_filename;
94  double m_home_tolerance;
95  double m_step_duration;
96  yarp::dev::Pid m_orig_pid;
97  yarp::dev::Pid m_new_pid;
98 };
99 
100 #endif
This tests checks the a position PID response, sending a step reference signal with a positionDirect ...