ocra-recipes
Doxygen documentation for the ocra-recipes repository
PoseTaskBuilder.cpp
Go to the documentation of this file.
2 
3 using namespace ocra;
4 
5 PoseTaskBuilder::PoseTaskBuilder(const TaskBuilderOptions& taskOptions, Model::Ptr modelPtr)
6 : TaskBuilder(taskOptions, modelPtr)
7 {
8 }
9 
11 {
12 
13 }
14 
16 {
17  std::string featFrameName = this->options.taskName + ".SegmentFrame";
18  std::string featName = this->options.taskName + ".DisplacementFeature";
19  std::string segmentName = this->model->SegmentName(this->options.segment);
20 
21  ControlFrame::Ptr featFrame = std::make_shared<SegmentFrame>(featFrameName, *this->model, segmentName, this->options.offset);
22 
23  return std::make_shared<DisplacementFeature>(featName, featFrame, this->options.axes);
24 }
25 
27 {
28  std::string featDesFrameName = this->options.taskName + ".TargetFrame";
29  std::string featDesName = this->options.taskName + ".DisplacementFeatureDesired";
30 
31  ControlFrame::Ptr featDesFrame = std::make_shared<TargetFrame>(featDesFrameName, *this->model);
32 
33  return std::make_shared<DisplacementFeature>(featDesName, featDesFrame, this->options.axes);
34 }
35 
37 {
38  TaskState state;
39  // Make sure the desired vector is the same size as the number of axes being controlled.
40  if(this->options.desired.size() > 0){
41  // Set the pose
43  }else{
44  // If the desired position was not given then just get it from the current state of the task.
45  state.setPosition(this->task->getTaskState().getPosition());
46  }
47 
48  // Set velocity and acceleration to zero.
49  state.setVelocity(Eigen::Twistd::Zero());
50  state.setAcceleration(Eigen::Twistd::Zero());
51 
52  this->task->setDesiredTaskStateDirect(state);
53 }
54 
56 {
57  this->task->setTaskType(Task::ACCELERATIONTASK);
58  this->task->setMetaTaskType(Task::POSE);
59 }
void setPosition(const Eigen::Displacementd &newPosition)
Definition: TaskState.cpp:79
PoseTaskBuilder(const TaskBuilderOptions &taskOptions, Model::Ptr modelPtr)
void setAcceleration(const Eigen::Twistd &newAcceleration)
Definition: TaskState.cpp:93
virtual void setTaskState()
virtual void setTaskType()
void setVelocity(const Eigen::Twistd &newVelocity)
Definition: TaskState.cpp:86
Optimization-based Robot Controller namespace. a library of classes to write and solve optimization p...
Task::Ptr task
Definition: TaskBuilder.h:19
virtual Feature::Ptr buildFeature()
Eigen::Displacementd eigenVectorToDisplacementd(const Eigen::VectorXd &eigenVector)
TaskBuilderOptions options
Definition: TaskBuilder.h:21
Model::Ptr model
Definition: TaskBuilder.h:20
virtual Feature::Ptr buildFeatureDesired()
Eigen::Displacementd offset