icub-test
PositionControlAccuracyExternalPid.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 _POSITIONACCURACYEXTERNALPID_H_
22 #define _POSITIONACCURACYEXTERNALPID_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 <iCub/ctrl/math.h>
29 #include <iCub/ctrl/pids.h>
30 
62 class PositionControlAccuracyExernalPid : public yarp::robottestingframework::TestCase {
63 public:
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 executeCmd();
75  void setMode(int desired_mode);
76  void saveToFile(std::string filename, yarp::os::Bottle &b);
77 
78 private:
79  std::string m_robotName;
80  std::string m_partName;
81  int* m_jointsList;
82  int m_cycles;
83  double m_sampleTime;
84  double* m_zeros;
85  double m_step;
86  int m_n_part_joints;
87  int m_n_cmd_joints;
88  yarp::os::Bottle m_dataToSave;
89 
90  yarp::dev::PolyDriver *dd;
91  yarp::dev::IPositionControl *ipos;
92  yarp::dev::IControlMode *icmd;
93  yarp::dev::IInteractionMode *iimd;
94  yarp::dev::IEncoders *ienc;
95  yarp::dev::IPositionDirect *idir;
96  yarp::dev::IPWMControl *ipwm;
97 
98  iCub::ctrl::parallelPID *ppid;
99 
100  double m_pospid_vup;
101  double m_pospid_vdown;
102 
103 
104  double m_cmd_single;
105  double* m_encoders;
106  std::string m_requested_filename;
107  double m_home_tolerance;
108  double m_step_duration;
109 };
110 
111 #endif
This tests checks the response of the system to a position step, sending directly PWM commands to a j...