KatanaNativeInterface  $VERSION$
kmlExt.h
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 /******************************************************************************************************************/
23 #ifndef _KMLEXT_H_
24 #define _KMLEXT_H_
25 /******************************************************************************************************************/
26 #include "common/dllexport.h"
27 #include "common/exception.h"
28 
29 #include "KNI/kmlBase.h"
30 #include "KNI/kmlMotBase.h"
31 
32 #include <vector>
33 
34 
35 /******************************************************************************************************************/
36 
41 
46 public:
47  ConfigFileOpenException(const std::string & port) throw ():
48  Exception("Cannot open configuration file '" + port + "'", -40) {}
49 };
50 
54 
55 namespace KNI {
56  class kmlFactory;
57 }
58 
64 class DLLDIR CKatana {
65 protected:
66  //-------------------------------------//
68 
74 
77  void setTolerance(long idx, int enc_tolerance);
78 
79 public:
80  //-------------------------------------//
81  CKatBase* GetBase() { return base; }
82 
86  CKatana() { base = new CKatBase; }
89  ~CKatana() { delete base; }
90  //------------------------------------------------------------------------------//
93  void create(const char* configurationFile, CCplBase* protocol);
94  void create(KNI::kmlFactory* infos, CCplBase* protocol);
95 
98  void create(TKatGNL& gnl,
99  TKatMOT& mot,
100  TKatSCT& sct,
101  TKatEFF& eff,
102  CCplBase* protocol
103  );
104  //------------------------------------------------------------------------------//
105 
106 
107  /* \brief calibrates the robot
108  */
109  void calibrate();
110 
111  void calibrate( long idx,
112  TMotCLB clb,
113  TMotSCP scp,
114  TMotDYL dyl
115  );
116 
117  //------------------------------------------------------------------------------//
118 
119  void searchMechStop(long idx,
120  TSearchDir dir,
121  TMotSCP scp,
122  TMotDYL dyl
123  );
124 
125 
126  //------------------------------------------------------------------------------//
129  void inc(long idx, int dif, bool wait = false, int tolerance = 100, long timeout = TM_ENDLESS);
132  void dec(long idx, int dif, bool wait = false, int tolerance = 100, long timeout = TM_ENDLESS);
136  void mov(long idx, int tar, bool wait = false, int tolerance = 100, long timeout = TM_ENDLESS);
137 
138  //------------------------------------------------------------------------------//
141  void incDegrees(long idx, double dif, bool wait = false, int tolerance = 100, long timeout = TM_ENDLESS);
144  void decDegrees(long idx, double dif, bool wait = false, int tolerance = 100, long timeout = TM_ENDLESS);
148  void movDegrees(long idx, double tar, bool wait = false, int tolerance = 100, long timeout = TM_ENDLESS);
149 
150  //------------------------------------------------------------------------------//
151 
152 
158  void setTPSP(long idx, int tar);
163  void resetTPSP();
168  void sendTPSP(bool wait = false, long timeout = TM_ENDLESS);
174  void setTPSPDegrees(long idx, double tar);
175 
176  //------------------------------------------------------------------------------//
177  // public just for dubbuging purposes
181  bool checkENLD(long idx, double degrees);
182 
183  //------------------------------------------------------------------------------//
184 
188  void setGripperParameters(bool isPresent, int openEncoders, int closeEncoders);
189 
190  //------------------------------------------------------------------------------//
191 
194  void enableCrashLimits();
197  void disableCrashLimits();
200  void unBlock();
203  void setCrashLimit(long idx, int limit);
206  void setPositionCollisionLimit(long idx, int limit);
209  void setSpeedCollisionLimit(long idx, int limit);
210 
211  //------------------------------------------------------------------------------//
212 
213  short getNumberOfMotors() const;
214  int getMotorEncoders(short number, bool refreshEncoders = true) const;
215 
219  std::vector<int>::iterator getRobotEncoders(std::vector<int>::iterator start, std::vector<int>::const_iterator end, bool refreshEncoders = true) const;
220 
224  std::vector<int> getRobotEncoders(bool refreshEncoders = true) const;
225 
226  short getMotorVelocityLimit( short number ) const;
227  short getMotorAccelerationLimit( short number ) const;
228 
229  void setMotorVelocityLimit( short number, short velocity );
230  void setMotorAccelerationLimit( short number, short acceleration );
231 
232  void setRobotVelocityLimit( short velocity );
235  void setRobotAccelerationLimit( short acceleration );
236 
237  void moveMotorByEnc( short number, int encoders, bool waitUntilReached = false, int waitTimeout = 0);
238  void moveMotorBy ( short number, double radianAngle, bool waitUntilReached = false, int waitTimeout = 0);
239 
240  void moveMotorToEnc( short number, int encoders, bool waitUntilReached = false, int encTolerance = 100, int waitTimeout = 0);
241  void moveMotorTo ( short number, double radianAngle, bool waitUntilReached = false, int waitTimeout = 0);
242 
243  void waitForMotor( short number, int encoders, int encTolerance = 100, short mode = 0, int waitTimeout = 5000);
244 
248  void moveRobotToEnc(std::vector<int>::const_iterator start, std::vector<int>::const_iterator end, bool waitUntilReached = false, int encTolerance = 100, int waitTimeout = 0);
252  void moveRobotToEnc(std::vector<int> encoders, bool waitUntilReached = false, int encTolerance = 100, int waitTimeout = 0);
254  void moveRobotToEnc4D(std::vector<int> target, int velocity=180, int acceleration = 1, int encTolerance = 100);
255 
256  void openGripper (bool waitUntilReached = false, int waitTimeout = 100);
257  void closeGripper(bool waitUntilReached = false, int waitTimeout = 100);
258 
259  void freezeRobot();
260  void freezeMotor(short number);
261  void switchRobotOn();
262  void switchRobotOff();
263  void switchMotorOn(short number);
264  void switchMotorOff(short number);
265 
269  void startSplineMovement(bool exactflag, int moreflag = 1);
270 
273  void startFourSplinesMovement(bool exactflag);
274 
278  void sendSplineToMotor(unsigned short number, short targetPosition, short duration, short p1, short p2, short p3, short p4);
279 
284  void sendFourSplinesToMotor(unsigned short number, short targetPosition, short duration, std::vector<short>& coefficients);
285  void sendFourSplinesToMotor(unsigned short number, short targetPosition, short duration, short p01, short p11, short p21, short p31, short p02, short p12, short p22, short p32,short p03, short p13, short p23, short p33,short p04, short p14, short p24, short p34);
286 };
287 
288 /******************************************************************************************************************/
289 #endif //_KMLEXT_H_
290 /******************************************************************************************************************/
int mKatanaType
The type of KatanaXXX (300 or 400)
Definition: kmlExt.h:73
CKatBase * base
base katana
Definition: kmlExt.h:67
Abstract base class for protocol definiton.
Definition: cplBase.h:47
[SCT] every sens ctrl's attributes
Definition: kmlSctBase.h:41
#define DLLDIR
Definition: dllexport.h:30
~CKatana()
Destructor.
Definition: kmlExt.h:89
ConfigFileOpenException(const std::string &port)
Definition: kmlExt.h:47
#define TM_ENDLESS
timeout symbol for 'endless' waiting
Definition: kmlBase.h:51
Base Katana class.
Definition: kmlBase.h:132
Exception(const std::string &message, const int error_number)
Definition: exception.h:85
TSearchDir
Definition: kmlMotBase.h:68
bool _gripperIsPresent
Definition: kmlExt.h:69
[DYL] dynamic limits
Definition: kmlMotBase.h:137
Calibration structure for single motors.
Definition: kmlMotBase.h:181
Inverse Kinematics structure of the endeffektor.
Definition: kmlBase.h:113
[MOT] every motor's attributes
Definition: kmlMotBase.h:40
CKatBase * GetBase()
Returns pointer to 'CKatBase*'.
Definition: kmlExt.h:81
Accessing the given configuration file failed (may be: access denied or wrong path)
Definition: kmlExt.h:45
Extended Katana class with additional functions.
Definition: kmlExt.h:64
[SCP] static controller parameters
Definition: kmlMotBase.h:109
[GNL] general robot attributes
Definition: kmlBase.h:67
CKatana()
Constructor.
Definition: kmlExt.h:86
int _gripperCloseEncoders
Definition: kmlExt.h:71
This class is for internal use only It may change at any time It shields the configuration file parsi...
Definition: kmlFactories.h:75
int _gripperOpenEncoders
Definition: kmlExt.h:70
Definition: Timer.h:30