32 # include "keyboard.h" 52 static std::vector<int> x,y,
z,u,v,w;
53 static const int xArr[], yArr[], zArr[], uArr[], vArr[], wArr[];
59 const int Tpos::xArr[] = {30206, -23393, -3066, 14454, 30000, 30000};
60 const int Tpos::yArr[] = {24327, -7837, -16796, 5803, 30290, 31000};
61 const int Tpos::zArr[] = {24327, -7837, -16796, 5802, 30290, 10924};
62 const int Tpos::uArr[] = {5333, -13791, -9985, 11449, 30996, 12063};
63 const int Tpos::vArr[] = {-3799, -5703, -11676, 8210, 30995, 12063};
64 const int Tpos::wArr[] = {-3799, -5703, -11676, 8210, 30995, 30992};
65 std::vector<int>
Tpos::x(xArr, xArr +
sizeof(xArr)/
sizeof(*xArr));
66 std::vector<int>
Tpos::y(yArr, yArr +
sizeof(yArr)/
sizeof(*yArr));
67 std::vector<int>
Tpos::z(zArr, zArr +
sizeof(zArr)/
sizeof(*zArr));
68 std::vector<int>
Tpos::u(uArr, uArr +
sizeof(uArr)/
sizeof(*uArr));
69 std::vector<int>
Tpos::v(vArr, vArr +
sizeof(vArr)/
sizeof(*vArr));
70 std::vector<int>
Tpos::w(wArr, wArr +
sizeof(wArr)/
sizeof(*wArr));
71 std::vector<TPoint>
points(0);
79 const double PI = 3.14159265358979323846;
82 std::cout <<
"------------------------------------------- \n";
83 std::cout <<
"?: Display this help\n";
84 std::cout <<
"c: Calibrate the Katana\n";
85 std::cout <<
"b: Read current controller types\n";
86 std::cout <<
"e: Read the current encoder values\n";
87 std::cout <<
"E: Read the current force values\n";
88 std::cout <<
"o: Switch motors off/on (Default: On)\n";
89 std::cout <<
"r: Switch angle format: Radian/Degree (Default: Rad)\n";
90 std::cout <<
"x: Read the current position\n";
91 std::cout <<
"v: Set the velocity limits for all motors seperately\n";
92 std::cout <<
"V: Set the velocity limits for all motors (or for the TCP if in linear movement mode)\n";
93 std::cout <<
"a: Set the acceleration limits for all motors seperately\n";
94 std::cout <<
"A: Set the acceleration limits for all motors\n";
95 std::cout <<
",: Set the force limits for all motors\n";
96 std::cout <<
"w: Read the velocity limits of all motors \n";
97 std::cout <<
"W: Read the acceleration limits of all motors \n";
98 std::cout <<
"q: Read the Sensors\n";
99 std::cout <<
"y: Set a new position using IK\n";
100 std::cout <<
"l: Switch on/off linear movements\n";
101 std::cout <<
"<: Add a point to the point list\n";
102 std::cout <<
">: Move to a specific point\n";
103 std::cout <<
" : (space) Move to the next point in the point list\n";
104 std::cout <<
"=: write pointlist to file\n";
105 std::cout <<
"(: calculate DK from any encoders\n";
106 std::cout <<
"f: read pointlist from file\n";
107 std::cout <<
"g: Open Gripper\n";
108 std::cout <<
"h: Close Gripper\n";
109 std::cout <<
"n: Set the speed collision limit for all motors seperately\n";
110 std::cout <<
"N: Set the speed collision limit for all motors\n";
111 std::cout <<
"s: Set the position collision limit for all motors seperately\n";
112 std::cout <<
"S: Set the position collision limit for all motors\n";
113 std::cout <<
"t: Switch collision limit on\n";
114 std::cout <<
"T: Switch collision limit off\n";
115 std::cout <<
"u: Unblock motors after crash\n";
116 std::cout <<
"d: Move motor to degrees\n";
117 std::cout <<
"z: Set TCP offset\n\n\n";
118 std::cout <<
"Keyboard of Katana, use the following keys:\n\n";
119 std::cout <<
"1: Move motor1 left\n";
120 std::cout <<
"2: Move motor1 right\n";
121 std::cout <<
"3: Move motor2 left\n";
122 std::cout <<
"4: Move motor2 right\n";
123 std::cout <<
"5: Move motor3 left\n";
124 std::cout <<
"6: Move motor3 right\n";
125 std::cout <<
"7: Move motor4 left\n";
126 std::cout <<
"8: Move motor4 right\n";
127 std::cout <<
"9: Move motor5 left\n";
128 std::cout <<
"0: Move motor5 right\n";
129 std::cout <<
"/: Move motor6 left\n";
130 std::cout <<
"*: Move motor6 right\n";
131 std::cout <<
".: Toggle Step mode\n";
132 std::cout <<
"+: Increase step size\n";
133 std::cout <<
"-: Decrease step size\n\n";
134 std::cout <<
"$: Start/Stop Program\n";
135 std::cout <<
"p: Start/Stop movement through points list\n\n";
138 int main(
int argc,
char *argv[]) {
141 std::cout <<
"---------------------------------\n";
142 std::cout <<
"usage: control CONFIGFILE IP_ADDR\n";
143 std::cout <<
"---------------------------------\n";
147 std::cout <<
"--------------------\n";
148 std::cout <<
"CONTROL DEMO STARTED\n";
149 std::cout <<
"--------------------\n";
156 std::unique_ptr<CCdlSocket>
device;
157 std::unique_ptr<CCplSerialCRC>
protocol;
164 std::cout <<
"-------------------------------------------\n";
165 std::cout <<
"success: port " << port <<
" open\n";
166 std::cout <<
"-------------------------------------------\n";
173 std::cout <<
"-------------------------------------------\n";
174 std::cout <<
"success: protocol class instantiated\n";
175 std::cout <<
"-------------------------------------------\n";
176 protocol->init(device.get());
177 std::cout <<
"-------------------------------------------\n";
178 std::cout <<
"success: communication with Katana initialized\n";
179 std::cout <<
"-------------------------------------------\n";
186 katana->create(argv[1], protocol.get());
190 std::cout <<
"ERROR: " << e.
message() << std::endl;
193 std::cout <<
"-------------------------------------------\n";
194 std::cout <<
"success: katana initialized\n";
195 std::cout <<
"-------------------------------------------\n";
202 bool DispInRad =
true;
204 bool useLinearMode =
false;
205 double RadToDeg = 1.0;
209 for (
int i = 0; i< 6; i++){
215 bool stepMode =
false;
217 bool runProgram =
false;
230 katana->setMaximumLinearVelocity(60);
265 std::vector<double> pose_result(6, 0);
266 std::vector<int> etc;
267 etc.push_back(20000);
268 etc.push_back(-20000);
269 etc.push_back(-20000);
270 etc.push_back(20000);
271 etc.push_back(20000);
272 etc.push_back(20000);
273 katana->getCoordinatesFromEncoders(pose_result, etc);
274 std::cout.precision(6);
275 std::cout <<
"\n------------------------------------\n";
276 std::cout <<
"X: " << pose_result.at(0) <<
"\n";
277 std::cout <<
"Y: " << pose_result.at(1) <<
"\n";
278 std::cout <<
"Z: " << pose_result.at(2) <<
"\n";
279 std::cout <<
"phi: " << RadToDeg*pose_result.at(3) <<
"\n";
280 std::cout <<
"theta: " << RadToDeg*pose_result.at(4) <<
"\n";
281 std::cout <<
"psi: " << RadToDeg*pose_result.at(5) <<
"\n";
282 std::cout <<
"------------------------------------\n";
287 if(stepMode ==
false){
289 std::cout <<
"Step Mode ON \n" << std::endl;
293 std::cout <<
"Step Mode OFF \n" << std::endl;
297 if(stepSize <= 3000){
299 std::cout <<
"Step Size = " << stepSize << std::endl;
306 std::cout <<
"Step Size = " << stepSize << std::endl;
310 if((stepMode ==
true) ||(mot[0].running ==
false || (mot[0].running ==
true && mot[0].dir ==
LEFT))){
312 motors =
katana->GetBase()->GetMOT();
313 pos = motors->arr[mot[0].
idx].GetEncoderMinPos();
314 if(motors->arr[mot[0].
idx].checkEncoderInRange(mot[0].
idx)){
316 pos =
katana->getMotorEncoders(0) + stepSize;
318 std::cout <<
"\nMoving to max encoder position " << pos << std::endl;
319 katana->moveMotorToEnc(mot[0].idx, pos);
324 std::cout <<
"\nEncoder target value out of range! \n" << std::endl;
333 if((stepMode ==
true) ||(mot[0].running ==
false || (mot[0].running ==
true && mot[0].dir ==
RIGHT))){
336 motors =
katana->GetBase()->GetMOT();
337 pos = motors->arr[mot[0].
idx].GetEncoderMaxPos();
338 if(motors->arr[mot[0].
idx].checkEncoderInRange(mot[0].
idx)){
340 pos =
katana->getMotorEncoders(0) - stepSize;
342 std::cout <<
"\nMoving to max encoder position " << pos << std::endl;
343 katana->moveMotorToEnc(mot[0].idx, pos);
348 std::cout <<
"\nEncoder target value out of range! \n" << std::endl;
357 if((stepMode ==
true) ||(mot[1].running ==
false || (mot[1].running ==
true && mot[1].dir ==
LEFT))){
359 motors =
katana->GetBase()->GetMOT();
360 pos = motors->arr[mot[1].
idx].GetEncoderMinPos();
361 if(motors->arr[mot[1].
idx].checkEncoderInRange(mot[1].
idx)){
363 pos =
katana->getMotorEncoders(1) + stepSize;
365 std::cout <<
"\nMoving to max encoder position " << pos << std::endl;
366 katana->moveMotorToEnc(mot[1].idx, pos);
371 std::cout <<
"\nEncoder target value out of range! \n" << std::endl;
380 if((stepMode ==
true) ||(mot[1].running ==
false || (mot[1].running ==
true && mot[1].dir ==
RIGHT))){
383 motors =
katana->GetBase()->GetMOT();
384 pos = motors->arr[mot[1].
idx].GetEncoderMaxPos();
385 if(motors->arr[mot[1].
idx].checkEncoderInRange(mot[1].
idx)){
387 pos =
katana->getMotorEncoders(1) - stepSize;
389 std::cout <<
"\nMoving to max encoder position " << pos << std::endl;
390 katana->moveMotorToEnc(mot[1].idx, pos);
395 std::cout <<
"\nEncoder target value out of range! \n" << std::endl;
404 if((stepMode ==
true) ||(mot[2].running ==
false || (mot[2].running ==
true && mot[2].dir ==
LEFT))){
406 motors =
katana->GetBase()->GetMOT();
407 pos = motors->arr[mot[2].
idx].GetEncoderMinPos();
408 if(motors->arr[mot[2].
idx].checkEncoderInRange(mot[2].
idx)){
410 pos =
katana->getMotorEncoders(2) + stepSize;
412 std::cout <<
"\nMoving to max encoder position " << pos << std::endl;
413 katana->moveMotorToEnc(mot[2].idx, pos);
418 std::cout <<
"\nErunProgram =ncoder target value out of range! \n" << std::endl;
427 if((stepMode ==
true) ||(mot[2].running ==
false || (mot[2].running ==
true && mot[2].dir ==
RIGHT))){
430 motors =
katana->GetBase()->GetMOT();
431 pos = motors->arr[mot[2].
idx].GetEncoderMaxPos();
432 if(motors->arr[mot[2].
idx].checkEncoderInRange(mot[2].
idx)){
434 pos =
katana->getMotorEncoders(2) - stepSize;
436 std::cout <<
"\nMoving to max encoder position " << pos << std::endl;
437 katana->moveMotorToEnc(mot[2].idx, pos);
442 std::cout <<
"\nEncoder target value out of range! \n" << std::endl;
451 if((stepMode ==
true) ||(mot[3].running ==
false || (mot[3].running ==
true && mot[3].dir ==
LEFT))){
453 motors =
katana->GetBase()->GetMOT();
454 pos = motors->arr[mot[3].
idx].GetEncoderMinPos();
455 if(motors->arr[mot[3].
idx].checkEncoderInRange(mot[3].
idx)){
457 pos =
katana->getMotorEncoders(3) + stepSize;
459 std::cout <<
"\nMoving to max encoder position " << pos << std::endl;
460 katana->moveMotorToEnc(mot[3].idx, pos);
465 std::cout <<
"\nEncoder target value out of range! \n" << std::endl;
469 katana->freezeMotor(3);runProgram =
474 if((stepMode ==
true) ||(mot[3].running ==
false || (mot[3].running ==
true && mot[3].dir ==
RIGHT))){
477 motors =
katana->GetBase()->GetMOT();
478 pos = motors->arr[mot[3].
idx].GetEncoderMaxPos();
479 if(motors->arr[mot[3].
idx].checkEncoderInRange(mot[3].
idx)){
481 pos =
katana->getMotorEncoders(3) - stepSize;
483 std::cout <<
"\nMoving to max encoder position " << pos << std::endl;
484 katana->moveMotorToEnc(mot[3].idx, pos);
489 std::cout <<
"\nEncoder target value out of range! \n" << std::endl;
498 if((stepMode ==
true) ||(mot[4].running ==
false || (mot[4].running ==
true && mot[4].dir ==
LEFT))){
500 motors =
katana->GetBase()->GetMOT();
501 pos = motors->arr[mot[4].
idx].GetEncoderMinPos();
502 if(motors->arr[mot[4].
idx].checkEncoderInRange(mot[4].
idx)){
504 pos =
katana->getMotorEncoders(4) + stepSize;
506 std::cout <<
"\nMoving to max encoder position " << pos << std::endl;
507 katana->moveMotorToEnc(mot[4].idx, pos);
512 std::cout <<
"\nEncoder target value out of range! \n" << std::endl;
521 if((stepMode ==
true) ||(mot[4].running ==
false || (mot[4].running ==
true && mot[4].dir ==
RIGHT))){
524 motors =
katana->GetBase()->GetMOT();
525 pos = motors->arr[mot[4].
idx].GetEncoderMaxPos();
526 if(motors->arr[mot[4].
idx].checkEncoderInRange(mot[4].
idx)){
528 pos =
katana->getMotorEncoders(4) - stepSize;
530 std::cout <<
"\nMoving to max encoder position " << pos << std::endl;
531 katana->moveMotorToEnc(mot[4].idx, pos);
536 std::cout <<
"\nEncoder target value out of range! \n" << std::endl;
545 if((stepMode ==
true) ||(mot[5].running ==
false || (mot[5].running ==
true && mot[5].dir ==
LEFT))){
547 motors =
katana->GetBase()->GetMOT();
548 pos = motors->arr[mot[0].
idx].GetEncoderMinPos();
549 if(motors->arr[mot[0].
idx].checkEncoderInRange(mot[5].
idx)){
551 pos =
katana->getMotorEncoders(5) + stepSize;
552 std::cout <<
"\nMoving to max encoder position " << pos + 1000 << std::endl;
553 katana->moveMotorToEnc(mot[5].idx, pos);
562 std::cout <<
"\nEncoder target value out of range! \n" << std::endl;
571 if((stepMode ==
true) ||(mot[5].running ==
false || (mot[5].running ==
true && mot[5].dir ==
RIGHT))){
574 motors =
katana->GetBase()->GetMOT();
575 pos = motors->arr[mot[5].
idx].GetEncoderMaxPos();
576 if(motors->arr[mot[5].
idx].checkEncoderInRange(mot[5].
idx)){
578 pos =
katana->getMotorEncoders(5) - stepSize;
579 std::cout <<
"\nMoving to max encoder position " << pos << std::endl;
580 katana->moveMotorToEnc(mot[5].idx, pos);
589 std::cout <<
"\nEncoder target value out of range! \n" << std::endl;
601 std::cout <<
"\n Adjust hardcoded pointlist and program for your katana before running the program!!!\n" << std::endl;
611 std::cout <<
"\nAngles in DEGREE !! \n" << std::endl;
615 std::cout <<
"\nAngles in RADIAN !! \n" << std::endl;
621 std::cout <<
"\nCalibrating Katana, please wait for termination... \n" << std::flush;
626 std::cout <<
"\nController types: " << std::endl;
627 for (
int i = 0; i <
katana->getNumberOfMotors(); ++i) {
628 std::cout <<
" " << (
katana->getCurrentControllerType(i+1) == 0 ?
"position" :
"current");
630 std::cout << std::endl;
634 std::cout <<
"\nEncoder values: " << std::endl;
636 for (std::vector<int>::iterator i=
encoders.begin(); i !=
encoders.end(); ++i) {
637 std::cout << *i <<
" ";
639 std::cout << std::endl;
643 std::cout <<
"\nForce values:" << std::endl;
644 for (
int i = 0; i <
katana->getNumberOfMotors(); ++i) {
645 std::cout <<
" " << (int)
katana->getForce(i+1);
647 std::cout << std::endl;
654 std::cout <<
"\nMotors on\n";
658 std::cout <<
"\nMotors off\n";
667 std::cout.precision(6);
668 std::cout <<
"\n------------------------------------\n";
669 std::cout <<
"X: " << p.
X <<
"\n";
670 std::cout <<
"Y: " << p.
Y <<
"\n";
671 std::cout <<
"Z: " << p.
Z <<
"\n";
672 std::cout <<
"phi: " << RadToDeg*p.
phi <<
"\n";
673 std::cout <<
"theta: " << RadToDeg*p.
theta <<
"\n";
674 std::cout <<
"psi: " << RadToDeg*p.
psi <<
"\n";
675 std::cout <<
"------------------------------------\n";
681 std::cout <<
"\nCurrent Sensor values:" << std::endl;
683 bool* change =
new bool[data->
cnt];
686 for (
int k=0; k<data->
cnt; k++) {
688 lastarr[k] = (
byte) data->
arr[k];
692 for (
int i=0; i<data->
cnt; i++) {
694 std::cout << data->
arr[i] <<
" ";
709 std::cout <<
"\n\nSet maximum velocity for motors to: \n";
710 for(
short motorNumber = 0; motorNumber <
katana->getNumberOfMotors(); ++motorNumber) {
711 std::cout << motorNumber+1 <<
": ";
713 katana->setMotorVelocityLimit(motorNumber, velocity);
722 std::cout <<
"\n\nSet the TCP velocity to: ";
724 katana->setMaximumLinearVelocity(velocity);
725 katana->setRobotVelocityLimit(static_cast<short>(velocity));
728 std::cout <<
"\n\nSet maximum velocity for all motors to: ";
730 katana->setRobotVelocityLimit(velocity);
731 katana->setMaximumLinearVelocity(static_cast<double>(velocity));
733 std::cout << std::endl;
740 std::cout <<
"\n\nSet maximum velocity for motors to: \n";
741 for(
short motorNumber = 0; motorNumber <
katana->getNumberOfMotors(); ++motorNumber) {
742 std::cout << motorNumber+1 <<
": ";
744 katana->setMotorAccelerationLimit(motorNumber, acceleration);
751 std::cout <<
"\n\nSet maximum acceleration for all motors to: ";
753 std::cout << std::endl;
754 katana->setRobotAccelerationLimit(acceleration);
760 std::cout <<
"\nSet force limit for all motors to (%): ";
762 std::cout << std::endl;
763 katana->setForceLimit(0, limit);
769 std::cout <<
"\nCurrent velocity limits:" << std::endl;
770 for(
short motorNumber = 0; motorNumber <
katana->getNumberOfMotors(); ++motorNumber)
771 std::cout << motorNumber+1 <<
": " <<
katana->getMotorVelocityLimit(motorNumber) << std::endl;
772 std::cout <<
"linear: " <<
katana->getMaximumLinearVelocity() << std::endl;
777 std::cout <<
"\nCurrent acceleration limits:" << std::endl;
778 for(
short motorNumber = 0; motorNumber <
katana->getNumberOfMotors(); ++motorNumber)
779 std::cout << motorNumber+1 <<
": " <<
katana->getMotorAccelerationLimit(motorNumber) << std::endl;
785 std::cout <<
"Switching to inverse kinematics movement mode\n";
787 std::cout <<
"Switching to linear movement mode\n";
789 useLinearMode = !useLinearMode;
792 std::cout <<
"\n\nInsert cartesian parameters: \n";
794 std::cin >> arr_pos[0];
796 std::cin >> arr_pos[1];
798 std::cin >> arr_pos[2];
799 std::cout <<
"phi: ";
800 std::cin >> arr_pos[3];
801 std::cout <<
"theta: ";
802 std::cin >> arr_pos[4];
803 std::cout <<
"psi: ";
804 std::cin >> arr_pos[5];
806 arr_pos[3] = 1/RadToDeg*arr_pos[3];
807 arr_pos[4] = 1/RadToDeg*arr_pos[4];
808 arr_pos[5] = 1/RadToDeg*arr_pos[5];
811 katana->moveRobotLinearTo(arr_pos[0], arr_pos[1], arr_pos[2], arr_pos[3], arr_pos[4], arr_pos[5]);
813 katana->moveRobotTo(arr_pos[0], arr_pos[1], arr_pos[2], arr_pos[3], arr_pos[4], arr_pos[5]);
818 std::cout.precision(6);
821 std::cout <<
"Point: ";
822 std::cout <<
" X=" << point.
X;
823 std::cout <<
", Y=" << point.
Y;
824 std::cout <<
", Z=" << point.
Z;
825 std::cout <<
", phi=" << RadToDeg*point.
phi;
826 std::cout <<
", theta="<< RadToDeg*point.
theta;
827 std::cout <<
", psi=" << RadToDeg*point.
psi;
828 std::cout <<
" ... added to point list as number ";
829 std::cout <<
points.size() << std::endl;
835 std::cout.precision(3);
836 std::cout <<
"\nMoving to point? ";
837 unsigned int pointNumber;
838 std::cin >> pointNumber;
839 if(pointNumber >=
points.size()) {
840 std::cout <<
"Invalid point number. You have only " <<
points.size() <<
" points in your list" << std::endl;
844 std::cout <<
" x=" <<
points[pointNumber].X;
846 std::cout <<
" y=" <<
points[pointNumber].Y;
848 std::cout <<
" z=" <<
points[pointNumber].Z;
850 std::cout <<
" phi=" << RadToDeg*
points[pointNumber].phi;
852 std::cout <<
" theta=" <<RadToDeg*
points[pointNumber].theta;
854 std::cout <<
" psi=" << RadToDeg*
points[pointNumber].psi;
855 std::cout << std::endl;
872 std::cout.precision(3);
873 std::cout <<
"Moving to point " << counter <<
": ";
875 std::cout <<
" x=" <<
points[counter].X;
877 std::cout <<
" y=" <<
points[counter].Y;
879 std::cout <<
" z=" <<
points[counter].Z;
881 std::cout <<
" phi=" << RadToDeg*
points[counter].phi;
883 std::cout <<
" theta=" <<RadToDeg*
points[counter].theta;
885 std::cout <<
" psi=" << RadToDeg*
points[counter].psi;
886 std::cout << std::endl;
894 counter = counter % ((short)
points.size());
898 std::cout <<
"Opening gripper...\n";
902 std::cout <<
"Close gripper...\n";
906 std::cout <<
"Set speed collision limit for motors to: \n";
907 for(
short motorNumber = 0; motorNumber <
katana->getNumberOfMotors(); ++motorNumber) {
908 std::cout << motorNumber+1 <<
": ";
910 katana->setSpeedCollisionLimit(motorNumber, limit);
914 std::cout <<
"Set speed collision limit for all motors to: \n";
916 for(
short motorNumber = 0; motorNumber <
katana->getNumberOfMotors(); ++motorNumber) {
917 katana->setSpeedCollisionLimit(motorNumber, limit);
921 std::cout <<
"Set position collision limit for motors to: \n";
922 for(
short motorNumber = 0; motorNumber <
katana->getNumberOfMotors(); ++motorNumber) {
923 std::cout << motorNumber+1 <<
": ";
925 katana->setPositionCollisionLimit(motorNumber, limit);
929 std::cout <<
"Set position collision limit for all motors to: \n";
931 for(
short motorNumber = 0; motorNumber <
katana->getNumberOfMotors(); ++motorNumber) {
932 katana->setPositionCollisionLimit(motorNumber, limit);
936 std::cout <<
"Collision detection enabled\n";
937 katana->enableCrashLimits();
940 std::cout <<
"WARNING: Collision detection disabled\n";
941 katana->disableCrashLimits();
944 std::cout <<
"Unblocking motors\n";
951 cout <<
"Loading which file?\n";
955 ifstream listfile(filename.c_str());
957 cout <<
"File not found or access denied." << endl;
962 vector<string> tokens;
963 const string delimiter =
",";
967 while(!listfile.eof()) {
969 string::size_type lastPos = line.find_first_not_of(delimiter, 0);
970 string::size_type pos = line.find_first_of(delimiter, lastPos);
972 while (string::npos != pos || string::npos != lastPos) {
974 tokens.push_back(line.substr(lastPos, pos - lastPos));
976 lastPos = line.find_first_not_of(delimiter, pos);
978 pos = line.find_first_of(delimiter, lastPos);
982 point.
X = atof((tokens.at(0)).data());
983 point.
Y = atof((tokens.at(1)).data());
984 point.
Z = atof((tokens.at(2)).data());
985 point.
phi = atof((tokens.at(3)).data())/RadToDeg;
986 point.
theta = atof((tokens.at(4)).data())/RadToDeg;
987 point.
psi = atof((tokens.at(5)).data())/RadToDeg;
988 points.push_back( point );
992 cout << lines <<
" points loaded.\n";
999 cout <<
"Which file? WARNING: Will be overwritten!\n";
1003 ofstream listfile(filename.c_str(), ios_base::out);
1007 for(std::vector<TPoint>::iterator iter =
points.begin(); iter !=
points.end(); ++iter) {
1008 listfile.precision(8);
1011 listfile << iter->X <<
"," << iter->Y <<
"," << iter->Z <<
",";
1012 listfile << iter->phi <<
"," << iter->theta <<
"," << iter->psi;
1015 cout << count <<
" points saved.\n";
1020 using namespace std;
1025 std::cout <<
"Start playback!\n";
1026 for(
int i = 1; i > 0 ; ++i) {
1034 std::cout << i <<
", " << std::flush;
1045 std::cout <<
"\nMoving motor to degrees\n";
1046 std::cout <<
" motor: ";
1048 std::cout <<
" degrees: ";
1049 std::cin >> degrees;
1050 if ((motor > 0) && (motor < 7)) {
1051 katana->movDegrees(motor - 1, degrees);
1053 std::cout <<
"motor has to be a number from 1 to 6\n";
1060 double xoff, yoff, zoff, psioff;
1061 std::cout <<
"X offset (m): ";
1063 std::cout <<
"Y offset (m): ";
1065 std::cout <<
"Z offset (m): ";
1067 std::cout <<
"psi offset around x axis (rad): ";
1069 katana->setTcpOffset(xoff, yoff, zoff, psioff);
1075 std::cout <<
"\n'" << input <<
"' is not a valid command.\n" << std::endl;
1080 std::cout <<
"\nERROR: " << e.
message() << std::endl;
1102 std::cout <<
"\nProgram running...type any key to stop after the next cycle\n";
1112 return ((
void*) &
retVal);
static std::unique_ptr< CCdlSocket > device
unsigned char byte
type specification (8 bit)
static std::unique_ptr< CCplSerialCRC > protocol
std::string message() const
std::unique_ptr< CLMBase > katana
Implement the Serial-Zero protocol.
PTW32_DLLPORT int PTW32_CDECL pthread_detach(pthread_t tid)
short cnt
count of sensors
[MOT] every motor's attributes
void StartPointlistMovement()
Encapsulates the socket communication device.
void StartProgram(int index)
static std::vector< int > w
static std::vector< int > z
structure for the currently active axis
static std::vector< int > x
int main(int argc, char *argv[])
static std::vector< int > u
std::vector< TPoint > points(0)
static std::vector< int > v
PTW32_DLLPORT int PTW32_CDECL pthread_create(pthread_t *tid, const pthread_attr_t *attr, void *(*start)(void *), void *arg)
struct pthread_mutex_t_ * pthread_mutex_t
void * RunProgram(void *)
static std::vector< int > y
PTW32_DLLPORT void PTW32_CDECL pthread_exit(void *value_ptr)
std::vector< int > encoders
void recvDAT()
receive data