ocra-recipes
Doxygen documentation for the ocra-recipes repository
TaskBuilder.cpp
Go to the documentation of this file.
2 
3 using namespace ocra;
4 
5 
6 TaskBuilder::TaskBuilder(const TaskBuilderOptions& taskOptions, Model::Ptr modelPtr)
7 : options(taskOptions)
8 , model(modelPtr)
9 {
10 
11 }
12 
14 {
15 
16 }
17 
19 {
20  Feature::Ptr feature = buildFeature();
21  Feature::Ptr featureDes = buildFeatureDesired();
22  if (featureDes && feature) {
23  this->task = std::make_shared<Task>(this->options.taskName, this->model, feature, featureDes);
24  } else {
25  if (feature)
26  this->task = std::make_shared<Task>(this->options.taskName, this->model, feature);
27  else {
28  std::cout << "[ERROR] TaskBuilder::buildTask() : Neither feature nor featureDes were created" << std::endl;
29  }
30  }
31  setTaskType();
32 }
33 
35 {
36  return this->task;
37 }
38 
40 {
41  // Generic to all tasks
43  setTaskLevel();
44  setTaskWeight();
45  setTaskStiffness();
46  setTaskDamping();
47 
48  // Specific to the type of task
49  setTaskState();
50 }
51 
53 {
54  this->task->activateAsObjective();
55 }
56 
57 void TaskBuilder::setTaskLevel()
58 {
59  this->task->setHierarchyLevel(this->options.hierarchyLevel);
60 }
61 
62 void TaskBuilder::setTaskWeight()
63 {
65  this->task->setWeight(this->options.weightVector);
66  } else {
67  this->task->setWeight(this->options.weight);
68  }
69 }
70 
71 void TaskBuilder::setTaskStiffness()
72 {
73  this->task->setStiffness(this->options.kp);
74 }
75 
76 void TaskBuilder::setTaskDamping()
77 {
78  this->task->setDamping(this->options.kd);
79 }
virtual void setTaskState()=0
TaskBuilder(const TaskBuilderOptions &taskOptions, Model::Ptr modelPtr)
Definition: TaskBuilder.cpp:6
virtual Feature::Ptr buildFeature()=0
Optimization-based Robot Controller namespace. a library of classes to write and solve optimization p...
Task::Ptr getTask()
Definition: TaskBuilder.cpp:34
virtual void setTaskAsObjectiveOrConstraint()
Definition: TaskBuilder.cpp:52
Task::Ptr task
Definition: TaskBuilder.h:19
virtual void setTaskType()=0
TaskBuilderOptions options
Definition: TaskBuilder.h:21
virtual ~TaskBuilder()
Definition: TaskBuilder.cpp:13
Model::Ptr model
Definition: TaskBuilder.h:20
void setTaskParameters()
Definition: TaskBuilder.cpp:39
virtual Feature::Ptr buildFeatureDesired()=0