51 #include "rnr/rnrconfig.h" 53 #include "Dynamixel/Dynamixel.h" 54 #include "Dynamixel/DynaServo.h" 65 double HekCalib::moveWait(
const string &strJointName,
66 const double fJointGoalPos,
67 const double fJointGoalVel)
69 static const int TuneMaxSecs = 30;
70 static const int TuneWaituSec = 300000;
72 int nMaxIters = TuneMaxSecs * MILLION / TuneWaituSec;
74 double fJointCurPos, fJointCurVel;
76 LOGDIAG3(
"%s(): Move joint %s to goalpos=%.2lf at goalvel=%.3lf", LOGFUNCNAME,
80 m_robot.m_pKin->move(strJointName, fJointGoalPos, fJointGoalVel);
85 for(
int i=0; i<nMaxIters; ++i)
87 if( m_robot.m_pKin->isStopped(strJointName) )
89 LOGDIAG3(
"%s(): %s is stopped.", LOGFUNCNAME, strJointName.c_str());
93 m_robot.m_pKin->getJointCurPosVel(strJointName, fJointCurPos, fJointCurVel);
95 LOGDIAG3(
"%s(): %s at curpos=%.2lf, curvel=%.3lf", LOGFUNCNAME,
102 m_robot.m_pKin->getJointCurPosVel(strJointName, fJointCurPos, fJointCurVel);
104 LOGDIAG3(
"%s(): Joint %s move ended at to curpos=%.2lf", LOGFUNCNAME,
105 strJointName.c_str(),
radToDeg(fJointCurPos));
110 double HekCalib::moveToTorqueLimit(
const string &strJointName,
111 const double fJointGoalPos,
112 const double fJointGoalVel)
114 static const int TuneMaxSecs = 30;
115 static const int TuneWaituSec = 300000;
117 int nMaxIters = TuneMaxSecs * MILLION / TuneWaituSec;
119 double fJointCurPos, fJointCurVel;
121 LOGDIAG3(
"%s(): Move joint %s to goalpos=%.2lf at goalvel=%.3lf", LOGFUNCNAME,
125 m_robot.m_pKin->move(strJointName, fJointGoalPos, fJointGoalVel);
130 for(
int i=0; i<nMaxIters; ++i)
133 if( m_robot.m_pKin->hasOverTorqueCondition(strJointName) )
135 LOGDIAG3(
"%s(): %s in over torque condition.", LOGFUNCNAME,
136 strJointName.c_str());
141 else if( m_robot.m_pKin->isStopped(strJointName) )
143 LOGDIAG3(
"%s(): %s is stopped.", LOGFUNCNAME, strJointName.c_str());
147 m_robot.m_pKin->getJointCurPosVel(strJointName, fJointCurPos, fJointCurVel);
149 LOGDIAG3(
"%s(): %s at curpos=%.2lf, curvel=%.3lf", LOGFUNCNAME,
153 usleep(TuneWaituSec);
156 m_robot.m_pKin->getJointCurPosVel(strJointName, fJointCurPos, fJointCurVel);
158 LOGDIAG3(
"%s(): Joint %s move ended at to curpos=%.2lf", LOGFUNCNAME,
159 strJointName.c_str(),
radToDeg(fJointCurPos));
164 double HekCalib::moveToLight(
const string &strJointName,
165 const double fJointGoalPos,
166 const double fJointGoalVel,
169 static const int TuneMaxSecs = 30;
170 static const int TuneWaituSec = 200000;
172 int nMaxIters = TuneMaxSecs * MILLION / TuneWaituSec;
174 double fJointCurPos, fJointCurVel;
177 LOGDIAG3(
"%s(): Move %s to goalpos=%.2lf at goalvel=%.3lf", LOGFUNCNAME,
181 m_robot.m_pKin->move(strJointName, fJointGoalPos, fJointGoalVel);
184 for(
int i=0; i<nMaxIters; ++i)
187 if( m_robot.m_pKin->hasOverTorqueCondition(strJointName) )
189 LOGDIAG3(
"%s(): %s in over torque condition.", LOGFUNCNAME,
190 strJointName.c_str());
195 else if( m_robot.m_pKin->isStopped(strJointName) )
197 LOGDIAG3(
"%s(): %s is stopped.", LOGFUNCNAME, strJointName.c_str());
202 byLimits = m_robot.m_monitor.getJointLimitBits();
207 LOGDIAG3(
"%s(): %s reached the light.", LOGFUNCNAME,
208 strJointName.c_str());
212 m_robot.m_pKin->getJointCurPosVel(strJointName, fJointCurPos, fJointCurVel);
214 LOGDIAG3(
"%s(): %s at curpos=%.2lf, curvel=%.3lf", LOGFUNCNAME,
218 usleep(TuneWaituSec);
221 m_robot.m_pKin->stop(strJointName);
223 usleep(TuneWaituSec);
225 byLimits = m_robot.m_monitor.getJointLimitBits();
229 LOGWARN(
"%s(): %s stopped before finding the light.", LOGFUNCNAME,
230 strJointName.c_str());
233 m_robot.m_pKin->getJointCurPosVel(strJointName, fJointCurPos, fJointCurVel);
235 LOGDIAG3(
"%s(): Joint %s move ended at to curpos=%.2lf", LOGFUNCNAME,
236 strJointName.c_str(),
radToDeg(fJointCurPos));
241 double HekCalib::moveToDark(
const string &strJointName,
242 const double fJointGoalPos,
243 const double fJointGoalVel,
246 static const int TuneMaxSecs = 30;
247 static const int TuneWaituSec = 200000;
249 int nMaxIters = TuneMaxSecs * MILLION / TuneWaituSec;
251 double fJointCurPos, fJointCurVel;
254 LOGDIAG3(
"%s(): Move %s to goalpos=%.2lf at goalvel=%.3lf", LOGFUNCNAME,
258 m_robot.m_pKin->move(strJointName, fJointGoalPos, fJointGoalVel);
261 for(
int i=0; i<nMaxIters; ++i)
264 if( m_robot.m_pKin->hasOverTorqueCondition(strJointName) )
266 LOGDIAG3(
"%s(): %s in over torque condition.", LOGFUNCNAME,
267 strJointName.c_str());
272 else if( m_robot.m_pKin->isStopped(strJointName) )
274 LOGDIAG3(
"%s(): %s is stopped.", LOGFUNCNAME, strJointName.c_str());
279 byLimits = m_robot.m_monitor.getJointLimitBits();
284 LOGDIAG3(
"%s(): %s reached the dark.", LOGFUNCNAME,
285 strJointName.c_str());
289 m_robot.m_pKin->getJointCurPosVel(strJointName, fJointCurPos, fJointCurVel);
291 LOGDIAG3(
"%s(): %s at curpos=%.2lf, curvel=%.3lf", LOGFUNCNAME,
295 usleep(TuneWaituSec);
298 m_robot.m_pKin->stop(strJointName);
300 usleep(TuneWaituSec);
302 byLimits = m_robot.m_monitor.getJointLimitBits();
306 LOGWARN(
"%s(): %s stopped before finding the dark.", LOGFUNCNAME,
307 strJointName.c_str());
310 m_robot.m_pKin->getJointCurPosVel(strJointName, fJointCurPos, fJointCurVel);
312 LOGDIAG3(
"%s(): Joint %s move ended at to curpos=%.2lf", LOGFUNCNAME,
313 strJointName.c_str(),
radToDeg(fJointCurPos));
HekCalib - Hekateros calibration abstract base class interface.
double radToDeg(double r)
Convert radians to degrees.
static byte_t getDarkOpticalLimits(byte_t byBits, byte_t byMask)
Test if any of the optical limits have been triggered (occluded).
HekRobot - Hekateros Robot Class interface.
Top-level package include file.
static byte_t getLitOpticalLimits(byte_t byBits, byte_t byMask)
Test if any of the optical limits are lit (not occluded).
Hekateros common utilities.
The <b><i>Hekateros</i></b> namespace encapsulates all <b><i>Hekateros</i></b> related constructs...