ocra-recipes
Doxygen documentation for the ocra-recipes repository
gOcraSegCartesianTaskManager.cpp
Go to the documentation of this file.
2 
3 namespace gocra
4 {
5 
16 gOcraSegCartesianTaskManager::gOcraSegCartesianTaskManager(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::Vector3d::Zero(), _stiffness, _damping);
20 }
21 
33 gOcraSegCartesianTaskManager::gOcraSegCartesianTaskManager(GHCJTController& _ctrl, const ocra::Model& _model, const std::string& _taskName, const std::string& _segmentName, const Eigen::Vector3d& _segPoint_Local, ocra::ECartesianDof _axes, double _stiffness, double _damping)
34  : gOcraTaskManagerBase(_ctrl, _model, _taskName), segmentName(_segmentName), axes(_axes)
35 {
36  _init(_segPoint_Local, _stiffness, _damping);
37 }
38 
50 gOcraSegCartesianTaskManager::gOcraSegCartesianTaskManager(GHCJTController& _ctrl, const ocra::Model& _model, const std::string& _taskName, const std::string& _segmentName, ocra::ECartesianDof _axes, double _stiffness, double _damping, const Eigen::Vector3d& _poseDes)
51  : gOcraTaskManagerBase(_ctrl, _model, _taskName), segmentName(_segmentName), axes(_axes)
52 {
53  _init(Eigen::Vector3d::Zero(), _stiffness, _damping);
54  // Have no idea this wrapper needs to be done
55  setState(_poseDes);
56 }
57 
70 gOcraSegCartesianTaskManager::gOcraSegCartesianTaskManager(GHCJTController& _ctrl, const ocra::Model& _model, const std::string& _taskName, const std::string& _segmentName, const Vector3d& _segPoint_Local, ocra::ECartesianDof _axes, double _stiffness, double _damping, const Eigen::Vector3d& _poseDes)
71  : gOcraTaskManagerBase(_ctrl, _model, _taskName), segmentName(_segmentName), axes(_axes)
72 {
73  _init(_segPoint_Local, _stiffness, _damping);
74  setState(_poseDes);
75 }
76 
77 
81 void gOcraSegCartesianTaskManager::_init(const Eigen::Vector3d& _taskPoint_LocalFrame, double _stiffness, double _damping)
82 {
83  featFrame = new ocra::SegmentFrame(name + ".SegmentFrame", model, model.SegmentName(segmentName), Eigen::Displacementd(_taskPoint_LocalFrame));
84  featDesFrame = new ocra::TargetFrame(name + ".TargetFrame", model);
85  feat = new ocra::PositionFeature(name + ".PositionFeature", *featFrame, axes);
86  featDes = new ocra::PositionFeature(name + ".PositionFeature_Des", *featDesFrame, axes);
87 
88 
89 
90  task = &(ctrl.createGHCJTTask(name, *feat, *featDes));
91  ctrl.addTask(task);
92 
93  task->activateAsObjective();
94  task->setStiffness(_stiffness);
95  task->setDamping(_damping);
96 
97  // Set the desired state to the current position of the segment with 0 vel or acc
98  setState(model.getSegmentPosition(model.getSegmentIndex(segmentName)).getTranslation());
99 }
100 
105 void gOcraSegCartesianTaskManager::setState(const Eigen::Vector3d& position)
106 {
107  setState(position, Eigen::Vector3d::Zero(), Eigen::Vector3d::Zero());
108 }
109 
116 void gOcraSegCartesianTaskManager::setState(const Eigen::Vector3d& position, const Eigen::Vector3d& velocity, const Eigen::Vector3d& acceleration)
117 {
118  featDesFrame->setPosition(Eigen::Displacementd(position));
119  featDesFrame->setVelocity(Eigen::Twistd(0.0, 0.0, 0.0, velocity(0), velocity(1), velocity(2)) );
120  featDesFrame->setAcceleration(Eigen::Twistd(0.0, 0.0, 0.0, acceleration(0), acceleration(1), acceleration(2)) );
121 }
122 
123 
129 {
130  task->setStiffness(stiffness);
131 }
132 
138 {
139  Eigen::MatrixXd K = task->getStiffness();
140  return K(0, 0);
141 }
142 
148 {
149  task->setDamping(damping);
150 }
151 
157 {
158  Eigen::MatrixXd C = task->getDamping();
159  return C(0, 0);
160 }
161 
166 {
167  task->activateAsObjective();
168 }
169 
174 {
175  task->deactivate();
176 }
177 
182 {
183  return task->getError();
184 }
185 
186 
187 }
void setState(const Eigen::Vector3d &position)
void setDamping(double B)
Definition: Task.cpp:378
const Eigen::MatrixXd & getDamping() const
Definition: Task.cpp:466
const Eigen::VectorXd & getError() const
Definition: Task.cpp:576
Model class.
Definition: Model.h:38
gOcraSegCartesianTaskManager(GHCJTController &ctrl, const ocra::Model &model, const std::string &taskName, const std::string &segmentName, ocra::ECartesianDof axes, double stiffness, double damping)
gOcraTaskManagerBase(gocra::GHCJTController &ctrl, const ocra::Model &model, const std::string &name)
Task Manager for the Center of Mass (CoM) task with the gOcra Controllers.
gOcra Controller based on LQP solver for the ocra framework.
Used to build positioning tasks.
Definition: Feature.h:101
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)
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
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