ocra-recipes
Doxygen documentation for the ocra-recipes repository
gOcraSegOrientationTaskManager.cpp
Go to the documentation of this file.
2 
3 namespace gocra
4 {
5 
15 gOcraSegOrientationTaskManager::gOcraSegOrientationTaskManager(GHCJTController& _ctrl, const ocra::Model& _model, const std::string& _taskName, const std::string& _segmentName, double _stiffness, double _damping)
16  : gOcraTaskManagerBase(_ctrl, _model, _taskName), segmentName(_segmentName)
17 {
18  _init(Eigen::Rotation3d::Identity(), _stiffness, _damping);
19 }
20 
31 gOcraSegOrientationTaskManager::gOcraSegOrientationTaskManager(GHCJTController& _ctrl, const ocra::Model& _model, const std::string& _taskName, const std::string& _segmentName, double _stiffness, double _damping, const Eigen::Rotation3d& _orientationDes)
32  : gOcraTaskManagerBase(_ctrl, _model, _taskName), segmentName(_segmentName)
33 {
34  _init(Eigen::Rotation3d::Identity(), _stiffness, _damping);
35  setOrientation(_orientationDes);
36 }
37 
41 void gOcraSegOrientationTaskManager::_init(Eigen::Rotation3d _refOrientation_LocalFrame, double _stiffness, double _damping)
42 {
43  featFrame = new ocra::SegmentFrame(name + ".SegmentFrame", model, model.SegmentName(segmentName), Eigen::Displacementd(Eigen::Vector3d::Zero(), _refOrientation_LocalFrame));
44  featDesFrame = new ocra::TargetFrame(name + ".TargetFrame", model);
45  feat = new ocra::OrientationFeature(name + ".OrientationFeature", *featFrame);
46  featDes = new ocra::OrientationFeature(name + ".OrientationFeature_Des", *featDesFrame);
47 
48  featDesFrame->setPosition(Eigen::Displacementd::Identity());
49  featDesFrame->setVelocity(Eigen::Twistd::Zero());
50  featDesFrame->setAcceleration(Eigen::Twistd::Zero());
51 
52  task = &(ctrl.createGHCJTTask(name, *feat, *featDes));
53 
54  ctrl.addTask(task);
55 
56  task->activateAsObjective();
57  task->setStiffness(_stiffness);
58  task->setDamping(_damping);
59 }
60 
65 void gOcraSegOrientationTaskManager::setOrientation(const Eigen::Rotation3d& orientation)
66 {
67  featDesFrame->setPosition(Eigen::Displacementd(Eigen::Vector3d::Zero(), orientation));
68  featDesFrame->setVelocity(Eigen::Twistd::Zero());
69  featDesFrame->setAcceleration(Eigen::Twistd::Zero());
70 }
71 
72 
73 
79 {
80  task->setStiffness(stiffness);
81 }
82 
88 {
89  Eigen::MatrixXd K = task->getStiffness();
90  return K(0, 0);
91 }
92 
98 {
99  task->setDamping(damping);
100 }
101 
107 {
108  Eigen::MatrixXd C = task->getDamping();
109  return C(0, 0);
110 }
111 
116 {
117  task->activateAsObjective();
118 }
119 
124 {
125  task->deactivate();
126 }
127 
132 {
133  return task->getError();
134 }
135 
136 
137 }
void setDamping(double B)
Definition: Task.cpp:378
Used to build orientation tasks.
Definition: Feature.h:191
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.
gOcraSegOrientationTaskManager(GHCJTController &ctrl, const ocra::Model &model, const std::string &taskName, const std::string &segmentName, double stiffness, double damping)
gOcra Controller based on LQP solver for the ocra framework.
void deactivate()
Definition: Task.cpp:326
void setPosition(const Eigen::Displacementd &H)
A frame attached to a segment of a model.
Definition: ControlFrame.h:104
gocra::GHCJTController & ctrl
void setAcceleration(const Eigen::Twistd &gamma)
void setVelocity(const Eigen::Twistd &T)
void setStiffness(double K)
Definition: Task.cpp:395
const std::string SegmentName(const std::string &name) const
Definition: Model.cpp:245
void addTask(std::shared_ptr< Task > task)
Definition: Controller.cpp:184
void activateAsObjective()
Definition: Task.cpp:298
void setOrientation(const Eigen::Rotation3d &pos)
GHCJTTask & createGHCJTTask(const std::string &name, Feature::Ptr feature, Feature::Ptr featureDes) const
Represents a &#39;target&#39;, i.e. something that does not depend on a model but must match with another fra...
Definition: ControlFrame.h:75
const Eigen::MatrixXd & getStiffness() const
Definition: Task.cpp:471