|
@ -13,37 +13,16 @@ |
|
|
#include "LinearTrajectory.h"
|
|
|
#include "LinearTrajectory.h"
|
|
|
#include <boost/thread/thread.hpp>
|
|
|
#include <boost/thread/thread.hpp>
|
|
|
|
|
|
|
|
|
void printUsage(SocketObject& client) |
|
|
|
|
|
|
|
|
void printUsage(SocketObject& client, std::string& arg) |
|
|
{ |
|
|
{ |
|
|
client.Send(SVR_HELP_MSG); |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void mattoabc(float M[3][4], float &a, float &b, float &c) |
|
|
|
|
|
{ |
|
|
|
|
|
float norm; |
|
|
|
|
|
float sa; |
|
|
|
|
|
float ca; |
|
|
|
|
|
|
|
|
|
|
|
norm = sqrt((M[0][0]*M[0][0])+(M[1][0]*M[1][0])); |
|
|
|
|
|
|
|
|
|
|
|
if (norm>1e-5) |
|
|
|
|
|
|
|
|
(void) arg; |
|
|
|
|
|
for (unsigned int i = 0 ; i < commandCount; ++i) |
|
|
{ |
|
|
{ |
|
|
sa = M[1][0]/norm; |
|
|
|
|
|
ca = M[0][0]/norm; |
|
|
|
|
|
a = atan2(sa,ca); |
|
|
|
|
|
} else { |
|
|
|
|
|
sa = 0; |
|
|
|
|
|
ca = 1; |
|
|
|
|
|
a = 0; |
|
|
|
|
|
|
|
|
if(commands[i].printHelp != NULL) |
|
|
|
|
|
commands[i].printHelp(); |
|
|
|
|
|
else |
|
|
|
|
|
client.Send(commands[i].aberration+"\t-\t"+commands[i].longVersion); |
|
|
} |
|
|
} |
|
|
b = atan2(-M[2][0],ca*M[0][0]+sa*M[1][0]); |
|
|
|
|
|
c = atan2(sa*M[0][2]-ca*M[1][2],-sa*M[0][1]+ca*M[1][1]); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void debugMat(Mat4f M) |
|
|
|
|
|
{ |
|
|
|
|
|
cout << M << "\n\r" << endl; |
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
VecJoint kukaBackwardCalc(double M_[12], float arg[3]) |
|
|
VecJoint kukaBackwardCalc(double M_[12], float arg[3]) |
|
@ -316,6 +295,96 @@ Mat4f getTranslation(double tx, double ty, double tz) |
|
|
|
|
|
|
|
|
SvrHandling::SvrHandling() |
|
|
SvrHandling::SvrHandling() |
|
|
{ |
|
|
{ |
|
|
|
|
|
// add each command which is possible
|
|
|
|
|
|
commands = new ClientCommand[20]; |
|
|
|
|
|
|
|
|
|
|
|
int i = 0; |
|
|
|
|
|
commands[i].aberration = "GPJ"; |
|
|
|
|
|
commands[i].longVersion = "GetPositionJoints"; |
|
|
|
|
|
commands[i].processCommand = &getPositionJoints; |
|
|
|
|
|
commands[i].printHelp = NULL; |
|
|
|
|
|
i+=1; |
|
|
|
|
|
commands[i].aberration = "GPHRW"; |
|
|
|
|
|
commands[i].longVersion = "GetPositionHomRowWise"; |
|
|
|
|
|
commands[i].processCommand = &getPositionHomRowWise; |
|
|
|
|
|
commands[i].printHelp = NULL; |
|
|
|
|
|
i+=1; |
|
|
|
|
|
commands[i].aberration = "GFT"; |
|
|
|
|
|
commands[i].longVersion = "GetForceTorqueTcp"; |
|
|
|
|
|
commands[i].processCommand = &getForceTorqueTcp; |
|
|
|
|
|
commands[i].printHelp = NULL; |
|
|
|
|
|
i+=1; |
|
|
|
|
|
commands[i].aberration = "MPTPJ"; |
|
|
|
|
|
commands[i].longVersion = "MovePTPJoints"; |
|
|
|
|
|
commands[i].processCommand = &movePTPJoints; |
|
|
|
|
|
commands[i].printHelp = NULL; |
|
|
|
|
|
i+=1; |
|
|
|
|
|
commands[i].aberration = "MHRWS"; |
|
|
|
|
|
commands[i].longVersion = "MoveHomRowWiseStatus"; |
|
|
|
|
|
commands[i].processCommand = &moveHomRowWiseStatus; |
|
|
|
|
|
commands[i].printHelp = NULL; |
|
|
|
|
|
i+=1; |
|
|
|
|
|
commands[i].aberration = "SS"; |
|
|
|
|
|
commands[i].longVersion = "SetSpeed"; |
|
|
|
|
|
commands[i].processCommand = &setSpeed; |
|
|
|
|
|
commands[i].printHelp = NULL; |
|
|
|
|
|
i+=1; |
|
|
|
|
|
commands[i].aberration = "SA"; |
|
|
|
|
|
commands[i].longVersion = "SetAccel"; |
|
|
|
|
|
commands[i].processCommand = &setAccel; |
|
|
|
|
|
commands[i].printHelp = NULL; |
|
|
|
|
|
i+=1; |
|
|
|
|
|
commands[i].aberration = "STPF"; |
|
|
|
|
|
commands[i].longVersion = "StartPotFieldMode"; |
|
|
|
|
|
commands[i].processCommand = &startPotFieldMode; |
|
|
|
|
|
commands[i].printHelp = NULL; |
|
|
|
|
|
i+=1; |
|
|
|
|
|
commands[i].aberration = "SPPF"; |
|
|
|
|
|
commands[i].longVersion = "StopPotFieldMode"; |
|
|
|
|
|
commands[i].processCommand = &stopPotFieldMode; |
|
|
|
|
|
commands[i].printHelp = NULL; |
|
|
|
|
|
i+=1; |
|
|
|
|
|
commands[i].aberration = "SP"; |
|
|
|
|
|
commands[i].longVersion = "SetPos"; |
|
|
|
|
|
commands[i].processCommand = &setPos; |
|
|
|
|
|
commands[i].printHelp = NULL; |
|
|
|
|
|
i+=1; |
|
|
|
|
|
commands[i].aberration = "SJ"; |
|
|
|
|
|
commands[i].longVersion = "SetJoints"; |
|
|
|
|
|
commands[i].processCommand = &setJoints; |
|
|
|
|
|
commands[i].printHelp = NULL; |
|
|
|
|
|
i+=1; |
|
|
|
|
|
commands[i].aberration = "Q"; |
|
|
|
|
|
commands[i].longVersion = "Quit"; |
|
|
|
|
|
commands[i].processCommand = &quit; |
|
|
|
|
|
commands[i].printHelp = NULL; |
|
|
|
|
|
i+=1; |
|
|
|
|
|
commands[i].aberration = "?"; |
|
|
|
|
|
commands[i].longVersion = "Help"; |
|
|
|
|
|
commands[i].processCommand = &printUsage; |
|
|
|
|
|
commands[i].printHelp = NULL; |
|
|
|
|
|
i+=1; |
|
|
|
|
|
commands[i].aberration = "ISKUKA"; |
|
|
|
|
|
commands[i].longVersion = "IsKukaLWR"; |
|
|
|
|
|
commands[i].processCommand = NULL; |
|
|
|
|
|
commands[i].printHelp = NULL; |
|
|
|
|
|
i+=1; |
|
|
|
|
|
commands[i].aberration = "MC"; |
|
|
|
|
|
commands[i].longVersion = "MoveCartesian"; |
|
|
|
|
|
commands[i].processCommand = &moveCartesian; |
|
|
|
|
|
commands[i].printHelp = NULL; |
|
|
|
|
|
i+=1; |
|
|
|
|
|
commands[i].aberration = "GT"; |
|
|
|
|
|
commands[i].longVersion = "GetTrajectoryType"; |
|
|
|
|
|
commands[i].processCommand = &getTrajectoryType; |
|
|
|
|
|
commands[i].printHelp = NULL; |
|
|
|
|
|
i+=1; |
|
|
|
|
|
commands[i].aberration = "ST"; |
|
|
|
|
|
commands[i].longVersion = "SetTrajectoryType"; |
|
|
|
|
|
commands[i].processCommand = &setTrajectoryType; |
|
|
|
|
|
commands[i].printHelp = NULL; |
|
|
|
|
|
|
|
|
|
|
|
commandCount = i; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
SvrHandling::~SvrHandling() |
|
|
SvrHandling::~SvrHandling() |
|
@ -392,71 +461,35 @@ void SvrHandling::clientCommandLoop(SocketObject& client) |
|
|
cout<<message; |
|
|
cout<<message; |
|
|
StringTool::String2CmdArg((const string) message, cmd, arg); |
|
|
StringTool::String2CmdArg((const string) message, cmd, arg); |
|
|
|
|
|
|
|
|
if (cmd == CMD_GetPositionJoints) |
|
|
|
|
|
{ |
|
|
|
|
|
GetPositionJoints(client); |
|
|
|
|
|
} else if (cmd == CMD_GetPositionHomRowWise) |
|
|
|
|
|
{ |
|
|
|
|
|
GetPositionHomRowWise(client); |
|
|
|
|
|
} else if (cmd == CMD_GetForceTorqueTcp) |
|
|
|
|
|
{ |
|
|
|
|
|
GetForceTorqueTcp(client); |
|
|
|
|
|
} else if (cmd == CMD_MovePTPJoints) |
|
|
|
|
|
{ |
|
|
|
|
|
MovePTPJoints(client, arg); |
|
|
|
|
|
} else if (cmd == CMD_MoveHomRowWiseStatus) |
|
|
|
|
|
{ |
|
|
|
|
|
MoveHomRowWiseStatus(client, arg); |
|
|
|
|
|
// TODO: MoveMinChangeHomRowWiseStatus
|
|
|
|
|
|
} else if (cmd == CMD_SetSpeed) |
|
|
|
|
|
{ |
|
|
|
|
|
SetSpeed(client, arg); |
|
|
|
|
|
} else if (cmd == CMD_SetAccel) |
|
|
|
|
|
{ |
|
|
|
|
|
SetAccel(client, arg); |
|
|
|
|
|
}else if (cmd == CMD_StartPotFieldMode) |
|
|
|
|
|
{ |
|
|
|
|
|
StartPotFieldMode(client, arg); |
|
|
|
|
|
}else if (cmd == CMD_StopPotFieldMode) |
|
|
|
|
|
{ |
|
|
|
|
|
StopPotFieldMode(client, arg); |
|
|
|
|
|
}else if (cmd == CMD_SetPos) |
|
|
|
|
|
{ |
|
|
|
|
|
SetPos(client, arg); |
|
|
|
|
|
}else if (cmd == CMD_SetJoints) |
|
|
|
|
|
{ |
|
|
|
|
|
SetJoints(client, arg); |
|
|
|
|
|
}else if (cmd == CMD_MoveCartesian) |
|
|
|
|
|
{ |
|
|
|
|
|
MoveCartesian(client, arg); |
|
|
|
|
|
} else if (cmd == "debug") |
|
|
|
|
|
{ |
|
|
|
|
|
debug(client); |
|
|
|
|
|
} else if (cmd == "") |
|
|
|
|
|
{ |
|
|
|
|
|
// ignore blank lines
|
|
|
|
|
|
|
|
|
// ignore blank lines
|
|
|
|
|
|
if (cmd == "") |
|
|
continue; |
|
|
continue; |
|
|
} else if (cmd == CMD_ISKUKA) |
|
|
|
|
|
{ |
|
|
|
|
|
client.Send(SVR_TRUE_RSP); |
|
|
|
|
|
} else if (cmd == CMD_SET_TRAJECTORY_TYPE) |
|
|
|
|
|
{ |
|
|
|
|
|
setTrajectoryType(client, arg); |
|
|
|
|
|
} else if (cmd == CMD_GET_TRAJECTORY_TYPE) |
|
|
|
|
|
{ |
|
|
|
|
|
getTrajectoryType(client); |
|
|
|
|
|
} else if (cmd == CMD_HELP) |
|
|
|
|
|
{ |
|
|
|
|
|
printUsage(client); |
|
|
|
|
|
} else if (cmd == CMD_QUIT || cmd == CMD_QUIT1 || cmd == CMD_QUIT2) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// check command table for equivalence
|
|
|
|
|
|
bool match = false; |
|
|
|
|
|
for (unsigned int i = 0 ; i < commandCount ; ++ i) |
|
|
{ |
|
|
{ |
|
|
quit(client); |
|
|
|
|
|
} else |
|
|
|
|
|
|
|
|
if (cmd == commands[i].longVersion || cmd == commands[i].aberration) |
|
|
|
|
|
{ |
|
|
|
|
|
if (commands[i].processCommand != NULL) |
|
|
|
|
|
{ |
|
|
|
|
|
commands[i].processCommand(client,arg); |
|
|
|
|
|
}else |
|
|
|
|
|
{ |
|
|
|
|
|
client.Send(SVR_UNIMPLEMENTED_COMMAND); |
|
|
|
|
|
} |
|
|
|
|
|
match = true; |
|
|
|
|
|
match = true; |
|
|
|
|
|
break; |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
// command not found
|
|
|
|
|
|
if (match == false) |
|
|
{ |
|
|
{ |
|
|
message = "Error: Unknown command!"; |
|
|
|
|
|
client.Send(message); |
|
|
|
|
|
printUsage(client); |
|
|
|
|
|
|
|
|
client.Send(SVR_UNKNOWN_COMMAND); |
|
|
|
|
|
printUsage(client, arg); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
}else |
|
|
}else |
|
|
{ |
|
|
{ |
|
|
cout << timestamp() + "Connection to client lost..\n"; |
|
|
cout << timestamp() + "Connection to client lost..\n"; |
|
@ -465,7 +498,6 @@ void SvrHandling::clientCommandLoop(SocketObject& client) |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
string SvrHandling::timestamp() |
|
|
string SvrHandling::timestamp() |
|
|
{ |
|
|
{ |
|
|
time_t rawtime; |
|
|
time_t rawtime; |
|
@ -481,8 +513,11 @@ string SvrHandling::timestamp() |
|
|
return output; |
|
|
return output; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
void SvrHandling::GetPositionJoints(SocketObject& client) |
|
|
|
|
|
|
|
|
void getPositionJoints(SocketObject& client, std::string& arg) |
|
|
{ |
|
|
{ |
|
|
|
|
|
// unused
|
|
|
|
|
|
(void) arg; |
|
|
|
|
|
|
|
|
string out = ""; |
|
|
string out = ""; |
|
|
stringstream ss (stringstream::in | stringstream::out); |
|
|
stringstream ss (stringstream::in | stringstream::out); |
|
|
|
|
|
|
|
@ -501,15 +536,18 @@ void SvrHandling::GetPositionJoints(SocketObject& client) |
|
|
client.Send(out); |
|
|
client.Send(out); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
void SvrHandling::GetPositionHomRowWise(SocketObject& client) |
|
|
|
|
|
|
|
|
void getPositionHomRowWise(SocketObject& client, std::string& arg) |
|
|
{ |
|
|
{ |
|
|
|
|
|
// unused
|
|
|
|
|
|
(void) arg; |
|
|
|
|
|
|
|
|
string out = ""; |
|
|
string out = ""; |
|
|
stringstream ss (stringstream::in | stringstream::out); |
|
|
stringstream ss (stringstream::in | stringstream::out); |
|
|
|
|
|
|
|
|
// get current Cartesianpositions from database
|
|
|
|
|
|
|
|
|
// get current Cartesian positions from database
|
|
|
MatCarthesian cartPos = SvrData::getInstance()->getMessuredCartPos(); |
|
|
MatCarthesian cartPos = SvrData::getInstance()->getMessuredCartPos(); |
|
|
|
|
|
|
|
|
// assemble command feadback row wise
|
|
|
|
|
|
|
|
|
// assemble command feedback row wise
|
|
|
for (int i=0; i< FRI_CART_FRM_DIM; i++) |
|
|
for (int i=0; i< FRI_CART_FRM_DIM; i++) |
|
|
{ |
|
|
{ |
|
|
int row = i % 4; |
|
|
int row = i % 4; |
|
@ -524,8 +562,11 @@ void SvrHandling::GetPositionHomRowWise(SocketObject& client) |
|
|
client.Send(out); |
|
|
client.Send(out); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
void SvrHandling::GetForceTorqueTcp(SocketObject& client) |
|
|
|
|
|
|
|
|
void getForceTorqueTcp(SocketObject& client, std::string& arg) |
|
|
{ |
|
|
{ |
|
|
|
|
|
// unused
|
|
|
|
|
|
(void) arg; |
|
|
|
|
|
|
|
|
string out = ""; |
|
|
string out = ""; |
|
|
stringstream ss (stringstream::in | stringstream::out); |
|
|
stringstream ss (stringstream::in | stringstream::out); |
|
|
|
|
|
|
|
@ -539,11 +580,11 @@ void SvrHandling::GetForceTorqueTcp(SocketObject& client) |
|
|
client.Send(out); |
|
|
client.Send(out); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
void SvrHandling::MovePTPJoints(SocketObject& client, string& args) |
|
|
|
|
|
|
|
|
void movePTPJoints(SocketObject& client, string& arg) |
|
|
{ |
|
|
{ |
|
|
string buf; |
|
|
string buf; |
|
|
|
|
|
|
|
|
stringstream ss(args); |
|
|
|
|
|
|
|
|
stringstream ss(arg); |
|
|
stringstream ss2f; |
|
|
stringstream ss2f; |
|
|
|
|
|
|
|
|
// convert string to joint vector
|
|
|
// convert string to joint vector
|
|
@ -604,11 +645,11 @@ void SvrHandling::MovePTPJoints(SocketObject& client, string& args) |
|
|
client.Send(SVR_TRUE_RSP); |
|
|
client.Send(SVR_TRUE_RSP); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
void SvrHandling::MoveHomRowWiseStatus(SocketObject& client, string& args) |
|
|
|
|
|
|
|
|
void moveHomRowWiseStatus(SocketObject& client, string& arg) |
|
|
{ |
|
|
{ |
|
|
string buf; |
|
|
string buf; |
|
|
double temp[15]; |
|
|
double temp[15]; |
|
|
stringstream ss(args); |
|
|
|
|
|
|
|
|
stringstream ss(arg); |
|
|
stringstream ss2f; |
|
|
stringstream ss2f; |
|
|
int argc = 0; |
|
|
int argc = 0; |
|
|
|
|
|
|
|
@ -647,14 +688,14 @@ void SvrHandling::MoveHomRowWiseStatus(SocketObject& client, string& args) |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
// extract elbow flip and hand parameter
|
|
|
// extract elbow flip and hand parameter
|
|
|
float arg[3]; |
|
|
|
|
|
|
|
|
float configurationParameter[3]; |
|
|
for (int i=0;i<3;i++) |
|
|
for (int i=0;i<3;i++) |
|
|
{ |
|
|
{ |
|
|
arg[i] = temp[12+i]; |
|
|
|
|
|
|
|
|
configurationParameter[i] = temp[12+i]; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
//Backward Calculation
|
|
|
//Backward Calculation
|
|
|
VecJoint newJointPos = kukaBackwardCalc(temp, arg); |
|
|
|
|
|
|
|
|
VecJoint newJointPos = kukaBackwardCalc(temp, configurationParameter); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//Check for Joint Range
|
|
|
//Check for Joint Range
|
|
@ -691,17 +732,17 @@ void SvrHandling::MoveHomRowWiseStatus(SocketObject& client, string& args) |
|
|
client.Send(SVR_TRUE_RSP); |
|
|
client.Send(SVR_TRUE_RSP); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
void SvrHandling::SetSpeed(SocketObject& client, string& args) |
|
|
|
|
|
|
|
|
void setSpeed(SocketObject& client, string& arg) |
|
|
{ |
|
|
{ |
|
|
string buf; |
|
|
string buf; |
|
|
float newVelocityPercentage; |
|
|
float newVelocityPercentage; |
|
|
int argc = 0; |
|
|
int argc = 0; |
|
|
stringstream ss(args); |
|
|
|
|
|
|
|
|
stringstream ss(arg); |
|
|
stringstream ss2f; |
|
|
stringstream ss2f; |
|
|
vector<string> tokens; |
|
|
vector<string> tokens; |
|
|
|
|
|
|
|
|
// no speed argument
|
|
|
// no speed argument
|
|
|
if (args == "") |
|
|
|
|
|
|
|
|
if (arg == "") |
|
|
{ |
|
|
{ |
|
|
client.Send(SVR_FALSE_RSP); |
|
|
client.Send(SVR_FALSE_RSP); |
|
|
return; |
|
|
return; |
|
@ -737,16 +778,16 @@ void SvrHandling::SetSpeed(SocketObject& client, string& args) |
|
|
client.Send(SVR_TRUE_RSP); |
|
|
client.Send(SVR_TRUE_RSP); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
void SvrHandling::SetAccel(SocketObject& client, string& args) |
|
|
|
|
|
|
|
|
void setAccel(SocketObject& client, string& arg) |
|
|
{ |
|
|
{ |
|
|
string buf; |
|
|
string buf; |
|
|
float newAccelerationPercentage; |
|
|
float newAccelerationPercentage; |
|
|
stringstream ss(args); |
|
|
|
|
|
|
|
|
stringstream ss(arg); |
|
|
stringstream ss2f; |
|
|
stringstream ss2f; |
|
|
int argc = 0; |
|
|
int argc = 0; |
|
|
|
|
|
|
|
|
// need at least one argument
|
|
|
// need at least one argument
|
|
|
if (args == "") |
|
|
|
|
|
|
|
|
if (arg == "") |
|
|
{ |
|
|
{ |
|
|
client.Send(SVR_FALSE_RSP); |
|
|
client.Send(SVR_FALSE_RSP); |
|
|
return; |
|
|
return; |
|
@ -782,8 +823,10 @@ void SvrHandling::SetAccel(SocketObject& client, string& args) |
|
|
client.Send(SVR_TRUE_RSP); |
|
|
client.Send(SVR_TRUE_RSP); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
void SvrHandling::StartPotFieldMode(SocketObject& client, string& args) |
|
|
|
|
|
|
|
|
void startPotFieldMode(SocketObject& client, string& arg) |
|
|
{ |
|
|
{ |
|
|
|
|
|
// unused
|
|
|
|
|
|
(void) arg; |
|
|
#if 0
|
|
|
#if 0
|
|
|
__MSRSTARTPOTFIELD = false; |
|
|
__MSRSTARTPOTFIELD = false; |
|
|
__MSRSTOPPOTFIELD = false; |
|
|
__MSRSTOPPOTFIELD = false; |
|
@ -804,8 +847,10 @@ void SvrHandling::StartPotFieldMode(SocketObject& client, string& args) |
|
|
client.Send(SVR_TRUE_RSP); |
|
|
client.Send(SVR_TRUE_RSP); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
void SvrHandling::StopPotFieldMode(SocketObject& client, string& args) |
|
|
|
|
|
|
|
|
void stopPotFieldMode(SocketObject& client, string& arg) |
|
|
{ |
|
|
{ |
|
|
|
|
|
// unused
|
|
|
|
|
|
(void) arg; |
|
|
#if 0
|
|
|
#if 0
|
|
|
__POTFIELDMODE = false; |
|
|
__POTFIELDMODE = false; |
|
|
|
|
|
|
|
@ -820,11 +865,11 @@ void SvrHandling::StopPotFieldMode(SocketObject& client, string& args) |
|
|
client.Send(SVR_TRUE_RSP); |
|
|
client.Send(SVR_TRUE_RSP); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
void SvrHandling::SetPos(SocketObject& client, string& args) |
|
|
|
|
|
|
|
|
void setPos(SocketObject& client, string& arg) |
|
|
{ |
|
|
{ |
|
|
string buf; |
|
|
string buf; |
|
|
double temp[15]; |
|
|
double temp[15]; |
|
|
stringstream ss(args); |
|
|
|
|
|
|
|
|
stringstream ss(arg); |
|
|
stringstream ss2f; |
|
|
stringstream ss2f; |
|
|
int argc = 0; |
|
|
int argc = 0; |
|
|
|
|
|
|
|
@ -864,14 +909,14 @@ void SvrHandling::SetPos(SocketObject& client, string& args) |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
// extract elbow flip and hand parameter
|
|
|
// extract elbow flip and hand parameter
|
|
|
float arg[3]; |
|
|
|
|
|
|
|
|
float configurationParameter[3]; |
|
|
for (int i=0;i<3;i++) |
|
|
for (int i=0;i<3;i++) |
|
|
{ |
|
|
{ |
|
|
arg[i] = temp[12+i]; |
|
|
|
|
|
|
|
|
configurationParameter[i] = temp[12+i]; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
//Backward Calculation of the position
|
|
|
//Backward Calculation of the position
|
|
|
VecJoint CalcJoints = kukaBackwardCalc(temp, arg); |
|
|
|
|
|
|
|
|
VecJoint CalcJoints = kukaBackwardCalc(temp, configurationParameter); |
|
|
|
|
|
|
|
|
//Check for a valid joint range
|
|
|
//Check for a valid joint range
|
|
|
if (!SvrData::getInstance()->checkJointRange(CalcJoints)) |
|
|
if (!SvrData::getInstance()->checkJointRange(CalcJoints)) |
|
@ -891,19 +936,19 @@ void SvrHandling::SetPos(SocketObject& client, string& args) |
|
|
client.Send(SVR_TRUE_RSP); |
|
|
client.Send(SVR_TRUE_RSP); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
void SvrHandling::SetJoints(SocketObject& client, string& args) |
|
|
|
|
|
|
|
|
void setJoints(SocketObject& client, string& arg) |
|
|
{ |
|
|
{ |
|
|
string buf; |
|
|
string buf; |
|
|
VecJoint newJointPos(0.0f); |
|
|
VecJoint newJointPos(0.0f); |
|
|
stringstream ss(args); |
|
|
|
|
|
|
|
|
stringstream ss(arg); |
|
|
stringstream ss2f; |
|
|
stringstream ss2f; |
|
|
int i = 0; |
|
|
|
|
|
|
|
|
int argc = 0; |
|
|
|
|
|
|
|
|
// convert to Joint vector
|
|
|
// convert to Joint vector
|
|
|
while (ss >> buf) |
|
|
while (ss >> buf) |
|
|
{ |
|
|
{ |
|
|
// to many input arguments or Joints
|
|
|
// to many input arguments or Joints
|
|
|
if (i>=JOINT_NUMBER) |
|
|
|
|
|
|
|
|
if (argc>=JOINT_NUMBER) |
|
|
{ |
|
|
{ |
|
|
client.Send(SVR_INVALID_ARGUMENT_COUNT); |
|
|
client.Send(SVR_INVALID_ARGUMENT_COUNT); |
|
|
return; |
|
|
return; |
|
@ -913,12 +958,12 @@ void SvrHandling::SetJoints(SocketObject& client, string& args) |
|
|
ss2f.flush(); |
|
|
ss2f.flush(); |
|
|
ss2f.clear(); |
|
|
ss2f.clear(); |
|
|
ss2f << buf; |
|
|
ss2f << buf; |
|
|
ss2f >> newJointPos(i); |
|
|
|
|
|
i++; |
|
|
|
|
|
|
|
|
ss2f >> newJointPos(argc); |
|
|
|
|
|
argc++; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
// to less joint values
|
|
|
// to less joint values
|
|
|
if (i != JOINT_NUMBER) |
|
|
|
|
|
|
|
|
if (argc != JOINT_NUMBER) |
|
|
{ |
|
|
{ |
|
|
client.Send(SVR_INVALID_ARGUMENT_COUNT); |
|
|
client.Send(SVR_INVALID_ARGUMENT_COUNT); |
|
|
return; |
|
|
return; |
|
@ -946,11 +991,11 @@ void SvrHandling::SetJoints(SocketObject& client, string& args) |
|
|
client.Send(SVR_TRUE_RSP); |
|
|
client.Send(SVR_TRUE_RSP); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
void SvrHandling::MoveCartesian(SocketObject& client, string& args) |
|
|
|
|
|
|
|
|
void moveCartesian(SocketObject& client, string& arg) |
|
|
{ |
|
|
{ |
|
|
string buf; |
|
|
string buf; |
|
|
float temp[15]; |
|
|
float temp[15]; |
|
|
stringstream ss(args); |
|
|
|
|
|
|
|
|
stringstream ss(arg); |
|
|
stringstream ss2f; |
|
|
stringstream ss2f; |
|
|
int argc = 0; |
|
|
int argc = 0; |
|
|
|
|
|
|
|
@ -977,10 +1022,10 @@ void SvrHandling::MoveCartesian(SocketObject& client, string& args) |
|
|
return ; |
|
|
return ; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
float arg[3]; |
|
|
|
|
|
|
|
|
float configurationParameter[3]; |
|
|
for (int i=0;i<3;i++) |
|
|
for (int i=0;i<3;i++) |
|
|
{ |
|
|
{ |
|
|
arg[i] = temp[12+i]; |
|
|
|
|
|
|
|
|
configurationParameter[i] = temp[12+i]; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
//Calculating end-effector position for target "TRobot"
|
|
|
//Calculating end-effector position for target "TRobot"
|
|
@ -1005,12 +1050,16 @@ void SvrHandling::MoveCartesian(SocketObject& client, string& args) |
|
|
client.Send(SVR_TRUE_RSP); |
|
|
client.Send(SVR_TRUE_RSP); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
void SvrHandling::quit(SocketObject& client) |
|
|
|
|
|
|
|
|
void quit(SocketObject& client , std::string& arg) |
|
|
{ |
|
|
{ |
|
|
|
|
|
//unused
|
|
|
|
|
|
(void) arg; |
|
|
|
|
|
|
|
|
client.Send(SVR_TRUE_RSP); |
|
|
client.Send(SVR_TRUE_RSP); |
|
|
client.Disconnect(); |
|
|
client.Disconnect(); |
|
|
} |
|
|
} |
|
|
void SvrHandling::setTrajectoryType(SocketObject& client, string& arg) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void setTrajectoryType(SocketObject& client, std::string& arg) |
|
|
{ |
|
|
{ |
|
|
string buf; |
|
|
string buf; |
|
|
enum TrajectoryType newType = TrajectoryDefault; |
|
|
enum TrajectoryType newType = TrajectoryDefault; |
|
@ -1021,7 +1070,7 @@ void SvrHandling::setTrajectoryType(SocketObject& client, string& arg) |
|
|
|
|
|
|
|
|
client.Send(SVR_TRUE_RSP); |
|
|
client.Send(SVR_TRUE_RSP); |
|
|
} |
|
|
} |
|
|
void SvrHandling::getTrajectoryType(SocketObject& client) |
|
|
|
|
|
|
|
|
void getTrajectoryType(SocketObject& client, std::string& arg) |
|
|
{ |
|
|
{ |
|
|
enum TrajectoryType currType = SvrData::getInstance()->getTrajectoryType(); |
|
|
enum TrajectoryType currType = SvrData::getInstance()->getTrajectoryType(); |
|
|
cout << "curr trajectory type : "<< toString(currType) << "\n"; |
|
|
cout << "curr trajectory type : "<< toString(currType) << "\n"; |
|
@ -1029,7 +1078,7 @@ void SvrHandling::getTrajectoryType(SocketObject& client) |
|
|
client.Send("current trajectory: " + toString(currType)); |
|
|
client.Send("current trajectory: " + toString(currType)); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
void SvrHandling::debug(SocketObject& client) |
|
|
|
|
|
|
|
|
void debug(SocketObject& client, std::string& arg) |
|
|
{ |
|
|
{ |
|
|
|
|
|
|
|
|
//check = true;
|
|
|
//check = true;
|
|
|