ocra-recipes
Doxygen documentation for the ocra-recipes repository
CartesianTaskBuilder.cpp
Go to the documentation of this file.
2 
3 using namespace ocra;
4 
5 CartesianTaskBuilder::CartesianTaskBuilder(const TaskBuilderOptions& taskOptions, Model::Ptr modelPtr)
6 : TaskBuilder(taskOptions, modelPtr)
7 {
8  this->nDoF = utils::computeDimensionFor(this->options.axes);
9 }
10 
12 {
13 
14 }
15 
17 {
18  std::string featFrameName = this->options.taskName + ".SegmentFrame";
19  std::string featName = this->options.taskName + ".PositionFeature";
20  std::string segmentName = this->model->SegmentName(this->options.segment);
21 
22  ControlFrame::Ptr featFrame = std::make_shared<SegmentFrame>(featFrameName, *this->model, segmentName, this->options.offset);
23 
24  return std::make_shared<PositionFeature>(featName, featFrame, this->options.axes);
25 }
26 
28 {
29  std::string featDesFrameName = this->options.taskName + ".TargetFrame";
30  std::string featDesName = this->options.taskName + ".PositionFeatureDesired";
31 
32  ControlFrame::Ptr featDesFrame = std::make_shared<TargetFrame>(featDesFrameName, *this->model);
33 
34  return std::make_shared<PositionFeature>(featDesName, featDesFrame, this->options.axes);
35 }
36 
38 {
39  TaskState state;
40 
41  // Make sure the desired vector is the same size as the number of axes being controlled.
42  if(this->options.desired.size() > 0){
43  // Set the pose
45  }else{
46  // If the desired position was not given then just get it from the current state of the task.
47  state.setPosition(this->task->getTaskState().getPosition());
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::POSITION);
61 }
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 buildFeature()
Task::Ptr task
Definition: TaskBuilder.h:19
virtual Feature::Ptr buildFeatureDesired()
Eigen::Displacementd eigenVectorToDisplacementd(const Eigen::VectorXd &eigenVector)
TaskBuilderOptions options
Definition: TaskBuilder.h:21
Model::Ptr model
Definition: TaskBuilder.h:20
CartesianTaskBuilder(const TaskBuilderOptions &taskOptions, Model::Ptr modelPtr)
int computeDimensionFor(ECartesianDof fixedPosition, ECartesianDof fixedOrientation)
Computes the number of directions specified by two ECartesianDof enums.
Definition: ControlEnum.h:39
Eigen::Displacementd offset