ocra-recipes
Doxygen documentation for the ocra-recipes repository
ComTaskBuilder.cpp
Go to the documentation of this file.
2 
3 using namespace ocra;
4 
5 ComTaskBuilder::ComTaskBuilder(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 + ".ComFrame";
19  std::string featName = this->options.taskName + ".PositionFeature";
20 
21  // The only difference between a CoM task and a Cartesian Task is the feature frame used.
22  ControlFrame::Ptr featFrame = std::make_shared<CoMFrame>(featFrameName, *this->model);
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  // Make sure the desired vector is the same size as the number of axes being controlled.
41  if(this->options.desired.size() > 0){
42  // Set the pose
44  }else{
45  // If the desired position was not given then just get it from the current state of the task.
46  state.setPosition(this->task->getTaskState().getPosition());
47  }
48 
49  // Set velocity and acceleration to zero.
50  state.setVelocity(Eigen::Twistd::Zero());
51  state.setAcceleration(Eigen::Twistd::Zero());
52 
53  this->task->setDesiredTaskStateDirect(state);
54 }
55 
57 {
58  this->task->setTaskType(Task::ACCELERATIONTASK);
59  this->task->setMetaTaskType(Task::COM);
60 }
void setPosition(const Eigen::Displacementd &newPosition)
Definition: TaskState.cpp:79
virtual void setTaskState()
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
Eigen::Displacementd eigenVectorToDisplacementd(const Eigen::VectorXd &eigenVector)
TaskBuilderOptions options
Definition: TaskBuilder.h:21
Model::Ptr model
Definition: TaskBuilder.h:20
virtual void setTaskType()
virtual Feature::Ptr buildFeatureDesired()
ComTaskBuilder(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