ocra-recipes
Doxygen documentation for the ocra-recipes repository
FullPostureTaskBuilder.cpp
Go to the documentation of this file.
2 
3 using namespace ocra;
4 
5 FullPostureTaskBuilder::FullPostureTaskBuilder(const TaskBuilderOptions& taskOptions, Model::Ptr modelPtr)
6 : TaskBuilder(taskOptions, modelPtr)
7 {
8  // Set the type of Full State we want to use:
9  // FULL_STATE, FREE_FLYER, or INTERNAL
10  // FULL_STATE = FloatingBase + InternalDoF
11  // FREE_FLYER = FloatingBase
12  // INTERNAL = InternalDoF (joints)
13 
14  this->fullStateType = FullState::INTERNAL;
15 }
16 
18 {
19 }
20 
22 {
23  std::string featStateName = this->options.taskName + ".FullModelState";
24  std::string featName = this->options.taskName + ".FullStateFeature";
25 
26  FullState::Ptr featState = std::make_shared<FullModelState>(featStateName, *this->model, this->fullStateType);
27 
28  return std::make_shared<FullStateFeature>(featName, featState);
29 }
30 
32 {
33  std::string featDesStateName = this->options.taskName + ".FullTargetState";
34  std::string featDesName = this->options.taskName + ".FullStateFeatureDesired";
35 
36  FullState::Ptr featDesState = std::make_shared<FullTargetState>(featDesStateName, *this->model, this->fullStateType);
37 
38  return std::make_shared<FullStateFeature>(featDesName, featDesState);
39 }
40 
42 {
43  TaskState state;
44  // Get the number of joints on the robot.
45  int nJoints = this->model->nbInternalDofs();
46  // Make sure the desired vector is the same size as the number of axes being controlled.
47  if(this->options.desired.size() == nJoints){
48  // Set the pose
49  state.setQ(this->options.desired);
50  }else{
51  // If the desired position was not given then just get it from the current state of the task.
52  state.setQ(this->task->getTaskState().getQ());
53  }
54 
55  // Set velocity and acceleration to zero.
56  state.setQd(Eigen::VectorXd::Zero(nJoints));
57  state.setQdd(Eigen::VectorXd::Zero(nJoints));
58 
59  this->task->setDesiredTaskStateDirect(state);
60 }
61 
63 {
64  this->task->setTaskType(Task::ACCELERATIONTASK);
65  this->task->setMetaTaskType(Task::FULL_POSTURE);
66 }
FullPostureTaskBuilder(const TaskBuilderOptions &taskOptions, Model::Ptr modelPtr)
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
void setQd(const Eigen::VectorXd &newQd)
Definition: TaskState.cpp:107
TaskBuilderOptions options
Definition: TaskBuilder.h:21
Model::Ptr model
Definition: TaskBuilder.h:20
void setQdd(const Eigen::VectorXd &newQdd)
Definition: TaskState.cpp:114
void setQ(const Eigen::VectorXd &newQ)
Definition: TaskState.cpp:100