ocra-recipes
Doxygen documentation for the ocra-recipes repository
TrajectoryThread.cpp
Go to the documentation of this file.
1 
9 /*
10  * This file is part of ocra-icub.
11  * Copyright (C) 2016 Institut des Systèmes Intelligents et de Robotique (ISIR)
12  *
13  * This program is free software: you can redistribute it and/or modify
14  * it under the terms of the GNU General Public License as published by
15  * the Free Software Foundation, either version 3 of the License, or
16  * (at your option) any later version.
17  *
18  * This program is distributed in the hope that it will be useful,
19  * but WITHOUT ANY WARRANTY; without even the implied warranty of
20  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21  * GNU General Public License for more details.
22  *
23  * You should have received a copy of the GNU General Public License
24  * along with this program. If not, see <http://www.gnu.org/licenses/>.
25 */
26 
28 
29 #ifndef VAR_THRESH
30 #define VAR_THRESH 0.99
31 #endif
32 
33 using namespace ocra_recipes;
34 
35 // TrajectoryThread::TrajectoryThread()
36 // {
37 //
38 // }
39 
41 {
42  if(this->isRunning()) {
43 // task->closeControlPorts();
44  this->stop();
45  }
46 }
47 
49  const std::string& taskName,
50  const TRAJECTORY_TYPE trajectoryType,
51  const TERMINATION_STRATEGY _terminationStrategy)
52 : RateThread(period)
53 , trajType(trajectoryType)
54 , terminationStrategy(_terminationStrategy)
55 {
56  task = std::make_shared<TaskConnection>(taskName);
57  task->openControlPorts();
58  init();
59 }
60 
62  const std::string& taskName,
63  const Eigen::MatrixXd& waypoints,
64  const TRAJECTORY_TYPE trajectoryType,
65  const TERMINATION_STRATEGY _terminationStrategy):
66 RateThread(period),
67 userWaypoints(waypoints),
68 trajType(trajectoryType),
69 terminationStrategy(_terminationStrategy)
70 {
71  task = std::make_shared<TaskConnection>(taskName);
72  task->openControlPorts();
73  init();
74 }
75 
77  const std::string& taskName,
78  const std::list<Eigen::VectorXd>& waypoints,
79  const TRAJECTORY_TYPE trajectoryType,
80  const TERMINATION_STRATEGY _terminationStrategy):
81 RateThread(period),
82 userWaypointList(waypoints),
83 trajType(trajectoryType),
84 terminationStrategy(_terminationStrategy)
85 {
86  task = std::make_shared<TaskConnection>(taskName);
87  task->openControlPorts();
88  init();
89 }
90 
92 {
93  // Set up class variables:
94  waypointsHaveBeenSet = false;
96  errorThreshold = 0.03;
97  useVarianceModulation = true;
98  deactivationDelay = 0.0;
99  deactivationTimeout = 5.0;
100  deactivationLatch = false;
101  isPaused = false;
103  returningHome = false;
104 
105  isTaskCurrentlyActive = task->isActivated();
106  weightDimension = task->getTaskDimension();
107  taskType = task->getTaskType();
108 
109 
112  } else {
114  }
115 
116  switch (trajType)
117  {
118  case MIN_JERK:
119  trajectory = std::make_shared<ocra::MinimumJerkTrajectory>();
120  break;
121  case LIN_INTERP:
122  trajectory = std::make_shared<ocra::LinearInterpolationTrajectory>();
123  break;
124  case GAUSSIAN_PROCESS:
125  #if USING_SMLT
126  trajectory = std::make_shared<ocra::GaussianProcessTrajectory>();
127  #else
128  std::cout << "You need the SMLT libs to use GAUSSIAN_PROCESS type trajectories. I'm gonna make you a MIN_JERK instead." << std::endl;
129  trajType = MIN_JERK;
130  trajectory = std::make_shared<ocra::MinimumJerkTrajectory>();
131  #endif
132  break;
133  case TIME_OPTIMAL:
134  #if USING_GTTRAJ
135  trajectory = std::make_shared<ocra::TimeOptimalTrajectory>();
136  #else
137  std::cout << "You need the GTTraj libs to use TIME_OPTIMAL type trajectories. I'm gonna make you a MIN_JERK instead." << std::endl;
138  trajType = MIN_JERK;
139  trajectory = std::make_shared<ocra::MinimumJerkTrajectory>();
140  #endif
141  break;
142  }
143 }
144 
146 {
148  {
149  desiredVariance = Eigen::VectorXd::Ones(weightDimension);
150  varianceThresh = Eigen::ArrayXd::Constant(weightDimension, VAR_THRESH);
151  }
152 
153  if ( (userWaypointList.size()>0) || (userWaypoints.size()>0) ) {
154  if (trajType==TIME_OPTIMAL) {
156  } else {
158  }
159  }
160  else {
161  return true;
162  }
163 }
164 
166 {
167  task->closeControlPorts();
168  std::cout<< "\nTrajectoryThread: Trajectory thread finished.\n";
169 }
170 
172 {
173  if (waypointsHaveBeenSet && !isPaused) {
175  {
176  switch (terminationStrategy)
177  {
178  case BACK_AND_FORTH:
179  flipWaypoints();
180  if (trajType==TIME_OPTIMAL) {
182  } else {
184  }
185  break;
186 
187  case REVERSE:
188  if (returningHome) {
190  std::cout << "Trajectory thread for task: " << task->getTaskName() << " has attained its goal state. Awaiting new commands." << std::endl;
191  printWaitingNoticeOnce = false;
192  }
193  } else {
194  flipWaypoints();
195  if (trajType==TIME_OPTIMAL) {
197  } else {
199  }
200  returningHome = true;
201  }
202  break;
203 
204  case REVERSE_STOP:
205  if (returningHome) {
206  stop();
207  } else {
208  flipWaypoints();
209  if (trajType==TIME_OPTIMAL) {
211  } else {
213  }
214  returningHome = true;
215  }
216  break;
217 
219  if (returningHome) {
220  if(task->deactivate()){
221  isTaskCurrentlyActive = task->isActivated();
222  stop();
223  }else{
224  std::cout << "[WARNING] Trajectory thread for task: " << task->getTaskName() << " has attained its goal state, but cannot be deactivated." << std::endl;
225  yarp::os::Time::delay(1.0); // try again in one second.
226  deactivationDelay += 1.0;
228  std::cout << "[WARNING] Deactivation timeout." << std::endl;
229  stop();
230  }
231  }
232  } else {
233  flipWaypoints();
234  if (trajType==TIME_OPTIMAL) {
236  } else {
238  }
239  returningHome = true;
240  }
241  break;
242 
243  case CYCLE:
244  cycleWaypoints();
245  if (trajType==TIME_OPTIMAL) {
247  } else {
249  }
250  break;
251 
252  case STOP_THREAD:
253  stop();
254  break;
256  if(task->deactivate()){
257  isTaskCurrentlyActive = task->isActivated();
258  stop();
259  }else{
260  std::cout << "[WARNING] Trajectory thread for task: " << task->getTaskName() << " has attained its goal state, but cannot be deactivated." << std::endl;
261  yarp::os::Time::delay(1.0); // try again in one second.
262  deactivationDelay += 1.0;
264  std::cout << "[WARNING] Deactivation timeout." << std::endl;
265  stop();
266  }
267  }
268  break;
269  case WAIT:
271  std::cout << "Trajectory thread for task: " << task->getTaskName() << " has attained its goal state. Awaiting new commands." << std::endl;
272  printWaitingNoticeOnce = false;
273  }
274  break;
275  case WAIT_DEACTIVATE:
277  if(task->deactivate()){
278  isTaskCurrentlyActive = task->isActivated();
279 
280  std::cout << "Trajectory thread for task: " << task->getTaskName() << " has attained its goal state. Deactivating task and awaiting new commands." << std::endl;
281  printWaitingNoticeOnce = false;
282  deactivationLatch = true;
283  }else{
284  std::cout << "Trajectory thread for task: " << task->getTaskName() << " has attained its goal state and is awaiting new commands. [WARNING] Could not deactivate the task." << std::endl;
285  yarp::os::Time::delay(1.0); // try again in one second.
286  deactivationDelay += 1.0;
288  printWaitingNoticeOnce = false;
289  std::cout << "[WARNING] Deactivation timeout." << std::endl;
290  }
291  }
292  }
293  break;
294  }
295  }
296  else{
297  if (!isTaskCurrentlyActive) {
298  task->activate();
299  isTaskCurrentlyActive = task->isActivated();
300  }
301 
302  desStateBottle.clear();
303 
304  double relativeTime = yarp::os::Time::now() - timeElapsedDuringPause;
305  Eigen::MatrixXd desiredState_tmp;
306 
308  {
309  // trajectory->getDesiredValues(relativeTime, desiredState_tmp, desiredVariance);
310  // desiredState << desiredState_tmp;
311 
312 
313  // for(int i=0; i<desiredState.size(); i++)
314  // {
315  // desStateBottle.addDouble(desiredState(i));
316  // }
317  // #if USING_SMLT
318  // if(useVarianceModulation)
319  // {
320  // Eigen::VectorXd desiredWeights = varianceToWeights(desiredVariance);
321  // for(int i=0; i<desiredWeights.size(); i++)
322  // {
323  // desStateBottle.addDouble(desiredWeights(i));
324  // }
325  // }
326  // #endif
327  }
328  else
329  {
330  // desiredState << trajectory->getDesiredValues(relativeTime);
331  // for(int i=0; i<desiredState.size(); i++)
332  // {
333  // desStateBottle.addDouble(desiredState(i));
334  // }
335  desiredState_tmp = trajectory->getDesiredValues(relativeTime);
336  }
337 
338 
339  // task->sendDesiredStateAsBottle(desStateBottle);
340  // ocra::TaskState state = matrixToTaskState(desiredState_tmp);
341  task->setDesiredTaskStateDirect(matrixToTaskState(desiredState_tmp));
342  }
343  }
344 }
345 
346 
347 
349 {
350  isPaused = true;
351  pauseTime = yarp::os::Time::now();
352 }
353 
355 {
356  isPaused = false;
357  timeElapsedDuringPause = yarp::os::Time::now() - pauseTime;
358 }
359 
360 
362 
363 Eigen::VectorXd TrajectoryThread::varianceToWeights(Eigen::VectorXd& desiredVariance, const double beta)
364 {
365  desiredVariance /= maximumVariance;
366  desiredVariance = desiredVariance.array().min(varianceThresh); //limit desiredVariance to 0.99 maximum
367  Eigen::VectorXd desiredWeights = (Eigen::VectorXd::Ones(desiredVariance.rows()) - desiredVariance) / beta;
368  return desiredWeights;
369 }
370 
372 {
374  return (goalStateVector - getCurrentTaskStateAsVector()).norm() <= errorThreshold;
375  } else {
376  return false;
377  }
378 }
379 
381 {
382  return (goalStateVector - getCurrentTaskStateAsVector()).norm();
383 }
384 
386 {
387  if (trajType==TIME_OPTIMAL) {
388  std::list<Eigen::VectorXd> wptListCopy = allWaypointList;
389  allWaypointList.clear();
390  for (auto rit = wptListCopy.rbegin(); rit!= wptListCopy.rend(); ++rit){
391  allWaypointList.push_back(*rit);
392  }
393  goalStateVector = *allWaypointList.rbegin();
394  } else {
395  int nCols = allWaypoints.cols();
396  Eigen::MatrixXd tmp(allWaypoints.rows(), nCols);
397 
398  int c_tmp = nCols - 1;
399  for(int c=0; c<nCols; c++)
400  {
401  tmp.col(c_tmp) = allWaypoints.col(c);
402  c_tmp--;
403  }
404  allWaypoints = tmp;
405  goalStateVector = allWaypoints.rightCols(1);
406  }
407 }
408 
410 {
411  if (trajType==TIME_OPTIMAL) {
412  allWaypointList.push_front(*allWaypointList.rbegin());
413  allWaypointList.pop_back();
414  goalStateVector = *allWaypointList.rbegin();
415  } else {
416  int nCols = allWaypoints.cols();
417  Eigen::MatrixXd tmp(allWaypoints.rows(), nCols);
418 
419  tmp.col(0) = allWaypoints.rightCols(1);
420  tmp.rightCols(nCols-1) = allWaypoints.leftCols(nCols-1);
421  allWaypoints = tmp;
422  goalStateVector = allWaypoints.rightCols(1);
423  }
424 }
425 
426 bool TrajectoryThread::setTrajectoryWaypoints(const Eigen::MatrixXd& userWaypoints, bool containsStartingWaypoint)
427 {
428  Eigen::MatrixXd _userWaypoints = userWaypoints; // Copy waypoints first in case we use allWaypoints as an arg.
429  if (weightDimension==_userWaypoints.rows())
430  {
431  if(containsStartingWaypoint)
432  {
433  allWaypoints = _userWaypoints;
434  }
435  else // Add starting waypoint
436  {
437  allWaypoints = Eigen::MatrixXd(weightDimension, _userWaypoints.cols()+1);
438  allWaypoints.col(0) << getCurrentTaskStateAsVector();
439  for(int i=0; i<_userWaypoints.cols(); i++)
440  {
441  allWaypoints.col(i+1) << _userWaypoints.col(i);
442  }
443  }
444 
445  goalStateVector = allWaypoints.rightCols(1);
446 
447  trajectory->setWaypoints(allWaypoints);
448 
449  #if USING_SMLT
451  {
452  maximumVariance = std::dynamic_pointer_cast<ocra::GaussianProcessTrajectory>(trajectory)->getMaxVariance();
453  }
454  #endif
455 
457  deactivationLatch = false;
458  waypointsHaveBeenSet = true;
459  return true;
460  }
461  else
462  {
463  std::cout << "[ERROR](TrajectoryThread::setTrajectoryWaypoints): The dimension (# DOF) of the waypoints you provided, " << _userWaypoints.rows() << ", does not match the dimension of the task, " << weightDimension <<". Thread not starting." << std::endl;
464  return false;
465  }
466 }
467 
468 bool TrajectoryThread::setTrajectoryWaypoints(const std::list<Eigen::VectorXd>& waypointList, bool containsStartingWaypoint)
469 {
470  if (weightDimension==waypointList.begin()->rows())
471  {
472 
473  allWaypointList = waypointList;
474  if(!containsStartingWaypoint)
475  {
476  allWaypointList.push_front(getCurrentTaskStateAsVector());
477  }
478 
479  goalStateVector = *allWaypointList.rbegin();
480 
481 
482  trajectory->setWaypoints(allWaypointList);
483 
485  deactivationLatch = false;
486  waypointsHaveBeenSet = true;
487  return true;
488  }
489  else
490  {
491  std::cout << "[ERROR](TrajectoryThread::setTrajectoryWaypoints): The dimension (# DOF) of the waypoints you provided, " << waypointList.begin()->rows() << ", does not match the dimension of the task, " << weightDimension <<". Thread not starting." << std::endl;
492  return false;
493  }
494 }
495 
496 
497 bool TrajectoryThread::setDisplacement(double dispDouble)
498 {
499  return setDisplacement(Eigen::VectorXd::Constant(weightDimension, dispDouble));
500 }
501 
502 bool TrajectoryThread::setDisplacement(const Eigen::VectorXd& displacementVector)
503 {
504  if (weightDimension == displacementVector.rows())
505  {
506  startStateVector = getCurrentTaskStateAsVector();
507  Eigen::MatrixXd tmpWaypoints = Eigen::MatrixXd::Zero(weightDimension, 2);
508  tmpWaypoints.col(0) << startStateVector;
509  tmpWaypoints.col(1) << startStateVector + displacementVector;
510  setTrajectoryWaypoints(tmpWaypoints, true);
511  return true;
512  }
513  else{
514  return false;
515  }
516 }
517 
518 ocra::TaskState TrajectoryThread::matrixToTaskState(const Eigen::MatrixXd& desMat)
519 {
520  ocra::TaskState desState;
521  switch (taskType) {
522  case ocra::Task::META_TASK_TYPE::UNKNOWN:
523  {
524  // do nothing
525  }break;
526  case ocra::Task::META_TASK_TYPE::POSITION:
527  {
528  desState.setPosition(ocra::util::eigenVectorToDisplacementd(desMat.col(POS_COL)));
529  desState.setVelocity(ocra::util::eigenVectorToTwistd(desMat.col(VEL_COL)));
530  desState.setAcceleration(ocra::util::eigenVectorToTwistd(desMat.col(ACC_COL)));
531  }break;
532  case ocra::Task::META_TASK_TYPE::ORIENTATION:
533  {
534  desState.setPosition(ocra::util::eigenVectorToDisplacementd(desMat.col(POS_COL)));
535  desState.setVelocity(ocra::util::eigenVectorToTwistd(desMat.col(VEL_COL)));
536  desState.setAcceleration(ocra::util::eigenVectorToTwistd(desMat.col(ACC_COL)));
537  }break;
538  case ocra::Task::META_TASK_TYPE::POSE:
539  {
540  desState.setPosition(ocra::util::eigenVectorToDisplacementd(desMat.col(POS_COL)));
541  desState.setVelocity(ocra::util::eigenVectorToTwistd(desMat.col(VEL_COL)));
542  desState.setAcceleration(ocra::util::eigenVectorToTwistd(desMat.col(ACC_COL)));
543  }break;
544  case ocra::Task::META_TASK_TYPE::FORCE:
545  {
546  desState.setWrench(ocra::util::eigenVectorToWrenchd(desMat.col(POS_COL)));
547  }break;
548  case ocra::Task::META_TASK_TYPE::COM:
549  {
550  desState.setPosition(ocra::util::eigenVectorToDisplacementd(desMat.col(POS_COL)));
551  desState.setVelocity(ocra::util::eigenVectorToTwistd(desMat.col(VEL_COL)));
552  desState.setAcceleration(ocra::util::eigenVectorToTwistd(desMat.col(ACC_COL)));
553  }break;
554  case ocra::Task::META_TASK_TYPE::COM_MOMENTUM:
555  {
556  desState.setPosition(ocra::util::eigenVectorToDisplacementd(desMat.col(POS_COL)));
557  desState.setVelocity(ocra::util::eigenVectorToTwistd(desMat.col(VEL_COL)));
558  desState.setAcceleration(ocra::util::eigenVectorToTwistd(desMat.col(ACC_COL)));
559  }break;
560  case ocra::Task::META_TASK_TYPE::PARTIAL_POSTURE:
561  {
562  desState.setQ(desMat.col(POS_COL));
563  desState.setQd(desMat.col(VEL_COL));
564  desState.setQdd(desMat.col(ACC_COL));
565  }break;
566  case ocra::Task::META_TASK_TYPE::FULL_POSTURE:
567  {
568  desState.setQ(desMat.col(POS_COL));
569  desState.setQd(desMat.col(VEL_COL));
570  desState.setQdd(desMat.col(ACC_COL));
571  }break;
572  case ocra::Task::META_TASK_TYPE::PARTIAL_TORQUE:
573  {
574  desState.setTorque(desMat.col(POS_COL));
575  }break;
576  case ocra::Task::META_TASK_TYPE::FULL_TORQUE:
577  {
578  desState.setTorque(desMat.col(POS_COL));
579  }break;
580  default:
581  {
582 
583  }break;
584  }
585 
586  return desState;
587 }
588 
590 {
591  flipWaypoints();
592  if (trajType==TIME_OPTIMAL) {
594  } else {
596  }
597  returningHome = true;
598 }
599 
600 Eigen::VectorXd TrajectoryThread::getCurrentTaskStateAsVector()
601 {
602  Eigen::VectorXd startVector = Eigen::VectorXd::Zero(weightDimension);
603  ocra::TaskState state = task->getTaskState();
604 
605  switch (taskType) {
606  case ocra::Task::META_TASK_TYPE::UNKNOWN:
607  {
608  // do nothing
609  }break;
610  case ocra::Task::META_TASK_TYPE::POSITION:
611  {
612  startVector = state.getPosition().getTranslation();
613  }break;
614  case ocra::Task::META_TASK_TYPE::ORIENTATION:
615  {
616  Eigen::Rotation3d quat = state.getPosition().getRotation();
617  startVector = Eigen::VectorXd(4);
618  startVector << quat.w(), quat.x(), quat.y(), quat.z();
619  }break;
620  case ocra::Task::META_TASK_TYPE::POSE:
621  {
622  Eigen::Displacementd disp = state.getPosition();
623  startVector = Eigen::VectorXd(7);
624  startVector << disp.x(), disp.y(), disp.z(), disp.qw(), disp.qx(), disp.qy(), disp.qz();
625  }break;
626  case ocra::Task::META_TASK_TYPE::FORCE:
627  {
628  startVector = state.getWrench();
629  }break;
630  case ocra::Task::META_TASK_TYPE::COM:
631  {
632  startVector = state.getPosition().getTranslation();
633 
634  }break;
635  case ocra::Task::META_TASK_TYPE::COM_MOMENTUM:
636  {
637  startVector = state.getPosition().getTranslation();
638 
639  }break;
640  case ocra::Task::META_TASK_TYPE::PARTIAL_POSTURE:
641  {
642  startVector = state.getQ();
643 
644  }break;
645  case ocra::Task::META_TASK_TYPE::FULL_POSTURE:
646  {
647  startVector = state.getQ();
648 
649  }break;
650  case ocra::Task::META_TASK_TYPE::PARTIAL_TORQUE:
651  {
652  startVector = state.getTorque();
653 
654  }break;
655  case ocra::Task::META_TASK_TYPE::FULL_TORQUE:
656  {
657  startVector = state.getTorque();
658 
659  }break;
660  default:
661  {
662 
663  }break;
664  }
665  return startVector;
666 }
667 
669 {
670  trajectory->setMaxVelocity(maxVel);
672  trajectory->recalculateTrajectory();
673  }
674 }
675 void TrajectoryThread::setMaxVelocity(Eigen::VectorXd maxVel)
676 {
677  trajectory->setMaxVelocity(maxVel);
679  trajectory->recalculateTrajectory();
680  }
681 }
683 {
684  trajectory->setMaxAcceleration(maxAcc);
686  trajectory->recalculateTrajectory();
687  }
688 }
689 void TrajectoryThread::setMaxAcceleration(Eigen::VectorXd maxAcc)
690 {
691  trajectory->setMaxAcceleration(maxAcc);
693  trajectory->recalculateTrajectory();
694  }
695 }
696 
697 void TrajectoryThread::setMaxVelocityAndAcceleration(double maxVel, double maxAcc)
698 {
699  trajectory->setMaxVelocity(maxVel);
700  trajectory->setMaxAcceleration(maxAcc);
702  trajectory->recalculateTrajectory();
703  }
704 }
705 
706 void TrajectoryThread::setMaxVelocityAndAcceleration(const Eigen::VectorXd& maxVel, const Eigen::VectorXd& maxAcc)
707 {
708  trajectory->setMaxVelocity(maxVel);
709  trajectory->setMaxAcceleration(maxAcc);
711  trajectory->recalculateTrajectory();
712  }
713 }
714 
715 
716 #if USING_SMLT
717 void TrajectoryThread::setMeanWaypoints(std::vector<bool>& isMeanWaypoint)
718 {
719  std::dynamic_pointer_cast<ocra::GaussianProcessTrajectory>(trajectory)->setMeanWaypoints(isMeanWaypoint);
720 }
721 
722 void TrajectoryThread::setVarianceWaypoints(std::vector<bool>& isVarWaypoint)
723 {
724  std::dynamic_pointer_cast<ocra::GaussianProcessTrajectory>(trajectory)->setVarianceWaypoints(isVarWaypoint);
725 }
726 
727 void TrajectoryThread::setOptimizationWaypoints(std::vector<bool>& isOptWaypoint)
728 {
729  std::dynamic_pointer_cast<ocra::GaussianProcessTrajectory>(trajectory)->setOptimizationWaypoints(isOptWaypoint);
730 }
731 
732 void TrajectoryThread::setDofToOptimize(std::vector<Eigen::VectorXi>& dofToOptimize)
733 {
734  std::dynamic_pointer_cast<ocra::GaussianProcessTrajectory>(trajectory)->setDofToOptimize(dofToOptimize);
735 }
736 
737 Eigen::VectorXd TrajectoryThread::getBayesianOptimizationVariables()
738 {
739  return std::dynamic_pointer_cast<ocra::GaussianProcessTrajectory>(trajectory)->getBoptVariables();
740 }
741 #endif
742 
743 
745 {
746  return trajectory->getDuration();
747 }
748 
749 std::list<Eigen::VectorXd> TrajectoryThread::getWaypointList()
750 {
751  return allWaypointList;
752 }
ocra::Task::META_TASK_TYPE taskType
void setPosition(const Eigen::Displacementd &newPosition)
Definition: TaskState.cpp:79
void setTorque(const Eigen::VectorXd &newTorque)
Definition: TaskState.cpp:121
void setAcceleration(const Eigen::Twistd &newAcceleration)
Definition: TaskState.cpp:93
std::list< Eigen::VectorXd > userWaypointList
Eigen::Twistd eigenVectorToTwistd(const Eigen::VectorXd &eigenVector, bool linearOnly=true, bool angularOnly=false)
void setVelocity(const Eigen::Twistd &newVelocity)
Definition: TaskState.cpp:86
TrajectoryThread(int period, const std::string &taskPortName, const TRAJECTORY_TYPE=MIN_JERK, const TERMINATION_STRATEGY _terminationStrategy=STOP_THREAD)
std::shared_ptr< TaskConnection > task
Eigen::VectorXd getQ() const
Definition: TaskState.cpp:49
bool setDisplacement(double dispDouble)
void setQd(const Eigen::VectorXd &newQd)
Definition: TaskState.cpp:107
void setMaxVelocityAndAcceleration(double maxVel, double maxAcc)
Eigen::Displacementd eigenVectorToDisplacementd(const Eigen::VectorXd &eigenVector)
bool setTrajectoryWaypoints(const Eigen::MatrixXd &userWaypoints, bool containsStartingWaypoint=false)
Eigen::VectorXd getTorque() const
Definition: TaskState.cpp:67
std::shared_ptr< ocra::Trajectory > trajectory
Eigen::Wrenchd eigenVectorToWrenchd(const Eigen::VectorXd &eigenVector, bool linearOnly=true, bool angularOnly=false)
std::list< Eigen::VectorXd > allWaypointList
#define VAR_THRESH
A thread for launching trajectory generators.
void setMaxAcceleration(double maxAcc)
void setQdd(const Eigen::VectorXd &newQdd)
Definition: TaskState.cpp:114
Eigen::Wrenchd getWrench() const
Definition: TaskState.cpp:73
std::list< Eigen::VectorXd > getWaypointList()
Eigen::VectorXd varianceToWeights(Eigen::VectorXd &desiredVariance, const double beta=1.0)
void setWrench(const Eigen::Wrenchd &newWrench)
Definition: TaskState.cpp:128
void setQ(const Eigen::VectorXd &newQ)
Definition: TaskState.cpp:100
Eigen::Displacementd getPosition() const
Definition: TaskState.cpp:31
TERMINATION_STRATEGY terminationStrategy