ocra-recipes
Doxygen documentation for the ocra-recipes repository
TaskYarpInterface.cpp
Go to the documentation of this file.
2 
3 using namespace ocra;
4 
5 
13 : task(taskPtr)
14 , controlPortsOpen(false)
15 , taskMode(TASK_NOT_DEFINED)
16 , logMessages(true)
17 , numberOfOpenRequests(0)
18 {
19  if(task) {
20  portName = "/Task/"+task->getName()+"/rpc:i";
21  rpcCallback = std::make_shared<RpcMessageCallback>(*this);
22  rpcPort.open(portName.c_str());
23  rpcPort.setReader(*rpcCallback);
24  }
25 }
26 
27 
29 {
30  std::cout << "\t--> Closing ports" << std::endl;
31  rpcPort.close();
32  if(stateThread){
33  closeControlPorts();
34  }
35 }
36 
38 {
39  return task->getHierarchyLevel();
40 }
41 
43 {
44  task->setHierarchyLevel(level);
45  return;
46 }
47 
49 {
50  if(task){
51  if(isActivated()){taskMode = getTaskMode();}
52  return activate(taskMode);
53  }
54  else{
55  yLog.error() << "No valid task(s) to activate.";
56  return false;
57  }
58 }
59 
61 {
62  bool allActivated;
63  if(task)
64  {
65  switch (tmode)
66  {
67  case TASK_AS_OBJECTIVE:
68  {
69  task->activateAsObjective();
70  allActivated = true;
71  }break;
72 
73  case TASK_AS_CONSTRAINT:
74  {
75  task->activateAsConstraint();
76  allActivated = true;
77  }break;
78 
79  case TASK_NOT_DEFINED:
80  {
81  yLog.error() << "Task, " << task->getName() << ", has not been defined as an objective or constraint therefore I can't activate it.";
82  allActivated = false;
83  }break;
84 
85  default:
86  {
87  allActivated = false;
88  }break;
89  }
90  }
91  return allActivated;
92 }
93 
95 {
96  if(task){
97  if(isActivated()){taskMode = getTaskMode();}
98  task->deactivate();
99  return true;
100  }
101  else{
102  taskMode = TASK_NOT_DEFINED;
103  yLog.error() << "No valid task(s) to activate.";
104  return false;
105  }
106 }
107 
109 {
110  if (task->isActiveAsObjective()) {
111  return TASK_AS_OBJECTIVE;
112  } else if (task->isActiveAsConstraint()) {
113  return TASK_AS_CONSTRAINT;
114  } else {
115  return TASK_NOT_DEFINED;
116  }
117 }
118 
120 {
121  if(task){
122  return task->isActiveAsObjective() || task->isActiveAsConstraint();
123  } else {
124  return false;
125  }
126 }
127 
128 
130 {
131  if(task) {
132  return task->getError();
133  } else {
134  return Eigen::VectorXd::Zero(0);
135  }
136 }
137 
139 {
140  return getTaskError().norm();
141 }
142 
144 {
145  if(task) {
146  task->setStiffness(K);
147  } else {
148  std::cout << "\n\n\n FUUUUUUCK" << std::endl;
149  }
150 }
151 
152 void TaskYarpInterface::setStiffness(const VectorXd& K)
153 {
154  if(task) {
155  task->setStiffness(K);
156  }
157 }
158 
159 void TaskYarpInterface::setStiffness(const MatrixXd& K)
160 {
161  if(task) {
162  task->setStiffness(K);
163  }
164 }
165 
167 {
168  if(task) {
169  // Get the first entry in the stiffness matrix.
170  return getStiffnessMatrix()(0,0);
171  } else {
172  yLog.error() << "Unable to get the stiffness of the task because it does not exist. Returning 0.0";
173  return 0.0;
174  }
175 }
176 
178 {
179  if(task) {
180  return task->getStiffness();
181  } else {
182  yLog.error() << "Unable to get the stiffness of the task because it does not exist. Returning empty matrix";
183  return Eigen::MatrixXd::Zero(0,0);
184  }
185 }
186 
188 {
189  if(task) {
190  task->setDamping(B);
191  }
192 }
193 
194 void TaskYarpInterface::setDamping(const VectorXd& B)
195 {
196  if(task) {
197  task->setDamping(B);
198  }
199 }
200 
201 void TaskYarpInterface::setDamping(const MatrixXd& B)
202 {
203  if(task) {
204  task->setDamping(B);
205  }
206 }
207 
209 {
210  if(task) {
211  // Get the first entry in the stiffness matrix.
212  return getDampingMatrix()(0,0);
213  } else {
214  yLog.error() << "Unable to get the damping coeff of the task because it does not exist. Returning 0.0";
215  return 0.0;
216  }
217 }
218 
220 {
221  if(task) {
222  return task->getDamping();
223  } else {
224  yLog.error() << "Unable to get the damping coeffs of the task because it does not exist. Returning empty matrix";
225  return Eigen::MatrixXd::Zero(0,0);
226  }
227 }
228 
229 void TaskYarpInterface::setWeight(double weight)
230 {
231  if(task) {
232  return task->setWeight(weight);
233  }
234 }
235 
236 void TaskYarpInterface::setWeight(const Eigen::VectorXd& weights)
237 {
238  if(task) {
239  return task->setWeight(weights);
240  }
241 }
242 
244 {
245  if(task) {
246  return task->getWeight();
247  } else {
248  yLog.error() << "Unable to get the weights of the task because it does not exist. Returning empty vector";
249  return Eigen::VectorXd::Zero(0);
250  }
251 }
252 
253 
255 {
256 // getTaskStateMutex.wait();
257 // std::cout<<"task state queried"<<std::endl;
258  TaskState tmp = this->task->getTaskState();
259 // getTaskStateMutex.post();
260  return tmp;
261 }
262 
264 {
265  return this->task->getDesiredTaskState();
266 }
267 
268 void TaskYarpInterface::setDesiredTaskState(const TaskState& newDesiredTaskState)
269 {
270  return this->task->setDesiredTaskState(newDesiredTaskState);
271 }
272 
274 {
275  return this->task->setDesiredTaskStateDirect(newDesiredTaskState);
276 }
277 
279 {
280  stateOutBottle.clear();
281  this->getTaskState().putIntoBottle(stateOutBottle);
282  outputControlPort.write(stateOutBottle);
283 
284  desiredStateOutBottle.clear();
285  this->getDesiredTaskState().putIntoBottle(desiredStateOutBottle);
286  desiredStateOutputPort.write(desiredStateOutBottle);
287 }
288 
289 bool TaskYarpInterface::openControlPorts()
290 {
291  ++numberOfOpenRequests;
292  bool res = true;
293  if (!controlPortsOpen)
294  {
295  inputControlPortName = "/Task/"+task->getName()+"/state:i";
296  outputControlPortName = "/Task/"+task->getName()+"/state:o";
297  desiredStateOutputPortName = "/Task/"+task->getName()+"/desired_state:o";
298 
299  res = res && inputControlPort.open(inputControlPortName.c_str());
300  res = res && outputControlPort.open(outputControlPortName.c_str());
301  res = res && desiredStateOutputPort.open(desiredStateOutputPortName.c_str());
302 
303  controlPortsOpen = res;
304 
305  } else {
306  OCRA_WARNING("You already opened the control ports. No need to do so again.")
307  }
308 
309  if (!controlCallback) {
310  controlCallback = std::make_shared<ControlInputCallback>(*this);
311  inputControlPort.setReader(*controlCallback);
312  }
313  if(!stateThread) {
314  stateThread = std::make_shared<StateUpdateThread>(10, *this);
315  }
316  if (!stateThread->isRunning()) {
317  stateThread->start();
318  }
319 
320  return res;
321 }
322 
323 bool TaskYarpInterface::closeControlPorts()
324 {
325  --numberOfOpenRequests;
326  if (numberOfOpenRequests==0) {
327  std::cout<<"TaskYarpInterface::closeControlPorts() - " << std::endl;
328  if(stateThread) {
329  std::cout<<"Check if StateThreadis running"<<std::endl;
330  if (stateThread->isRunning()) {
331  std::cout<<"Telling stateThread stop! motherfucker!!! "<< std::endl;
332  stateThread->stop();
333  }
334  }
335  if (controlPortsOpen) {
336  inputControlPort.close();
337  outputControlPort.close();
338  desiredStateOutputPort.close();
339  }
340 
341  bool controlPortsClosed = !inputControlPort.isOpen() && !outputControlPort.isOpen() && !desiredStateOutputPort.isOpen();
342 
343  controlPortsOpen = !controlPortsClosed;
344 
345  return controlPortsClosed;
346  } else {
347  OCRA_WARNING("There are still other TaskConnection occurences using these ports so I am keeping them open... Muthafucka.")
348  return false;
349  }
350 
351 }
352 
353 bool TaskYarpInterface::parseControlInput(yarp::os::Bottle& input)
354 {
355  TaskState state;
356  int dummyInt;
357  state.extractFromBottle(input, dummyInt);
358  this->setDesiredTaskStateDirect(state);
359 }
360 
361 
362 
364 // Segment Frame Tasks
366 
368 {
369  return getTaskState().getPosition();
370 }
371 
373 {
374  return getTaskState().getVelocity();
375 }
376 
378 {
379  return getTaskState().getAcceleration();
380 }
381 
383 {
384  return getTaskFrameDisplacement().getTranslation();
385 }
386 
388 {
389  return getTaskFrameDisplacement().getRotation();
390 }
391 
393 {
394  return getTaskFrameVelocity().getLinearVelocity();
395 }
396 
398 {
399  return getTaskFrameVelocity().getAngularVelocity();
400 }
401 
403 {
404  return getTaskFrameAcceleration().getLinearVelocity();
405 }
406 
408 {
409  return getTaskFrameAcceleration().getAngularVelocity();
410 }
411 
413 
414 
415 
417 {
418  return portName;
419 }
420 
421 
422 /**************************************************************************************************
423  Nested RpcMessageCallback Class
424 **************************************************************************************************/
426 : tmBase(tmBaseRef)
427 {
428  //do nothing
429 }
430 
431 bool TaskYarpInterface::RpcMessageCallback::read(yarp::os::ConnectionReader& connection)
432 {
433  yarp::os::Bottle input;
434  yarp::os::Bottle reply;
435 
436  if (!input.read(connection)){
437  return false;
438  }
439  else{
440  tmBase.parseIncomingMessage(input, reply);
441  yarp::os::ConnectionWriter* returnToSender = connection.getWriter();
442  if (returnToSender!=NULL) {
443  if (!reply.write(*returnToSender)) {
444  OCRA_ERROR("Reply was not successfully written");
445  return false;
446  }
447  }
448  return true;
449  }
450 }
451 /**************************************************************************************************
452 **************************************************************************************************/
453 
454 
455 
456 /**************************************************************************************************
457  Nested ControlInputCallback Class
458 **************************************************************************************************/
460 : tmBase(tmBaseRef)
461 {
462  //do nothing
463 }
464 
465 bool TaskYarpInterface::ControlInputCallback::read(yarp::os::ConnectionReader& connection)
466 {
467  input.clear();
468  if (input.read(connection)) {
469  return tmBase.parseControlInput(input);
470  } else {
471  return false;
472  }
473 }
474 /**************************************************************************************************
475 **************************************************************************************************/
476 
477 
478 /**************************************************************************************************
479  Nested StateUpdateThread Class
480 **************************************************************************************************/
482 RateThread(period),
483 tmBase(tmBaseRef)
484 {
485 }
487 {
488  std::cout << "StateUpdateThread: Opening.\n";
489  return true;
490 }
492 {
493  tmBase.publishTaskState();
494 }
496 {
497  std::cout << "StateUpdateThread: Closing.\n";
498 }
499 /**************************************************************************************************
500 **************************************************************************************************/
501 
502 void TaskYarpInterface::parseIncomingMessage(yarp::os::Bottle& input, yarp::os::Bottle& reply)
503 {
504  int btlSize = input.size();
505  for (auto i=0; i<btlSize; ++i) {
506  int msg;
507  int testInt = input.get(0).asInt();
508  std::string testStr = input.get(0).asString();
509  if ((testStr=="") && (testInt!=0)) {
510  msg = TASK_MESSAGE(testInt);
511  } else {
513  }
514  switch (msg) {
515 
516  case GET_TASK_STATE:
517  {
518  if (logMessages) {
519  yLog.info() << " ["<< this->task->getName() <<"]: " << "Processing request: GET_TASK_STATE";
520  }
521  TaskState state = this->task->getTaskState();
522  state.putIntoBottle(reply);
523  }break;
524 
525  case GET_STIFFNESS:
526  {
527  if (logMessages) {
528  yLog.info() << " ["<< this->task->getName() <<"]: " << "Processing request: GET_STIFFNESS";
529  }
531  }break;
532 
533  case GET_DAMPING:
534  {
535  if (logMessages) {
536  yLog.info() << " ["<< this->task->getName() <<"]: " << "Processing request: GET_DAMPING";
537  }
539  }break;
540 
541  case GET_WEIGHTS:
542  {
543  if (logMessages) {
544  yLog.info() << " ["<< this->task->getName() <<"]: " << "Processing request: GET_WEIGHTS";
545  }
547  }break;
548 
550  {
551  if (logMessages) {
552  yLog.info() << " ["<< this->task->getName() <<"]: " << "Processing request: GET_DESIRED_TASK_STATE";
553  }
554  TaskState state = this->task->getDesiredTaskState();
555  state.putIntoBottle(reply);
556  }break;
557 
558  case GET_TASK_POSITION:
559  {
560  if (logMessages) {
561  yLog.info() << " ["<< this->task->getName() <<"]: " << "Processing request: GET_TASK_POSITION";
562  }
563  if ((this->task->getMetaTaskType()==Task::META_TASK_TYPE::POSITION) || (this->task->getMetaTaskType()==Task::META_TASK_TYPE::COM)) {
564  Eigen::Vector3d pos = this->task->getTaskState().getPosition().getTranslation();
566  }
567  }break;
568 
570  {
571  if (logMessages) {
572  yLog.info() << " ["<< this->task->getName() <<"]: " << "Processing request: GET_DESIRED_TASK_POSITION";
573  }
574  if ((this->task->getMetaTaskType()==Task::META_TASK_TYPE::POSITION) || (this->task->getMetaTaskType()==Task::META_TASK_TYPE::COM)) {
575  Eigen::Vector3d pos = this->task->getDesiredTaskState().getPosition().getTranslation();
577  }
578  }break;
579 
580  case GET_ACTIVITY_STATUS:
581  {
582  if (logMessages) {
583  yLog.info() << " ["<< this->task->getName() <<"]: " << "Processing request: GET_ACTIVITY_STATUS";
584  }
585  if (this->isActivated()) {
586  reply.addInt(TASK_IS_ACTIVATED);
587  } else {
588  reply.addInt(TASK_IS_DEACTIVATED);
589  }
590 
591  }break;
592 
593  case GET_DIMENSION:
594  {
595  if (logMessages) {
596  yLog.info() << " ["<< this->task->getName() <<"]: " << "Processing request: GET_DIMENSION";
597  }
598  OCRA_WARNING("this->task->getWeight() " << this->task->getWeight().size())
599  reply.addInt(this->task->getWeight().size());
600  }break;
601 
602  case GET_TYPE:
603  {
604  if (logMessages) {
605  yLog.info() << " ["<< this->task->getName() <<"]: " << "Processing request: GET_TYPE";
606  }
607  reply.addInt(this->task->getMetaTaskType());
608  }break;
609 
610  case GET_TYPE_AS_STRING:
611  {
612  if (logMessages) {
613  yLog.info() << " ["<< this->task->getName() <<"]: " << "Processing request: GET_TYPE";
614  }
615  reply.addString(this->task->getMetaTaskTypeAsString());
616  }break;
617 
618  case GET_NAME:
619  {
620  if (logMessages) {
621  yLog.info() << " ["<< this->task->getName() <<"]: " << "Processing request: GET_NAME";
622  }
623  reply.addString(this->task->getName());
624  }break;
625 
627  {
628  if (logMessages) {
629  yLog.info() << " ["<< this->task->getName() <<"]: " << "Processing request: GET_CONTROL_PORT_NAMES";
630  }
631  reply.addString(this->inputControlPortName);
632  reply.addString(this->outputControlPortName);
633  reply.addString(this->desiredStateOutputPortName);
634  }break;
635 
636  case GET_TASK_PORT_NAME:
637  {
638  if (logMessages) {
639  yLog.info() << " ["<< this->task->getName() <<"]: " << "Processing request: GET_TASK_PORT_NAME";
640  }
641  reply.addString(this->getPortName());
642  }break;
643 
644  case GET_TASK_ERROR:
645  {
646  if (logMessages) {
647  yLog.info() << " ["<< this->task->getName() <<"]: " << "Processing request: GET_TASK_ERROR";
648  }
650  }break;
651 
652  case SET_STIFFNESS:
653  {
654  if (logMessages) {
655  yLog.info() << " ["<< this->task->getName() <<"]: " << "Processing request: SET_STIFFNESS";
656  }
657  ++i;
658  setStiffness(input.get(i).asDouble());
659  reply.addInt(OCRA_SUCCESS);
660  }break;
661 
663  {
664  if (logMessages) {
665  yLog.info() << " ["<< this->task->getName() <<"]: " << "Processing request: SET_STIFFNESS_VECTOR";
666  }
667  int indexesToSkip;
668  this->setStiffness(util::pourBottleIntoEigenVector(util::trimBottle(input, i+1), indexesToSkip) );
669  i += indexesToSkip;
670  reply.addInt(OCRA_SUCCESS);
671  }break;
672 
674  {
675  if (logMessages) {
676  yLog.info() << " ["<< this->task->getName() <<"]: " << "Processing request: SET_STIFFNESS_MATRIX";
677  }
678  int indexesToSkip;
679  this->setStiffness(util::pourBottleIntoEigenMatrix(util::trimBottle(input, i+1), indexesToSkip) );
680  i += indexesToSkip;
681  reply.addInt(OCRA_SUCCESS);
682  }break;
683 
684  case SET_DAMPING:
685  {
686  if (logMessages) {
687  yLog.info() << " ["<< this->task->getName() <<"]: " << "Processing request: SET_DAMPING";
688  }
689  ++i;
690  this->setDamping(input.get(i).asDouble());
691  reply.addInt(OCRA_SUCCESS);
692  }break;
693 
694  case SET_DAMPING_VECTOR:
695  {
696  if (logMessages) {
697  yLog.info() << " ["<< this->task->getName() <<"]: " << "Processing request: SET_DAMPING_VECTOR";
698  }
699  int indexesToSkip;
700  this->setDamping(util::pourBottleIntoEigenVector(util::trimBottle(input, i+1), indexesToSkip) );
701  i += indexesToSkip;
702  reply.addInt(OCRA_SUCCESS);
703  }break;
704 
705  case SET_DAMPING_MATRIX:
706  {
707  if (logMessages) {
708  yLog.info() << " ["<< this->task->getName() <<"]: " << "Processing request: SET_DAMPING_MATRIX";
709  }
710  int indexesToSkip;
711  this->setDamping(util::pourBottleIntoEigenMatrix(util::trimBottle(input, i+1), indexesToSkip) );
712  i += indexesToSkip;
713  reply.addInt(OCRA_SUCCESS);
714  }break;
715 
716  case SET_WEIGHT:
717  {
718  if (logMessages) {
719  yLog.info() << " ["<< this->task->getName() <<"]: " << "Processing request: SET_WEIGHT";
720  }
721  ++i;
722  this->setWeight(input.get(i).asDouble());
723  reply.addInt(OCRA_SUCCESS);
724  }break;
725 
726  case SET_WEIGHT_VECTOR:
727  {
728  if (logMessages) {
729  yLog.info() << " ["<< this->task->getName() <<"]: " << "Processing request: SET_WEIGHT_VECTOR";
730  }
731  int indexesToSkip;
732  this->setWeight(util::pourBottleIntoEigenVector(util::trimBottle(input, i+1), indexesToSkip) );
733  i += indexesToSkip;
734  reply.addInt(OCRA_SUCCESS);
735  }break;
736 
738  {
739  if (logMessages) {
740  yLog.info() << " ["<< this->task->getName() <<"]: " << "Processing request: SET_DESIRED_TASK_STATE";
741  }
742 
743  int indexesToSkip;
744  TaskState state;
745  bool extractSuccess = state.extractFromBottle(util::trimBottle(input, i+1), indexesToSkip);
746  i += indexesToSkip;
747  if (extractSuccess) {
748  // TODO: Set to setDesiredTaskState (needs internal traj gen.) See Task::setDesiredTaskState()
749  this->setDesiredTaskStateDirect(state);
750  reply.addInt(OCRA_SUCCESS);
751  } else {
752  reply.addInt(OCRA_FAILURE);
753  }
754 
755  }break;
756 
758  {
759  if (logMessages) {
760  yLog.info() << " ["<< this->task->getName() <<"]: " << "Processing request: SET_DESIRED_TASK_POSITION";
761  }
762  if (((this->task->getMetaTaskType()==Task::META_TASK_TYPE::POSITION) || (this->task->getMetaTaskType()==Task::META_TASK_TYPE::COM)) && (input.size()>=4)){
763  Eigen::Vector3d pos(input.get(i+1).asDouble(), input.get(i+2).asDouble(), input.get(i+3).asDouble());
764  TaskState state;
765  state.setPosition(Eigen::Displacementd(pos, Eigen::Rotation3d::Identity()));
766  // TODO: Set to setDesiredTaskState (needs internal traj gen.) See Task::setDesiredTaskState()
767  this->setDesiredTaskStateDirect(state);
768  i += 3;
769  reply.addInt(OCRA_SUCCESS);
770  } else {
771  reply.addInt(OCRA_FAILURE);
772  }
773  }break;
774 
775  case ACTIVATE:
776  {
777  if (logMessages) {
778  yLog.info() << " ["<< this->task->getName() <<"]: " << "Processing request: ACTIVATE";
779  }
780  if(this->activate()) {
781  reply.addInt(OCRA_SUCCESS);
782  } else {
783  reply.addInt(OCRA_FAILURE);
784  }
785  }break;
786 
787  case DEACTIVATE:
788  {
789  if (logMessages) {
790  yLog.info() << " ["<< this->task->getName() <<"]: " << "Processing request: DEACTIVATE";
791  }
792  if(this->deactivate()) {
793  reply.addInt(OCRA_SUCCESS);
794  } else {
795  reply.addInt(OCRA_FAILURE);
796  }
797  }break;
798 
799  case OPEN_CONTROL_PORTS:
800  {
801  if (logMessages) {
802  yLog.info() << " ["<< this->task->getName() <<"]: " << "Processing request: OPEN_CONTROL_PORTS";
803  }
804  if(openControlPorts()) {
805  reply.addInt(OCRA_SUCCESS);
806  } else {
807  reply.addInt(OCRA_FAILURE);
808  }
809  }break;
810 
811  case CLOSE_CONTROL_PORTS:
812  {
813  if (logMessages) {
814  yLog.info() << " ["<< this->task->getName() <<"]: " << "Processing request: CLOSE_CONTROL_PORTS";
815  }
816  if(closeControlPorts()) {
817  reply.addInt(OCRA_SUCCESS);
818  } else {
819  reply.addInt(OCRA_FAILURE);
820  }
821  }break;
822 
823  case HELP:
824  {
825  if (logMessages) {
826  yLog.info() << " ["<< this->task->getName() <<"]: " << "Processing request: HELP";
827  }
828 
829  }break;
830 
831  default:
832  {
833  yLog.warning() << "Unrecognized request tag.";
834 
835  }break;
836 
837 
838  }
839  }
840 }
841 
842 
843 std::string TaskYarpInterface::printValidMessageTags()
844 {
845  std::string helpString = "\n=== Valid message tags are: ===\n";
846  helpString += "setStiffness: Allows you to set the Kp gain. Expects 1 double value.\n";
847  helpString += "setDamping: Allows you to set the Kd gain. Expects 1 double value.\n";
848  helpString += "setWeight: Allows you to set the task weight. Expects 1 double value.\n";
849  helpString += "setDesired: Allows you to set the desired task reference. Expects nDoF double values where nDoF is the task dimension.\n";
850  helpString += "getCurrentState: Allows you to get the current state of the task. No arguments expected.\n";
851  helpString += "getStiffness: Allows you to get the Kp gain. No arguments expected.\n";
852  helpString += "getDamping: Allows you to get the Kd gain. No arguments expected.\n";
853  helpString += "getWeight: Allows you to get the task weight. No arguments expected.\n";
854  helpString += "getDesired: Allows you to get the desired task reference. No arguments expected.\n";
855  helpString += "getActivityStatus: Queries the activity status of the task. No arguments expected.\n";
856  helpString += "activate: Allows you to activate the task. No arguments expected.\n";
857  helpString += "deactivate: Allows you to deactivate the task. No arguments expected.\n";
858  helpString += "getDimension: Prints the state dimension. No arguments expected.\n";
859  helpString += "getType: Retrieve the Type of the task. No arguments expected.\n";
860  helpString += "getName: Retrieve the Name of the task. No arguments expected.\n";
861  helpString += "openControlPorts: Open up high speed yarp control ports.\n";
862  helpString += "closeControlPorts: Close high speed yarp control ports.\n";
863  helpString += "getControlPortNames: Get the names of the high speed yarp control ports.\n";
864  helpString += "help: Prints all the valid commands. No arguments expected.\n";
865 
866  helpString += "\nTypical usage: [message tag] [message value(s)]\ne.g. >> stiffness 20 damping 10 desired_state 1.0 2.0 2.0\n";
867 
868  return helpString;
869 }
Eigen::Vector3d getTaskFramePosition()
StateUpdateThread(int period, TaskYarpInterface &tmBaseRef)
void setPosition(const Eigen::Displacementd &newPosition)
Definition: TaskState.cpp:79
Eigen::Vector3d getTaskFrameAngularVelocity()
Eigen::Vector3d getTaskFrameLinearVelocity()
void setWeight(double weight)
ControlInputCallback(TaskYarpInterface &tmBaseRef)
yarp::os::Bottle trimBottle(const yarp::os::Bottle &bottle, int startIndex, int endIndex=-1)
#define OCRA_ERROR(msg)
Definition: ErrorsHelper.h:32
Eigen::Twistd getTaskFrameAcceleration()
Eigen::Vector3d getTaskFrameLinearAcceleration()
void setTaskHierarchyLevel(int level)
void putIntoBottle(yarp::os::Bottle &bottle) const
Definition: TaskState.cpp:230
bool extractFromBottle(const yarp::os::Bottle &bottle, int &sizeOfOptions)
Definition: TaskState.cpp:174
void setDesiredTaskState(const TaskState &newDesiredTaskState)
Optimization-based Robot Controller namespace. a library of classes to write and solve optimization p...
Eigen::MatrixXd pourBottleIntoEigenMatrix(yarp::os::Bottle bottle, int &indexesToSkip)
Definition: YarpUtilities.h:92
virtual bool read(yarp::os::ConnectionReader &connection)
RpcMessageCallback(TaskYarpInterface &tmBaseRef)
static TASK_MESSAGE stringToTaskManagerMessageTag(std::string testString)
void pourEigenMatrixIntoBottle(const Eigen::MatrixXd &mat, yarp::os::Bottle &bottle)
Eigen::Rotation3d getTaskFrameOrientation()
Eigen::MatrixXd getDampingMatrix()
Eigen::VectorXd getTaskError()
Eigen::Twistd getTaskFrameVelocity()
Eigen::MatrixXd getStiffnessMatrix()
TASK_MODE
A basic enumeration for the different types of tasks we can have.
Eigen::Vector3d getTaskFrameAngularAcceleration()
void pourEigenVectorIntoBottle(const Eigen::VectorXd &vec, yarp::os::Bottle &bottle)
Eigen::Twistd getAcceleration() const
Definition: TaskState.cpp:43
Eigen::Displacementd getPosition() const
Definition: TaskState.cpp:31
virtual bool read(yarp::os::ConnectionReader &connection)
Eigen::Twistd getVelocity() const
Definition: TaskState.cpp:37
Eigen::VectorXd pourBottleIntoEigenVector(yarp::os::Bottle bottle, int &indexesToSkip)
Definition: YarpUtilities.h:27
Eigen::Displacementd getTaskFrameDisplacement()
void setDesiredTaskStateDirect(const TaskState &newDesiredTaskState)
TaskYarpInterface(Task::Ptr taskPtr)