ocra-recipes
Doxygen documentation for the ocra-recipes repository
PartialPostureTaskBuilder.cpp
Go to the documentation of this file.
2 
3 using namespace ocra;
4 
6 : TaskBuilder(taskOptions, modelPtr)
7 {
8  // Set the type of Partial 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->partialStateType = FullState::INTERNAL;
15 }
16 
18 {
19 }
20 
22 {
23  std::string featStateName = this->options.taskName + ".PartialModelState";
24  std::string featName = this->options.taskName + ".PartialStateFeature";
25 
26  PartialState::Ptr featState = std::make_shared<PartialModelState>(featStateName, *this->model, this->options.jointIndexes, this->partialStateType);
27 
28  return std::make_shared<PartialStateFeature>(featName, featState);
29 }
30 
32 {
33  std::string featDesStateName = this->options.taskName + ".PartialTargetState";
34  std::string featDesName = this->options.taskName + ".PartialStateFeatureDesired";
35 
36  PartialState::Ptr featDesState = std::make_shared<PartialTargetState>(featDesStateName, *this->model, this->options.jointIndexes, this->partialStateType);
37 
38  return std::make_shared<PartialStateFeature>(featDesName, featDesState);
39 }
40 
42 {
43  TaskState state;
44  // Get the number of joints on the robot.
45  int nJoints = this->options.jointIndexes.rows();
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::PARTIAL_POSTURE);
66 }
Optimization-based Robot Controller namespace. a library of classes to write and solve optimization p...
Task::Ptr task
Definition: TaskBuilder.h:19
void setQd(const Eigen::VectorXd &newQd)
Definition: TaskState.cpp:107
PartialPostureTaskBuilder(const TaskBuilderOptions &taskOptions, Model::Ptr modelPtr)
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