Hekateros  3.4.3
RoadNarrows Robotics Robot Arm Project
hekJoint.h
Go to the documentation of this file.
1 ////////////////////////////////////////////////////////////////////////////////
2 //
3 // Package: Hekateros
4 //
5 // Library: libhekateros
6 //
7 // File: hekJoint.h
8 //
9 /*! \file
10  *
11  * $LastChangedDate: 2014-11-18 14:31:49 -0700 (Tue, 18 Nov 2014) $
12  * $Rev: 3810 $
13  *
14  * \brief Hekateros joint classes interfaces.
15  *
16  * Data classes to hold description and state information.
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_JOINT_H
52 #define _HEK_JOINT_H
53 
54 #include <string>
55 #include <vector>
56 #include <map>
57 
58 #include "rnr/rnrconfig.h"
59 
60 #include "Hekateros/hekateros.h"
61 #include "Hekateros/hekOptical.h"
62 
63 namespace hekateros
64 {
65  //
66  // Forward declarations
67  //
68  class HekRobot;
69 
70  // ---------------------------------------------------------------------------
71  // Class HekRobotJoint
72  // ---------------------------------------------------------------------------
73 
74  /*!
75  * \brief Operational robotic joint description class.
76  *
77  * This class contains all of the data necessary to control the operation
78  * of an \h_hek robotic joint.
79  */
81  {
82  public:
83  /*!
84  * \brief Default constructor.
85  */
86  HekRobotJoint();
87 
88  /*!
89  * \brief Copy constructor.
90  */
91  HekRobotJoint(const HekRobotJoint &src);
92 
93  /*!
94  * \brief Destructor.
95  */
97 
98  /*!
99  * \brief Assignment operator.
100  *
101  * \param rhs Right hand side object.
102  *
103  * \return Returns copy of this.
104  */
106 
107  /*!
108  * \brief Get joint name.
109  *
110  * \return String.
111  */
112  std::string getJointName() const
113  {
114  return m_strName;
115  }
116 
117  /*!
118  * \brief Get master servo id.
119  *
120  * \return Returns servo id.
121  */
122  int getMasterServoId() const
123  {
124  return m_nMasterServoId;
125  }
126 
127  /*!
128  * \brief Set auto-stop at joint electronic limits state.
129  *
130  * \param bStopAtLimits Do [not] auto-stop at limits.
131  */
132  void setStopAtLimitsState(bool bStopAtLimits)
133  {
134  m_bStopAtOptLimits = bStopAtLimits;
135  }
136 
137  /*!
138  * \brief Get auto-stop at joint electronic limits state.
139  *
140  * \return Returns true or false.
141  */
142  bool doStopAtLimits() const
143  {
144  return m_bStopAtOptLimits;
145  }
146 
147  protected:
148  // (derived) specification
149  std::string m_strName; ///< joint name
150  int m_nMasterServoId; ///< master servo id
151  int m_nSlaveServoId; ///< linked slave servo id (if any)
152  bool m_bIsServoContinuous; ///< servo should [not] be continuous mode
153  int m_nMasterServoDir; ///< master servo normalized direction
154  int m_eJointType; ///< joint type
155  double m_fGearRatio; ///< joint gear ratio
156  double m_fTicksPerServoRad; ///< encoder/odom. ticks per servo radian
157  double m_fTicksPerJointRad; ///< encoder/odom. ticks per joint radian
158  double m_fMaxServoRadsPerSec;///< maximum servo radians per second
159  double m_fMaxJointRadsPerSec;///< maximum joint radians per second
160 
161  // discovered limits and positions
162  double m_fMinPhyLimitRads; ///< joint min physical limit (radians)
163  double m_fMaxPhyLimitRads; ///< joint max physical limit (radians)
164  int m_nMinPhyLimitOd; ///< joint min phys limit (odometer ticks)
165  int m_nMaxPhyLimitOd; ///< joint max phys limit (odometer ticks)
166  double m_fMinSoftLimitRads; ///< joint min soft limit (radians)
167  double m_fMaxSoftLimitRads; ///< joint max soft limit (radians)
168  int m_nMinSoftLimitOd; ///< joint min soft limit (odometer ticks)
169  int m_nMaxSoftLimitOd; ///< joint max soft limit (odometer ticks)
170  double m_fCalibPosRads; ///< joint calibrated position (radians)
171  double m_fBalPosRads; ///< joint balanced position (radians)
172  double m_fParkPosRads; ///< joint parked position (radians)
173  int m_eLimitTypes; ///< joint limit types
174  double m_fOverTorqueThDft; ///< joint over torque th default (norm).
176  ///< optical limit mask array
177 
178  // state
179  HekOpState m_eOpState; ///< current operational state
180  bool m_bStopAtOptLimits; ///< do [not] stop at optical limits
181 
182  // who isn't a friend of Mr. Loosey Joint?
183  friend class HekRobot;
184  friend class HekKinJoint;
185  friend class HekKinJointWristRot;
186  friend class HekMonitor;
187  friend class HekCalibStretch;
188  friend class HekXmlTune;
189  };
190 
191  /*!
192  * \brief Map of robot joints.
193  *
194  * \termblock
195  * \term key: \termdata master servo id \endterm
196  * \term mapped type: \termdata joint data \endterm
197  * \endtermblock
198  *
199  * \note Joint order is critical. Ascending servo ids keeps map in order,
200  * but if this cannot be guaranteed, then change strategy.
201  */
202  typedef std::map<int, HekRobotJoint> MapRobotJoints;
203 
204 
205  // ---------------------------------------------------------------------------
206  // Class HekJointOptical
207  // ---------------------------------------------------------------------------
208 
209  /*!
210  * \brief Operational robotic joint optical limits class.
211  *
212  * This class contains all of the data necessary to control the operation
213  * of the robotic joint optical limits triggers.
214  */
216  {
217  public:
218  /*!
219  * \brief Default constructor.
220  */
222  {
223  m_uMask = 0x00;
224  m_uCurVal = 0x00;
225  m_pJoint = NULL;
226 
227  m_limit.clear();
228  }
229 
230  /*!
231  * \brief Copy constructor.
232  */
234  {
235  m_uMask = src.m_uMask;
236  m_uCurVal = src.m_uCurVal;
237  m_pJoint = src.m_pJoint;
238  m_limit = src.m_limit;
239  }
240 
241  /*!
242  * \brief Destructor.
243  */
245  {
246  }
247 
248  /*!
249  * \brief Assignment operator.
250  *
251  * \param rhs Right hand side object.
252  *
253  * \return Returns copy of this.
254  */
256  {
257  m_uMask = rhs.m_uMask;
258  m_uCurVal = rhs.m_uCurVal;
259  m_pJoint = rhs.m_pJoint;
260  m_limit = rhs.m_limit;
261 
262  return *this;
263  }
264 
265  protected:
266  byte_t m_uMask; ///< i/o expander bit mask
267  byte_t m_uCurVal; ///< i/o expander current bit value
268  HekRobotJoint *m_pJoint; ///< limit switch associated robotic joint
269  HekOpticalLimit_T m_limit; ///< optical limit info
270 
271  friend class HekRobot;
272  friend class HekMonitor;
273  friend class HekCalib;
274  friend class HekCalibStretch;
275  };
276 
277 
278  // ---------------------------------------------------------------------------
279  // Class HekJointState
280  // ---------------------------------------------------------------------------
281 
282  /*!
283  * \brief Joint state class.
284  *
285  * This class encapsulates the current state of one joint.
286  */
288  {
289  public:
290  /*!
291  * \brief Default constructor.
292  */
293  HekJointState();
294 
295  /*!
296  * \brief Copy constructor.
297  */
298  HekJointState(const HekJointState &src);
299 
300  /*!
301  * \brief Destructor.
302  */
304  {
305  }
306 
307  /*!
308  * \brief Assignment operator.
309  *
310  * \param rhs Right hand side object.
311  *
312  * \return Returns copy of this.
313  */
315 
316  std::string m_strName; ///< joint name
317  HekOpState m_eOpState; ///< joint operational state
318  int m_nMasterServoId; ///< master servo id
319  int m_nSlaveServoId; ///< linked slave servo id (if any)
320  double m_fPosition; ///< current joint position (radians)
321  double m_fVelocity; ///< current joint velocity (% of max)
322  double m_fEffort; ///< current joint effort (servo load)
323  int m_nOdPos; ///< current master servo odometer pos (ticks)
324  int m_nEncPos; ///< current master servo encoder pos (ticks)
325  int m_nSpeed; ///< current master servo raw speed (unitless)
327  ///< current state of optical switch(es)
328  };
329 
330 
331  // ---------------------------------------------------------------------------
332  // Class HekJointStatePoint
333  // ---------------------------------------------------------------------------
334 
335  /*!
336  * \brief Joint state point class.
337  *
338  * This class encapsulates the current state of all joints in a kinematic
339  * chain.
340  *
341  * A joint state point (J0, J1, ..., Jn-1) specifies the current dynamic
342  * state of a set of joints (kinematic chain) Ji, i=0,n-1.
343  */
345  {
346  public:
347  /*!
348  * \brief Default constructor.
349  */
351  {
352  }
353 
354  /*!
355  * \brief Copy constructor.
356  */
358  {
359  m_strKinName = src.m_strKinName;
360  m_jointState = src.m_jointState;
361  }
362 
363  /*!
364  * \brief Destructor.
365  */
367  {
368  }
369 
370  /*!
371  * \brief Assignment operator.
372  *
373  * \param rhs Right hand side object.
374  *
375  * \return Returns copy of this.
376  */
378  {
379  m_strKinName = rhs.m_strKinName;
380  m_jointState = rhs.m_jointState;
381 
382  return *this;
383  }
384 
385  /*!
386  * \brief Get the kinematic chain name.
387  *
388  * \return String.
389  */
390  std::string getKinematicChainName()
391  {
392  return m_strKinName;
393  }
394 
395  /*!
396  * \brief Set the kinematic chain name.
397  *
398  * \param String.
399  */
400  void setKinematicChainName(std::string strKinName)
401  {
402  m_strKinName = strKinName;
403  }
404 
405  /*!
406  * \brief Get the number of joint states in joint state point.
407  *
408  * \return Number of points.
409  */
410  size_t getNumPoints()
411  {
412  return m_jointState.size();
413  }
414 
415  /*!
416  * \brief Test if joint is a member of the joint state.
417  *
418  * \param strJointName Joint name.
419  *
420  * \return Returns true or false.
421  */
422  bool hasJoint(const std::string &strJointName);
423 
424  /*!
425  * \brief Append joint state to end of joint state point.
426  *
427  * \param jointState Joint state to append.
428  */
429  void append(const HekJointState &jointState)
430  {
431  m_jointState.push_back(jointState);
432  }
433 
434  /*!
435  * \brief Subscript operator to get reference to joint point at the
436  * given index.
437  *
438  * Big boy warranty. No out of bound checks are made.
439  *
440  * \param i Index.
441  *
442  * \return Joint state.
443  */
444  HekJointState &operator[](const size_t i)
445  {
446  return m_jointState[i];
447  }
448 
449  /*!
450  * \brief Key subscript operator to get reference to joint point at the
451  * given index.
452  *
453  * Big boy warranty. No out of bound checks are made.
454  *
455  * \param strJointName Joint name.
456  *
457  * \return Joint state.
458  */
459  HekJointState &operator[](const std::string &strJointName);
460 
461  /*!
462  * \brief Clear all state data.
463  */
464  void clear()
465  {
466  m_strKinName.clear();
467  m_jointState.clear();
468  }
469 
470  protected:
471  std::string m_strKinName; ///< name of kinematic chain
472  std::vector<HekJointState> m_jointState; ///< vector of joint states
473  };
474 
475 } // namespace hekateros
476 
477 
478 #endif // _HEK_JOINT_H
int m_nSlaveServoId
linked slave servo id (if any)
Definition: hekJoint.h:151
int getMasterServoId() const
Get master servo id.
Definition: hekJoint.h:122
Hekateros robotic manipulator calibration by stretching class.
HekRobotJoint * m_pJoint
limit switch associated robotic joint
Definition: hekJoint.h:268
void setStopAtLimitsState(bool bStopAtLimits)
Set auto-stop at joint electronic limits state.
Definition: hekJoint.h:132
HekRobotJoint operator=(const HekRobotJoint &rhs)
Assignment operator.
Definition: hekJoint.cxx:169
int m_nMaxSoftLimitOd
joint max soft limit (odometer ticks)
Definition: hekJoint.h:169
HekOpState m_eOpState
current operational state
Definition: hekJoint.h:179
double m_fMinSoftLimitRads
joint min soft limit (radians)
Definition: hekJoint.h:166
int m_nOdPos
current master servo odometer pos (ticks)
Definition: hekJoint.h:323
int m_eLimitTypes
joint limit types
Definition: hekJoint.h:173
HekJointStatePoint(const HekJointStatePoint &src)
Copy constructor.
Definition: hekJoint.h:357
Operational robotic joint description class.
Definition: hekJoint.h:80
int m_nSpeed
current master servo raw speed (unitless)
Definition: hekJoint.h:325
~HekJointOptical()
Destructor.
Definition: hekJoint.h:244
Optical limit switch.
Definition: hekOptical.h:148
<b><i>Hekateros</i></b> optical limit switches.
void clear()
Clear all state data.
Definition: hekJoint.h:464
double m_fTicksPerJointRad
encoder/odom. ticks per joint radian
Definition: hekJoint.h:157
double m_fTicksPerServoRad
encoder/odom. ticks per servo radian
Definition: hekJoint.h:156
double m_fMaxServoRadsPerSec
maximum servo radians per second
Definition: hekJoint.h:158
int m_eJointType
joint type
Definition: hekJoint.h:154
double m_fMaxJointRadsPerSec
maximum joint radians per second
Definition: hekJoint.h:159
double m_fPosition
current joint position (radians)
Definition: hekJoint.h:320
size_t getNumPoints()
Get the number of joint states in joint state point.
Definition: hekJoint.h:410
double m_fVelocity
current joint velocity (% of max)
Definition: hekJoint.h:321
~HekRobotJoint()
Destructor.
Definition: hekJoint.cxx:165
int m_nMinPhyLimitOd
joint min phys limit (odometer ticks)
Definition: hekJoint.h:164
int m_nMasterServoId
master servo id
Definition: hekJoint.h:150
HekJointState & operator[](const size_t i)
Subscript operator to get reference to joint point at the given index.
Definition: hekJoint.h:444
HekOpState m_eOpState
joint operational state
Definition: hekJoint.h:317
std::string getJointName() const
Get joint name.
Definition: hekJoint.h:112
double m_fParkPosRads
joint parked position (radians)
Definition: hekJoint.h:172
HekJointOptical operator=(const HekJointOptical &rhs)
Assignment operator.
Definition: hekJoint.h:255
void append(const HekJointState &jointState)
Append joint state to end of joint state point.
Definition: hekJoint.h:429
Hekateros powered joint dynamics and kinematics control class.
Definition: hekKinJoint.h:387
HekTriState
<b><i>Hekateros</i></b> tri-state type.
Definition: hekateros.h:479
int m_nMasterServoId
master servo id
Definition: hekJoint.h:318
double m_fCalibPosRads
joint calibrated position (radians)
Definition: hekJoint.h:170
double m_fMinPhyLimitRads
joint min physical limit (radians)
Definition: hekJoint.h:162
bool doStopAtLimits() const
Get auto-stop at joint electronic limits state.
Definition: hekJoint.h:142
byte_t m_uCurVal
i/o expander current bit value
Definition: hekJoint.h:267
bool m_bIsServoContinuous
servo should [not] be continuous mode
Definition: hekJoint.h:152
HekXmlTune <b><i>Hekateros</i></b> XML tuning class.
Definition: hekXmlTune.h:72
int m_nMinSoftLimitOd
joint min soft limit (odometer ticks)
Definition: hekJoint.h:168
int m_nMaxPhyLimitOd
joint max phys limit (odometer ticks)
Definition: hekJoint.h:165
~HekJointState()
Destructor.
Definition: hekJoint.h:303
std::string m_strKinName
name of kinematic chain
Definition: hekJoint.h:471
byte_t m_byOptLimitMask[HekOptLimitMaxPerJoint]
optical limit mask array
Definition: hekJoint.h:175
HekRobotJoint()
Default constructor.
Definition: hekJoint.cxx:74
HekOpState
Robot or joint operational states.
Definition: hekateros.h:516
bool m_bStopAtOptLimits
do [not] stop at optical limits
Definition: hekJoint.h:180
~HekJointStatePoint()
Destructor.
Definition: hekJoint.h:366
HekJointOptical(const HekJointOptical &src)
Copy constructor.
Definition: hekJoint.h:233
HekJointOptical()
Default constructor.
Definition: hekJoint.h:221
void setKinematicChainName(std::string strKinName)
Set the kinematic chain name.
Definition: hekJoint.h:400
std::map< int, HekRobotJoint > MapRobotJoints
Map of robot joints.
Definition: hekJoint.h:202
std::string m_strName
joint name
Definition: hekJoint.h:316
std::vector< HekJointState > m_jointState
vector of joint states
Definition: hekJoint.h:472
std::string m_strName
joint name
Definition: hekJoint.h:149
static const int HekOptLimitMaxPerJoint
max limits/joint
Definition: hekOptical.h:120
Hekateros robotic manipulator calibration abstract base class.
Definition: hekCalib.h:73
byte_t m_uMask
i/o expander bit mask
Definition: hekJoint.h:266
Top-level package include file.
double m_fMaxSoftLimitRads
joint max soft limit (radians)
Definition: hekJoint.h:167
double m_fBalPosRads
joint balanced position (radians)
Definition: hekJoint.h:171
int m_nSlaveServoId
linked slave servo id (if any)
Definition: hekJoint.h:319
int m_nMasterServoDir
master servo normalized direction
Definition: hekJoint.h:153
double m_fGearRatio
joint gear ratio
Definition: hekJoint.h:155
Joint state class.
Definition: hekJoint.h:287
Joint state point class.
Definition: hekJoint.h:344
<b><i>Hekateros</i></b> power, joint limits, and alarm monitoring class.
Definition: hekMonitor.h:100
Operational robotic joint optical limits class.
Definition: hekJoint.h:215
Hekateros robotic manipulator plus accesories class.
Definition: hekRobot.h:88
double m_fEffort
current joint effort (servo load)
Definition: hekJoint.h:322
double m_fMaxPhyLimitRads
joint max physical limit (radians)
Definition: hekJoint.h:163
HekJointStatePoint()
Default constructor.
Definition: hekJoint.h:350
int m_nEncPos
current master servo encoder pos (ticks)
Definition: hekJoint.h:324
std::string getKinematicChainName()
Get the kinematic chain name.
Definition: hekJoint.h:390
HekOpticalLimit_T m_limit
optical limit info
Definition: hekJoint.h:269
Special wrist rotation joint kinematics and dynamics class.
Definition: hekKinJoint.h:1143
The <b><i>Hekateros</i></b> namespace encapsulates all <b><i>Hekateros</i></b> related constructs...
Definition: hekateros.h:56
HekJointStatePoint operator=(const HekJointStatePoint &rhs)
Assignment operator.
Definition: hekJoint.h:377
double m_fOverTorqueThDft
joint over torque th default (norm).
Definition: hekJoint.h:174