iCub-main
Loading...
Searching...
No Matches
parametricCalibratorEth.h
Go to the documentation of this file.
1// -*- mode:C++; tab-width:4; c-basic-offset:4; indent-tabs-mode:nil -*-
2
3/*
4 * Copyright (C) 20014 iCub Facility, Istituto Italiano di Tecnologia
5 *
6 * Authors: Alberto Cardellino, Marco Randazzo, Valentina Gaggero
7 *
8 * CopyPolicy: Released under the terms of the LGPLv2.1 or later, see LGPL.TXT
9 *
10 */
11
12
13#ifndef __ICUB_PARAMETRIC_CALIBRATOR__
14#define __ICUB_PARAMETRIC_CALIBRATOR__
15
16#include <list>
17#include <string>
18#include <atomic>
19#include <vector>
20#include <yarp/dev/PolyDriver.h>
21#include <yarp/dev/CalibratorInterfaces.h>
22#include <yarp/dev/ControlBoardInterfaces.h>
23
24namespace yarp {
25 namespace dev
26 {
27 class parametricCalibratorEth;
28 }
29}
30
42class yarp::dev::parametricCalibratorEth : public ICalibrator, public DeviceDriver, public IRemoteCalibrator
43{
44public:
49
54
61 bool calibrate(DeviceDriver *device) override;
62
69 virtual bool open (yarp::os::Searchable& config) override;
70
75 virtual bool close () override;
76
77 virtual bool park(DeviceDriver *dd, bool wait=true) override;
78
79 virtual bool quitPark() override;
80
81 virtual bool quitCalibrate() override;
82
83 // IRemoteCalibrator
84
85 virtual yarp::dev::IRemoteCalibrator *getCalibratorDevice() override;
86
87 virtual bool calibrateSingleJoint(int j) override;
88
89 virtual bool calibrateWholePart() override;
90
91 virtual bool homingSingleJoint(int j) override;
92
93 virtual bool homingWholePart() override;
94
95 virtual bool parkSingleJoint(int j, bool _wait=true) override;
96
97 virtual bool parkWholePart() override;
98
99private:
100
101 // helper struct
102 struct PositionSequence
103 {
104 int seq_num{0}; // progressive number indicating sequence ID
105 std::vector<double> positions; // vector of positions, one for each joint
106 std::vector<double> velocities; // vector of velocities, one for each joint
107 };
108
109 bool calibrate();
110 bool calibrateJoint(int j);
111 bool goToStartupPosition(int j);
112 bool checkCalibrateJointEnded(std::list<int> set);
113 bool checkGoneToZeroThreshold(int j);
114 bool checkHwFault();
115
116
117 yarp::dev::PolyDriver *dev2calibrate;
118 yarp::dev::IControlCalibration *iCalibrate;
119 yarp::dev::IPidControl *iPids;
120 yarp::dev::IEncoders *iEncoders;
121 yarp::dev::IPositionControl *iPosition;
122 yarp::dev::IControlMode *iControlMode;
123 yarp::dev::IAmplifierControl *iAmp;
124
125 std::list<std::list<int> > joints;
126
127 int n_joints;
128
129 yarp::dev::CalibrationParameters* calibParams;
130 int *startupMaxPWM;
131 double *currPos;
132 double *currVel;
133 double *original_max_pwm;
134 double *limited_max_pwm;
135
136 double *startupPosThreshold;
137 PositionSequence legacyStartupPosition; // upgraded old array to new struct; to be removed when old method will be deprecated
138 PositionSequence legacyParkingPosition; // upgraded old array to new struct; to be removed when old method will be deprecated
139
140 bool abortCalib;
141 bool abortParking;
142 std::atomic<bool> isCalibrated;
143 bool skipCalibration;
144 int *disableHomeAndPark;
145 int *disableStartupPosCheck;
146 bool clearHwFault;
147
148 int *timeout_goToZero;
149 int *timeout_calibration;
150
151 int totJointsToCalibrate;
152 std::string deviceName;
153 yarp::os::Bottle calibJointsString; // joints handled by this caibrator as a string for error messages
154 std::list<int> calibJoints; // joints handled by this caibrator as a list
155
156 // store the positions for a custom parking sequence
157 int currentParkingSeq_step;
158 std::vector<PositionSequence> parkingSequence;
159 bool useLegacyParking; // calibrator is using new parking sequence
160 bool parseSequenceGroup(yarp::os::Searchable &config, std::string sequence, std::vector<PositionSequence> &seqList);
161 bool moveAndCheck(PositionSequence &data);
162
163 // to be removed
164 bool moveAndCheck_legacy(PositionSequence &data, std::vector<bool> &cannotPark, bool wait);
165};
166#endif
@ data
parametricCalibrator: implement calibration routines for the iCub arm(s) (version 1....
virtual bool park(DeviceDriver *dd, bool wait=true) override
virtual bool open(yarp::os::Searchable &config) override
Open the device driver.
virtual bool homingSingleJoint(int j) override
virtual bool calibrateSingleJoint(int j) override
virtual bool parkSingleJoint(int j, bool _wait=true) override
virtual bool close() override
Close the device driver.
virtual yarp::dev::IRemoteCalibrator * getCalibratorDevice() override
bool calibrate(DeviceDriver *device) override
Calibrate method.
Copyright (C) 2008 RobotCub Consortium.