Hekateros  3.4.3
RoadNarrows Robotics Robot Arm Project
hekTune.cxx
Go to the documentation of this file.
1 ////////////////////////////////////////////////////////////////////////////////
2 //
3 // Package: Hekateros
4 //
5 // Library: libhekateros
6 //
7 // File: hekTune.cxx
8 //
9 /*! \file
10  *
11  * $LastChangedDate: 2014-10-11 20:13:57 +0000 (Sat, 11 Oct 2014) $
12  * $Rev: 3782 $
13  *
14  * \brief Hekateros tuning implementation.
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  * 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 #include <string>
50 #include <map>
51 
52 #include "rnr/rnrconfig.h"
53 
54 #include "Hekateros/hekateros.h"
55 #include "Hekateros/hekTune.h"
56 #include "Hekateros/hekUtils.h"
57 
58 using namespace std;
59 using namespace hekateros;
60 
61 //------------------------------------------------------------------------------
62 // HekTunesJoint Class
63 //------------------------------------------------------------------------------
64 
65 HekTunesJoint::HekTunesJoint()
66 {
67  m_fTolPos = degToRad(HekTuneTolPosDft);
68  m_fTolVel = degToRad(HekTuneTolVelDft);
69  m_fPidKp = HekTunePidKpDft;
70  m_fPidKi = HekTunePidKiDft;
71  m_fPidKd = HekTunePidKdDft;
72  m_fPidMaxDeltaV = degToRad(HekTunePidMaxDeltaVDft);
73  m_fOverTorqueTh = HekTuneOverTorqueThDft / 100.0;
74 }
75 
76 HekTunesJoint &HekTunesJoint::operator=(const HekTunesJoint &rhs)
77 {
78  m_fTolPos = rhs.m_fTolPos;
79  m_fTolVel = rhs.m_fTolVel;
80  m_fPidKp = rhs.m_fPidKp;
81  m_fPidKi = rhs.m_fPidKi;
82  m_fPidKd = rhs.m_fPidKd;
83  m_fPidMaxDeltaV = rhs.m_fPidMaxDeltaV;
84  m_fOverTorqueTh = rhs.m_fOverTorqueTh;
85 }
86 
87 
88 //------------------------------------------------------------------------------
89 // HekTunes Class
90 //------------------------------------------------------------------------------
91 
92 HekTunes::HekTunes()
93 {
94  m_fKinematicsHz = HekTuneKinHzDft;
95  m_fClearTorqueOffset = HekTuneClearTorqueOffsetDft / 100.0;
96  m_fVelDerate = HekTuneVelDerateDft / 100.0;
97  m_eTrajNorm = HekTuneTrajNormDft;
98  m_fTrajEpsilon = degToRad(HekTuneTrajEpsilonDft);
99 }
100 
101 void HekTunes::getToleranceParams(const std::string &strJointName,
102  double &fTolPos, double &fTolVel) const
103 {
104  MapJointTunes::const_iterator pos;
105 
106  if( (pos = m_mapJointTunes.find(strJointName)) != m_mapJointTunes.end() )
107  {
108  fTolPos = pos->second.m_fTolPos;
109  fTolVel = pos->second.m_fTolVel;
110  }
111  else
112  {
113  fTolPos = degToRad(HekTuneTolPosDft);
114  fTolVel = degToRad(HekTuneTolVelDft);
115  }
116 }
117 
118 void HekTunes::getPidKParams(const std::string &strJointName,
119  double &fKp, double &fKi, double &fKd) const
120 {
121  MapJointTunes::const_iterator pos;
122 
123  if( (pos = m_mapJointTunes.find(strJointName)) != m_mapJointTunes.end() )
124  {
125  fKp = pos->second.m_fPidKp;
126  fKi = pos->second.m_fPidKi;
127  fKd = pos->second.m_fPidKd;
128  }
129  else
130  {
131  fKp = HekTunePidKpDft;
132  fKi = HekTunePidKiDft;
133  fKd = HekTunePidKdDft;
134  }
135 }
136 
137 double HekTunes::getPidMaxDeltaV(const std::string &strJointName) const
138 {
139  MapJointTunes::const_iterator pos;
140 
141  if( (pos = m_mapJointTunes.find(strJointName)) != m_mapJointTunes.end() )
142  {
143  return pos->second.m_fPidMaxDeltaV;
144  }
145  else
146  {
147  return degToRad(HekTunePidMaxDeltaVDft);
148  }
149 }
150 
151 void HekTunes::getTorqueParams(const std::string &strJointName,
152  double &fOverTorqueTh,
153  double &fClearTorqueTh) const
154 {
155  MapJointTunes::const_iterator pos;
156 
157  if( (pos = m_mapJointTunes.find(strJointName)) != m_mapJointTunes.end() )
158  {
159  fOverTorqueTh = pos->second.m_fOverTorqueTh;
160  }
161  else
162  {
163  fOverTorqueTh = HekTuneOverTorqueThDft / 100.0;
164  }
165  fClearTorqueTh = fOverTorqueTh * m_fClearTorqueOffset;
166 }
double m_fPidKi
position and velocity PID integral constant
Definition: hekTune.h:373
double m_fPidKp
position and velocity PID proportional const
Definition: hekTune.h:372
double m_fTolVel
velocitiy tolerance (radians/second)
Definition: hekTune.h:371
Hekateros tuning per joint data class.
Definition: hekTune.h:367
double m_fOverTorqueTh
over torque conditon threshold (fraction)
Definition: hekTune.h:376
double m_fPidKd
position and velocity PID derivative constant
Definition: hekTune.h:374
double m_fPidMaxDeltaV
max output delta v (radians/second)
Definition: hekTune.h:375
Top-level package include file.
double degToRad(double d)
Convert degrees to radians.
Definition: hekUtils.h:125
Hekateros common utilities.
Hekateros tuning.
The <b><i>Hekateros</i></b> namespace encapsulates all <b><i>Hekateros</i></b> related constructs...
Definition: hekateros.h:56
double m_fTolPos
position tolerance (radians)
Definition: hekTune.h:370