Hekateros  3.4.3
RoadNarrows Robotics Robot Arm Project
hekCalibStretch.h
Go to the documentation of this file.
1 ////////////////////////////////////////////////////////////////////////////////
2 //
3 // Package: Hekateros
4 //
5 // Library: libhekateros
6 //
7 // File: hekCalibStretch.h
8 //
9 /*! \file
10  *
11  * $LastChangedDate: 2015-02-11 14:47:16 -0700 (Wed, 11 Feb 2015) $
12  * $Rev: 3867 $
13  *
14  * \brief HekCalibStretch - Hekateros calibration by stretching class interface.
15  *
16  * Yawn. Gosh if feels good to stretch! Now where is my coffee?
17  *
18  * \author Robin Knight (robin.knight@roadnarrows.com)
19  *
20  * \copyright
21  * \h_copy 2013-2017. RoadNarrows LLC.\n
22  * http://www.roadnarrows.com\n
23  * All Rights Reserved
24  */
25 /*
26  * @EulaBegin@
27  *
28  * Unless otherwise stated explicitly, all materials contained are copyrighted
29  * and may not be used without RoadNarrows LLC's written consent,
30  * except as provided in these terms and conditions or in the copyright
31  * notice (documents and software) or other proprietary notice provided with
32  * the relevant materials.
33  *
34  * IN NO EVENT SHALL THE AUTHOR, ROADNARROWS LLC, OR ANY
35  * MEMBERS/EMPLOYEES/CONTRACTORS OF ROADNARROWS OR DISTRIBUTORS OF THIS SOFTWARE
36  * BE LIABLE TO ANY PARTY FOR DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR
37  * CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS
38  * DOCUMENTATION, EVEN IF THE AUTHORS OR ANY OF THE ABOVE PARTIES HAVE BEEN
39  * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
40  *
41  * THE AUTHORS AND ROADNARROWS LLC SPECIFICALLY DISCLAIM ANY WARRANTIES,
42  * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
43  * FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS ON AN
44  * "AS IS" BASIS, AND THE AUTHORS AND DISTRIBUTORS HAVE NO OBLIGATION TO
45  * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
46  *
47  * @EulaEnd@
48  */
49 ////////////////////////////////////////////////////////////////////////////////
50 
51 #ifndef _HEK_CALIB_STRETCH_H
52 #define _HEK_CALIB_STRETCH_H
53 
54 #include "Hekateros/hekateros.h"
55 #include "Hekateros/hekJoint.h"
56 #include "Hekateros/hekCalib.h"
57 
58 
59 namespace hekateros
60 {
61  //
62  // Forward declaraions.
63  //
64  class HekRobot;
65 
66  /*!
67  * \brief Hekateros robotic manipulator calibration by stretching class.
68  *
69  * The hekateros will do a choreographed sequence of moves to find the limits
70  * or top-dead-centers for all joints.
71  *
72  * \note It is best if the user places the arm in the upright position and
73  * with not obstructions in the workspace prior to executing sequence.
74  *
75  * \par Move Sequence:
76  * \li End effector open and close limits. (torque determines this range).
77  * \li Wrist rotation top dead center.
78  * \li Wrist pitch clockwise and counter-clockwise limits.
79  * \li Elbow clockwise and counter-clockwise limits.
80  * \li Shoulder clockwise and counter-clockwise limits.
81  * \li Base rotation top dead center.
82  */
83  class HekCalibStretch : public HekCalib
84  {
85  public:
86 
87  /*!
88  * \breif Default initialization constructor.
89  *
90  * \param robot Instance of \h_hek robot.
91  */
93  {
94  }
95 
96  /*!
97  * \breif Destructor.
98  */
99  virtual ~HekCalibStretch()
100  {
101  }
102 
103  /*!
104  * \brief Calibrate the \h_hek's robotic arm.
105  *
106  * \copydoc doc_return_std
107  */
108  virtual int calibrate();
109 
110  protected:
111  /*!
112  * \brief Calibrate a continuously rotating joint by top-dead-center
113  * electronic limits.
114  *
115  * The joint has optical limit switch(es) at defined location, typically
116  * at 0\h_deg and/or, at 180\h_deg. A small occlusion band triggers
117  * the (occludes) the switch(es).
118  *
119  * The joint is rotated until the electronic limits are triggered to find
120  * top-dead-center.
121  *
122  * When the joint calibration moves are finished, the joint is repositioned
123  * at its new home position.
124  *
125  * \par Heuristic:
126  * light = optical switch unoccluded (closed)\n
127  * dark = optical switch occluded (open)
128  * -# If starting in the light
129  * -# Rotate a small number of degrees in minimum direction.
130  * -# If light, rotate joint in the oposite direction 360\h_deg.
131  * -# If light, return with failure.
132  * -# Started in or moved to the dark.
133  * -# Now find an edge of occlusion band (dark to light).
134  * -# Move back to find opposite edge.
135  * -# Calculated center of band from both edge positions and rotate
136  * there.
137  * -# Rotate to 0\h_deg.
138  * -# Reset odometer.
139  * -# Return with success.
140  *
141  * \param joint Robotic joint to calibrate.
142  *
143  * \copydoc doc_return_std
144  */
145  virtual int calibrateJointTopDeadCenter(HekRobotJoint &joint);
146 
147  /*!
148  * \brief Calibrate a rovolute joint by electronic limits.
149  *
150  * The joint has an electronic limit switch and a occlusion band that marks
151  * the minimum and maximum rotation limits.
152  *
153  * The joint is rotated until the electronic limit are triggered to find
154  * these min,max limits.
155  *
156  * When the joint calibration moves are finished, the joint is repositioned
157  * at its new home position.
158  *
159  * \par Heuristic:
160  * light = optical switch unoccluded (closed)\n
161  * dark = optical switch occluded (open)
162  * -# If starting in the dark.
163  * -# Get the park position from spec to determine best guess direction.
164  * -# Try to rotate \e X degrees to find the light, stopping either when
165  * first light is detected, torqued limit is reached,
166  * or have rotated \e X\h_deg.
167  * -# If in the light, goto 4.
168  * -# Else if over torqued (probably at physical limit).
169  * -# Reverse rotate \e X degrees to find the light, stopping either
170  * when first light is detected, torqued limit is reached,
171  * or have rotated \e X\h_deg.
172  * -# If in the light, goto 4.
173  * -# Else cannot get out of the dark, return with failure.
174  * -# Else starting in the light.
175  * -# Rotate in minimum direction \e Y degrees to find the dark,
176  * stopping either when first dark is detected,
177  * torqued limit is reached,
178  * or have rotated \e Y\h_deg.
179  * -# If in the dark, goto 4.
180  * -# Else probably obstructed.
181  * -# While less than \e MAX tries.
182  * -# Rotate in maximum direction \e Y degrees to find the dark,
183  * stopping either when first dark is detected,
184  * torqued limit is reached,
185  * or have rotated \e Y\h_deg.
186  * -# If in the dark, goto 4.
187  * -# Else if have helpful parent joint (e.g. shoulder for elbow).
188  * -# Rotate parent joint position \e Z degrees.
189  * -# If no movement return with failure.
190  * -# Else break loop.
191  * -# Return with failure.
192  * -# Final Stage.
193  * -# Fine tune to find edge precisely.
194  * -# While less than \e MAX tries.
195  * -# Rotate to 0\h_deg.
196  * -# If reached 0\h_deg.
197  * -# Reset odometer.
198  * -# Return with success.
199  * -# Else if have helpful parent joint.
200  * -# Rotate parent joint position \e Z degrees.
201  * -# If no movement return with failure.
202  * -# Else break loop.
203  * -# Return with failure
204  *
205  * \param joint Robotic joint to calibrate.
206  *
207  * \copydoc doc_return_std
208  */
209  virtual int calibrateJointByLimits(HekRobotJoint &joint);
210 
211  /*!
212  * \brief Perform final calibration by limits calculations and movements.
213  *
214  * \param joint Robotic joint.
215  * \param byOptMask Joint optical limit bit mask;
216  * \param nEdge Which edge triggered limit switch. The minimum,
217  * unknown, or maximum leading edge is specified as
218  * \h_lt 0, 0, or \h_gt 0, respectively.
219  *
220  * \copydoc doc_return_std
221  */
222  virtual int calibByLimitsFinal(HekRobotJoint &joint,
223  byte_t byOptMask,
224  int nEdge);
225 
226  /*!
227  * \brief Calibrate joint by torque limits.
228  *
229  * The joint is rotated to its minimum and maximum physical end
230  * points. When the torque reaches a software defined limit, an endpoint
231  * is considered reached.
232  *
233  * From the joint specification and detected limits, the home position
234  * at 0\h_deg is fine tuned.
235  *
236  * When the joint calibration moves are finished, the joint is repositioned
237  * at its new home position.
238  *
239  * \par Heuristic:
240  * -# Rotate in minimum direction until torque limit reached.
241  * -# Mark position.
242  * -# Rotate in maximum direction until torque limit reached.
243  * -# Mark position.
244  * -# Calculate 0\h_deg based on expected min,max positions and detected
245  * min,max positions.
246  * -# Rotate to 0\h_deg.
247  * -# Reset odomter.
248  *
249  * \param joint Robotic joint to calibrate.
250  *
251  * \copydoc doc_return_std
252  */
253  virtual int calibrateJointByTorqueLimits(HekRobotJoint &joint);
254 
255  /*!
256  * \brief Calibrate joint by trust.
257  *
258  * The joint is assumed to be already position at zero degrees by the user.
259  *
260  * \param joint Robotic joint to calibrate.
261  *
262  * \copydoc doc_return_std
263  */
264  virtual int calibrateJointByTrust(HekRobotJoint &joint);
265 
266  /*!
267  * \brief Fine tune joint to top dead center of optical limit.
268  *
269  * The position of the joint must be in the dark, occluded region of a band
270  * prior to calling this function.
271  *
272  * \par TDC Fine Tuning:
273  * \verbatim
274  * fine tune step occlusion band
275  * _____________________
276  * 0 (start) | * |
277  * | * |
278  * 1 lit_edge_0 * <------ * |
279  * * | |
280  * 2 dark_edge_0 * ----> * |
281  * | * |
282  * 3 lit_edge_1 | * ----------------> *
283  * | | *
284  * 4 center | * <---------- *
285  * |___________________|
286  *
287  * \endverbatim
288  *
289  * \param joint Robotic joint.
290  * \param byOptMask Joint optical limit bit mask;
291  * \param nEdge Which edge triggered limit switch. The minimum,
292  * unknown, or maximum leading edge is specified as
293  * \h_lt 0, 0, or \h_gt 0, respectively.
294  * <b>Not used</b>
295  * \param [out] fPosition Difference of determined uncalibrated joint
296  * position at TDC and the designed TDC (radians).
297  *
298  * \copydoc doc_return_std
299  */
300  virtual int fineTuneTDC(HekRobotJoint &joint,
301  byte_t byOptMask,
302  int nEdge,
303  double &fPosition);
304 
305 
306  /*!
307  * \brief Fine tune joint to optical limit edge.
308  *
309  * \par Limit Fine Tuning:
310  * \verbatim
311  * fine tune step occlusion band
312  * _____________________
313  * 0 (start) | * |
314  * | * |
315  * 1 lit_edge * <------ * |
316  * * | |
317  * 2 dark_edge * ----> * |
318  * |___________________|
319  *
320  * Or:
321  *
322  * fine tune step occlusion band
323  * _____________________
324  * 0 start * | |
325  * * | |
326  * 2 dark_edge * ----> * |
327  * |___________________|
328  * \endverbatim
329  *
330  * \param joint Robotic joint.
331  * \param byOptMask Joint optical limit bit mask;
332  * \param nEdge Which edge triggered limit switch. The minimum,
333  * unknown, or maximum leading edge is specified as
334  * \h_lt 0, 0, or \h_gt 0, respectively.
335  * \param [out] fDeltaPos Delta position (radians) from current to zero
336  * point as determined by the optical limit.
337  *
338  * \copydoc doc_return_std
339  */
340  virtual int fineTuneLimit(HekRobotJoint &joint,
341  byte_t byOptMask,
342  int nEdge,
343  double &fDeltaPos);
344 
345  /*!
346  * \brief Calculate two joints' gear ratios.
347  *
348  * \param strJointName1 First joint.
349  * \apram strJointName2 Second joint.
350  *
351  * \return joint1 gear ratio to joint 2 gear ratio.
352  */
353  double calcJointRatios(const std::string &strJointName1,
354  const std::string &strJointName2);
355 
356 
357  /*!
358  * \brief Move joint until unoccluded optical limit position is detected.
359  *
360  * Since moving a given joint during calibration may result in large
361  * trajectory arcs, other joints may be reposition to minimize this effects.
362  *
363  * This call blocks until move is complete.
364  *
365  * \param strJointName Name of joint.
366  * \param nDir Direction indicator.
367  * \param fJointGoalPos Joint goal position (radians).
368  * \param fJointGoalVel Joint goal velocity (radians/second).
369  * \param byMask Mask of limits to check.
370  *
371  * \copydoc doc_return_std
372  */
373  virtual int multiMoveToLight(const std::string &strJointName,
374  int nDir,
375  double fJointGoalPos,
376  double fJointGoalVel,
377  byte_t byMask);
378 
379  /*!
380  * \brief Move joint until occluded optical limit position is detected.
381  *
382  * Since moving a given joint during calibration may result in large
383  * trajectory arcs, other joints may be reposition to minimize this effects.
384  *
385  * This call blocks until move is complete.
386  *
387  * \param strJointName Name of joint.
388  * \param nDir Direction indicator.
389  * \param fJointGoalPos Joint goal position (radians).
390  * \param fJointGoalVel Joint goal velocity (radians/second).
391  * \param byMask Mask of limits to check.
392  *
393  * \copydoc doc_return_std
394  */
395  virtual int multiMoveToDark(const std::string &strJointName,
396  int nDir,
397  double fJointGoalPos,
398  double fJointGoalVel,
399  byte_t byMask);
400 
401  /*!
402  * \brief Get the parent joint (and link) that could aid in calibration.
403  *
404  * Only a few joints serve this function.
405  *
406  * \param nChildServoId Child joint's master servo id.
407  *
408  * \return If parenet exists, returns pointer to parent joint.
409  * Otherwise returns NULL.
410  */
411  virtual HekRobotJoint *getHelpfulParentJoint(int nChildServoId);
412  };
413 
414 } // namespace hekateros
415 
416 #endif // _HEK_CALIB_STRETCH_H
HekCalib - Hekateros calibration abstract base class interface.
Hekateros robotic manipulator calibration by stretching class.
double calcJointRatios(const std::string &strJointName1, const std::string &strJointName2)
Calculate two joints&#39; gear ratios.
Operational robotic joint description class.
Definition: hekJoint.h:80
virtual int fineTuneLimit(HekRobotJoint &joint, byte_t byOptMask, int nEdge, double &fDeltaPos)
Fine tune joint to optical limit edge.
virtual int calibrateJointByLimits(HekRobotJoint &joint)
Calibrate a rovolute joint by electronic limits.
Hekateros joint classes interfaces.
virtual int multiMoveToDark(const std::string &strJointName, int nDir, double fJointGoalPos, double fJointGoalVel, byte_t byMask)
Move joint until occluded optical limit position is detected.
virtual int calibrate()
Calibrate the <b><i>Hekateros</i></b>&#39;s robotic arm.
Hekateros robotic manipulator calibration abstract base class.
Definition: hekCalib.h:73
Top-level package include file.
virtual int multiMoveToLight(const std::string &strJointName, int nDir, double fJointGoalPos, double fJointGoalVel, byte_t byMask)
Move joint until unoccluded optical limit position is detected.
virtual int calibrateJointTopDeadCenter(HekRobotJoint &joint)
Calibrate a continuously rotating joint by top-dead-center electronic limits.
virtual int fineTuneTDC(HekRobotJoint &joint, byte_t byOptMask, int nEdge, double &fPosition)
Fine tune joint to top dead center of optical limit.
virtual int calibrateJointByTrust(HekRobotJoint &joint)
Calibrate joint by trust.
virtual int calibByLimitsFinal(HekRobotJoint &joint, byte_t byOptMask, int nEdge)
Perform final calibration by limits calculations and movements.
Hekateros robotic manipulator plus accesories class.
Definition: hekRobot.h:88
virtual HekRobotJoint * getHelpfulParentJoint(int nChildServoId)
Get the parent joint (and link) that could aid in calibration.
HekCalibStretch(HekRobot &robot)
virtual int calibrateJointByTorqueLimits(HekRobotJoint &joint)
Calibrate joint by torque limits.
The <b><i>Hekateros</i></b> namespace encapsulates all <b><i>Hekateros</i></b> related constructs...
Definition: hekateros.h:56