ocra-recipes
Doxygen documentation for the ocra-recipes repository
gOcraFullPostureTaskManager.cpp
Go to the documentation of this file.
2 
3 namespace gocra
4 {
5 
15 gOcraFullPostureTaskManager::gOcraFullPostureTaskManager(GHCJTController& _ctrl, const ocra::Model& _model, const std::string& _taskName, int _fullStateType, double _stiffness, double _damping)
16  : gOcraTaskManagerBase(_ctrl, _model, _taskName)
17 {
18  _init(_fullStateType, _stiffness, _damping);
19 }
20 
31 gOcraFullPostureTaskManager::gOcraFullPostureTaskManager(GHCJTController& _ctrl, const ocra::Model& _model, const std::string& _taskName, int _fullStateType, double _stiffness, double _damping, const Eigen::VectorXd& _init_q)
32  : gOcraTaskManagerBase(_ctrl, _model, _taskName)
33 {
34  _init(_fullStateType, _stiffness, _damping);
35  setPosture(_init_q);
36 }
37 
41 void gOcraFullPostureTaskManager::_init(int fullStateType, double stiffness, double damping)
42 {
43  featState = new ocra::FullModelState(name + ".FullModelState", model, fullStateType);
44  featDesState = new ocra::FullTargetState(name + ".FullTargetState", model, fullStateType);
45  feat = new ocra::FullStateFeature(name + ".FullStateFeature", *featState);
46  featDes = new ocra::FullStateFeature(name + ".FullStateFeature_Des", *featDesState);
47 
48  // The feature initializes as Zero for posture
49  task = &(ctrl.createGHCJTTask(name, *feat, *featDes));
50 
51  ctrl.addTask(task);
52 
53 
54  task->setStiffness(stiffness);
55  task->setDamping(damping);
56  task->setWeight(1);
57  task->activateAsObjective();
58 }
59 
63 void gOcraFullPostureTaskManager::setPosture(const Eigen::VectorXd& q)
64 {
65  setPosture(q, Eigen::VectorXd::Zero(featDesState->getSize()), Eigen::VectorXd::Zero(featDesState->getSize()));
66 }
67 
71 void gOcraFullPostureTaskManager::setPosture(const Eigen::VectorXd& q, const Eigen::VectorXd& qdot, const Eigen::VectorXd& qddot)
72 {
73  // Need to check size of q
74  if (q.size() != featDesState->getSize())
75  {
76  throw std::runtime_error("[gOcraFullPostureTaskManager::setPosture(Eigen::VectorXd&, Eigen::VectorXd&, Eigen::VectorXd&)] Input pose and required dimension does not match");
77  }
78  else if (qdot.size() != featDesState->getSize())
79  {
80  throw std::runtime_error("[gOcraFullPostureTaskManager::setPosture(Eigen::VectorXd&, Eigen::VectorXd&, Eigen::VectorXd&)] Input pose velocity and required dimension does not match");
81  }
82  else if (qddot.size() != featDesState->getSize())
83  {
84  throw std::runtime_error("[gOcraFullPostureTaskManager::setPosture(Eigen::VectorXd&, Eigen::VectorXd&, Eigen::VectorXd&)] Input pose acceleration and required dimension does not match");
85  }
86 
87  featDesState->set_q(q);
88  featDesState->set_qdot(qdot);
89  featDesState->set_qddot(qddot);
90 }
91 
92 
93 
99 {
100  task->setStiffness(stiffness);
101 }
102 
108 {
109  Eigen::MatrixXd K = task->getStiffness();
110  return K(0, 0);
111 }
112 
118 {
119  task->setDamping(damping);
120 }
121 
127 {
128  Eigen::MatrixXd C = task->getDamping();
129  return C(0, 0);
130 }
131 
136 {
137  task->activateAsObjective();
138 }
139 
144 {
145  task->deactivate();
146 }
147 
152 {
153  return task->getError();
154 }
155 
156 
157 }
void setDamping(double B)
Definition: Task.cpp:378
gOcraFullPostureTaskManager(GHCJTController &ctrl, const ocra::Model &model, const std::string &taskName, int fullStateType, double stiffness, double damping)
const Eigen::MatrixXd & getDamping() const
Definition: Task.cpp:466
const Eigen::VectorXd & getError() const
Definition: Task.cpp:576
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
Used to build tasks in the manikin configuration space.
Definition: Feature.h:326
gocra::GHCJTController & ctrl
void setWeight(double weight)
Definition: Task.cpp:501
void setStiffness(double K)
Definition: Task.cpp:395
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
const Eigen::MatrixXd & getStiffness() const
Definition: Task.cpp:471