Hekateros  3.4.3
RoadNarrows Robotics Robot Arm Project
hekSpec.h
Go to the documentation of this file.
1 ////////////////////////////////////////////////////////////////////////////////
2 //
3 // Package: Hekateros
4 //
5 // Library: libhekateros
6 //
7 // File: hekSpec.h
8 //
9 /*! \file
10  *
11  * $LastChangedDate: 2014-09-18 16:53:49 -0600 (Thu, 18 Sep 2014) $
12  * $Rev: 3748 $
13  *
14  * \brief \h_hek product specification base classes.
15  *
16  * \author Robin Knight (robin.knight@roadnarrows.com)
17  *
18  * \copyright
19  * \h_copy 2013-2017. RoadNarrows LLC.\n
20  * http://www.roadnarrows.com\n
21  * All Rights Reserved
22  */
23 /*
24  * @EulaBegin@
25  *
26  * Unless otherwise stated explicitly, all materials contained are copyrighted
27  * and may not be used without RoadNarrows LLC's written consent,
28  * except as provided in these terms and conditions or in the copyright
29  * notice (documents and software) or other proprietary notice provided with
30  * the relevant materials.
31  *
32  * IN NO EVENT SHALL THE AUTHOR, ROADNARROWS LLC, OR ANY
33  * MEMBERS/EMPLOYEES/CONTRACTORS OF ROADNARROWS OR DISTRIBUTORS OF THIS SOFTWARE
34  * BE LIABLE TO ANY PARTY FOR DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR
35  * CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS
36  * DOCUMENTATION, EVEN IF THE AUTHORS OR ANY OF THE ABOVE PARTIES HAVE BEEN
37  * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
38  *
39  * THE AUTHORS AND ROADNARROWS LLC SPECIFICALLY DISCLAIM ANY WARRANTIES,
40  * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
41  * FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS ON AN
42  * "AS IS" BASIS, AND THE AUTHORS AND DISTRIBUTORS HAVE NO OBLIGATION TO
43  * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
44  *
45  * @EulaEnd@
46  */
47 ////////////////////////////////////////////////////////////////////////////////
48 
49 #ifndef _HEK_SPEC_H
50 #define _HEK_SPEC_H
51 
52 #include <string>
53 #include <vector>
54 
55 #include "rnr/rnrconfig.h"
56 
57 #include "Dynamixel/Dynamixel.h"
58 
59 #include "Hekateros/hekateros.h"
60 #include "Hekateros/hekOptical.h"
61 
62 namespace hekateros
63 {
64  //
65  // Forward declarations.
66  //
67  class HekDesc;
68  class HekRobot;
69 
70  /*!
71  * \brief Supported joint types.
72  */
74  {
75  HekJointTypeUnknown = 0, ///< unknown/undefined joint type
76  HekJointTypeFixed, ///< fixed joint
77  HekJointTypeRevolute, ///< limited rotation
78  HekJointTypeContinuous, ///< continuous rotation
79  HekJointTypeRevMimic, ///< mimic rotation (e.g. fingers)
80 
81  HekJointTypeNumOf = 4 ///< number of supported joint types
82  };
83 
84  /*!
85  * \brief Joint limit detection types.
86  *
87  * A joint may have more than one type.
88  */
90  {
91  HekLimitTypeUnknown = 0x00, ///< unknown/undefined joint type
92  HekLimitTypeNone = 0x01, ///< no limit detection
93  HekLimitTypePhys = 0x02, ///< physical
94  HekLimitTypeElec = 0x04, ///< electronic
95  HekLimitTypeElecTDC = 0x08, ///< electronic top dead center
96  HekLimitTypeAbsEnc = 0x10, ///< absolute encoder
97 
98  HekLimitTypeNumOf = 5 ///< number of supported joint types
99  };
100 
101  // ---------------------------------------------------------------------------
102  // Struct HekSpecLink_T
103  // ---------------------------------------------------------------------------
104 
105  /*!
106  * \brief Robotic link specification.
107  */
109  {
110  /*!
111  * \brief Assignment operator.
112  *
113  * \note May add weights, cogs, etc.
114  *
115  * \param rhs Right hand side object.
116  *
117  * \return this.
118  */
120  {
121  m_strName = rhs.m_strName;
122  m_fLength = rhs.m_fLength;
123 
124  return *this;
125  }
126 
127  std::string m_strName; ///< link name
128  double m_fLength; ///< link length (mm)
129  };
130 
131 
132  // ---------------------------------------------------------------------------
133  // Struct HekSpecJoint_T
134  // ---------------------------------------------------------------------------
135 
136  /*!
137  * \brief Robotic joint specification.
138  */
140  {
141  /*!
142  * \brief Assignment operator.
143  *
144  * \param rhs Right hand side object.
145  *
146  * \return this.
147  */
149  {
150  int i;
151 
152  m_strName = rhs.m_strName;
153  m_nMasterServoId = rhs.m_nMasterServoId;
154  m_nSlaveServoId = rhs.m_nSlaveServoId;
155  m_eJointType = rhs.m_eJointType;
156  m_fGearRatio = rhs.m_fGearRatio;
157  m_fMinPhyLimit = rhs.m_fMinPhyLimit;
158  m_fMaxPhyLimit = rhs.m_fMaxPhyLimit;
159  m_eLimitTypes = rhs.m_eLimitTypes;
160  m_fCalibPos = rhs.m_fCalibPos;
161  m_fBalancedPos = rhs.m_fBalancedPos;
162  m_fParkedPos = rhs.m_fParkedPos;
163  m_nLinkParent = rhs.m_nLinkParent;
164  m_nLinkChild = rhs.m_nLinkChild;
165 
166  for(i=0; i<HekOptLimitMaxPerJoint; ++i)
167  {
168  m_limit[i] = rhs.m_limit[i];
169  }
170 
171  return *this;
172  }
173 
174  std::string m_strName; ///< joint name
175  int m_nMasterServoId; ///< master servo id
176  int m_nSlaveServoId; ///< linked slave servo id, if any
177  int m_eJointType; ///< joint type
178  double m_fGearRatio; ///< joint gear ratio
179  double m_fMinPhyLimit; ///< joint minimum physical limit (degrees)
180  double m_fMaxPhyLimit; ///< joint maximum physical limit (degrees)
181  int m_eLimitTypes; ///< joint limit types
183  ///< optical limits
184  double m_fCalibPos; ///< joint calibrated position (degrees)
185  double m_fBalancedPos; ///< joint balanced position (degrees)
186  double m_fParkedPos; ///< joint parked position (degrees)
187  int m_nLinkParent; ///< parent link index
188  int m_nLinkChild; ///< child link index
189  };
190 
191 
192  // ---------------------------------------------------------------------------
193  // Struct HekSpecServo_T
194  // ---------------------------------------------------------------------------
195 
196  /*!
197  * \brief Robotic servo specification.
198  */
200  {
201  /*!
202  * \brief Assignment operator.
203  *
204  * \param rhs Right hand side object.
205  *
206  * \return this.
207  */
209  {
210  m_nServoId = rhs.m_nServoId;
211  m_bMaster = rhs.m_bMaster;
212  m_bIsContinuous = rhs.m_bIsContinuous;
213  m_nDir = rhs.m_nDir;
214  m_fTorqueLimitPct = rhs.m_fTorqueLimitPct;
215  }
216 
217  int m_nServoId; ///< servo id
218  bool m_bMaster; ///< servo is [not] master in doulbe servo joints
219  bool m_bIsContinuous; ///< servo should [not] be configured in 360 mode
220  int m_nDir; ///< normalize cw/ccw direction.
221  double m_fTorqueLimitPct;///< torque limit(%). Set to 0 for no limit
222  };
223 
224 
225  // ---------------------------------------------------------------------------
226  // Class HekSpec
227  // ---------------------------------------------------------------------------
228 
229  /*!
230  * \brief Robotic specification.
231  */
232  class HekSpec
233  {
234  public:
235  /*!
236  * \brief Constructor.
237  */
238  HekSpec();
239 
240  /*!
241  * \brief Destructor.
242  */
243  ~HekSpec();
244 
245  /*!
246  * \brief Set product fixed specification.
247  *
248  * \param eProdId \h_hek arm product id.
249  * \param uHwVer Hardware version.
250  */
251  int set(int eProdId, uint_t uHwVer);
252 
253  /*!
254  * \brief Clear product fixed specification.
255  */
256  void clear();
257 
258  /*!
259  * \brief Get specification's product family id.
260  *
261  * \return Returns family id.
262  */
264  {
265  return m_eProdFamily;
266  }
267 
268  /*!
269  * \brief Get specification's product id.
270  *
271  * \return Returns product id. See \ref HekProdId.
272  */
273  int getProdId()
274  {
275  return m_eProdId;
276  }
277 
278  /*!
279  * \brief Get specification's product hardware version number.
280  *
281  * \return Returns version number.
282  */
283  uint_t getProdHwVer()
284  {
285  return m_uHwVer;
286  }
287 
288  /*!
289  * \brief Get specification's number of links.
290  *
291  * \return Returns number of links.
292  */
294  {
295  return m_nNumLinks;
296  }
297 
298  /*!
299  * \brief Get specification's degrees of freedom.
300  *
301  * \return Returns DoF.
302  */
303  int getDoF()
304  {
305  return m_nDoF;
306  }
307 
308  /*!
309  * \brief Get specification's number of optical limits.
310  *
311  * \return Returns number of optical limits.
312  */
314  {
315  return m_nNumOptLimits;
316  }
317 
318  /*!
319  * \brief Get specification's number of servos.
320  *
321  * \return Returns number of servos.
322  */
324  {
325  return m_nNumServos;
326  }
327 
328  /*!
329  * \brief Get link spec at the given index.
330  *
331  * \param index Link index.
332  *
333  * \return If found, returns pointer to spec. Otherwise returns NULL.
334  */
336  {
337  return index < m_vecSpecLinks.size()? &m_vecSpecLinks.at(index): NULL;
338  }
339 
340  /*!
341  * \brief Get joint spec at the given index.
342  *
343  * \param index Joint index.
344  *
345  * \return If found, returns pointer to spec. Otherwise returns NULL.
346  */
348  {
349  return index < m_vecSpecJoints.size()? &m_vecSpecJoints.at(index): NULL;
350  }
351 
352  /*!
353  * \brief Get joint spec associated joint name.
354  *
355  * \param strName Joint name (primary key).
356  *
357  * \return If found, returns pointer to spec. Otherwise returns NULL.
358  */
359  HekSpecJoint_T *getJointSpec(std::string &strName);
360 
361  /*!
362  * \brief Get joint spec associated with servo id.
363  *
364  * \param nServoId Servo id (secondary key).
365  *
366  * \return If found, returns pointer to spec. Otherwise returns NULL.
367  */
368  HekSpecJoint_T *getJointSpec(int nServoId);
369 
370  /*!
371  * \brief Get servo spec at the given index.
372  *
373  * \param index Servo index.
374  *
375  * \return If found, returns pointer to spec. Otherwise returns NULL.
376  */
378  {
379  return index < m_vecSpecServos.size()? &m_vecSpecServos.at(index): NULL;
380  }
381 
382  /*!
383  * \brief Get servo spec associated with servo id.
384  *
385  * \param nServoId Servo id (key).
386  *
387  * \return If found, returns pointer to spec. Otherwise returns NULL.
388  */
389  HekSpecServo_T *getServoSpec(int nServoId);
390 
391  /*!
392  * \brief Test if servo id is in the servo specifications.
393  *
394  * \return Returns true or false.
395  */
396  bool hasServo(int nServoId);
397 
398  protected:
399  int m_eProdFamily; ///< product family
400  int m_eProdId; ///< product id
401  uint_t m_uHwVer; ///< hardware version
402  int m_nNumLinks; ///< number of links
403  int m_nDoF; ///< degrees of freedom
404  int m_nNumOptLimits; ///< number of optical limits
405  int m_nNumServos; ///< number of servos
406  std::vector<HekSpecLink_T> m_vecSpecLinks; ///< vector of link specs
407  std::vector<HekSpecJoint_T> m_vecSpecJoints; ///< vector of joint specs
408  std::vector<HekSpecServo_T> m_vecSpecServos; ///< vector of servo specs
409 
410  friend class HekDesc;
411  friend class HekRobot;
412  };
413 } // namespace hekateros
414 
415 
416 #endif // _HEK_SPEC_H
int m_nSlaveServoId
linked slave servo id, if any
Definition: hekSpec.h:176
double m_fCalibPos
joint calibrated position (degrees)
Definition: hekSpec.h:184
bool m_bMaster
servo is [not] master in doulbe servo joints
Definition: hekSpec.h:218
HekOpticalLimit_T m_limit[HekOptLimitMaxPerJoint]
optical limits
Definition: hekSpec.h:182
HekSpecServo_T operator=(const HekSpecServo_T &rhs)
Assignment operator.
Definition: hekSpec.h:208
std::string m_strName
joint name
Definition: hekSpec.h:174
unknown/undefined joint type
Definition: hekSpec.h:91
int m_nNumLinks
number of links
Definition: hekSpec.h:402
absolute encoder
Definition: hekSpec.h:96
std::vector< HekSpecJoint_T > m_vecSpecJoints
vector of joint specs
Definition: hekSpec.h:407
HekLimitType
Joint limit detection types.
Definition: hekSpec.h:89
double m_fBalancedPos
joint balanced position (degrees)
Definition: hekSpec.h:185
number of supported joint types
Definition: hekSpec.h:98
std::vector< HekSpecLink_T > m_vecSpecLinks
vector of link specs
Definition: hekSpec.h:406
HekSpecLink_T * getLinkSpecAt(int index)
Get link spec at the given index.
Definition: hekSpec.h:335
double m_fGearRatio
joint gear ratio
Definition: hekSpec.h:178
int m_nLinkParent
parent link index
Definition: hekSpec.h:187
Robotic specification.
Definition: hekSpec.h:232
Optical limit switch.
Definition: hekOptical.h:148
<b><i>Hekateros</i></b> optical limit switches.
int getProdId()
Get specification&#39;s product id.
Definition: hekSpec.h:273
int m_nLinkChild
child link index
Definition: hekSpec.h:188
limited rotation
Definition: hekSpec.h:77
bool m_bIsContinuous
servo should [not] be configured in 360 mode
Definition: hekSpec.h:219
double m_fTorqueLimitPct
torque limit(%). Set to 0 for no limit
Definition: hekSpec.h:221
HekJointType
Supported joint types.
Definition: hekSpec.h:73
int m_eLimitTypes
joint limit types
Definition: hekSpec.h:181
continuous rotation
Definition: hekSpec.h:78
int m_eProdId
product id
Definition: hekSpec.h:400
double m_fMinPhyLimit
joint minimum physical limit (degrees)
Definition: hekSpec.h:179
int m_eProdFamily
product family
Definition: hekSpec.h:399
int getNumServos()
Get specification&#39;s number of servos.
Definition: hekSpec.h:323
HekSpecJoint_T * getJointSpecAt(int index)
Get joint spec at the given index.
Definition: hekSpec.h:347
uint_t m_uHwVer
hardware version
Definition: hekSpec.h:401
HekSpecJoint_T operator=(const HekSpecJoint_T &rhs)
Assignment operator.
Definition: hekSpec.h:148
int m_nMasterServoId
master servo id
Definition: hekSpec.h:175
int m_nNumOptLimits
number of optical limits
Definition: hekSpec.h:404
number of supported joint types
Definition: hekSpec.h:81
double m_fParkedPos
joint parked position (degrees)
Definition: hekSpec.h:186
int m_nDir
normalize cw/ccw direction.
Definition: hekSpec.h:220
double m_fMaxPhyLimit
joint maximum physical limit (degrees)
Definition: hekSpec.h:180
Hekateros robotic manipulator full description class.
Definition: hekDesc.h:75
static const int HekOptLimitMaxPerJoint
max limits/joint
Definition: hekOptical.h:120
int m_nDoF
degrees of freedom
Definition: hekSpec.h:403
HekSpecServo_T * getServoSpecAt(int index)
Get servo spec at the given index.
Definition: hekSpec.h:377
int getProdFamily()
Get specification&#39;s product family id.
Definition: hekSpec.h:263
Top-level package include file.
electronic top dead center
Definition: hekSpec.h:95
int m_eJointType
joint type
Definition: hekSpec.h:177
unknown/undefined joint type
Definition: hekSpec.h:75
int getNumLinks()
Get specification&#39;s number of links.
Definition: hekSpec.h:293
int m_nNumServos
number of servos
Definition: hekSpec.h:405
uint_t getProdHwVer()
Get specification&#39;s product hardware version number.
Definition: hekSpec.h:283
int getDoF()
Get specification&#39;s degrees of freedom.
Definition: hekSpec.h:303
int getNumOpticalLimits()
Get specification&#39;s number of optical limits.
Definition: hekSpec.h:313
Hekateros robotic manipulator plus accesories class.
Definition: hekRobot.h:88
Robotic joint specification.
Definition: hekSpec.h:139
mimic rotation (e.g. fingers)
Definition: hekSpec.h:79
Robotic servo specification.
Definition: hekSpec.h:199
std::vector< HekSpecServo_T > m_vecSpecServos
vector of servo specs
Definition: hekSpec.h:408
no limit detection
Definition: hekSpec.h:92
int m_nServoId
servo id
Definition: hekSpec.h:217
The <b><i>Hekateros</i></b> namespace encapsulates all <b><i>Hekateros</i></b> related constructs...
Definition: hekateros.h:56