ocra-recipes
Doxygen documentation for the ocra-recipes repository
TorqueLimitConstraint.cpp
Go to the documentation of this file.
1 
9 
10 
11 
12 namespace ocra
13 {
14 
15 
16 
18 
25  : NamedInstance("Torque Limit Equation Function")
27  , CoupledInputOutputSize(false)
28  , _torqueDim(model.getJointTorqueVariable().getSize())
29  , LinearFunction(model.getJointTorqueVariable(), 2*model.getJointTorqueVariable().getSize())
30 {
31  //_model.connect<EVT_CHANGE_VALUE>(*this, &DynamicEquationFunction::invalidateAll); // not necessary because A (jacobian) is constant
32  //_model.connect<EVT_CHANGE_VALUE>(*this, &JointLimitFunction::invalidateb); // b is constant, unless someone changes it by calling setTorqueLimits
33 
34  /* The function is on the form:
35  * | O -I | | taumax |
36  * | O I | tau + | -taumax |
37  *
38  * where O (nx6) is defined if the model has a free-floating base (we cannot limit the range of this "joint"), else O is a void matrix (nx0)
39  *
40  * The associated constraint is:
41  * A ddq + b >= 0
42  */
43 
44  // Building of A, the jacobian, which is constant:
45  Eigen::MatrixXd I = Eigen::MatrixXd::Identity(_torqueDim, _torqueDim);
46 
47  _jacobian = Eigen::MatrixXd::Zero(2*_torqueDim, _torqueDim);
48  _jacobian.topRows(_torqueDim) = -I;
49  _jacobian.bottomRows(_torqueDim) = I;
50 
51  // Set limit from model
52  setTorqueLimits( Eigen::VectorXd::Constant(_torqueDim, 1000) );
53 }
54 
59 {
60 
61 }
62 
68 {
69 
70 }
71 
77 {
78  _b.head(_torqueDim) = _torqueLimits;
79  _b.tail(_torqueDim) = _torqueLimits;
80 }
81 
82 
87 void TorqueLimitFunction::setTorqueLimits(const Eigen::VectorXd& torqueLimits)
88 {
89  _torqueLimits = torqueLimits;
90  updateb();
91 }
92 
97 const Eigen::VectorXd& TorqueLimitFunction::getTorqueLimits() const
98 {
99  return _torqueLimits;
100 }
101 
102 
103 
104 
105 } // end namespace ocra
Model class.
Definition: Model.h:38
LinearFunction class.
Optimization-based Robot Controller namespace. a library of classes to write and solve optimization p...
MatrixXd & _jacobian
Definition: Function.h:313
TorqueLimitFunction(const Model &model)
Define torque limit constraint for wOcra controller.
void setTorqueLimits(const Eigen::VectorXd &torqueLimits)
const Eigen::VectorXd & getTorqueLimits() const