ocra-recipes
Doxygen documentation for the ocra-recipes repository
gOcraPartialPostureTaskManager.cpp
Go to the documentation of this file.
2 
3 namespace gocra
4 {
5 
16 gOcraPartialPostureTaskManager::gOcraPartialPostureTaskManager(GHCJTController& _ctrl, const ocra::Model& _model, const std::string& _taskName, int _fullStateType, Eigen::VectorXi& _dofIndices, double _stiffness, double _damping)
17  : gOcraTaskManagerBase(_ctrl, _model, _taskName)
18 {
19  _init(_fullStateType, _dofIndices, _stiffness, _damping);
20 }
21 
33 gOcraPartialPostureTaskManager::gOcraPartialPostureTaskManager(GHCJTController& _ctrl, const ocra::Model& _model, const std::string& _taskName, int _fullStateType, Eigen::VectorXi& _dofIndices, double _stiffness, double _damping, Eigen::VectorXd& _init_q)
34  : gOcraTaskManagerBase(_ctrl, _model, _taskName)
35 {
36  _init(_fullStateType, _dofIndices, _stiffness, _damping);
37  setPosture(_init_q);
38 }
39 
43 void gOcraPartialPostureTaskManager::_init(int _fullStateType, VectorXi& _dofIndices, double _stiffness, double _damping)
44 {
45  featState = new ocra::PartialModelState(name + ".PartialModelState", model, _dofIndices, _fullStateType);
46  featDesState = new ocra::PartialTargetState(name + ".PartialTargetState", model, _dofIndices, _fullStateType);
47  feat = new ocra::PartialStateFeature(name + ".PartialStateFeature", *featState);
48  featDes = new ocra::PartialStateFeature(name + ".PartialStateFeature_Des", *featDesState);
49 
50  // The feature initializes as Zero for posture
51  task = &(ctrl.createGHCJTTask(name, *feat, *featDes));
52  ctrl.addTask(task);
53 
54 
55  task->setStiffness(_stiffness);
56  task->setDamping(_damping);
57  task->setWeight(1);
58 
59  task->activateAsObjective();
60 }
61 
66 {
67  // Need to check size of q
68  if (q.size() != featDesState->getSize())
69  {
70  throw std::runtime_error("[gOcraPartialPostureTaskManager::setPosture(Eigen::VectorXd&)] Input pose and required dimension does not match");
71  }
72  featDesState->set_q(q);
73  featDesState->set_qdot(Eigen::VectorXd::Zero(featDesState->getSize()));
74  featDesState->set_qddot(Eigen::VectorXd::Zero(featDesState->getSize()));
75 }
76 
80 void gOcraPartialPostureTaskManager::setPosture(Eigen::VectorXd& q, Eigen::VectorXd& qdot, Eigen::VectorXd& qddot)
81 {
82  // Need to check size of q
83  if (q.size() != featDesState->getSize())
84  {
85  throw std::runtime_error("[gOcraPartialPostureTaskManager::setPosture(Eigen::VectorXd&, Eigen::VectorXd&, Eigen::VectorXd&)] Input pose and required dimension does not match");
86  }
87  else if (qdot.size() != featDesState->getSize())
88  {
89  throw std::runtime_error("[gOcraPartialPostureTaskManager::setPosture(Eigen::VectorXd&, Eigen::VectorXd&, Eigen::VectorXd&)] Input pose velocity and required dimension does not match");
90  }
91  else if (qddot.size() != featDesState->getSize())
92  {
93  throw std::runtime_error("[gOcraPartialPostureTaskManager::setPosture(Eigen::VectorXd&, Eigen::VectorXd&, Eigen::VectorXd&)] Input pose acceleration and required dimension does not match");
94  }
95 
96  featDesState->set_q(q);
97  featDesState->set_qdot(qdot);
98  featDesState->set_qddot(qddot);
99 }
100 
101 
106 {
107  task->activateAsObjective();
108 }
109 
114 {
115  task->deactivate();
116 }
117 
118 
119 }
Used to build tasks in a partial configuration space.
Definition: Feature.h:369
void setDamping(double B)
Definition: Task.cpp:378
gOcraPartialPostureTaskManager(GHCJTController &ctrl, const ocra::Model &model, const std::string &taskName, int fullStateType, Eigen::VectorXi &dofIndices, double stiffness, double damping)
Model class.
Definition: Model.h:38
Task Manager for the Center of Mass (CoM) task with the gOcra Controllers.
gOcra Controller based on LQP solver for the ocra framework.
void deactivate()
Definition: Task.cpp:326
gocra::GHCJTController & ctrl
void setWeight(double weight)
Definition: Task.cpp:501
void setStiffness(double K)
Definition: Task.cpp:395
A partial state of the model.
Definition: PartialState.h:66
void addTask(std::shared_ptr< Task > task)
Definition: Controller.cpp:184
void activateAsObjective()
Definition: Task.cpp:298
GHCJTTask & createGHCJTTask(const std::string &name, Feature::Ptr feature, Feature::Ptr featureDes) const
A target for a model partial state.
Definition: PartialState.h:92