Kuon  1.1.3
RoadNarrows Robotics Large Outdoor Mobile Robot Project
kuonSpec.h
Go to the documentation of this file.
1 ////////////////////////////////////////////////////////////////////////////////
2 //
3 // Package: Kuon
4 //
5 // Library: libkuon
6 //
7 // File: kuonSpec.h
8 //
9 /*! \file
10  *
11  * $LastChangedDate: 2014-04-04 17:05:03 -0600 (Fri, 04 Apr 2014) $
12  * $Rev: 3629 $
13  *
14  * \brief \h_kuon 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  * Permission is hereby granted, without written agreement and without
27  * license or royalty fees, to use, copy, modify, and distribute this
28  * software and its documentation for any purpose, provided that
29  * (1) The above copyright notice and the following two paragraphs
30  * appear in all copies of the source code and (2) redistributions
31  * including binaries reproduces these notices in the supporting
32  * documentation. Substantial modifications to this software may be
33  * copyrighted by their authors and need not follow the licensing terms
34  * described here, provided that the new terms are clearly indicated in
35  * all files where they apply.
36  *
37  * IN NO EVENT SHALL THE AUTHOR, ROADNARROWS LLC, OR ANY MEMBERS/EMPLOYEES
38  * OF ROADNARROW LLC OR DISTRIBUTORS OF THIS SOFTWARE BE LIABLE TO ANY
39  * PARTY FOR DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL
40  * DAMAGES ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION,
41  * EVEN IF THE AUTHORS OR ANY OF THE ABOVE PARTIES HAVE BEEN ADVISED OF
42  * THE POSSIBILITY OF SUCH DAMAGE.
43  *
44  * THE AUTHOR AND ROADNARROWS LLC SPECIFICALLY DISCLAIM ANY WARRANTIES,
45  * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
46  * FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS ON AN
47  * "AS IS" BASIS, AND THE AUTHORS AND DISTRIBUTORS HAVE NO OBLIGATION TO
48  * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
49  *
50  * @EulaEnd@
51  */
52 ////////////////////////////////////////////////////////////////////////////////
53 
54 #ifndef _KUON_SPEC_H
55 #define _KUON_SPEC_H
56 
57 #include <string>
58 #include <vector>
59 
60 #include "rnr/rnrconfig.h"
61 
62 #include "Kuon/kuon.h"
63 
64 namespace kuon
65 {
66  //
67  // Forward declarations.
68  //
69  class KuonDesc;
70  class KuonRobot;
71 
72  /*!
73  * \brief Supported joint/wheel types. Not really used for now.
74  */
76  {
77  KuonJointTypeUnknown = 0, ///< unknown/undefined joint type
78  KuonJointTypeFixed, ///< fixed joint
79  KuonJointTypeRevolute, ///< limited rotation
80  KuonJointTypeContinuous, ///< continuous rotation
81  KuonJointTypeRevMimic, ///< mimic rotation (e.g. fingers)
82 
83  KuonJointTypeNumOf = 4 ///< number of supported joint types
84  };
85 
86  /*!
87  * \brief Joint/wheel limit detection types. Not really used for now.
88  *
89  * A joint may have more than one type.
90  */
92  {
93  KuonLimitTypeUnknown = 0x00, ///< unknown/undefined joint type
94  KuonLimitTypeNone = 0x01, ///< no limit detection
95  KuonLimitTypePhys = 0x02, ///< physical
96  KuonLimitTypeElec = 0x04, ///< electronic
97  KuonLimitTypeElecTDC = 0x08, ///< electronic top dead center
98  KuonLimitTypeAbsEnc = 0x10, ///< absolute encoder
99 
100  KuonLimitTypeNumOf = 5 ///< number of supported joint types
101  };
102 
103 
104  // ---------------------------------------------------------------------------
105  // Struct KuonSpecMotor_T
106  // ---------------------------------------------------------------------------
107 
108  /*!
109  * \brief Robotic motor specification.
110  */
112  {
113  /*!
114  * \brief Assignment operator.
115  *
116  * \param rhs Right hand side object.
117  *
118  * \return this.
119  */
121  {
122  int i;
123 
124  m_strName = rhs.m_strName;
125  m_nMotorId = rhs.m_nMotorId;
130  m_nDir = rhs.m_nDir;
131 
132  return *this;
133  }
134 
135  std::string m_strName; ///< motor name
136  int m_nMotorId; ///< robot unique robot motor id
137  int m_nMotorCtlrId; ///< motor controller id
138  int m_nMotorIndex; ///< motor controller unique motor index
139  double m_fGearRatio; ///< motor gear ratio
140  double m_fTireRadius; ///< tire radius (mm)
141  int m_nDir; ///< normalize cw/ccw direction.
142  };
143 
144  // ---------------------------------------------------------------------------
145  // Class KuonSpec
146  // ---------------------------------------------------------------------------
147 
148  /*!
149  * \brief Robotic specification.
150  */
151  class KuonSpec
152  {
153  public:
154  /*!
155  * \brief Constructor.
156  */
157  KuonSpec();
158 
159  /*!
160  * \brief Destructor.
161  */
162  ~KuonSpec();
163 
164  /*!
165  * \brief Set product fixed specification.
166  *
167  * \param eProdId \h_kuon arm product id.
168  * \param uHwVer Hardware version.
169  * \param fFrontTireRadius Radius of front tires (mm). If zero, then
170  * factory defaults are used.
171  * \param fRearTireRadius Radius of rear tires (mm). If zero, then
172  * factory defaults are used.
173  */
174  int set(int eProdId,
175  uint_t uHwVer,
176  double fFrontTireRadius,
177  double fRearTireRadius);
178 
179  /*!
180  * \brief Clear product fixed specification.
181  */
182  void clear();
183 
184  /*!
185  * \brief Get specification's product id.
186  *
187  * \return Returns product id. See \ref KuonProdId.
188  */
189  int getProdId()
190  {
191  return m_eProdId;
192  }
193 
194  /*!
195  * \brief Get specification's product hardware version number.
196  *
197  * \return Returns version number.
198  */
199  uint_t getProdHwVer()
200  {
201  return m_uHwVer;
202  }
203 
204  /*!
205  * \brief Get specification's number of motors.
206  *
207  * \return Returns number of motors.
208  */
210  {
211  return m_nNumMotors;
212  }
213 
214  /*!
215  * \brief Get motor spec at the given index.
216  *
217  * \param index Motor index.
218  *
219  * \return If found, returns pointer to spec. Otherwise returns NULL.
220  */
222  {
223  return index < m_vecSpecMotors.size()? &m_vecSpecMotors.at(index): NULL;
224  }
225 
226  /*!
227  * \brief Get motor spec associated motor name.
228  *
229  * \param strName Motor name (primary key).
230  *
231  * \return If found, returns pointer to spec. Otherwise returns NULL.
232  */
233  KuonSpecMotor_T *getMotorSpec(const std::string &strName);
234 
235  /*!
236  * \brief Get motor spec associated with motor id.
237  *
238  * \param nMotorId Motor id (secondary key).
239  *
240  * \return If found, returns pointer to spec. Otherwise returns NULL.
241  */
242  KuonSpecMotor_T *getMotorSpec(int nMotorId);
243 
244  /*!
245  * \brief Test if motor id is in the motor specifications.
246  *
247  * \return Returns true or false.
248  */
249  bool hasMotor(int nMotorId)
250  {
251  return getMotorSpec(nMotorId) == NULL? false: true;
252  }
253 
254  /*!
255  * \brief Get front and rear tire radii (mm).
256  *
257  * \param [out] fFrontTireRadius Front tires.
258  * \param [out] fRearTireRadius Rear tires.
259  */
260  void getTireSizes(double &fFrontTireRadius, double &fRearTireRadius);
261 
262  protected:
263  int m_eProdId; ///< product id
264  uint_t m_uHwVer; ///< hardware version
265  int m_nNumMotors; ///< number of drive motors
266  double m_fFrontTireRadius; ///< front tire radius (mm)
267  double m_fRearTireRadius; ///< rear tire radius (mm)
268 
269  std::vector<KuonSpecMotor_T> m_vecSpecMotors; ///< vector of motor specs
270 
271  friend class KuonDesc;
272  friend class KuonRobot;
273  };
274 } // namespace kuon
275 
276 
277 #endif // _KUON_SPEC_H
int m_nMotorIndex
motor controller unique motor index
Definition: kuonSpec.h:138
int getProdId()
Get specification&#39;s product id.
Definition: kuonSpec.h:189
limited rotation
Definition: kuonSpec.h:79
number of supported joint types
Definition: kuonSpec.h:83
KuonJointType
Supported joint/wheel types. Not really used for now.
Definition: kuonSpec.h:75
double m_fGearRatio
motor gear ratio
Definition: kuonSpec.h:139
Kuon robotic manipulator plus accesories class.
Definition: kuonRobot.h:83
uint_t m_uHwVer
hardware version
Definition: kuonSpec.h:264
uint_t getProdHwVer()
Get specification&#39;s product hardware version number.
Definition: kuonSpec.h:199
std::vector< KuonSpecMotor_T > m_vecSpecMotors
vector of motor specs
Definition: kuonSpec.h:269
The <b><i>Kuon</i></b> namespace encapsulates all <b><i>Kuon</i></b> related constructs.
Definition: kuon.h:66
KuonLimitType
Joint/wheel limit detection types. Not really used for now.
Definition: kuonSpec.h:91
Robotic motor specification.
Definition: kuonSpec.h:111
double m_fFrontTireRadius
front tire radius (mm)
Definition: kuonSpec.h:266
bool hasMotor(int nMotorId)
Test if motor id is in the motor specifications.
Definition: kuonSpec.h:249
RoadNarrows Kuon robot top-level header file.
electronic top dead center
Definition: kuonSpec.h:97
number of supported joint types
Definition: kuonSpec.h:100
unknown/undefined joint type
Definition: kuonSpec.h:77
KuonSpecMotor_T * getMotorSpecAt(int index)
Get motor spec at the given index.
Definition: kuonSpec.h:221
int m_eProdId
product id
Definition: kuonSpec.h:263
int m_nMotorCtlrId
motor controller id
Definition: kuonSpec.h:137
absolute encoder
Definition: kuonSpec.h:98
int m_nDir
normalize cw/ccw direction.
Definition: kuonSpec.h:141
Kuon robotic manipulator full description class.
Definition: kuonDesc.h:83
double m_fRearTireRadius
rear tire radius (mm)
Definition: kuonSpec.h:267
mimic rotation (e.g. fingers)
Definition: kuonSpec.h:81
int m_nMotorId
robot unique robot motor id
Definition: kuonSpec.h:136
unknown/undefined joint type
Definition: kuonSpec.h:93
KuonSpecMotor_T operator=(const KuonSpecMotor_T &rhs)
Assignment operator.
Definition: kuonSpec.h:120
int getNumMotors()
Get specification&#39;s number of motors.
Definition: kuonSpec.h:209
int m_nNumMotors
number of drive motors
Definition: kuonSpec.h:265
no limit detection
Definition: kuonSpec.h:94
continuous rotation
Definition: kuonSpec.h:80
std::string m_strName
motor name
Definition: kuonSpec.h:135
double m_fTireRadius
tire radius (mm)
Definition: kuonSpec.h:140
Robotic specification.
Definition: kuonSpec.h:151