AUV-Coop-Assembly
Master Thesis for Robotics Engineering. Cooperative peg-in-hole assembly with two underwater vehicles guided by vision
missionManager.cpp
1 #include "header/missionManager.h"
2 #include <chrono>
3 
4 
17 int main(int argc, char **argv)
18 {
19  if (argc < 3){
20  std::cout << "[MISSION_MANAGER] Please insert the two robots name"<< std::endl;
21  return -1;
22  }
23  std::string robotName = argv[1];
24  std::string otherRobotName = argv[2];
25  std::string pathLog;
26  if (LOG && (argc > 3)){ //if flag log setted to 1 and path log is given
27  pathLog = argv[3];
28  }
29 
30 
32  ros::init(argc, argv, robotName + "_MissionManager");
33  std::cout << "[" << robotName << "][MISSION_MANAGER] Start" << std::endl;
34  ros::NodeHandle nh;
35 
36 
42  double goalLinearVect[] = {-0.287, -0.090, 8};
44  Eigen::Matrix4d wTgoalVeh_eigen = Eigen::Matrix4d::Identity();
45  //rot part
46  wTgoalVeh_eigen.topLeftCorner(3,3) = Eigen::Matrix3d::Identity();
47  //trasl part
48  wTgoalVeh_eigen(0, 3) = goalLinearVect[0];
49  wTgoalVeh_eigen(1, 3) = goalLinearVect[1];
50  wTgoalVeh_eigen(2, 3) = goalLinearVect[2];
51 
53  double goalLinearVectEE[3];
54  if (robotName.compare("g500_A") == 0){
55  goalLinearVectEE[0] = 2.89;
56  goalLinearVectEE[1] = -0.090;
57  goalLinearVectEE[2] = 9.594;
58 
59  } else {
60  goalLinearVectEE[0] = -1.11;
61  goalLinearVectEE[1] = -0.090;
62  goalLinearVectEE[2] = 9.594;
63  }
64  Eigen::Matrix4d wTgoalEE_eigen = Eigen::Matrix4d::Identity();
65  //rot part
66  //wTgoalEE_eigen.topLeftCorner<3,3>() = Eigen::Matrix3d::Identity();
67  //the ee must rotate of 90 on z axis degree to catch the peg
68  wTgoalEE_eigen.topLeftCorner(3,3) << 0, -1, 0,
69  1, 0, 0,
70  0, 0, 1;
71  //trasl part
72  wTgoalEE_eigen(0, 3) = goalLinearVectEE[0];
73  wTgoalEE_eigen(1, 3) = goalLinearVectEE[1];
74  wTgoalEE_eigen(2, 3) = goalLinearVectEE[2];
75 
77  //double goalLinearVectTool[] = {-0.27, -0.102, 2.124};
78  //double goalLinearVectTool[] = {0.9999999999999999, -9.999999999999998, 8.378840300977453};
79  double goalLinearVectTool[] = {0.9999999999999999, -9.999999999999998, 8.378840300977453}; //with error
80 
81  std::vector<double> eulRadTrue = {0, 0, -1.443185307179587}; //true angular
82  std::vector<double> eulRad = {0, 0.0, -1.443185307179587}; //with error on z: 0.1rad ~ 6deg
83  Eigen::Matrix4d wTgoalTool_eigen = Eigen::Matrix4d::Identity();
84 
85  //rot part
86 // wTgoalTool_eigen.topLeftCorner<3,3>() << 0, 1, 0,
87 // -1, 0, 0,
88 // 0, 0, 1;
89  wTgoalTool_eigen.topLeftCorner<3,3>() = FRM::eul2Rot(eulRad);
90 
91  //to get inside the hole of 0.2m:
92  Eigen::Vector3d v_inside;
93  //v_inside << 0.40, 0.18, 0; //rigth big hole + error
94  v_inside << 0.20, 0, 0;
95  Eigen::Vector3d w_inside = FRM::eul2Rot(eulRadTrue) * v_inside;
96 
97  //trasl part
98  wTgoalTool_eigen(0, 3) = goalLinearVectTool[0] + w_inside(0);
99  wTgoalTool_eigen(1, 3) = goalLinearVectTool[1] + w_inside(1);
100  wTgoalTool_eigen(2, 3) = goalLinearVectTool[2] + w_inside(2);
101 
102 
107  Infos robInfo;
109  //struct transforms to pass them to Controller class
110  robInfo.transforms.wTgoalVeh_eigen = wTgoalVeh_eigen;
111  robInfo.transforms.wTgoalEE_eigen = wTgoalEE_eigen;
112  robInfo.transforms.wTgoalTool_eigen = wTgoalTool_eigen;
113  robInfo.robotState.vehicleVel.resize(VEHICLE_DOF);
114  std::fill(robInfo.robotState.vehicleVel.begin(), robInfo.robotState.vehicleVel.end(), 0);
115 
116 
118  RobotInterface robotInterface(nh, robotName);
119  robotInterface.init();
120 
121  WorldInterface worldInterface(robotName);
122  worldInterface.waitReady("world", otherRobotName);
123 
125  robotInterface.getJointState(&(robInfo.robotState.jState));
126  robotInterface.getwTv(&(robInfo.robotState.wTv_eigen));
127  worldInterface.getwPos(&(robInfo.exchangedInfo.otherRobPos), otherRobotName);
128 
130  if (robotName.compare("g500_A") == 0){
131  worldInterface.getwT(&(robInfo.transforms.wTotherPeg),
132  "g500_B/eeA");
133 
134  } else {
135  worldInterface.getwT(&(robInfo.transforms.wTotherPeg),
136  "g500_A/eeB");
137  }
138 
139 
140  //DEBUGG
141  //robotInterface.getwTjoints(&(robInfo.robotState.wTjoints));
142 
144  std::string filenamePeg; //the model of robot with a "fake joint" in the peg
145  //so, it is ONLY for the already grasped scene
146  if (robotName.compare("g500_A") == 0){
147  filenamePeg = "/home/tori/UWsim/Peg/model/g500ARM5APeg2.urdf";
148  } else {
149  filenamePeg = "/home/tori/UWsim/Peg/model/g500ARM5BPeg2.urdf";
150  }
151  std::string vehicle = "base_link";
152  std::string link0 = "part0";
153  std::string endEffector = "end_effector";
154  std::string peg = "peg"; //pass this to kdlHelper costructor to have jacobian of the center of peg
155  std::string pegHead = "pegHead"; //pass this to kdlHelper constructor to have jacobian of the tip
156 
157  KDLHelper kdlHelper(filenamePeg, link0, endEffector, vehicle, pegHead);
158  // KDL parse for fixed things (e.g. vehicle and one of his sensor)
159  //TODO Maybe exist an easier method to parse fixed frame from urdf without needed of kdl solver
160  kdlHelper.getFixedFrame(vehicle, link0, &(robInfo.robotStruct.vTlink0));
161  // TODO vT0 non serve più?
162  //kdlHelper.getFixedFrame(endEffector, peg, &(robInfo.robotStruct.eeTtool));
163  kdlHelper.getFixedFrame(endEffector, pegHead, &(robInfo.robotStruct.eeTtoolTip));
164  //TODO TRY : for B is not really fixed...
165 
166  //get info from sensors
167  // for robot B in truth it takes infor from sensor of robot A
168  Eigen::Vector3d forceNotSat; //not saturated: to logging purpose
169  Eigen::Vector3d torqueNotSat;
170  robotInterface.getForceTorque(&forceNotSat, &torqueNotSat);
171  robInfo.robotSensor.forcePegTip = FRM::saturateVectorEigen(forceNotSat, 5);
172  robInfo.robotSensor.torquePegTip = FRM::saturateVectorEigen(torqueNotSat, 5);
173 
174  kdlHelper.setEESolvers();
175  //get ee pose RESPECT LINK 0
176  kdlHelper.getEEpose(robInfo.robotState.jState, &(robInfo.robotState.link0Tee_eigen));
177  // useful have vTee: even if it is redunant, everyone use it a lot
178  robInfo.robotState.vTee_eigen = robInfo.robotStruct.vTlink0 * robInfo.robotState.link0Tee_eigen;
179  // get jacobian respect link0
180  kdlHelper.getJacobianEE(robInfo.robotState.jState, &(robInfo.robotState.link0_Jee_man));
181  //get whole jacobian (arm+vehcile and projected on world
182  computeWholeJacobianEE(&robInfo);
183 
184  //kdlHelper.setToolSolvers(robInfo.robotStruct.eeTtool);
185  //kdlHelper.setToolSolvers(robInfo.robotStruct.eeTtoolTip);
186  kdlHelper.setToolSolvers(); //version for peg as robot link
187  kdlHelper.getJacobianTool(robInfo.robotState.jState, &(robInfo.robotState.v_Jtool_man));
188  computeWholeJacobianTool(&robInfo);
189 
190  robInfo.transforms.wTt_eigen = robInfo.robotState.wTv_eigen *
191  robInfo.robotState.vTee_eigen * robInfo.robotStruct.eeTtoolTip;
192 
193  CoordInterfaceMissMan coordInterface(nh, robotName);
194 
196  Controller controller(robotName);
197 
199  std::vector<Task*> tasksTPIK1; //the first, non coop, one
200  std::vector<Task*> tasksCoop;
201  std::vector<Task*> tasksArmVehCoord; //for arm-vehicle coord
202  setTaskLists(robotName, &tasksTPIK1, &tasksCoop, &tasksArmVehCoord);
203 
204 
205 
209 
212  Logger logger;
213  if (pathLog.size() > 0){
214  logger = Logger(robotName, pathLog);
215 
216  //to for each list... if task was in a previous list, no problem, folder with same name... overwrite?
217  logger.createTasksListDirectories(tasksTPIK1);
218  logger.createTasksListDirectories(tasksCoop);
219 
220  }
221 
226  //wait coordinator to start
227  double msinit = 1;
228  boost::asio::io_service ioinit;
229  std::cout << "[" << robotName << "][MISSION_MANAGER] Wating for "<<
230  "Coordinator to say I can start...\n";
231  while(!coordInterface.getStartFromCoord()){
232  boost::asio::deadline_timer loopRater(ioinit, boost::posix_time::milliseconds(msinit));
233  coordInterface.pubIamReadyOrNot(true);
234  if (coordInterface.getUpdatedGoal(&(robInfo.transforms.wTgoalTool_eigen)) == 0) {
235  std::cout << "[" << robotName << "][MISSION_MANAGER] Arrived goal from coordinator!\n";
236  }
237 
238  ros::spinOnce();
239  loopRater.wait();
240  }
241 
242  std::cout << "[" << robotName<< "][MISSION_MANAGER] Start from coordinator "<<
243  "received\n";
244 
245 
249  int ms = MS_CONTROL_LOOP;
250  boost::asio::io_service io;
251  boost::asio::io_service io2;
252 
253 
254 
255  //debug
256  double nLoop = 0.0;
257 
258  while(1){
259 
260  //auto start = std::chrono::steady_clock::now();
261 
262  // this must be inside loop
263  boost::asio::deadline_timer loopRater(io, boost::posix_time::milliseconds(ms));
264 
266  robotInterface.getJointState(&(robInfo.robotState.jState));
267  robotInterface.getwTv(&(robInfo.robotState.wTv_eigen));
268  worldInterface.getwPos(&(robInfo.exchangedInfo.otherRobPos), otherRobotName);
269  //worldInterface.getwT(&(robInfo.transforms.wTt_eigen), toolName);
270 
272  if (robotName.compare("g500_A") == 0){
273  worldInterface.getwT(&(robInfo.transforms.wTotherPeg), "g500_B/eeA");
274  } else {
275  worldInterface.getwT(&(robInfo.transforms.wTotherPeg), "g500_A/eeB");
276  }
277 
280  robotInterface.getForceTorque(&forceNotSat, &torqueNotSat);
281  //robInfo.robotSensor.forcePegTip = FRM::saturateVectorEigen(forceNotSat, 5);
282  //robInfo.robotSensor.torquePegTip = FRM::saturateVectorEigen(torqueNotSat, 5);
283  robInfo.robotSensor.forcePegTip = forceNotSat;
284  robInfo.robotSensor.torquePegTip = torqueNotSat;
285  //std::cout << "force torque arrive:\n"
286  // << robInfo.robotSensor.forcePegTip << "\n"
287  // << robInfo.robotSensor.torquePegTip << "\n\n";
288 
289 
290 
291  //get ee pose RESPECT LINK 0
292  kdlHelper.getEEpose(robInfo.robotState.jState, &(robInfo.robotState.link0Tee_eigen));
293  // useful have vTee: even if it is redunant, tasks use it a lot
294  robInfo.robotState.vTee_eigen = robInfo.robotStruct.vTlink0 * robInfo.robotState.link0Tee_eigen;
295  robInfo.transforms.wTt_eigen = robInfo.robotState.wTv_eigen *
296  robInfo.robotState.vTee_eigen * robInfo.robotStruct.eeTtoolTip;
297 
298 
299  kdlHelper.getJacobianEE(robInfo.robotState.jState, &(robInfo.robotState.link0_Jee_man));
300  computeWholeJacobianEE(&robInfo);
301 
302  //kdlHelper.setToolSolvers(eeTtool);
303  kdlHelper.getJacobianTool(robInfo.robotState.jState, &(robInfo.robotState.v_Jtool_man));
304  computeWholeJacobianTool(&robInfo);
305 
309  if (CHANGE_GOAL){
310 
311  if (coordInterface.getUpdatedGoal(&(robInfo.transforms.wTgoalTool_eigen)) == 0) {
312 
314  //std::cout << "Goal modified:\n";
315  //std::cout << robInfo.transforms.wTgoalTool_eigen;
316  //std::cout << "\n\n";
317  }
318  }
319 
322  controller.updateMultipleTasksMatrices(tasksTPIK1, &robInfo);
324  std::vector<double> yDotTPIK1 = controller.execAlgorithm(tasksTPIK1);
325 
326  std::vector<double> yDotFinal(TOT_DOF);
327 
329  Eigen::Matrix<double, VEHICLE_DOF, 1> nonCoopCartVel_eigen =
330  robInfo.robotState.w_Jtool_robot * CONV::vector_std2Eigen(yDotTPIK1);
331 
332  Eigen::Matrix<double, VEHICLE_DOF, VEHICLE_DOF> admisVelTool_eigen =
333  robInfo.robotState.w_Jtool_robot * FRM::pseudoInverse(robInfo.robotState.w_Jtool_robot);
334 
335  coordInterface.publishToCoord(nonCoopCartVel_eigen, admisVelTool_eigen);
336 
337  while (coordInterface.getCoopCartVel(&(robInfo.exchangedInfo.coopCartVel)) == 1){ //wait for coopVel to be ready
338  boost::asio::deadline_timer loopRater2(io2, boost::posix_time::milliseconds(1));
339  loopRater2.wait();
340  ros::spinOnce();
341  }
342 
343  controller.updateMultipleTasksMatrices(tasksCoop, &robInfo);
344  std::vector<double> yDotOnlyVeh = controller.execAlgorithm(tasksCoop);
345 
346 
347  controller.updateMultipleTasksMatrices(tasksArmVehCoord, &robInfo);
348  std::vector<double> yDotOnlyArm = controller.execAlgorithm(tasksArmVehCoord);
349 
350  for (int i=0; i<ARM_DOF; i++){
351  yDotFinal.at(i) = yDotOnlyArm.at(i);
352  }
353 
354  for (int i = ARM_DOF; i<TOT_DOF; i++) {
355  yDotFinal.at(i) = yDotOnlyVeh.at(i);
356  //at the moment no error so velocity are exaclty what we are giving
357  robInfo.robotState.vehicleVel.at(i-ARM_DOF) = yDotFinal.at(i);
358  }
359 
361  std::vector<double> deltayDotTot(TOT_DOF); //per log purpose
363  std::vector<double> yDotFinalWithCollision(TOT_DOF);
364  yDotFinalWithCollision = yDotFinal;
365  if (COLLISION_PROPAGATOR){ //if active, calculate and modify joint command accordingly
366  if (robotName.compare("g500_A") == 0){
367 
368  if (robInfo.robotSensor.forcePegTip.norm() > 0 ||
369  robInfo.robotSensor.torquePegTip.norm() > 0){
370 
371  deltayDotTot = CollisionPropagator::calculateCollisionDisturbArmVeh(robInfo.robotState.w_Jtool_robot,
372  robInfo.transforms.wTt_eigen, robInfo.robotSensor.forcePegTip, robInfo.robotSensor.torquePegTip);
373 
374  for (int i=0; i<ARM_DOF; i++){
375  deltayDotTot.at(i) *= 0.00005; // tori keep this it is needed for logs
376  yDotFinalWithCollision.at(i) += deltayDotTot.at(i); //add disturbs to command
377  }
378 
379  for (int i=ARM_DOF; i<TOT_DOF; i++){ //vehicle
380  deltayDotTot.at(i) *= 0.0001;
381  yDotFinalWithCollision.at(i) += deltayDotTot.at(i);
382  }
383 
384  //debug try: stop vehilce until collision resolved. zeroing vehicle vel both with and withoud collision prop
385  //withou collision prop is the task force which resolve the collision
386  //for (int i=ARM_DOF; i<TOT_DOF; i++){
387  // yDotFinalWithCollision.at(i) = 0;
388  //}
390 // std::cout << "collision command:\n";
391 // for (auto const& c : deltayDot){
392 // std::cout << c << ' ';
393 // }
394 // std::cout << "\n\n";
395  }
396  }
397  }
398 
403  std::vector<double> yDotFinalWithGrasp = yDotFinalWithCollision;
404  std::vector<double> graspyDot(TOT_DOF);
405 
406  if (GRASP_CONSTRAINER){
407 
408  if (robotName.compare("g500_B") == 0){
409 
411 // std::vector<double> graspyDot(ARM_DOF);
412 // graspyDot = GraspConstrainer::calculateGraspVelocities_arm(
413 // robInfo.robotState.w_Jtool_robot.leftCols<ARM_DOF>(),
414 // robInfo.transforms.otherEE_T_EE);
415 
417  robInfo.robotState.w_Jtool_robot,
418  robInfo.transforms.wTotherPeg,
419  robInfo.robotState.wTv_eigen * robInfo.robotState.vTee_eigen);
420 
421 
422  for (int i=0; i<graspyDot.size(); i++){
423  yDotFinalWithGrasp.at(i) += graspyDot.at(i);
424  }
425 
427 // std::cout << "GRASP command:\n";
428 // for (auto const& c : graspyDot){
429 // std::cout << c << ' ';
430 // }
431 // std::cout << "\n\n";
432  }
433  }
439  //robotInterface.sendyDot(yDotTPIK1);
441  //robotInterface.sendyDot(yDotOnlyVeh);
442  //robotInterface.sendyDot(yDotFinal);
443  //robotInterface.sendyDot(yDotFinalWithCollision);
444  robotInterface.sendyDot(yDotFinalWithGrasp);
445 
446 
447 
449  if (pathLog.size() != 0){
450  logger.logAllForTasks(tasksArmVehCoord);
451  logger.logNumbers(tasksArmVehCoord.at(4)->getJacobian(), "forceJacob");
452  //TODO flag LOGGED to not print same thing twice
453  //or maybe another list with ALL task only to log here and create folder for log
454  //for the moment, yDot are exactly how vehicle and arm are moving
455  logger.logNumbers(yDotTPIK1, "yDotTPIK1");
456  logger.logNumbers(yDotFinal, "yDotFinal"); //after cooperation and arm-veh
457  logger.logNumbers(yDotFinalWithCollision, "yDotFinalWithCollision"); //after collision
458  logger.logNumbers(robInfo.robotSensor.forcePegTip, "forces");
459  logger.logNumbers(robInfo.robotSensor.torquePegTip, "torques");
460  logger.logNumbers(robInfo.robotState.w_Jtool_robot *
461  CONV::vector_std2Eigen(deltayDotTot), "toolVel4Collision");
462  logger.logNumbers(robInfo.robotState.w_Jtool_robot *
463  CONV::vector_std2Eigen(graspyDot), "toolVel4Grasp");
464  //logger.logNumbers(admisVelTool_eigen, "JJsharp");
465  logger.logNumbers(robInfo.robotState.w_Jtool_robot
466  * CONV::vector_std2Eigen(yDotOnlyVeh), "toolCartVelCoop");
467  }
468 
471 
472 // std::cout << "JJsharp\n" << admisVelTool_eigen << "\n\n";
473 // std::cout << "SENDED non coop vel:\n" << nonCoopCartVel_eigen <<"\n\n\n";
474 // std::cout << "ARRIVED coop vel:\n" << robInfo.exchangedInfo.coopCartVel << "\n\n\n";
475 
476 
477 // std::cout << "J: \n"
478 // << robInfo.robotState.w_Jtool_robot
479 // << "\n\n";
480 // std::cout << "yDot: \n"
481 // << CONV::vector_std2Eigen(yDotOnlyVeh)
482 // << "\n\n";
483 // std::cout << "The tool velocity non coop are (J*yDot): \n"
484 // << nonCoopCartVel_eigen
485 // << "\n\n";
486 // std::cout << "The tool velocity coop are (J*yDot): \n"
487 // << robInfo.robotState.w_Jtool_robot
488 // * CONV::vector_std2Eigen(yDotFinal)
489 // << "\n\n";
490 
491 // std::vector<Task*> tasksDebug = tasksArmVehCoord;
492 // for(int i=0; i<tasksDebug.size(); i++){
493 // if (tasksDebug[i]->getName().compare("PIPE_REACHING_GOAL") == 0){
494 // std::cout << "ERROR " << tasksDebug[i]->getName() << ": \n";
495 // tasksDebug[i]->getError().PrintMtx() ;
496 // std::cout << "\n";
497 // std::cout << "JACOBIAN " << tasksDebug[i]->getName() << ": \n";
498 // tasksDebug[i]->getJacobian().PrintMtx();
499 // std::cout<< "\n";
500 // std::cout << "REFERENCE " << tasksDebug[i]->getName() << ": \n";
501 // tasksDebug[i]->getReference().PrintMtx() ;
502 // std::cout << "\n";
503 // }
504 // }
505 
506  controller.resetAllUpdatedFlags(tasksTPIK1);
507  controller.resetAllUpdatedFlags(tasksCoop);
508  controller.resetAllUpdatedFlags(tasksArmVehCoord);
509  ros::spinOnce();
510 
511 
512  //auto end = std::chrono::steady_clock::now();
513  //auto duration = std::chrono::duration_cast<std::chrono::milliseconds>( end - start ).count();
514  //std::cout << "TEMPOOOOO "<<duration << "\n\n";
515 
516 
517  loopRater.wait();
518  //nLoop += 1;
519 
520 // if (nLoop > 10){
521 // exit(-1);
522 // }
523 
524  } //end controol loop
525 
526 
527 
528 
529  coordInterface.pubIamReadyOrNot(false);
530 
531  //todo lista con all task per cancellarli
532  deleteTasks(&tasksArmVehCoord);
533 
534  return 0;
535 }
536 
537 
547 void setTaskLists(std::string robotName, std::vector<Task*> *tasks1,
548  std::vector<Task*> *tasksCoord, std::vector<Task*> *tasksArmVeh){
549 
550  bool eqType = true;
551  bool ineqType = false;
552 
553 
555  Task* coopTask6dof = new CoopTask(6, eqType, robotName);
556  //Task* coopTask5dof = new CoopTask(5, eqType, robotName);
557  Task* constrainVel = new VehicleConstrainVelTask(6, eqType, robotName);
558 
559 
561  Task* jl = new JointLimitTask(4, ineqType, robotName);
562  Task* ha = new HorizontalAttitudeTask(1, ineqType, robotName);
563  //Task* eeAvoid = new ObstacleAvoidEETask(1, ineqType, robotName);
564 
565 
567  Task* forceInsert = new ForceInsertTask(2, ineqType, robotName);
568  //Task* vehStill = new VehicleNullVelTask(6, eqType, robotName);
569 
571  //Task* pr5 = new PipeReachTask(5, eqType, robotName, BOTH);
572  Task* pr6 = new PipeReachTask(6, eqType, robotName, BOTH);
573  Task* pr3Lin = new PipeReachTask(3, eqType, robotName, BOTH, LIN);
574  Task* pr3Ang = new PipeReachTask(3, eqType, robotName, BOTH, ANG);
575 
576  //Task* eer = new EndEffectorReachTask(6, eqType, robotName);
577  //Task* vehR = new VehicleReachTask(3, eqType, robotName, ANGULAR);
578  //Task* vehYaxis = new VehicleReachTask(1, eqType, robotName, YAXIS);
579 
581  Task* shape = new ArmShapeTask(4, ineqType, robotName, PEG_GRASPED_PHASE);
582  //The "fake task" with all eye and zero matrices, needed as last one for algo?
583  Task* last = new LastTask(TOT_DOF, eqType, robotName);
584 
586  // note: order of priority at the moment is here
587  tasks1->push_back(jl);
588  tasks1->push_back(ha);
589  //tasks1->push_back(eeAvoid);
590  tasks1->push_back(forceInsert);
591  tasks1->push_back(pr6);
592  //tasks1->push_back(pr3Ang);
593  //tasks1->push_back(pr3Lin);
594  //TODO discutere diff tra pr6 e pr5... il 5 mette più stress sull obj?
595  //tasks1->push_back(vehR);
596  //tasks1->push_back(vehYaxis);
597  //tasks1->push_back(eer);
598  tasks1->push_back(shape);
599  tasks1->push_back(last);
600 
601  //TODO ASK al momento fatte così le versioni 6dof di pr e coop sono
602  //molto meglio
603  //coop 5 dof assolutamente no
604  //pr5 da un po di stress cmq (linearmente -0.034, -0.008, -0.020),
605  //i due tubi divisi si vedono tanto agli estremi
606  //si dovrebbe abbassare gain e saturaz per usare il pr5
607  //soprattutto se c'è sto shape fatto cosi che fa muovere tantissimo
608  //i bracci, è da cambiare lo shape desiderato
609  tasksCoord->push_back(coopTask6dof);
610  tasksCoord->push_back(jl);
611  tasksCoord->push_back(ha);
612  tasksCoord->push_back(forceInsert);
613  tasksCoord->push_back(pr6);
614  //tasksCoord->push_back(pr3Ang);
615  //tasksCoord->push_back(pr3Lin);
616  tasksCoord->push_back(shape);
617  tasksCoord->push_back(last);
618 
619  tasksArmVeh->push_back(coopTask6dof);
620  tasksArmVeh->push_back(constrainVel);
621  tasksArmVeh->push_back(jl);
622  tasksArmVeh->push_back(ha);
623  tasksArmVeh->push_back(forceInsert);
624  tasksArmVeh->push_back(pr6);
625  //tasksArmVeh->push_back(pr3Ang);
626  //tasksArmVeh->push_back(pr3Lin);
627  tasksArmVeh->push_back(shape);
628  tasksArmVeh->push_back(last);
629 
630 }
631 
632 
637 void deleteTasks(std::vector<Task*> *tasks){
638  for (std::vector< Task* >::iterator it = tasks->begin() ; it != tasks->end(); ++it)
639  {
640  delete (*it);
641  }
642  tasks->clear();
643 }
644 
645 
646 
647 
648 
649 
650 
651 
652 
653 
654 
655 
656 /********* OLD VERSIONS *********************************************************************************
657 
658 
659 
660 
661 void setTaskLists(std::string robotName, std::vector<Task*> *tasks){
662 
664  // note: order of priority at the moment is here
665  bool eqType = true;
666  bool ineqType = false;
667 
668  //tasks->push_back(new VehicleNullVelTask(6, ineqType));
669 
670  tasks->push_back(new JointLimitTask(4, ineqType, robotName));
671  tasks->push_back(new HorizontalAttitudeTask(1, ineqType, robotName));
672 
673  //tasks->push_back(new ObstacleAvoidEETask(1, ineqType, robotName));
674  //tasks->push_back(new ObstacleAvoidVehicleTask(1, ineqType, robotName));
675 
676  //tasks->push_back(new FovEEToToolTask(1, ineqType, robotName));
677 
678  //tasks->push_back(new EndEffectorReachTask(6, eqType, robotName));
679  tasks->push_back(new PipeReachTask(5, eqType, robotName, BOTH));
680  //tasks->push_back(new VehicleReachTask(6, eqType, robotName));
681 
682  tasks->push_back(new ArmShapeTask(4, ineqType, robotName, MID_LIMITS));
683  //The "fake task" with all eye and zero matrices, needed as last one for algo
684  tasks->push_back(new LastTask(TOT_DOF, eqType, robotName));
685 }
686 
687 void setTaskLists(std::string robotName, std::vector<Task*> *tasks1, std::vector<Task*> *tasksFinal){
688 
689  bool eqType = true;
690  bool ineqType = false;
691 
692 
694  Task* coopTask6dof = new CoopTask(6, eqType, robotName);
695  Task* coopTask5dof = new CoopTask(5, eqType, robotName);
696 
697 
699  Task* jl = new JointLimitTask(4, ineqType, robotName);
700  Task* ha = new HorizontalAttitudeTask(1, ineqType, robotName);
701 
702 
704 
705 
707  Task* pr5 = new PipeReachTask(5, eqType, robotName, BOTH);
708  Task* pr6 = new PipeReachTask(6, eqType, robotName, BOTH);
709 
710  Task* tr = new EndEffectorReachTask(6, eqType, robotName);
711 
713  Task* shape = new ArmShapeTask(4, ineqType, robotName, MID_LIMITS);
714  //The "fake task" with all eye and zero matrices, needed as last one for algo?
715  Task* last = new LastTask(TOT_DOF, eqType, robotName);
716 
718  // note: order of priority at the moment is here
719  tasks1->push_back(jl);
720  tasks1->push_back(ha);
721  tasks1->push_back(pr5);
722  //tasks1->push_back(tr);
723  //tasks1->push_back(shape);
724  tasks1->push_back(last);
725 
726  tasksFinal->push_back(coopTask5dof);
727  // tasksFinal->push_back(jl);
728  //tasksFinal->push_back(ha);
729  //tasksFinal->push_back(shape);
730  tasksFinal->push_back(last);
731 }
732 
733 
734 
735 
736 
737 
739 // std::cout << "JACOBIAN " << i << ": \n";
740 // tasks[i]->getJacobian().PrintMtx();
741 // std::cout<< "\n";
742 // std::cout << "REFERENCE " << i << ": \n";
743 // tasks[i]->getReference().PrintMtx() ;
744 // std::cout << "\n";
745 
746 
747 //std::cout << nonCoopCartVel_eigen << "\n\n";
748 //std::cout << admisVelTool_eigen << "\n\n";
749 
750 
751 //Q.PrintMtx("Q"); ///DEBUG
752 //yDot_cmat.PrintMtx("yDot");
753 
754 
755 
756 //DEBUGGGG
757 //computeJacobianToolNoKdl(&robInfo, robotName);
758 
759 //std::cout << "con KDL:\n" << robInfo.robotState.w_Jtool_robot << "\n\n";
760 //std::cout << "senza KDL:\n" << robInfo.robotState.w_JNoKdltool_robot << "\n\n";
761 
762 /*
763 //debug
764 Eigen::Matrix4d toolPose_eigen;
765 kdlHelper.getToolpose(robInfo.robotState.jState, eeTtool, &toolPose_eigen);
766 Eigen::Matrix4d W_toolPose_eigen = robInfo.robotState.wTv_eigen * robInfo.robotStruct.vTlink0 * toolPose_eigen;
767 
768 std::cout << "ToolPOSE\n" <<
769  W_toolPose_eigen << "\n\n";
770 */
Definition: logger.h:16
The Controller class is responsabile of 1) taking matrices and giving them to Tasks classes...
Definition: controller.h:20
std::vector< double > vehicleVel
vehicle and joint
Definition: infos.h:45
The ForceInsertTask class to help the inserting phase with force torque sensor this task is to genera...
robotInterface: a ros node responsible of taken info from simulator and robot sensors, and of given commands back. It is the intermiate layer between actual robot and mission manager ("main")
"Fake" Task needed as last to algorithm, it has all fixed matrices of eye and zeros so no setxx are n...
Definition: lastTask.h:9
static std::vector< double > calculateGraspVelocities_armVeh(Eigen::Matrix< double, 6, TOT_DOF > w_Jee_robot, Eigen::Matrix4d wTotherPeg, Eigen::Matrix4d wTee)
calculateGraspVelocities_armVeh for effect of firm grasp on the arm and on the vehicle ...
The CoopTask class.
Definition: coopTask.h:10
The vehicleConstrainVelTask class This task is a non-reactive one used to to constrain the velocities...
The CoordInterface class class to deal with ros comunications (pub/sub) from MissionManager node to C...
The WorldInterface class to get position from world to anything else.
Eigen::Matrix< double, 6, ARM_DOF > link0_Jee_man
Jacobians.
Definition: infos.h:52
Definition: infos.h:117
Eigen::Matrix4d wTv_eigen
Transforms.
Definition: infos.h:34
The ArmShapeTask class Preferred arm Shape: an optimization task. It is a non scalar task...
Definition: armShapeTask.h:20
ABSTRACT class task. Each task is a derived class of this class. It contains all the variable that th...
Definition: task.h:17