ocra-recipes
Doxygen documentation for the ocra-recipes repository
gOcraCoMTaskManager.cpp
Go to the documentation of this file.
2 
3 namespace gocra
4 {
5 
14 gOcraCoMTaskManager::gOcraCoMTaskManager(GHCJTController& _ctrl, const ocra::Model& _model, const std::string& _taskName, ocra::ECartesianDof _axes, double _stiffness, double _damping)
15  : gOcraTaskManagerBase(_ctrl, _model, _taskName), axes(_axes)
16 {
17  _init(_stiffness, _damping);
18 }
19 
29 gOcraCoMTaskManager::gOcraCoMTaskManager(GHCJTController& _ctrl, const ocra::Model& _model, const std::string& _taskName, ocra::ECartesianDof _axes, double _stiffness, double _damping, Eigen::Vector3d _posDes)
30  : gOcraTaskManagerBase(_ctrl, _model, _taskName), axes(_axes)
31 {
32  _init(_stiffness, _damping);
33  setState(_posDes);
34 }
35 
47 /*
48 gOcraCoMTaskManager::gOcraCoMTaskManager(GHCJTController& ctrl, const Model& model, const std::string& taskName, ocra::ECartesianDof axes, double stiffness, double damping, double weight, Eigen::Vector3d posDes, Eigen::Vector3d velDes, Eigen::Vector3d accDes)
49  : _ctrl(ctrl), _model(model), _name(taskName), axes(_axes)
50 {
51  _init(stiffness, damping, weight);
52 }
53 */
54 
58 void gOcraCoMTaskManager::_init(double stiffness, double damping)
59 {
60  featFrame = new ocra::CoMFrame(name + ".CoMFrame", model);
61  featDesFrame = new ocra::TargetFrame(name + ".TargetFrame", model);
62  feat = new ocra::PositionFeature(name + ".PositionFeature", *featFrame, axes);
63  featDes = new ocra::PositionFeature(name + ".PositionFeature_Des", *featDesFrame, axes);
64  task = &(ctrl.createGHCJTTask(name, *feat, *featDes));
65  ctrl.addTask(task);
66  task->setStiffness(stiffness);
67  task->setDamping(damping);
68  task->setWeight(1);
69  task->activateAsObjective();
70 
71  // Set the desired state to the current position of the segment with 0 vel or acc
73 }
74 
79 void gOcraCoMTaskManager::setState(const Eigen::Vector3d& position)
80 {
81  setState(position, Eigen::Vector3d::Zero(), Eigen::Vector3d::Zero());
82 }
83 
90 void gOcraCoMTaskManager::setState(const Eigen::Vector3d& position, const Eigen::Vector3d& velocity, const Eigen::Vector3d& acceleration)
91 {
92  featDesFrame->setPosition(Eigen::Displacementd(position));
93  featDesFrame->setVelocity(Eigen::Twistd(0.0, 0.0, 0.0, velocity(0), velocity(1), velocity(2)) );
94  featDesFrame->setAcceleration(Eigen::Twistd(0.0, 0.0, 0.0, acceleration(0), acceleration(1), acceleration(2)) );
95 }
96 
97 
98 
103 void gOcraCoMTaskManager::setStiffness(double stiffness)
104 {
105  task->setStiffness(stiffness);
106 }
107 
113 {
114  Eigen::MatrixXd K = task->getStiffness();
115  return K(0, 0);
116 }
117 
123 {
124  task->setDamping(damping);
125 }
126 
132 {
133  Eigen::MatrixXd C = task->getDamping();
134  return C(0, 0);
135 }
136 
141 {
142  task->activateAsObjective();
143 }
144 
149 {
150  task->deactivate();
151 }
152 
157 {
158  return task->getError();
159 }
160 
161 }
void setDamping(double B)
Definition: Task.cpp:378
gOcraCoMTaskManager(GHCJTController &ctrl, const ocra::Model &model, const std::string &taskName, 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.
virtual const Eigen::Vector3d & getCoMPosition() const =0
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
gocra::GHCJTController & ctrl
void setAcceleration(const Eigen::Twistd &gamma)
void setState(const Eigen::Vector3d &position)
void setVelocity(const Eigen::Twistd &T)
void setWeight(double weight)
Definition: Task.cpp:501
void setStiffness(double K)
Definition: Task.cpp:395
void setStiffness(double stiffness)
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
Creates a frame whose center is at the CoM of the model and whose axes are parallel to the axes of th...
Definition: ControlFrame.h:132
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