Kuon  1.1.3
RoadNarrows Robotics Large Outdoor Mobile Robot Project
kuonJoint.h
Go to the documentation of this file.
1 ////////////////////////////////////////////////////////////////////////////////
2 //
3 // Package: Kuon
4 //
5 // Library: libkuon
6 //
7 // File: hekJoint.h
8 //
9 /*! \file
10  *
11  * $LastChangedDate: 2014-04-07 08:16:52 -0600 (Mon, 07 Apr 2014) $
12  * $Rev: 3631 $
13  *
14  * \brief Kuon Robot Joint class interfaces.
15  *
16  * The Joints are the four wheels driven by the geared motors.
17  *
18  * \author Robin Knight (robin.knight@roadnarrows.com)
19  *
20  * \copyright
21  * \h_copy 2014-2017. RoadNarrows LLC.\n
22  * http://www.roadnarrows.com\n
23  * All Rights Reserved
24  */
25 /*
26  * @EulaBegin@
27  *
28  * Permission is hereby granted, without written agreement and without
29  * license or royalty fees, to use, copy, modify, and distribute this
30  * software and its documentation for any purpose, provided that
31  * (1) The above copyright notice and the following two paragraphs
32  * appear in all copies of the source code and (2) redistributions
33  * including binaries reproduces these notices in the supporting
34  * documentation. Substantial modifications to this software may be
35  * copyrighted by their authors and need not follow the licensing terms
36  * described here, provided that the new terms are clearly indicated in
37  * all files where they apply.
38  *
39  * IN NO EVENT SHALL THE AUTHOR, ROADNARROWS LLC, OR ANY MEMBERS/EMPLOYEES
40  * OF ROADNARROW LLC OR DISTRIBUTORS OF THIS SOFTWARE BE LIABLE TO ANY
41  * PARTY FOR DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL
42  * DAMAGES ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION,
43  * EVEN IF THE AUTHORS OR ANY OF THE ABOVE PARTIES HAVE BEEN ADVISED OF
44  * THE POSSIBILITY OF SUCH DAMAGE.
45  *
46  * THE AUTHOR AND ROADNARROWS LLC SPECIFICALLY DISCLAIM ANY WARRANTIES,
47  * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
48  * FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS ON AN
49  * "AS IS" BASIS, AND THE AUTHORS AND DISTRIBUTORS HAVE NO OBLIGATION TO
50  * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
51  *
52  * @EulaEnd@
53  */
54 ////////////////////////////////////////////////////////////////////////////////
55 
56 #ifndef _KUON_JOINT_H
57 #define _KUON_JOINT_H
58 
59 #include <string>
60 #include <vector>
61 
62 #include "rnr/rnrconfig.h"
63 
64 #include "Kuon/kuon.h"
65 
66 namespace kuon
67 {
68  //
69  // Forward declarations
70  //
71  class KuonRobot;
72 
73  // ---------------------------------------------------------------------------
74  // Class KuonRobotJoint
75  // ---------------------------------------------------------------------------
76 
77  /*!
78  * \brief Operational robotic joint class.
79  *
80  * This class contains all of the data necessary to control the operation
81  * of an \h_hek robotic joint.
82  */
84  {
85  public:
86  /*!
87  * \brief Default constructor.
88  */
90 
91  /*!
92  * \brief Copy constructor.
93  */
94  KuonRobotJoint(const KuonRobotJoint &src);
95 
96  /*!
97  * \brief Destructor.
98  */
100 
101  /*!
102  * \brief Assignment operator.
103  *
104  * \param rhs Right hand side object.
105  *
106  * \return Returns copy of this.
107  */
109 
110  /*!
111  * \brief Get joint name.
112  *
113  * \return String.
114  */
115  std::string getJointName() const
116  {
117  return m_strName;
118  }
119 
120  /*!
121  * \brief Get motor id.
122  *
123  * \return Returns motor id.
124  */
125  int getMotorId() const
126  {
127  return m_nMotorId;
128  }
129 
130  protected:
131  // (derived) specification
132  std::string m_strName; ///< joint name
133  int m_nMotorId; ///< motor id
134  int m_nMotorCtlrId; ///< motor controller id
135  int m_nMotorIndex; ///< motor controller unique motor index
136  int m_nMotorDir; ///< motor normalized direction
137  int m_eJointType; ///< joint type
138  double m_fGearRatio; ///< joint gear ratio
139  double m_fTireRadius; ///< tire radius
140  double m_fTicksPerMotorRad; ///< encoder/odom. ticks per motor radian
141  double m_fTicksPerWheelRad; ///< encoder/odom. ticks per wheel radian
142 
143  // discovered limits and positions
144 
145  friend class KuonRobot;
146  };
147 
148 
149 
150  // ---------------------------------------------------------------------------
151  // Class KuonJointState
152  // ---------------------------------------------------------------------------
153 
154  /*!
155  * \brief Joint state class.
156  *
157  * This class encapsulates the current state of one joint.
158  */
160  {
161  public:
162  /*!
163  * \brief Default constructor.
164  */
165  KuonJointState();
166 
167  /*!
168  * \brief Copy constructor.
169  */
170  KuonJointState(const KuonJointState &src);
171 
172  /*!
173  * \brief Destructor.
174  */
176  {
177  }
178 
179  /*!
180  * \brief Assignment operator.
181  *
182  * \param rhs Right hand side object.
183  *
184  * \return Returns copy of this.
185  */
187 
188  std::string m_strName; ///< motor joint name
189  int m_nMotorId; ///< motor id
190  double m_fPosition; ///< current joint position (radians)
191  double m_fVelocity; ///< current joint velocity (radians/second)
192  double m_fEffort; ///< current joint torque (N-m)
193  double m_fOdometer; ///< current wheel odometer reading (meters)
194  int m_nEncoder; ///< current motor encoder position (ticks)
195  double m_fVelocityMps; ///< current wheel velocity (meters/second)
196  int m_nSpeed; ///< current raw speed
197  double m_fPe; ///< current motor input electrical power (W)
198  double m_fPm; ///< current motor output mechanical power (W)
199  float m_fBrake; ///< current motor braking (normalized)
200  float m_fSlew; ///< current motor power slewing (normalized)
201  };
202 
203 
204  // ---------------------------------------------------------------------------
205  // Class KuonJointStatePoint
206  // ---------------------------------------------------------------------------
207 
208  /*!
209  * \brief Joint state point class.
210  *
211  * This class encapsulates the current state of all joints in a kinematic
212  * chain.
213  *
214  * A joint state point (J0, J1, ..., Jn-1) specifies the current dynamic
215  * state of a set of joints (kinematic chain) Ji, i=0,n-1.
216  */
218  {
219  public:
220  /*!
221  * \brief Default constructor.
222  */
224  {
225  }
226 
227  /*!
228  * \brief Copy constructor.
229  */
231  {
232  m_strKinName = src.m_strKinName;
233  m_jointState = src.m_jointState;
234  }
235 
236  /*!
237  * \brief Destructor.
238  */
240  {
241  }
242 
243  /*!
244  * \brief Assignment operator.
245  *
246  * \param rhs Right hand side object.
247  *
248  * \return Returns copy of this.
249  */
251  {
252  m_strKinName = rhs.m_strKinName;
253  m_jointState = rhs.m_jointState;
254 
255  return *this;
256  }
257 
258  /*!
259  * \brief Get the kinematic chain name.
260  *
261  * \return String.
262  */
263  std::string getKinematicChainName()
264  {
265  return m_strKinName;
266  }
267 
268  /*!
269  * \brief Set the kinematic chain name.
270  *
271  * \param String.
272  */
273  void setKinematicChainName(std::string strKinName)
274  {
275  m_strKinName = strKinName;
276  }
277 
278  /*!
279  * \brief Get the number of joint states in joint state point.
280  *
281  * \return Number of points.
282  */
283  size_t getNumPoints()
284  {
285  return m_jointState.size();
286  }
287 
288  /*!
289  * \brief Test if joint is a member of the joint state.
290  *
291  * \param strJointName Joint name.
292  *
293  * \return Returns true or false.
294  */
295  bool hasJoint(const std::string &strJointName);
296 
297  /*!
298  * \brief Append joint state to end of joint state point.
299  *
300  * \param jointState Joint state to append.
301  */
302  void append(const KuonJointState &jointState)
303  {
304  m_jointState.push_back(jointState);
305  }
306 
307  /*!
308  * \brief Subscript operator to get reference to joint point at the
309  * given index.
310  *
311  * Big boy warranty. No out of bound checks are made.
312  *
313  * \param i Index.
314  *
315  * \return Joint state.
316  */
317  KuonJointState &operator[](const size_t i)
318  {
319  return m_jointState[i];
320  }
321 
322  /*!
323  * \brief Key subscript operator to get reference to joint point at the
324  * given index.
325  *
326  * Big boy warranty. No out of bound checks are made.
327  *
328  * \param strJointName Joint name.
329  *
330  * \return Joint state.
331  */
332  KuonJointState &operator[](const std::string &strJointName);
333 
334  /*!
335  * \brief Clear all state data.
336  */
337  void clear()
338  {
339  m_strKinName.clear();
340  m_jointState.clear();
341  }
342 
343  protected:
344  std::string m_strKinName; ///< name of kinematic chain
345  std::vector<KuonJointState> m_jointState; ///< vector of joint states
346  };
347 
348 } // namespace kuon
349 
350 
351 #endif // _KUON_JOINT_H
double m_fTicksPerMotorRad
encoder/odom. ticks per motor radian
Definition: kuonJoint.h:140
~KuonRobotJoint()
Destructor.
Definition: kuonJoint.cxx:107
std::string m_strName
joint name
Definition: kuonJoint.h:132
double m_fVelocityMps
current wheel velocity (meters/second)
Definition: kuonJoint.h:195
std::string m_strName
motor joint name
Definition: kuonJoint.h:188
double m_fPosition
current joint position (radians)
Definition: kuonJoint.h:190
size_t getNumPoints()
Get the number of joint states in joint state point.
Definition: kuonJoint.h:283
int m_nMotorIndex
motor controller unique motor index
Definition: kuonJoint.h:135
KuonJointStatePoint(const KuonJointStatePoint &src)
Copy constructor.
Definition: kuonJoint.h:230
void append(const KuonJointState &jointState)
Append joint state to end of joint state point.
Definition: kuonJoint.h:302
Kuon robotic manipulator plus accesories class.
Definition: kuonRobot.h:83
KuonJointState & operator[](const size_t i)
Subscript operator to get reference to joint point at the given index.
Definition: kuonJoint.h:317
float m_fSlew
current motor power slewing (normalized)
Definition: kuonJoint.h:200
double m_fTicksPerWheelRad
encoder/odom. ticks per wheel radian
Definition: kuonJoint.h:141
The <b><i>Kuon</i></b> namespace encapsulates all <b><i>Kuon</i></b> related constructs.
Definition: kuon.h:66
double m_fGearRatio
joint gear ratio
Definition: kuonJoint.h:138
int m_nMotorCtlrId
motor controller id
Definition: kuonJoint.h:134
float m_fBrake
current motor braking (normalized)
Definition: kuonJoint.h:199
~KuonJointState()
Destructor.
Definition: kuonJoint.h:175
void setKinematicChainName(std::string strKinName)
Set the kinematic chain name.
Definition: kuonJoint.h:273
int m_nMotorDir
motor normalized direction
Definition: kuonJoint.h:136
int m_eJointType
joint type
Definition: kuonJoint.h:137
int m_nSpeed
current raw speed
Definition: kuonJoint.h:196
double m_fPm
current motor output mechanical power (W)
Definition: kuonJoint.h:198
~KuonJointStatePoint()
Destructor.
Definition: kuonJoint.h:239
KuonRobotJoint()
Default constructor.
Definition: kuonJoint.cxx:75
int m_nMotorId
motor id
Definition: kuonJoint.h:133
RoadNarrows Kuon robot top-level header file.
void clear()
Clear all state data.
Definition: kuonJoint.h:337
std::vector< KuonJointState > m_jointState
vector of joint states
Definition: kuonJoint.h:345
double m_fPe
current motor input electrical power (W)
Definition: kuonJoint.h:197
KuonJointStatePoint()
Default constructor.
Definition: kuonJoint.h:223
int m_nEncoder
current motor encoder position (ticks)
Definition: kuonJoint.h:194
std::string getJointName() const
Get joint name.
Definition: kuonJoint.h:115
double m_fOdometer
current wheel odometer reading (meters)
Definition: kuonJoint.h:193
Operational robotic joint class.
Definition: kuonJoint.h:83
Joint state point class.
Definition: kuonJoint.h:217
int m_nMotorId
motor id
Definition: kuonJoint.h:189
double m_fTireRadius
tire radius
Definition: kuonJoint.h:139
Joint state class.
Definition: kuonJoint.h:159
std::string getKinematicChainName()
Get the kinematic chain name.
Definition: kuonJoint.h:263
int getMotorId() const
Get motor id.
Definition: kuonJoint.h:125
double m_fVelocity
current joint velocity (radians/second)
Definition: kuonJoint.h:191
std::string m_strKinName
name of kinematic chain
Definition: kuonJoint.h:344
KuonJointStatePoint operator=(const KuonJointStatePoint &rhs)
Assignment operator.
Definition: kuonJoint.h:250
double m_fEffort
current joint torque (N-m)
Definition: kuonJoint.h:192
KuonRobotJoint operator=(const KuonRobotJoint &rhs)
Assignment operator.
Definition: kuonJoint.cxx:111