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