ocra-recipes
Doxygen documentation for the ocra-recipes repository
gOcraSegPoseTaskManager.cpp
Go to the documentation of this file.
2 
3 namespace gocra
4 {
5 
16 gOcraSegPoseTaskManager::gOcraSegPoseTaskManager(GHCJTController& _ctrl, const ocra::Model& _model, const std::string& _taskName, const std::string& _segmentName, ocra::ECartesianDof _axes, double _stiffness, double _damping)
17  : gOcraTaskManagerBase(_ctrl, _model, _taskName), segmentName(_segmentName), axes(_axes)
18 {
19  _init(Eigen::Displacementd::Identity(), _stiffness, _damping);
20 }
21 
33 gOcraSegPoseTaskManager::gOcraSegPoseTaskManager(GHCJTController& _ctrl, const ocra::Model& _model, const std::string& _taskName, const std::string& _segmentName, ocra::ECartesianDof _axes, double _stiffness, double _damping, const Eigen::Displacementd& _poseDes)
34  : gOcraTaskManagerBase(_ctrl, _model, _taskName), segmentName(_segmentName), axes(_axes)
35 {
36  _init(Eigen::Displacementd::Identity(), _stiffness, _damping);
37  setState(_poseDes);
38 }
39 
43 void gOcraSegPoseTaskManager::_init(const Eigen::Displacementd& _ref_LocalFrame, double _stiffness, double _damping)
44 {
45  featFrame = new ocra::SegmentFrame(name + ".SegmentFrame", model, model.SegmentName(segmentName), _ref_LocalFrame);
46  featDesFrame = new ocra::TargetFrame(name + ".TargetFrame", model);
47  feat = new ocra::DisplacementFeature(name + ".DisplacementFeature", *featFrame, axes);
48  featDes = new ocra::DisplacementFeature(name + ".DisplacementFeature_Des", *featDesFrame, axes);
49 
50  task = &(ctrl.createGHCJTTask(name, *feat, *featDes));
51 
52  ctrl.addTask(task);
53 
54  featDesFrame->setPosition(Eigen::Displacementd::Identity());
55  featDesFrame->setVelocity(Eigen::Twistd::Zero());
56  featDesFrame->setAcceleration(Eigen::Twistd::Zero());
57 
58  task->activateAsObjective();
59  task->setStiffness(_stiffness);
60  task->setDamping(_damping);
61 
62 
63  // Set the desired state to the current pose of the segment with 0 vel or acc
65 }
66 
71 void gOcraSegPoseTaskManager::setState(const Eigen::Displacementd& pose)
72 {
73  setState(pose, Eigen::Twistd::Zero(), Eigen::Twistd::Zero());
74 }
75 
82 void gOcraSegPoseTaskManager::setState(const Eigen::Displacementd& pose, const Eigen::Twistd& velocity, const Eigen::Twistd& acceleration)
83 {
84  featDesFrame->setPosition(pose);
85  featDesFrame->setVelocity(velocity);
86  featDesFrame->setAcceleration(acceleration);
87 }
88 
89 
95 {
96  task->setStiffness(stiffness);
97 }
98 
104 {
105  Eigen::MatrixXd K = task->getStiffness();
106  return K(0, 0);
107 }
108 
114 {
115  task->setDamping(damping);
116 }
117 
123 {
124  Eigen::MatrixXd C = task->getDamping();
125  return C(0, 0);
126 }
127 
132 {
133  return task->getError();
134 }
135 
136 
141 {
142  task->activateAsObjective();
143 }
144 
149 {
150  task->deactivate();
151 }
152 
153 }
void setDamping(double B)
Definition: Task.cpp:378
gOcraSegPoseTaskManager(GHCJTController &ctrl, const ocra::Model &model, const std::string &taskName, const std::string &segmentName, ocra::ECartesianDof axes, 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
void setPosition(const Eigen::Displacementd &H)
ECartesianDof
Definition: ControlEnum.h:18
A frame attached to a segment of a model.
Definition: ControlFrame.h:104
int getSegmentIndex(const std::string &name) const
Definition: Model.cpp:192
gocra::GHCJTController & ctrl
void setAcceleration(const Eigen::Twistd &gamma)
Used to build position/orientation tasks.
Definition: Feature.h:235
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 setState(const Eigen::Displacementd &pose)
void addTask(std::shared_ptr< Task > task)
Definition: Controller.cpp:184
void activateAsObjective()
Definition: Task.cpp:298
virtual const Eigen::Displacementd & getSegmentPosition(int index) const =0
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