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
46public:
47 ConfigFileOpenException(const std::string & port) throw ():
48 Exception("Cannot open configuration file '" + port + "'", -40) {}
49};
50
54
55namespace KNI {
56 class kmlFactory;
57}
58
65protected:
66 //-------------------------------------//
68
74
77 void setTolerance(long idx, int enc_tolerance);
78
79public:
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
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
260 void freezeMotor(short number);
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/******************************************************************************************************************/
Abstract base class for protocol definiton.
Definition: cplBase.h:47
Base Katana class.
Definition: kmlBase.h:132
Extended Katana class with additional functions.
Definition: kmlExt.h:64
void switchRobotOff()
void switchMotorOn(short number)
void disableCrashLimits()
crash limits disable
void startSplineMovement(bool exactflag, int moreflag=1)
Start a spline movement.
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)
int mKatanaType
The type of KatanaXXX (300 or 400)
Definition: kmlExt.h:73
void setMotorAccelerationLimit(short number, short acceleration)
int _gripperCloseEncoders
Definition: kmlExt.h:71
void sendSplineToMotor(unsigned short number, short targetPosition, short duration, short p1, short p2, short p3, short p4)
Send one spline to the motor.
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.
void switchRobotOn()
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.
void create(TKatGNL &gnl, TKatMOT &mot, TKatSCT &sct, TKatEFF &eff, CCplBase *protocol)
Create routine.
short getMotorVelocityLimit(short number) const
void openGripper(bool waitUntilReached=false, int waitTimeout=100)
void calibrate()
void switchMotorOff(short number)
bool _gripperIsPresent
Definition: kmlExt.h:69
void startFourSplinesMovement(bool exactflag)
Start a fourSplines movement.
void moveMotorBy(short number, double radianAngle, bool waitUntilReached=false, int waitTimeout=0)
void setCrashLimit(long idx, int limit)
unblock robot after a crash
void setTPSPDegrees(long idx, double tar)
Sets the target position of a motor in degree Units and allows the movement of that motor during the ...
void calibrate(long idx, TMotCLB clb, TMotSCP scp, TMotDYL dyl)
int getMotorEncoders(short number, bool refreshEncoders=true) const
void enableCrashLimits()
crash limits enable
void moveRobotToEnc(std::vector< int > encoders, bool waitUntilReached=false, int encTolerance=100, int waitTimeout=0)
Move to robot to given encoders in the vector-container.
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.
int _gripperOpenEncoders
Definition: kmlExt.h:70
void setTolerance(long idx, int enc_tolerance)
Sets the tolerance range in encoder units for the robots movements.
void resetTPSP()
Forbid the movement of all the motors during the parallel movement.
~CKatana()
Destructor.
Definition: kmlExt.h:89
void setPositionCollisionLimit(long idx, int limit)
set collision position limits
void setTPSP(long idx, int tar)
Sets the target position of a motor in encoders and allows the movement of that motor during the para...
short getNumberOfMotors() const
void setSpeedCollisionLimit(long idx, int limit)
set collision speed limits
void sendTPSP(bool wait=false, long timeout=TM_ENDLESS)
Moves the allowed motors simultaneously.
void moveMotorTo(short number, double radianAngle, bool waitUntilReached=false, int waitTimeout=0)
void create(const char *configurationFile, CCplBase *protocol)
Create routine.
bool checkENLD(long idx, double degrees)
Check if the absolute position in degrees is out of range.
std::vector< int >::iterator getRobotEncoders(std::vector< int >::iterator start, std::vector< int >::const_iterator end, bool refreshEncoders=true) const
Write the cached encoders into the container.
short getMotorAccelerationLimit(short number) const
void setGripperParameters(bool isPresent, int openEncoders, int closeEncoders)
Tell the robot about the presence of a gripper.
void freezeRobot()
void sendFourSplinesToMotor(unsigned short number, short targetPosition, short duration, std::vector< short > &coefficients)
Send four splines to the motor.
void closeGripper(bool waitUntilReached=false, int waitTimeout=100)
void moveRobotToEnc(std::vector< int >::const_iterator start, std::vector< int >::const_iterator end, bool waitUntilReached=false, int encTolerance=100, int waitTimeout=0)
Move to robot to given encoders.
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.
void freezeMotor(short number)
void setRobotAccelerationLimit(short acceleration)
Set the velocity of all motors together.
void setMotorVelocityLimit(short number, short velocity)
void moveMotorToEnc(short number, int encoders, bool waitUntilReached=false, int encTolerance=100, int waitTimeout=0)
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...
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.
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.
void waitForMotor(short number, int encoders, int encTolerance=100, short mode=0, int waitTimeout=5000)
void searchMechStop(long idx, TSearchDir dir, TMotSCP scp, TMotDYL dyl)
void setRobotVelocityLimit(short velocity)
void unBlock()
unblock robot after a crash
void moveMotorByEnc(short number, int encoders, bool waitUntilReached=false, int waitTimeout=0)
CKatBase * GetBase()
Returns pointer to 'CKatBase*'.
Definition: kmlExt.h:81
void create(KNI::kmlFactory *infos, CCplBase *protocol)
CKatBase * base
base katana
Definition: kmlExt.h:67
std::vector< int > getRobotEncoders(bool refreshEncoders=true) const
Get the current robot encoders as a vector-container.
CKatana()
Constructor.
Definition: kmlExt.h:86
Accessing the given configuration file failed (may be: access denied or wrong path)
Definition: kmlExt.h:45
ConfigFileOpenException(const std::string &port)
Definition: kmlExt.h:47
Exception(const std::string &message, const int error_number)
Definition: exception.h:85
This class is for internal use only It may change at any time It shields the configuration file parsi...
Definition: kmlFactories.h:75
#define DLLDIR
Definition: dllexport.h:30
#define TM_ENDLESS
timeout symbol for 'endless' waiting
Definition: kmlBase.h:51
TSearchDir
Definition: kmlMotBase.h:68
Definition: Timer.h:30
Inverse Kinematics structure of the endeffektor.
Definition: kmlBase.h:113
[GNL] general robot attributes
Definition: kmlBase.h:67
[MOT] every motor's attributes
Definition: kmlMotBase.h:40
[SCT] every sens ctrl's attributes
Definition: kmlSctBase.h:41
Calibration structure for single motors.
Definition: kmlMotBase.h:181
[DYL] dynamic limits
Definition: kmlMotBase.h:137
[SCP] static controller parameters
Definition: kmlMotBase.h:109