ocra-recipes
Doxygen documentation for the ocra-recipes repository
TaskBuilderOptions.cpp
Go to the documentation of this file.
2 
3 using namespace ocra;
4 
6 {
7  offset = Eigen::Displacementd::Identity();
8 }
9 
11 {
12 }
13 
14 bool TaskBuilderOptions::extractFromBottle(yarp::os::Bottle& bottle, int& sizeOfOptions)
15 {
16  int i = 0;
17  if (bottle.get(i).asInt() == TASK_BUILDER_OPTIONS_BOTTLE)
18  {
19  taskName = bottle.get(++i).asString();
20  taskType = bottle.get(++i).asString();
21  segment = bottle.get(++i).asString();
22 
23  kp = bottle.get(++i).asDouble();
24  kd = bottle.get(++i).asDouble();
25  weight = bottle.get(++i).asDouble();
26  mu = bottle.get(++i).asDouble();
27  margin = bottle.get(++i).asDouble();
28 
29  usesYarp = bottle.get(++i).asBool();;
30  useWeightVectorConstructor = bottle.get(++i).asBool();
31  axes = ECartesianDof(bottle.get(++i).asInt());
32  hierarchyLevel = bottle.get(++i).asInt();
33 
34  int indexesToSkip;
35 
36  desired = util::pourBottleIntoEigenVector(util::trimBottle(bottle, i+1), indexesToSkip); i += indexesToSkip;
37  indexDesired = util::pourBottleIntoEigenVector(util::trimBottle(bottle, i+1), indexesToSkip); i += indexesToSkip;
38  nameDesired = util::pourBottleIntoEigenVector(util::trimBottle(bottle, i+1), indexesToSkip); i += indexesToSkip;
39  weightVector = util::pourBottleIntoEigenVector(util::trimBottle(bottle, i+1), indexesToSkip); i += indexesToSkip;
40  indexWeightVector = util::pourBottleIntoEigenVector(util::trimBottle(bottle, i+1), indexesToSkip); i += indexesToSkip;
41  nameWeightVector = util::pourBottleIntoEigenVector(util::trimBottle(bottle, i+1), indexesToSkip); i += indexesToSkip;
42 
43  jointIndexes = util::pourBottleIntoEigenVectorXi(util::trimBottle(bottle, i+1), indexesToSkip); i += indexesToSkip;
44 
45  int numberOfJointNames = bottle.get(++i).asInt();
46  for (auto j = 0; j < numberOfJointNames; ++j) {
47  jointNames.push_back(bottle.get(++i).asString());
48  }
49 
50 
51  util::pourBottleIntoDisplacementd(util::trimBottle(bottle, i+1), indexesToSkip); i += indexesToSkip;
52 
53  sizeOfOptions = i;
54  return true;
55  }
56  return false;
57 
58 }
59 
60 void TaskBuilderOptions::putIntoBottle(yarp::os::Bottle& bottle)
61 {
62  bottle.addInt(TASK_BUILDER_OPTIONS_BOTTLE);
63 
64  bottle.addString(taskName);
65  bottle.addString(taskType);
66  bottle.addString(segment);
67 
68  bottle.addDouble(kp);
69  bottle.addDouble(kd);
70  bottle.addDouble(weight);
71  bottle.addDouble(mu);
72  bottle.addDouble(margin);
73 
74  bottle.addInt(usesYarp);
75  bottle.addInt(useWeightVectorConstructor);
76  bottle.addInt(axes);
77  bottle.addInt(hierarchyLevel);
78 
85 
87 
88  bottle.addInt(jointNames.size());
89  for(auto name : jointNames){
90  bottle.addString(name);
91  }
92 
94 }
Eigen::VectorXd indexWeightVector
void pourEigenVectorXiIntoBottle(const Eigen::VectorXi &vec, yarp::os::Bottle &bottle)
void putIntoBottle(yarp::os::Bottle &bottle)
yarp::os::Bottle trimBottle(const yarp::os::Bottle &bottle, int startIndex, int endIndex=-1)
void pourDisplacementdIntoBottle(const Eigen::Displacementd &disp, yarp::os::Bottle &bottle)
Optimization-based Robot Controller namespace. a library of classes to write and solve optimization p...
Eigen::VectorXi pourBottleIntoEigenVectorXi(yarp::os::Bottle bottle, int &indexesToSkip)
Definition: YarpUtilities.h:38
ECartesianDof
Definition: ControlEnum.h:18
std::vector< std::string > jointNames
bool extractFromBottle(yarp::os::Bottle &bottle, int &sizeOfOptions)
Eigen::VectorXd nameWeightVector
void pourEigenVectorIntoBottle(const Eigen::VectorXd &vec, yarp::os::Bottle &bottle)
Eigen::VectorXd pourBottleIntoEigenVector(yarp::os::Bottle bottle, int &indexesToSkip)
Definition: YarpUtilities.h:27
Eigen::Displacementd pourBottleIntoDisplacementd(yarp::os::Bottle bottle, int &indexesToSkip)
Definition: YarpUtilities.h:49
Eigen::Displacementd offset