22 static std::unique_ptr<CLMBase>
katana;
23 static std::unique_ptr<CCdlSocket>
device;
24 static std::unique_ptr<CCplSerialCRC>
protocol;
27 std::map< std::string, std::vector<TMovement> >
movements;
54 std::cout <<
"ERROR: " << e.
message() << std::endl;
56 MessageBox(NULL, TEXT(e.
message().c_str()),TEXT(
"KNI ERROR"),MB_OK | MB_ICONWARNING | MB_SYSTEMMODAL);
68 std::cout <<
"ERROR: " << e.
message() << std::endl;
70 MessageBox(NULL, TEXT(e.
message().c_str()),TEXT(
"KNI ERROR"),MB_OK | MB_ICONWARNING | MB_SYSTEMMODAL);
80 katana->setMotorVelocityLimit(axis-1, speed);
82 katana->setMotorAccelerationLimit(axis-1, accel);
84 katana->moveMotorToEnc(axis-1, enc);
97 std::cout <<
"ERROR: " << e.
message() << std::endl;
99 MessageBox(NULL, TEXT(e.
message().c_str()),TEXT(
"KNI ERROR"),MB_OK | MB_ICONWARNING | MB_SYSTEMMODAL);
108 katana->moveMotorToEnc(axis-1, targetpos);
112 std::cout <<
"ERROR: " << e.
message() << std::endl;
114 MessageBox(NULL, TEXT(e.
message().c_str()),TEXT(
"KNI ERROR"),MB_OK | MB_ICONWARNING | MB_SYSTEMMODAL);
123 katana->switchMotorOn(axis-1);
126 std::cout <<
"ERROR: " << e.
message() << std::endl;
128 MessageBox(NULL, TEXT(e.
message().c_str()),TEXT(
"KNI ERROR"),MB_OK | MB_ICONWARNING | MB_SYSTEMMODAL);
137 katana->switchMotorOff(axis-1);
140 std::cout <<
"ERROR: " << e.
message() << std::endl;
142 MessageBox(NULL, TEXT(e.
message().c_str()),TEXT(
"KNI ERROR"),MB_OK | MB_ICONWARNING | MB_SYSTEMMODAL);
154 std::cout <<
"ERROR: " << e.
message() << std::endl;
156 MessageBox(NULL, TEXT(e.
message().c_str()),TEXT(
"KNI ERROR"),MB_OK | MB_ICONWARNING | MB_SYSTEMMODAL);
168 std::cout <<
"ERROR: " << e.
message() << std::endl;
170 MessageBox(NULL, TEXT(e.
message().c_str()),TEXT(
"KNI ERROR"),MB_OK | MB_ICONWARNING | MB_SYSTEMMODAL);
180 int openEncoders = 30770;
181 int closeEncoders = 12240;
183 katana->setGripperParameters(hasGripper, openEncoders, closeEncoders);
186 std::cout <<
"ERROR: " << e.
message() << std::endl;
188 MessageBox(NULL, TEXT(e.
message().c_str()),TEXT(
"KNI ERROR"),MB_OK | MB_ICONWARNING | MB_SYSTEMMODAL);
200 std::cout <<
"ERROR: " << e.
message() << std::endl;
202 MessageBox(NULL, TEXT(e.
message().c_str()),TEXT(
"KNI ERROR"),MB_OK | MB_ICONWARNING | MB_SYSTEMMODAL);
214 std::cout <<
"ERROR: " << e.
message() << std::endl;
216 MessageBox(NULL, TEXT(e.
message().c_str()),TEXT(
"KNI ERROR"),MB_OK | MB_ICONWARNING | MB_SYSTEMMODAL);
224 std::cout <<
"moving to: " << enc1 <<
", " << enc2 <<
", " << enc3 <<
", " << enc4 <<
", " << enc5 <<
", " << enc6 <<
"\n";
228 katana->setMotorVelocityLimit(i, velocity);
230 katana->setMotorAccelerationLimit(i, acceleration);
233 std::vector<int>
enc;
240 katana->moveRobotToEnc(enc.begin(), enc.end(), _wait, tolerance);
243 std::cout <<
"ERROR: " << e.
message() << std::endl;
245 MessageBox(NULL, TEXT(e.
message().c_str()),TEXT(
"KNI ERROR"),MB_OK | MB_ICONWARNING | MB_SYSTEMMODAL);
254 katana->sendSplineToMotor((
unsigned short) (axis-1), (
short) targetpos, (
short) duration, p0, p1, p2, p3);
257 std::cout <<
"ERROR: " << e.
message() << std::endl;
259 MessageBox(NULL, TEXT(e.
message().c_str()),TEXT(
"KNI ERROR"),MB_OK | MB_ICONWARNING | MB_SYSTEMMODAL);
268 bool exact = (exactflag != 0);
269 katana->startSplineMovement(exact, contd);
272 std::cout <<
"ERROR: " << e.
message() << std::endl;
274 MessageBox(NULL, TEXT(e.
message().c_str()),TEXT(
"KNI ERROR"),MB_OK | MB_ICONWARNING | MB_SYSTEMMODAL);
283 katana->flushMoveBuffers();
286 std::cout <<
"ERROR: " << e.
message() << std::endl;
288 MessageBox(NULL, TEXT(e.
message().c_str()),TEXT(
"KNI ERROR"),MB_OK | MB_ICONWARNING | MB_SYSTEMMODAL);
300 std::cout <<
"ERROR: " << e.
message() << std::endl;
302 MessageBox(NULL, TEXT(e.
message().c_str()),TEXT(
"KNI ERROR"),MB_OK | MB_ICONWARNING | MB_SYSTEMMODAL);
316 std::cout <<
"ERROR: " << e.
message() << std::endl;
318 MessageBox(NULL, TEXT(e.
message().c_str()),TEXT(
"KNI ERROR"),MB_OK | MB_ICONWARNING | MB_SYSTEMMODAL);
329 katana->moveRobotLinearTo(targetPos->
X, targetPos->
Y, targetPos->
Z, targetPos->
phi, targetPos->
theta, targetPos->
psi);
332 std::cout <<
"ERROR: " << e.
message() << std::endl;
334 MessageBox(NULL, TEXT(e.
message().c_str()),TEXT(
"KNI ERROR"),MB_OK | MB_ICONWARNING | MB_SYSTEMMODAL);
344 std::string name_str(name);
347 movements[name_str].push_back(*movement);
350 std::cout <<
"ERROR: " << e.
message() << std::endl;
352 MessageBox(NULL, TEXT(e.
message().c_str()),TEXT(
"KNI ERROR"),MB_OK | MB_ICONWARNING | MB_SYSTEMMODAL);
363 std::string name_str(name);
365 std::map< std::string, std::vector<TMovement> >::iterator it;
373 if ((
int)movement_vector.size() >= index) {
378 movement_vector.erase(movement_vector.begin()+index);
387 std::cout <<
"ERROR: " << e.
message() << std::endl;
389 MessageBox(NULL, TEXT(e.
message().c_str()),TEXT(
"KNI ERROR"),MB_OK | MB_ICONWARNING | MB_SYSTEMMODAL);
400 std::string name_str(name);
402 std::map< std::string, std::vector<TMovement> >::iterator it;
417 std::cout <<
"ERROR: " << e.
message() << std::endl;
419 MessageBox(NULL, TEXT(e.
message().c_str()),TEXT(
"KNI ERROR"),MB_OK | MB_ICONWARNING | MB_SYSTEMMODAL);
430 std::string name_str(name);
432 std::map< std::string, std::vector<TMovement> >::iterator it;
441 int size = (int)movement_vector.size();
446 struct TPos *lastpos;
447 for (
int j = 0; j < loops; ++j) {
449 for (
int i = 0; i <
size; ++i) {
455 lastpos = &((movement_vector.at(i-1)).pos);
460 lastpos, first, last);
473 std::cout <<
"ERROR: " << e.
message() << std::endl;
475 MessageBox(NULL, TEXT(e.
message().c_str()),TEXT(
"KNI ERROR"),MB_OK | MB_ICONWARNING | MB_SYSTEMMODAL);
497 bool first,
bool last){
512 katana->movP2P(startPos->
X, startPos->
Y, startPos->
Z, startPos->
phi,
531 katana->movLM2P(startPos->
X, startPos->
Y, startPos->
Z, startPos->
phi,
552 packet[2] = (
byte)address;
553 packet[3] = (
byte)(value >> 8);
554 packet[4] = (
byte)value;
556 if (!
buffer[0] || ((
short) size != 4)){
561 std::cout <<
"ERROR: " << e.
message() << std::endl;
563 MessageBox(NULL, TEXT(e.
message().c_str()),TEXT(
"KNI ERROR"),MB_OK | MB_ICONWARNING | MB_SYSTEMMODAL);
576 packet[2] = (
byte)address;
578 if (!
buffer[0] || ((
short) size != 4)){
587 std::cout <<
"ERROR: " << e.
message() << std::endl;
589 MessageBox(NULL, TEXT(e.
message().c_str()),TEXT(
"KNI ERROR"),MB_OK | MB_ICONWARNING | MB_SYSTEMMODAL);
602 packet[2] = (
byte)value << output;
606 if (!
buffer[0] || ((
short) size != 2)) {
607 std::cout <<
" command failed!" << std::endl;
612 std::cout <<
"ERROR: " << e.
message() << std::endl;
614 MessageBox(NULL, TEXT(e.
message().c_str()),TEXT(
"KNI ERROR"),MB_OK | MB_ICONWARNING | MB_SYSTEMMODAL);
631 if (!
buffer[0] || ((
short) size != 2)) {
632 std::cout <<
" command failed!" << std::endl;
637 std::cout <<
"ERROR: " << e.
message() << std::endl;
639 MessageBox(NULL, TEXT(e.
message().c_str()),TEXT(
"KNI ERROR"),MB_OK | MB_ICONWARNING | MB_SYSTEMMODAL);
643 byte mask =
static_cast<byte>(pow(static_cast<double>(2), inputNr-1));
645 if((mask & (
int)
buffer[1]) > 0){
659 katana->GetBase()->GetMOT()->arr[i].sendTPS(&tps);
663 std::cout <<
"ERROR: " << e.
message() << std::endl;
665 MessageBox(NULL, TEXT(e.
message().c_str()),TEXT(
"KNI ERROR"),MB_OK | MB_ICONWARNING | MB_SYSTEMMODAL);
674 katana->GetBase()->GetMOT()->arr[axis-1].recvPVP();
675 short vel =
katana->GetBase()->GetMOT()->arr[axis-1].GetPVP()->vel;
679 std::cout <<
"ERROR: " << e.
message() << std::endl;
681 MessageBox(NULL, TEXT(e.
message().c_str()),TEXT(
"KNI ERROR"),MB_OK | MB_ICONWARNING | MB_SYSTEMMODAL);
690 katana->GetBase()->GetMOT()->arr[axis-1].recvPVP();
691 byte pwm =
katana->GetBase()->GetMOT()->arr[axis-1].GetPVP()->pwm;
695 std::cout <<
"ERROR: " << e.
message() << std::endl;
697 MessageBox(NULL, TEXT(e.
message().c_str()),TEXT(
"KNI ERROR"),MB_OK | MB_ICONWARNING | MB_SYSTEMMODAL);
710 std::cout <<
"ERROR: " << e.
message() << std::endl;
712 MessageBox(NULL, TEXT(e.
message().c_str()),TEXT(
"KNI ERROR"),MB_OK | MB_ICONWARNING | MB_SYSTEMMODAL);
721 katana->GetBase()->GetMOT()->arr[axis-1].recvSFW();
722 int v = (int)
katana->GetBase()->GetMOT()->arr[axis-1].GetSFW()->version;
723 int sv = (int)
katana->GetBase()->GetMOT()->arr[axis-1].GetSFW()->subversion;
724 int r = (int)
katana->GetBase()->GetMOT()->arr[axis-1].GetSFW()->revision;
725 std::stringstream ss;
726 ss << v <<
"." << sv <<
"." << r;
727 const char* cstr = ss.str().c_str();
731 value[index] = cstr[index];
732 }
while (cstr[index] !=
'\0');
735 std::cout <<
"ERROR: " << e.
message() << std::endl;
737 MessageBox(NULL, TEXT(e.
message().c_str()),TEXT(
"KNI ERROR"),MB_OK | MB_ICONWARNING | MB_SYSTEMMODAL);
746 katana->GetBase()->recvMFW();
747 int v = (int)
katana->GetBase()->GetMFW()->ver;
748 int r = (int)
katana->GetBase()->GetMFW()->rev;
749 std::stringstream ss;
751 const char* cstr = ss.str().c_str();
755 value[index] = cstr[index];
756 }
while (cstr[index] !=
'\0');
759 std::cout <<
"ERROR: " << e.
message() << std::endl;
761 MessageBox(NULL, TEXT(e.
message().c_str()),TEXT(
"KNI ERROR"),MB_OK | MB_ICONWARNING | MB_SYSTEMMODAL);
771 katana->enableCrashLimits();
773 else katana->disableCrashLimits();
776 std::cout <<
"ERROR: " << e.
message() << std::endl;
778 MessageBox(NULL, TEXT(e.
message().c_str()),TEXT(
"KNI ERROR"),MB_OK | MB_ICONWARNING | MB_SYSTEMMODAL);
787 katana->setPositionCollisionLimit(axis-1, limit);
790 std::cout <<
"ERROR: " << e.
message() << std::endl;
792 MessageBox(NULL, TEXT(e.
message().c_str()),TEXT(
"KNI ERROR"),MB_OK | MB_ICONWARNING | MB_SYSTEMMODAL);
801 katana->setSpeedCollisionLimit(axis-1, limit);
804 std::cout <<
"ERROR: " << e.
message() << std::endl;
806 MessageBox(NULL, TEXT(e.
message().c_str()),TEXT(
"KNI ERROR"),MB_OK | MB_ICONWARNING | MB_SYSTEMMODAL);
819 std::cout <<
"ERROR: " << e.
message() << std::endl;
821 MessageBox(NULL, TEXT(e.
message().c_str()),TEXT(
"KNI ERROR"),MB_OK | MB_ICONWARNING | MB_SYSTEMMODAL);
830 katana->setForceLimit(axis, limit);
833 std::cout <<
"ERROR: " << e.
message() << std::endl;
835 MessageBox(NULL, TEXT(e.
message().c_str()),TEXT(
"KNI ERROR"),MB_OK | MB_ICONWARNING | MB_SYSTEMMODAL);
844 return katana->getForce(axis);
847 std::cout <<
"ERROR: " << e.
message() << std::endl;
849 MessageBox(NULL, TEXT(e.
message().c_str()),TEXT(
"KNI ERROR"),MB_OK | MB_ICONWARNING | MB_SYSTEMMODAL);
857 return katana->getCurrentControllerType(axis);
860 std::cout <<
"ERROR: " << e.
message() << std::endl;
862 MessageBox(NULL, TEXT(e.
message().c_str()),TEXT(
"KNI ERROR"),MB_OK | MB_ICONWARNING | MB_SYSTEMMODAL);
873 std::cout <<
"ERROR: " << e.
message() << std::endl;
875 MessageBox(NULL, TEXT(e.
message().c_str()),TEXT(
"KNI ERROR"),MB_OK | MB_ICONWARNING | MB_SYSTEMMODAL);
884 katana->GetBase()->GetMOT()->arr[axis-1].setControllerParameters(kspeed, kpos, ki);
887 std::cout <<
"ERROR: " << e.
message() << std::endl;
889 MessageBox(NULL, TEXT(e.
message().c_str()),TEXT(
"KNI ERROR"),MB_OK | MB_ICONWARNING | MB_SYSTEMMODAL);
900 katana->setMotorVelocityLimit(i, vel);
904 katana->setMotorVelocityLimit(axis-1, vel);
906 katana->setMaximumLinearVelocity((
double)vel);
909 std::cout <<
"ERROR: " << e.
message() << std::endl;
911 MessageBox(NULL, TEXT(e.
message().c_str()),TEXT(
"KNI ERROR"),MB_OK | MB_ICONWARNING | MB_SYSTEMMODAL);
922 katana->setMotorAccelerationLimit(i, acceleration);
926 katana->setMotorAccelerationLimit(axis-1, acceleration);
931 std::cout <<
"ERROR: " << e.
message() << std::endl;
933 MessageBox(NULL, TEXT(e.
message().c_str()),TEXT(
"KNI ERROR"),MB_OK | MB_ICONWARNING | MB_SYSTEMMODAL);
942 return katana->getNumberOfMotors();
945 std::cout <<
"ERROR: " << e.
message() << std::endl;
947 MessageBox(NULL, TEXT(e.
message().c_str()),TEXT(
"KNI ERROR"),MB_OK | MB_ICONWARNING | MB_SYSTEMMODAL);
957 katana->GetBase()->recvECH();
960 std::cout <<
"ERROR: " << e.
message() << std::endl;
962 MessageBox(NULL, TEXT(e.
message().c_str()),TEXT(
"KNI ERROR"),MB_OK | MB_ICONWARNING | MB_SYSTEMMODAL);
double phi
the orientation of the TCP
static std::unique_ptr< CCdlSocket > device
unsigned char byte
type specification (8 bit)
DLLEXPORT int executeMovement(struct TMovement *movement)
static std::unique_ptr< CCplSerialCRC > protocol
std::string message() const
ETransition transition
the transition to this position, PTP or LINEAR
DLLEXPORT int initKatana(char *configFile, char *ipaddress)
This initializes the Katana (communication etc)
DLLEXPORT int moveMotAndWait(int axis, int targetpos, int tolerance)
int getVersion(char value[])
gets the controlboard firmware version and returns it in the value argument
DLLEXPORT int setCollisionParameters(int axis, int position, int velocity)
DLLEXPORT int moveToPosLin(struct TPos *targetPos, int velocity, int acceleration)
moves in LM
DLLEXPORT int setPositionCollisionLimit(int axis, int limit)
#define TM_ENDLESS
timeout symbol for 'endless' waiting
Implement the Serial-Zero protocol.
TPos pos
The position, see above struct TPos.
DLLEXPORT int motorOn(int axis)
DLLEXPORT int moveToPos(struct TPos *pos, int velocity, int acceleration)
moves in IK
DLLEXPORT int pushMovementToStack(struct TMovement *movement, char *name)
int getAxisFirmwareVersion(int axis, char value[])
gets the axis firmware version and returns it in the value argument
DLLEXPORT int getNumberOfMotors()
returns the number of motors configured
DLLEXPORT int ModBusTCP_writeWord(int address, int value)
int getEncoder(int axis, int &value)
DLLEXPORT int allMotorsOff()
extern C because we want to access these interfaces from anywhere:
DLLEXPORT int clearMoveBuffers()
clears the movebuffers
DLLEXPORT int closeGripper()
int velocity
The velocitiy for this particular movement.
DLLEXPORT int setMaxAccel(int axis, int acceleration)
DLLEXPORT int openGripper()
DLLEXPORT int allMotorsOn()
int ModBusTCP_readWord(int address, int &value)
reads a value from the register 'address' (if not connected, connect to the IP in katana...
int IO_readInput(int inputNr, int &value)
DLLEXPORT int motorOff(int axis)
DLLEXPORT int getCurrentControllerType(int axis)
DLLEXPORT int IO_setOutput(char output, int value)
std::vector< TMovement * > movement_vector
DLLEXPORT int getPosition(struct TPos *pos)
gets a position
DLLEXPORT int unblock()
unblocks the robot after collision/instantstop
static std::unique_ptr< CLMBase > katana
DLLEXPORT int executeConnectedMovement(struct TMovement *movement, struct TPos *startPos, bool first, bool last)
Encapsulates the socket communication device.
DLLEXPORT int moveToPosEnc(int enc1, int enc2, int enc3, int enc4, int enc5, int enc6, int velocity, int acceleration, int tolerance, bool _wait)
DLLEXPORT int setMaxVelocity(int axis, int vel)
int acceleration
the acceleration for this particular movement
double X
The position in cartesian space.
DLLEXPORT int deleteMovementFromStack(char *name, int index)
DLLEXPORT int runThroughMovementStack(char *name, int loops)
int getDrive(int axis, int &value)
int getVelocity(int axis, int &value)
DLLEXPORT int sendSplineToMotor(int axis, int targetpos, int duration, int p0, int p1, int p2, int p3)
DLLEXPORT int startSplineMovement(int contd, int exactflag)
DLLEXPORT int setForceLimit(int axis, int limit)
DLLEXPORT int setCollisionDetection(int axis, bool state)
DLLEXPORT int setControllerParameters(int axis, int ki, int kspeed, int kpos)
DLLEXPORT int deleteMovementStack(char *name)
deletes a movemnt stack
DLLEXPORT int flushMoveBuffers()
flush all the movebuffers
DLLEXPORT int ping(int axis)
DLLEXPORT int calibrate(int axis)
std::map< std::string, std::vector< TMovement > > movements
DLLEXPORT int moveMot(int axis, int enc, int speed, int accel)
DLLEXPORT int getForce(int axis)
set the current force
std::vector< int > encoders
DLLEXPORT int setGripper(bool hasGripper)
DLLEXPORT int waitForMot(int axis, int targetpos, int tolerance)
DLLEXPORT int setVelocityCollisionLimit(int axis, int limit)