kmlExt.cpp
Go to the documentation of this file.
1 /*
2  * Katana Native Interface - A C++ interface to the robot arm Katana.
3  * Copyright (C) 2005 Neuronics AG
4  * Check out the AUTHORS file for detailed contact information.
5  *
6  * This program is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 2 of the License, or
9  * (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program; if not, write to the Free Software
18  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19  */
20 
21 
22 #include "KNI/kmlExt.h"
23 #include "KNI/kmlFactories.h"
24 
26 #include "common/Timer.h"
27 
28 #include <iostream>
29 #include <algorithm>
30 #include <vector>
31 
32 #define max(a,b) (((a)>(b))?(a):(b))
34 
36 const int POLLFREQUENCY = 300;
37 
38 void CKatana::inc(long idx, int dif, bool wait, int tolerance, long timeout) {
39  base->GetMOT()->arr[idx].inc(dif,wait,tolerance,timeout);
40 }
41 
42 void CKatana::dec(long idx, int dif, bool wait, int tolerance, long timeout) {
43  base->GetMOT()->arr[idx].dec(dif,wait,tolerance,timeout);
44 }
45 
46 void CKatana::mov(long idx, int tar, bool wait, int tolerance, long timeout) {
47  base->GetMOT()->arr[idx].mov(tar, wait,tolerance,timeout);
48 }
49 
50 
51 
52 void CKatana::incDegrees(long idx, double dif, bool wait, int tolerance, long timeout) {
53  base->GetMOT()->arr[idx].incDegrees(dif,wait,tolerance,timeout);
54 }
55 
56 void CKatana::decDegrees(long idx, double dif, bool wait, int tolerance, long timeout) {
57  base->GetMOT()->arr[idx].decDegrees(dif,wait,tolerance,timeout);
58 }
59 
60 void CKatana::movDegrees(long idx, double tar, bool wait, int tolerance, long timeout) {
61  base->GetMOT()->arr[idx].movDegrees(tar,wait,tolerance,timeout);
62 }
63 
64 
65 void CKatana::create(const char* configurationFile, CCplBase* protocol) {
66  KNI::kmlFactory infos;
67  if(!infos.openFile(configurationFile)) {
68  throw ConfigFileOpenException(configurationFile);
69  }
70  create(&infos, protocol);
71 }
72 
74  base->init( infos->getGNL(), infos->getMOT(), infos->getSCT(), infos->getEFF(), protocol);
75 
76  for(int i=0; i<getNumberOfMotors(); ++i) {
77  TMotInit init = infos->getMotInit(i);
78 
80 
81  TMotCLB clb = infos->getMotCLB(i);
83 
84  base->GetMOT()->arr[i].setDYL( infos->getMotDYL(i) );
85  base->GetMOT()->arr[i].setSCP( infos->getMotSCP(i) );
86  }
87  mKatanaType = infos->getType();
88  if (mKatanaType == 450) {
89  mKinematics = infos->getKinematics();
90  if (protocol != NULL)
92  } else {
93  mKinematics = 0;
94  }
96  //incompatible config file
97  std::cout << "\n\n!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n";
98  std::cout << "Exit: Incompatible Config File!\n";
99  std::cout << "Check whether you have a Katana 400 or 300 and choose the config file accordingly\n";
100  std::cout << "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n\n.";
101  exit(0);
102  }
103  bool gripperIsPresent;
104  int gripperOpenEncoders, gripperCloseEncoders;
105  infos->getGripperParameters(gripperIsPresent, gripperOpenEncoders, gripperCloseEncoders);
106  setGripperParameters(gripperIsPresent, gripperOpenEncoders, gripperCloseEncoders);
107 
108 }
109 
111  base->init(gnl, mot, sct, eff, protocol);
112 }
113 
114 
116  if(mKatanaType >= 400){
117  std::cout << "Katana4xx calibration started\n";
118  //standalone calibration for Katana400
119  TMotCmdFlg cflg = MCF_CALIB;
120  TMotTPS tps;
121  tps.tarpos = 32000;
122  tps.mcfTPS = cflg;
123  for(int i=0; i < getNumberOfMotors(); ++i){
124  base->GetMOT()->arr[i].setCalibrated(false);
125  }
127  //standalone calibration for K400:
128  byte p[32]; //packet
129  byte buf[256]; //readbuf
130  byte sz = 10; //readbuf size
131  p[0] = 'C';
132  p[1] = 0; //calibrate all motors
133  p[2] = 4; //calibrate
134  p[3] = (byte)(tps.tarpos >> 8);
135  p[4] = (byte)(tps.tarpos);
136  base->getProtocol()->comm(p,buf,&sz);
138  for (int i=0; i < getNumberOfMotors(); ++i) {
139  base->GetMOT()->arr[i].setCalibrated(true);
140  }
141  //wait for termination:
142  p[0] = 'D';
143  p[1] = 1;
144  do{
145  KNI::sleep(1000);
146  base->getProtocol()->comm(p,buf,&sz);
147  }
148  while(buf[2] == 4);
149  std::cout << "...done with calibration.\n";
150 
151  }
152  else if(mKatanaType == 300){
153  std::cout << "Katana300 calibration started\n";
154  KNI::sleep(500);
155  //----------------------------------------------------------------//
156  //"traditional" calibration, works only up to K400 V0.4.0
157  //For newer Katana types, "type" has to be set to 400 in the config file section [GENERAL]
158  //set motors ON before calibrating
159  //----------------------------------------------------------------//
160  TMotAPS aps;
161  for (int i=0; i<getNumberOfMotors(); i++) {
162  aps.actpos = 0;
163  aps.mcfAPS = MCF_ON;
164  base->GetMOT()->arr[i].sendAPS(&aps);
165  }
166  for (int i=0; i < getNumberOfMotors(); ++i) {
167  for(int j=0; j < getNumberOfMotors(); ++j) {
168  if(base->GetMOT()->arr[j].GetCLB()->order == i) {
169  base->GetMOT()->arr[j].setCalibrated(false);
170  calibrate( j, *base->GetMOT()->arr[j].GetCLB(), *base->GetMOT()->arr[j].GetSCP(), *base->GetMOT()->arr[j].GetDYL() );
171  base->GetMOT()->arr[j].setCalibrated(true);
172  break;
173  }
174  }
175  }
176  }
177 }
178 
179 
180 
181 void CKatana::calibrate(long idx, TMotCLB clb, TMotSCP scp, TMotDYL dyl) {
182 
183  if (!clb.enable)
184  return;
185 
186  searchMechStop(idx,clb.dir,scp,dyl);
187 //std::cout << "setting actual position to " << base->GetMOT()->arr[idx].GetInitialParameters()->encoderOffset << " with motor command flag " << clb.mcf << std::endl;
188  TMotAPS aps = { clb.mcf, static_cast<short int>(base->GetMOT()->arr[idx].GetInitialParameters()->encoderOffset) };
189  base->GetMOT()->arr[idx].sendAPS(&aps);
190 
191  mov(idx, clb.encoderPositionAfter, true);
192 }
193 
194 
196  TMotSCP _scp, TMotDYL _dyl ) {
197 
198  base->GetMOT()->arr[idx].setPwmLimits(_scp.maxppwm_nmp, _scp.maxnpwm_nmp);
199  base->GetMOT()->arr[idx].setControllerParameters(_scp.kspeed_nmp, _scp.kpos_nmp, _scp.kI_nmp);
202  base->GetMOT()->arr[idx].setAccelerationLimit(1);
203  base->GetMOT()->arr[idx].setSpeedLimits(25, 25);
204 
205  TMotAPS aps;
206  switch (dir) {
207  case DIR_POSITIVE:
208  aps.actpos = -31000; // Set the actual position equal to the
209  aps.mcfAPS = MCF_FREEZE; // extreme opposite to direction I will move
210  base->GetMOT()->arr[idx].sendAPS(&aps);
211  break;
212  case DIR_NEGATIVE:
213  aps.actpos = 31000; // Set the actual position equal to the
214  aps.mcfAPS = MCF_FREEZE; // extreme opposite to direction I will move
215  base->GetMOT()->arr[idx].sendAPS(&aps);
216  break;
217  };
218 
219  TMotTPS tps;
220  switch (dir) {
221  case DIR_POSITIVE:
222  tps.tarpos = 32000;
223  tps.mcfTPS = MCF_ON;
224  base->GetMOT()->arr[idx].sendTPS(&tps); // Set the target position equal to
225  // the extreme I am moving towards.
226  break;
227  case DIR_NEGATIVE:
228  tps.tarpos = -32000;
229  tps.mcfTPS = MCF_ON;
230  base->GetMOT()->arr[idx].sendTPS(&tps);// Set the target position equal to
231  // the extreme I am moving towards.
232 
233  break;
234  };
235 
236  double firstSpeedSample = 100, secondSpeedSample = 100;
237 
238  KNI::Timer poll_t(POLLFREQUENCY);
239  while(true) {
240  poll_t.Start();
241  base->GetMOT()->arr[idx].recvPVP();
242  firstSpeedSample = base->GetMOT()->arr[idx].GetPVP()->vel;
243  //std::cout << firstSpeedSample << ", " << secondSpeedSample << std::endl;
244  if( (firstSpeedSample + secondSpeedSample) == 0.0 ) {
245  break; // stopper reached
246  }
247  secondSpeedSample = firstSpeedSample;
248  poll_t.WaitUntilElapsed();
249  }
250  // To avoid a compensation on the motor the actual position is set to 0
251  // Otherwise, as it didn't reach the target position it could attempt to go
252  // on moving
253 //std::cout << "V=0 @: " << base->GetMOT()->arr[idx].GetPVP()->pos << std::endl;
254  aps.actpos = 0;
255  aps.mcfAPS = MCF_FREEZE;
256 //std::cout << "actual pos struct set to pos 0 and motorcommandflag 8 (hold robot)\nsending actual pos..." << std::endl;
257  base->GetMOT()->arr[idx].sendAPS(&aps);
258 //std::cout << "sent successfully." << std::endl;
259 
260  // restore motor parameters
261  base->GetMOT()->arr[idx].setPwmLimits(_scp.maxppwm_nmp, _scp.maxnpwm_nmp);
262  base->GetMOT()->arr[idx].setControllerParameters(_scp.kspeed_nmp, _scp.kpos_nmp, _scp.kI_nmp);
265  base->GetMOT()->arr[idx].setAccelerationLimit((short) _dyl.maxaccel_nmp);
267 
268 }
269 
270 
271 void CKatana::setTolerance(long idx, int enc_tolerance) {
272  base->GetMOT()->arr[idx].setTolerance(enc_tolerance);
273 }
274 
275 
276 bool CKatana::checkENLD(long idx, double degrees) {
277  return base->GetMOT()->arr[idx].checkAngleInRange(degrees);
278 }
279 
280 
283 }
284 
285 
288 }
289 
290 
292  base->unBlock();
293 }
294 
295 
298 }
299 
300 
301 void CKatana::setCrashLimit(long idx, int limit) {
302  base->setCrashLimit(idx, limit);
303 }
304 
306 void CKatana::setPositionCollisionLimit(long idx, int limit){
307  base->GetMOT()->arr[idx].setPositionCollisionLimit(limit);
308 }
310 void CKatana::setSpeedCollisionLimit(long idx, int limit){
311  base->GetMOT()->arr[idx].setSpeedCollisionLimit(limit);
312 }
314 void CKatana::setForceLimit(int axis, int limit){
315  if(axis == 0){
316  for (int i=1; i <= getNumberOfMotors(); i++) {
317  setForceLimit(i, limit);
318  }
319  }
320 
321  // check axis number
322  if (axis < 1) return;
323  if (axis > getNumberOfMotors()) return;
324 
325  // can not set current limit on drive controller
326  if (base->GetMOT()->arr[axis-1].GetSFW()->type == 0) return;
327 
328  int force = abs(limit);
329  if (force > 100)
330  force = 100;
331 
332  byte p[32]; //packet
333  byte buf[256]; //readbuf
334  byte sz = 0; //readbuf size
335  p[0] = 'S';
336  p[1] = axis;
337  p[2] = 10; // subcommand 10 "Set Current Controller Limit"
338  p[3] = (char)(force >> 8);
339  p[4] = (char)(force);
340  p[5] = 0;
341  base->getProtocol()->comm(p,buf,&sz);
342 }
344 short CKatana::getForce(int axis){
345  byte r1, r2, r3;
346  base->GetMOT()->arr[axis-1].getParameterOrLimit(244, &r1, &r2, &r3);
347  char force = (char)r2;
348  return (short)force;
349 }
352  base->GetMOT()->arr[axis-1].recvSFW();
353  return (int) base->GetMOT()->arr[axis-1].GetSFW()->type;
354 }
356 short
358  return base->GetMOT()->cnt;
359 }
360 
361 int
362 CKatana::getMotorEncoders(short number, bool refreshEncoders) const {
363  if(refreshEncoders)
364  base->GetMOT()->arr[number].recvPVP(); // error handling using exceptions
365  return base->GetMOT()->arr[number].GetPVP()->pos;
366 }
367 
368 std::vector<int>::iterator
369 CKatana::getRobotEncoders(std::vector<int>::iterator start, std::vector<int>::const_iterator end, bool refreshEncoders) const {
370  if(refreshEncoders)
371  base->recvMPS();
372  std::vector<int>::iterator iter = start;
373  for(int i = 0; i < getNumberOfMotors(); ++i) {
374  if(iter == end)
375  return iter;
376  (*iter) = getMotorEncoders(i, false);
377  ++iter;
378  }
379  return iter;
380 }
381 
382 std::vector<int>
383 CKatana::getRobotEncoders(bool refreshEncoders) const {
384  std::vector<int> temp(getNumberOfMotors());
385  getRobotEncoders(temp.begin(),temp.end(), refreshEncoders);
386  return temp;
387 }
388 
389 short
390 CKatana::getMotorVelocityLimit(short number) const {
391  return base->GetMOT()->arr[number].GetDYL()->maxpspeed_nmp;
392 }
393 short
395  return base->GetMOT()->arr[number].GetDYL()->maxaccel_nmp;
396 }
397 
398 void
400  base->GetMOT()->arr[number].setSpeedLimit(velocity);
401 }
402 
403 void
405  for(short c = 0; c < getNumberOfMotors(); ++c) {
406  base->GetMOT()->arr[c].setSpeedLimit( velocity );
407  }
408 }
409 
410 void
412  base->GetMOT()->arr[number].setAccelerationLimit(acceleration);
413 }
414 
415 void
417  for(short c = 0; c < getNumberOfMotors(); ++c) {
418  base->GetMOT()->arr[c].setAccelerationLimit(acceleration);
419  }
420 }
421 
422 void
423 CKatana::moveMotorByEnc(short number, int encoders, bool waitUntilReached, int waitTimeout) {
424  if(encoders >= 0) {
425  inc(number, encoders, waitUntilReached, waitTimeout);
426  } else {
427  dec(number, abs(encoders), waitUntilReached, 100, waitTimeout);
428  }
429 }
430 
431 void
432 CKatana::moveMotorBy(short number, double radianAngle, bool waitUntilReached, int waitTimeout) {
433  double degree = radianAngle/M_PI*180;
434  base->GetMOT()->arr[number].incDegrees(degree, waitUntilReached, 100, waitTimeout);
435 }
436 
437 void
438 CKatana::moveMotorToEnc(short number, int encoders, bool waitUntilReached, int encTolerance, int waitTimeout) {
439  mov(number, encoders, waitUntilReached, encTolerance, waitTimeout);
440 }
441 
442 void
443 CKatana::moveMotorTo(short number, double radianAngle, bool waitUntilReached, int waitTimeout) {
444  int encoders = KNI_MHF::rad2enc( radianAngle,
449  mov(number, encoders, waitUntilReached, 100, waitTimeout);
450 }
451 
452 void
453 CKatana::waitForMotor( short number, int encoders, int encTolerance, short mode, int waitTimeout){
454  base->GetMOT()->arr[number].waitForMotor(encoders,encTolerance, mode, waitTimeout);
455 }
456 
457 void
458 CKatana::waitFor(TMotStsFlg status, int waitTimeout) {
459  base->waitFor(status, waitTimeout, _gripperIsPresent);
460 }
461 
462 void
463 CKatana::moveRobotToEnc(std::vector<int>::const_iterator start, std::vector<int>::const_iterator end, bool waitUntilReached, int encTolerance, int waitTimeout) {
464 
465  // // We'll do that some other time. We need to store the velocity twice for that
466  // for(unsigned int i = 0; i < getNumberOfMotors(); ++i) {
467  // distance[i] = std::abs(act_pos[i] - solution[i]);
468  // }
469  // int maxDistNr = std::distance(distance.begin(), std::max_element(distance.begin(), distance.end()));
470 
471  int i = 0;
472  std::vector<int>::const_iterator iter = start;
473  while( (iter != end) && (i < getNumberOfMotors()) ) {
474  // if(i != maxDistNr) {
475  // mot->arr[i].setSpeedLimit(distance[i]/(distance[maxDistNr]/mot->arr[maxDistNr].GetDYL()->maxpspeed_nmp));
476  // }
477  mov(i, *iter, false, encTolerance, waitTimeout);
478  ++i;
479  ++iter;
480  }
481 
482  // If wait is true, check if the target position is reached
483  if(!waitUntilReached)
484  return;
485 
486  const TKatMOT* mot = base->GetMOT();
487  bool pos_reached;
488  KNI::Timer t(waitTimeout), poll_t(POLLFREQUENCY);
489  t.Start();
490  while (true) {
491  if (t.Elapsed())
492  throw MotorTimeoutException();
493  pos_reached = true;
494  poll_t.Start();
495  base->recvMPS(); // get position for all motors
496  base->recvGMS(); // get status flags for all motors
497  for (int idx=0; idx<getNumberOfMotors(); idx++) {
498  if (mot->arr[idx].GetPVP()->msf == 40)
499  throw MotorCrashException();
500  pos_reached &= std::abs(mot->arr[idx].GetTPS()->tarpos - mot->arr[idx].GetPVP()->pos) < 100;
501  }
502  if (pos_reached)
503  break;
504  poll_t.WaitUntilElapsed();
505  }
506 }
507 
508 void
509 CKatana::moveRobotToEnc(std::vector<int> encoders, bool waitUntilReached, int encTolerance, int waitTimeout) {
510  moveRobotToEnc(encoders.begin(), encoders.end(), waitUntilReached, encTolerance, waitTimeout);
511 }
512 
513 void
514 CKatana::moveRobotToEnc4D(std::vector<int> target, int velocity, int acceleration, int encTolerance){
515 
516  int n, maxDistance = 0;
518  std::vector<int> diffMot,speed,oldSpeed;
519 
520  //Find the maximun difference between actual and target position for each motor
521  for (n=0;n<numberOfMotors;n++){
522  diffMot.push_back(std::abs(getMotorEncoders(n,true)-target.at(n)));
523  maxDistance=max(diffMot.at(n),maxDistance);
524  }
525 
526  //Save the old speeds and calculate the new speeds
527  for (n=0;n<numberOfMotors;n++){
528  oldSpeed.push_back(getMotorVelocityLimit(n));
529  speed.push_back(max(static_cast<int>((static_cast<double>(diffMot.at(n))/maxDistance) * velocity),10));
530  setMotorVelocityLimit(n,speed.at(n));
531  setMotorAccelerationLimit(n,acceleration);
532  }
533 
534  //Move each motor to the target position
535  for (n=0;n<numberOfMotors;n++){
536  moveMotorToEnc(n,target.at(n));
537  }
538 
539  //Wait until the target position for all motors with the encTolerance is reached
540  for (n=0;n<numberOfMotors;n++){
541  waitForMotor(n,target.at(n),encTolerance);
542  }
543 
544  //Restore the speeds
545  for (n=0;n<numberOfMotors;n++){
546  setMotorVelocityLimit(n,oldSpeed.at(n));
547  }
548 }
549 
550 void
551 CKatana::openGripper(bool waitUntilReached, int waitTimeout) {
552  if(!_gripperIsPresent)
553  return;
554  moveMotorToEnc( getNumberOfMotors()-1, _gripperOpenEncoders, waitUntilReached, waitTimeout );
555 }
556 
557 void
558 CKatana::closeGripper(bool waitUntilReached, int waitTimeout) {
559  if(!_gripperIsPresent)
560  return;
561  moveMotorToEnc( getNumberOfMotors()-1, _gripperCloseEncoders, waitUntilReached, waitTimeout );
562 }
563 
564 
565 void
567  for(int i = 0; i < getNumberOfMotors(); ++i)
568  freezeMotor(i);
569 }
570 void
571 CKatana::freezeMotor(short number) {
572  base->GetMOT()->arr[number].recvPVP();
573  const TMotPVP *pvp = base->GetMOT()->arr[number].GetPVP();
574  TMotTPS tps = { MCF_FREEZE, pvp->pos };
575  base->GetMOT()->arr[number].sendTPS(&tps);
576 }
577 void
579  for(int i = 0; i < getNumberOfMotors(); ++i)
580  // switchMotorOn(i); // with moving flag, old version for katana 1.1
581  freezeMotor(i); // switch on with freeze flag, new version, safer and for katana 1.2 too
582 }
583 void
585  for(int i = 0; i < getNumberOfMotors(); ++i)
586  switchMotorOff(i);
587 }
588 void
589 CKatana::switchMotorOn(short number) {
590  base->GetMOT()->arr[number].recvPVP();
591  const TMotPVP *pvp = base->GetMOT()->arr[number].GetPVP();
592  TMotTPS tps = { MCF_FREEZE, pvp->pos };
593  base->GetMOT()->arr[number].sendTPS(&tps);
594 }
595 void
596 CKatana::switchMotorOff(short number) {
597  base->GetMOT()->arr[number].recvPVP();
598  const TMotPVP *pvp = base->GetMOT()->arr[number].GetPVP();
599  TMotTPS tps = { MCF_OFF, pvp->pos };
600  base->GetMOT()->arr[number].sendTPS(&tps);
601 }
602 
603 void
604 CKatana::setGripperParameters(bool isPresent, int openEncoders, int closeEncoders) {
605  _gripperIsPresent = isPresent;
606  _gripperOpenEncoders = openEncoders;
607  _gripperCloseEncoders = closeEncoders;
608 }
609 
610 void
611 CKatana::getGripperParameters(bool &isPresent, int &openEncoders, int &closeEncoders) {
612  isPresent = _gripperIsPresent;
613  openEncoders = _gripperOpenEncoders;
614  closeEncoders = _gripperCloseEncoders;
615 }
616 
617 void
618 CKatana::startSplineMovement(bool exactflag, int moreflag) {
619  int exact = 0;
620  if (exactflag) {
621  exact = 1;
622  }
623  if (!_gripperIsPresent) {
624  exact += 2;
625  }
626  base->startSplineMovement(exact, moreflag);
627 }
628 
629 
630 void
631 CKatana::sendSplineToMotor(short number, short targetPosition, short duration, short p1, short p2, short p3, short p4) {
632  base->GetMOT()->arr[number].sendSpline(targetPosition, duration, p1, p2, p3, p4);
633 }
634 
635 void
636 CKatana::setAndStartPolyMovement(std::vector<short> polynomial, bool exactflag, int moreflag) {
637  int exact = 0;
638  if (exactflag) {
639  exact = 1;
640  }
641  if (!_gripperIsPresent) {
642  exact += 2;
643  }
644  base->setAndStartPolyMovement(polynomial, exact, moreflag);
645 }
646 
648  return base->readDigitalIO();
649 }
int mKatanaType
The type of KatanaXXX (300 or 400)
Definition: kmlExt.h:73
short actpos
actual position
Definition: kmlMotBase.h:98
int acceleration
_encT rad2enc(_angleT const &angle, _angleT const &angleOffset, _encT const &epc, _encT const &encOffset, _encT const &rotDir)
TMotCmdFlg mcf
motor flag after calibration
Definition: kmlMotBase.h:187
unsigned char byte
type specification (8 bit)
Definition: cdlBase.h:29
void mov(long idx, int tar, bool wait=false, int tolerance=100, long timeout=TM_ENDLESS)
Moves the motor specified by an index to a given target position in encoders.
Definition: kmlExt.cpp:46
void setTolerance(int tolerance)
Definition: kmlMotBase.cpp:358
int encoderPositionAfter
Definition: kmlMotBase.h:189
void sendSplineToMotor(short number, short targetPosition, short duration, short p1, short p2, short p3, short p4)
Definition: kmlExt.cpp:631
const TMotCLB * GetCLB()
Definition: kmlMotBase.h:248
void moveMotorTo(short number, double radianAngle, bool waitUntilReached=false, int waitTimeout=0)
Definition: kmlExt.cpp:443
void decDegrees(long idx, double dif, bool wait=false, int tolerance=100, long timeout=TM_ENDLESS)
Decrements the motor specified by an index postion in degree units.
Definition: kmlExt.cpp:56
[PVP] position, velocity, pulse width modulation
Definition: kmlMotBase.h:162
CKatBase * base
base katana
Definition: kmlExt.h:67
void freezeMotor(short number)
Definition: kmlExt.cpp:571
void setControllerParameters(byte kSpeed, byte kPos, byte kI)
Set the controller parameters.
Definition: kmlMotBase.cpp:186
static std::unique_ptr< CCplSerialCRC > protocol
Definition: kni_wrapper.cpp:24
virtual bool init(const TKatGNL _gnl, const TKatMOT _mot, const TKatSCT _sct, const TKatEFF _eff, CCplBase *_protocol)
Definition: kmlBase.cpp:27
void setCalibrated(bool calibrated)
Definition: kmlMotBase.cpp:353
void setGripperParameters(bool isPresent, int openEncoders, int closeEncoders)
Definition: kmlExt.cpp:604
void enableCrashLimits()
crash limits enable
Definition: kmlBase.cpp:169
TMotSCP getMotSCP(short number)
void setCrashLimit(long idx, int limit)
unblock robot after a crash
Definition: kmlExt.cpp:301
void setPwmLimits(byte maxppwm, byte maxnpwm)
Set the PWM limits (for the drive controller)
Definition: kmlMotBase.cpp:165
bool openFile(const char *filepath)
Definition: kmlFactories.h:86
Abstract base class for protocol definiton.
Definition: cplBase.h:47
const int POLLFREQUENCY
Polling position every POLLFREQUENCY milliseconds.
Definition: kmlExt.cpp:36
bool checkENLD(long idx, double degrees)
Check if the absolute position in degrees is out of range.
Definition: kmlExt.cpp:276
[SCT] every sens ctrl&#39;s attributes
Definition: kmlSctBase.h:41
bool enable
enable/disable
Definition: kmlMotBase.h:183
void sendTPS(const TMotTPS *_tps)
send data
Definition: kmlMotBase.cpp:73
void inc(int dif, bool wait=false, int tolerance=100, long timeout=TM_ENDLESS)
Increments the motor specified by an index postion in encoder units.
Definition: kmlMotBase.cpp:370
void setAndStartPolyMovement(std::vector< short > polynomial, int exactflag, int moreflag)
Definition: kmlBase.cpp:233
const TMotPVP * GetPVP()
Definition: kmlMotBase.h:246
int encoderOffset
Definition: kmlMotBase.h:200
const TMotTPS * GetTPS()
Definition: kmlMotBase.h:243
void sendSpline(short targetPosition, short duration, short p1, short p2, short p3, short p4)
Definition: kmlMotBase.cpp:299
Initial motor parameters.
Definition: kmlMotBase.h:199
TMotDYL getMotDYL(short number)
int encodersPerCycle
Definition: kmlMotBase.h:201
void recvPVP()
receive data
Definition: kmlMotBase.cpp:90
void inc(long idx, int dif, bool wait=false, int tolerance=100, long timeout=TM_ENDLESS)
Increments the motor specified by an index postion in encoders.
Definition: kmlExt.cpp:38
void decDegrees(double dif, bool wait=false, int tolerance=100, long timeout=TM_ENDLESS)
Decrements the motor specified by an index postion in degrees.
Definition: kmlMotBase.cpp:434
void openGripper(bool waitUntilReached=false, int waitTimeout=100)
Definition: kmlExt.cpp:551
void startSplineMovement(int exactflag, int moreflag=1)
Definition: kmlBase.cpp:223
void switchRobotOn()
Definition: kmlExt.cpp:578
void waitFor(TMotStsFlg status, int waitTimeout)
Definition: kmlExt.cpp:458
[TPS] target position
Definition: kmlMotBase.h:103
CMotBase * arr
array of motors
Definition: kmlMotBase.h:42
void switchMotorOff(short number)
Definition: kmlExt.cpp:596
void setAccelerationLimit(short acceleration)
Set the acceleration limits.
Definition: kmlMotBase.cpp:149
void setRobotVelocityLimit(short velocity)
Definition: kmlExt.cpp:404
calibrate
Definition: kmlMotBase.h:50
byte maxppwm_nmp
Max. value for positive voltage (0 => 0%, +70 => 100%)
Definition: kmlMotBase.h:127
[APS] actual position
Definition: kmlMotBase.h:96
TSearchDir
Definition: kmlMotBase.h:69
TMotStsFlg
status flags
Definition: kmlMotBase.h:58
void dec(long idx, int dif, bool wait=false, int tolerance=100, long timeout=TM_ENDLESS)
Decrements the motor specified by an index postion in encoders.
Definition: kmlExt.cpp:42
TMotCLB getMotCLB(short number)
int flushMoveBuffers()
flush move buffers on all motors:
Definition: kmlBase.cpp:291
void disableCrashLimits()
crash limits disable
Definition: kmlBase.cpp:186
KNI::Timer kni_timer
Definition: kmlExt.cpp:33
void setCalibrationParameters(bool doCalibration, short order, TSearchDir direction, TMotCmdFlg motorFlagAfter, int encoderPositionAfter)
Definition: kmlMotBase.cpp:343
CCplBase * getProtocol()
get a handle of the protocol, used in CKatana
Definition: kmlBase.h:200
bool _gripperIsPresent
Definition: kmlExt.h:69
void getParameterOrLimit(int subcommand, byte *R1, byte *R2, byte *R3)
Definition: kmlMotBase.cpp:274
void switchRobotOff()
Definition: kmlExt.cpp:584
int crash_limit_lin_nmp
Limit of error in position in linear movement.
Definition: kmlMotBase.h:133
void moveRobotToEnc4D(std::vector< int > target, int velocity=180, int acceleration=1, int encTolerance=100)
Move to robot to given target in the vector-container with the given velocity, acceleration and toler...
Definition: kmlExt.cpp:514
[DYL] dynamic limits
Definition: kmlMotBase.h:138
int numberOfMotors
Definition: kni_wrapper.cpp:31
void setForceLimit(int axis, int limit)
Set the force limit for the current controller.
Definition: kmlExt.cpp:314
int readDigitalIO()
get digital I/O data from Katana400:
Definition: kmlBase.cpp:278
void incDegrees(long idx, double dif, bool wait=false, int tolerance=100, long timeout=TM_ENDLESS)
Increments the motor specified by an index postion in degree units.
Definition: kmlExt.cpp:52
const TMotDYL * GetDYL()
Definition: kmlMotBase.h:245
void moveMotorByEnc(short number, int encoders, bool waitUntilReached=false, int waitTimeout=0)
Definition: kmlExt.cpp:423
void WaitUntilElapsed() const
Definition: Timer.cpp:78
int getMotorEncoders(short number, bool refreshEncoders=true) const
Definition: kmlExt.cpp:362
void moveMotorBy(short number, double radianAngle, bool waitUntilReached=false, int waitTimeout=0)
Definition: kmlExt.cpp:432
void waitFor(TMotStsFlg status, int waitTimeout, bool gripper)
wait for motor on all motors
Definition: kmlBase.cpp:118
const TKatMOT * GetMOT()
Get a pointer to the desired structure.
Definition: kmlBase.h:165
void startSplineMovement(bool exactflag, int moreflag=1)
Definition: kmlExt.cpp:618
void setTolerance(long idx, int enc_tolerance)
Sets the tolerance range in encoder units for the robots movements.
Definition: kmlExt.cpp:271
Calibration structure for single motors.
Definition: kmlMotBase.h:182
void searchMechStop(long idx, TSearchDir dir, TMotSCP scp, TMotDYL dyl)
Definition: kmlExt.cpp:195
virtual void comm(const byte *pack, byte *buf, byte *size)=0
Base communication function.
void recvMPS()
read all motor positions simultaneously
Definition: kmlBase.cpp:247
Inverse Kinematics structure of the endeffektor.
Definition: kmlBase.h:113
[MOT] every motor&#39;s attributes
Definition: kmlMotBase.h:40
void movDegrees(long idx, double tar, bool wait=false, int tolerance=100, long timeout=TM_ENDLESS)
Moves the motor specified by an index to a given target position in degree units. ...
Definition: kmlExt.cpp:60
int getCurrentControllerType(int axis)
Get the axis controller type.
Definition: kmlExt.cpp:351
void setSCP(TMotSCP _scp)
Definition: kmlMotBase.h:279
int mKinematics
The kinematics implementation: 0 for Analytical, 1 for RobAnaGuess.
Definition: kmlExt.h:75
void setPositionCollisionLimit(int limit)
Set the collision limit.
Definition: kmlMotBase.cpp:259
search direction for the meachanical stopper
Definition: kmlMotBase.h:70
short getForce(int axis)
Get the current force.
Definition: kmlExt.cpp:344
void mov(int tar, bool wait=false, int tolerance=100, long timeout=TM_ENDLESS)
Moves the motor specified by an index to a given target position in encoder units.
Definition: kmlMotBase.cpp:380
byte kI_nmp
Integral factor (1/kI) of control output added to the final control output.
Definition: kmlMotBase.h:131
int rotationDirection
Definition: kmlMotBase.h:204
TMotInit getMotInit(short number)
void incDegrees(double dif, bool wait=false, int tolerance=100, long timeout=TM_ENDLESS)
Increments the motor specified by an index postion in degrees.
Definition: kmlMotBase.cpp:427
void sendAPS(const TMotAPS *_aps)
send data
Definition: kmlMotBase.cpp:53
double angleRange
Definition: kmlMotBase.h:203
void sleep(long time)
Definition: Timer.cpp:86
short getMotorVelocityLimit(short number) const
Definition: kmlExt.cpp:390
void recvGMS()
receive data
Definition: kmlBase.cpp:102
void setCrashLimitLinear(int limit_lin)
Set the crash limit linear.
Definition: kmlMotBase.cpp:224
bool checkAngleInRange(double angle)
check limits in encoder values
Definition: kmlMotBase.cpp:362
void calibrate()
Definition: kmlExt.cpp:115
short tarpos
target position
Definition: kmlMotBase.h:105
void setCrashLimit(int limit)
Set the crash limit.
Definition: kmlMotBase.cpp:206
[SCP] static controller parameters
Definition: kmlMotBase.h:110
std::vector< int >::iterator getRobotEncoders(std::vector< int >::iterator start, std::vector< int >::const_iterator end, bool refreshEncoders=true) const
Definition: kmlExt.cpp:369
void unBlock()
unblock robot after a crash
Definition: kmlExt.cpp:291
void closeGripper(bool waitUntilReached=false, int waitTimeout=100)
Definition: kmlExt.cpp:558
TKatGNL getGNL()
void setSpeedLimit(short velocity)
Definition: kmlMotBase.h:331
void Start()
Definition: Timer.cpp:51
double angleOffset
Definition: kmlMotBase.h:202
#define max(a, b)
Definition: kmlExt.cpp:32
void waitForMotor(short number, int encoders, int encTolerance=100, short mode=0, int waitTimeout=5000)
Definition: kmlExt.cpp:453
void getGripperParameters(bool &isPresent, int &openEncoders, int &closeEncoders)
short pos
position
Definition: kmlMotBase.h:164
void switchMotorOn(short number)
Definition: kmlExt.cpp:589
int crash_limit_nmp
Limit of error in position.
Definition: kmlMotBase.h:132
const TMotInit * GetInitialParameters()
Definition: kmlMotBase.h:250
short order
order in which this motor will be calibrated. range: 0..5
Definition: kmlMotBase.h:184
void setInitialParameters(double angleOffset, double angleRange, int encodersPerCycle, int encoderOffset, int rotationDirection)
Definition: kmlMotBase.cpp:324
void setMotorAccelerationLimit(short number, short acceleration)
Definition: kmlExt.cpp:411
void create(const char *configurationFile, CCplBase *protocol)
Create routine.
Definition: kmlExt.cpp:65
[GNL] general robot attributes
Definition: kmlBase.h:67
void setSpeedCollisionLimit(long idx, int limit)
set collision speed limits
Definition: kmlExt.cpp:310
TSearchDir dir
search direction for mech. stopper
Definition: kmlMotBase.h:186
short cnt
count of motors
Definition: kmlMotBase.h:41
void setMotorVelocityLimit(short number, short velocity)
Definition: kmlExt.cpp:399
void dec(int dif, bool wait=false, int tolerance=100, long timeout=TM_ENDLESS)
Decrements the motor specified by an index postion in encoder units.
Definition: kmlMotBase.cpp:375
TMotStsFlg msf
motor status flag
Definition: kmlMotBase.h:163
set the motor on
Definition: kmlMotBase.h:52
void setCrashLimit(long idx, int limit)
set collision limits
Definition: kmlBase.cpp:197
int velocity
TKatMOT getMOT()
const TMotSFW * GetSFW()
Definition: kmlMotBase.h:247
short vel
velocity
Definition: kmlMotBase.h:165
int checkKatanaType(int type)
checks for a K300 or K400
Definition: kmlBase.cpp:260
short getNumberOfMotors() const
Definition: kmlExt.cpp:357
TMotCmdFlg mcfAPS
motor command flag
Definition: kmlMotBase.h:97
void flushMoveBuffers()
flush move buffers
Definition: kmlExt.cpp:296
byte type
controller type
Definition: kmlMotBase.h:90
byte maxaccel_nmp
Maximal acceleration and deceleration.
Definition: kmlMotBase.h:154
void freezeRobot()
Definition: kmlExt.cpp:566
TMotCmdFlg
command flags
Definition: kmlMotBase.h:48
freeze the motor
Definition: kmlMotBase.h:51
int _gripperCloseEncoders
Definition: kmlExt.h:71
void setPositionCollisionLimit(long idx, int limit)
set collision position limits
Definition: kmlExt.cpp:306
byte maxnpwm_nmp
Max. value for negative voltage (0 => 0%, +70 => 100%)
Definition: kmlMotBase.h:128
void waitForMotor(int tar, int encTolerance=100, short mode=0, int waitTimeout=TM_ENDLESS)
Waits until the Motor has reached the given targen position.
Definition: kmlMotBase.cpp:396
void unBlock()
unblock robot after a crash
Definition: kmlBase.cpp:217
void setDYL(TMotDYL _dyl)
Definition: kmlMotBase.h:280
void recvSFW()
receive data
Definition: kmlMotBase.cpp:109
TMotCmdFlg mcfTPS
motor command flag
Definition: kmlMotBase.h:104
void moveRobotToEnc(std::vector< int >::const_iterator start, std::vector< int >::const_iterator end, bool waitUntilReached=false, int encTolerance=100, int waitTimeout=0)
Definition: kmlExt.cpp:463
short maxpspeed_nmp
Max. allowed forward speed.
Definition: kmlMotBase.h:155
void setRobotAccelerationLimit(short acceleration)
Definition: kmlExt.cpp:416
const TMotSCP * GetSCP()
Definition: kmlMotBase.h:244
void setSpeedCollisionLimit(int limit)
Set the collision limit.
Definition: kmlMotBase.cpp:243
void enableCrashLimits()
crash limits enable
Definition: kmlExt.cpp:281
byte kpos_nmp
Proportional factor of position compensator.
Definition: kmlMotBase.h:130
short maxnspeed_nmp
Max. allowed reverse speed.
Definition: kmlMotBase.h:156
int _gripperOpenEncoders
Definition: kmlExt.h:70
std::vector< int > encoders
Definition: kni_wrapper.cpp:29
void disableCrashLimits()
crash limits disable
Definition: kmlExt.cpp:286
void setSpeedLimits(short positiveVelocity, short negativeVelocity)
Set speed limits.
Definition: kmlMotBase.cpp:130
void getGripperParameters(bool &isPresent, int &openEncoders, int &closeEncoders)
Get the gripper parameters.
Definition: kmlExt.cpp:611
byte kspeed_nmp
Proportional factor of speed compensator.
Definition: kmlMotBase.h:129
set the motor off
Definition: kmlMotBase.h:49
int readDigitalIO()
Read The Digital I/Os.
Definition: kmlExt.cpp:647
TKatSCT getSCT()
void moveMotorToEnc(short number, int encoders, bool waitUntilReached=false, int encTolerance=100, int waitTimeout=0)
Definition: kmlExt.cpp:438
short getMotorAccelerationLimit(short number) const
Definition: kmlExt.cpp:394
void setAndStartPolyMovement(std::vector< short > polynomial, bool exactflag, int moreflag)
Definition: kmlExt.cpp:636
void movDegrees(double tar, bool wait=false, int tolerance=100, long timeout=TM_ENDLESS)
Moves the motor specified by an index to a given target position in degrees.
Definition: kmlMotBase.cpp:441


kni
Author(s): Martin Günther
autogenerated on Fri Jun 7 2019 22:06:44