ocra-recipes
Doxygen documentation for the ocra-recipes repository
OrientationTaskBuilder.cpp
Go to the documentation of this file.
2 
3 using namespace ocra;
4 
5 OrientationTaskBuilder::OrientationTaskBuilder(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 + ".OrientationFeature";
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<OrientationFeature>(featName, featFrame);
24 }
25 
27 {
28  std::string featDesFrameName = this->options.taskName + ".TargetFrame";
29  std::string featDesName = this->options.taskName + ".OrientationFeatureDesired";
30 
31  ControlFrame::Ptr featDesFrame = std::make_shared<TargetFrame>(featDesFrameName, *this->model);
32 
33  return std::make_shared<OrientationFeature>(featDesName, featDesFrame);
34 }
35 
37 {
38  TaskState state;
39  // Make sure the desired vector is the same size as a quaternion.
40  if(this->options.desired.size() == ORIENTATION_VECTOR_SIZE){
41  // Set the orientation
42  Eigen::Rotation3d orientation(this->options.desired.data());
43  state.setPosition(Eigen::Displacementd(Eigen::Vector3d::Zero(), orientation));
44  }else{
45  // If the desired orientation was not given then just get it from the current state of the task.
46  Eigen::Rotation3d orientation = this->task->getTaskState().getPosition().getRotation();
47  state.setPosition(Eigen::Displacementd(Eigen::Vector3d::Zero(), orientation));
48  }
49 
50  // Set velocity and acceleration to zero.
51  state.setVelocity(Eigen::Twistd::Zero());
52  state.setAcceleration(Eigen::Twistd::Zero());
53 
54  this->task->setDesiredTaskStateDirect(state);
55 }
56 
58 {
59  this->task->setTaskType(Task::ACCELERATIONTASK);
60  this->task->setMetaTaskType(Task::ORIENTATION);
61 }
OrientationTaskBuilder(const TaskBuilderOptions &taskOptions, Model::Ptr modelPtr)
void setPosition(const Eigen::Displacementd &newPosition)
Definition: TaskState.cpp:79
void setAcceleration(const Eigen::Twistd &newAcceleration)
Definition: TaskState.cpp:93
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...
virtual Feature::Ptr buildFeatureDesired()
Task::Ptr task
Definition: TaskBuilder.h:19
TaskBuilderOptions options
Definition: TaskBuilder.h:21
Model::Ptr model
Definition: TaskBuilder.h:20
Eigen::Displacementd offset