Kuon  1.1.3
RoadNarrows Robotics Large Outdoor Mobile Robot Project
kuonJoint.cxx
Go to the documentation of this file.
1 ////////////////////////////////////////////////////////////////////////////////
2 //
3 // Package: Kuon
4 //
5 // Library: libkuon
6 //
7 // File: kuonJoint.cxx
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 implementations.
15  *
16  * \author Robin Knight (robin.knight@roadnarrows.com)
17  *
18  * \copyright
19  * \h_copy 2014-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 #include <stdio.h>
55 #include <unistd.h>
56 
57 #include <string>
58 
59 #include "rnr/rnrconfig.h"
60 #include "rnr/log.h"
61 
62 #include "Kuon/kuon.h"
63 #include "Kuon/kuonUtils.h"
64 #include "Kuon/kuonSpec.h"
65 #include "Kuon/kuonJoint.h"
66 
67 using namespace std;
68 using namespace kuon;
69 
70 
71 // -----------------------------------------------------------------------------
72 // Class KuonRobotJoint
73 // -----------------------------------------------------------------------------
74 
75 KuonRobotJoint::KuonRobotJoint()
76 {
77  // (derived) specification
78  m_nMotorId = KuonMotorIdNone;
79  m_nMotorCtlrId = KuonMotorCtlrIdNone;
80  m_nMotorIndex = 0;
81  m_nMotorDir = KuonMotorDirUnknown;
82  m_eJointType = KuonJointTypeUnknown;
83  m_fGearRatio = 1.0;
84  m_fTireRadius = 1.0;
85  m_fTicksPerMotorRad = 0.0;
86  m_fTicksPerWheelRad = 0.0;
87 
88  // discovered limits and positions
89 }
90 
91 KuonRobotJoint::KuonRobotJoint(const KuonRobotJoint &src)
92 {
93  // (derived) specification
94  m_strName = src.m_strName;
95  m_nMotorId = src.m_nMotorId;
96  m_nMotorCtlrId = src.m_nMotorCtlrId;
97  m_nMotorIndex = src.m_nMotorIndex;
98  m_nMotorDir = src.m_nMotorDir;
99  m_eJointType = src.m_eJointType;
100  m_fGearRatio = src.m_fGearRatio;
101  m_fTicksPerMotorRad = src.m_fTicksPerMotorRad;
102  m_fTicksPerWheelRad = src.m_fTicksPerWheelRad;
103 
104  // discovered limits and positions
105 }
106 
107 KuonRobotJoint::~KuonRobotJoint()
108 {
109 }
110 
111 KuonRobotJoint KuonRobotJoint::operator=(const KuonRobotJoint &rhs)
112 {
113  // (derived) specification
114  m_strName = rhs.m_strName;
115  m_nMotorId = rhs.m_nMotorId;
116  m_nMotorCtlrId = rhs.m_nMotorCtlrId;
117  m_nMotorIndex = rhs.m_nMotorIndex;
118  m_nMotorDir = rhs.m_nMotorDir;
119  m_eJointType = rhs.m_eJointType;
120  m_fGearRatio = rhs.m_fGearRatio;
121  m_fTicksPerMotorRad = rhs.m_fTicksPerMotorRad;
122  m_fTicksPerWheelRad = rhs.m_fTicksPerWheelRad;
123 
124  // discovered limits and positions
125 
126  return *this;
127 }
128 
129 
130 // -----------------------------------------------------------------------------
131 // Class KuonJointState
132 // -----------------------------------------------------------------------------
133 
134 KuonJointState::KuonJointState()
135 {
136  m_nMotorId = KuonMotorIdNone;
137  m_fPosition = 0.0;
138  m_fVelocity = 0.0;
139  m_fEffort = 0.0;
140  m_fOdometer = 0.0;
141  m_nEncoder = 0;
142  m_fVelocityMps = 0.0;
143  m_nSpeed = 0;
144  m_fPe = 0.0;
145  m_fPm = 0.0;
146  m_fBrake = 0.0;
147  m_fSlew = 0.0;
148 }
149 
150 KuonJointState::KuonJointState(const KuonJointState &src)
151 {
152  m_strName = src.m_strName;
153  m_nMotorId = src.m_nMotorId;
154  m_fPosition = src.m_fPosition;
155  m_fVelocity = src.m_fVelocity;
156  m_fEffort = src.m_fEffort;
157  m_fOdometer = src.m_fOdometer;
158  m_nEncoder = src.m_nEncoder;
159  m_fVelocityMps = src.m_fVelocityMps;
160  m_nSpeed = src.m_nSpeed;
161  m_fPe = src.m_fPe;
162  m_fPm = src.m_fPm;
163  m_fBrake = src.m_fBrake;
164  m_fSlew = src.m_fSlew;
165 }
166 
167 KuonJointState KuonJointState::operator=(const KuonJointState &rhs)
168 {
169  m_strName = rhs.m_strName;
170  m_nMotorId = rhs.m_nMotorId;
171  m_fPosition = rhs.m_fPosition;
172  m_fVelocity = rhs.m_fVelocity;
173  m_fEffort = rhs.m_fEffort;
174  m_fOdometer = rhs.m_fOdometer;
175  m_nEncoder = rhs.m_nEncoder;
176  m_fVelocityMps = rhs.m_fVelocityMps;
177  m_nSpeed = rhs.m_nSpeed;
178  m_fPe = rhs.m_fPe;
179  m_fPm = rhs.m_fPm;
180  m_fBrake = rhs.m_fBrake;
181  m_fSlew = rhs.m_fSlew;
182 
183  return *this;
184 }
185 
186 
187 // -----------------------------------------------------------------------------
188 // Class KuonJointStatePoint
189 // -----------------------------------------------------------------------------
190 
191 static KuonJointState nojointstate;
192 
193 bool KuonJointStatePoint::hasJoint(const string &strJointName)
194 {
195  vector<KuonJointState>::iterator iter;
196 
197  for(iter = m_jointState.begin(); iter != m_jointState.end(); ++iter)
198  {
199  if( iter->m_strName == strJointName )
200  {
201  return true;
202  }
203  }
204  return false;
205 }
206 
207 KuonJointState &KuonJointStatePoint::operator[](const string &strJointName)
208 {
209  vector<KuonJointState>::iterator iter;
210 
211  for(iter = m_jointState.begin(); iter != m_jointState.end(); ++iter)
212  {
213  if( iter->m_strName == strJointName )
214  {
215  return *iter;
216  }
217  }
218  return nojointstate;
219 }
double m_fTicksPerMotorRad
encoder/odom. ticks per motor radian
Definition: kuonJoint.h:140
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
Kuon common utilities.
double m_fPosition
current joint position (radians)
Definition: kuonJoint.h:190
int m_nMotorIndex
motor controller unique motor index
Definition: kuonJoint.h:135
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
Kuon Robot Joint class interfaces.
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
int m_nMotorId
motor id
Definition: kuonJoint.h:133
<b><i>Kuon</i></b> product specification base classes.
RoadNarrows Kuon robot top-level header file.
static const int KuonMotorIdNone
no motor id
Definition: kuon.h:301
static const int KuonMotorDirUnknown
unknown
Definition: kuon.h:313
double m_fPe
current motor input electrical power (W)
Definition: kuonJoint.h:197
unknown/undefined joint type
Definition: kuonSpec.h:77
int m_nEncoder
current motor encoder position (ticks)
Definition: kuonJoint.h:194
static const int KuonMotorCtlrIdNone
no motor controller id
Definition: kuon.h:308
double m_fOdometer
current wheel odometer reading (meters)
Definition: kuonJoint.h:193
Operational robotic joint class.
Definition: kuonJoint.h:83
int m_nMotorId
motor id
Definition: kuonJoint.h:189
Joint state class.
Definition: kuonJoint.h:159
double m_fVelocity
current joint velocity (radians/second)
Definition: kuonJoint.h:191
double m_fEffort
current joint torque (N-m)
Definition: kuonJoint.h:192