ocra-recipes
Doxygen documentation for the ocra-recipes repository
TorqueLimitConstraint.h
Go to the documentation of this file.
1 
8 #ifndef __TORQUELIMITCONSTRAINT_H__
9 #define __TORQUELIMITCONSTRAINT_H__
10 
11 
13 #include "ocra/control/Model.h"
14 #include "ocra/optim/Constraint.h"
15 
16 
17 namespace ocra
18 {
19 
40 {
41 public:
42  typedef LinearFunction functionType_t; //< alias on the type of the mother class. Needed to duplicate the function tree.
43 
44  TorqueLimitFunction(const Model& model);
46 
47  void setTorqueLimits(const Eigen::VectorXd& torqueLimits);
48  const Eigen::VectorXd& getTorqueLimits() const;
49 
50 protected:
51  void updateJacobian() const;
52  void updateb() const;
53 
54  Eigen::VectorXd _torqueLimits;
56 
57 private: // Forbid copy
59  TorqueLimitFunction& operator= (const TorqueLimitFunction&);
60 };
61 
62 
63 
64 
65 
66 
68 {
69 public:
71  : LinearConstraint(createTorqueLimiFunction(model)) {}; //GREATER_THAN_ZERO
72 
73  TorqueLimitConstraint(const Model& model, const Eigen::VectorXd& torqueLimits)
74  : LinearConstraint(createTorqueLimiFunction(model)) //GREATER_THAN_ZERO
75  {
76  _torqueLimitFunction->setTorqueLimits(torqueLimits);
77  };
78 
80  {
81  delete _torqueLimitFunction;
82  }
83 
84  void setTorqueLimits(const Eigen::VectorXd& torqueLimits) {_torqueLimitFunction->setTorqueLimits(torqueLimits);};
85  const Eigen::VectorXd& getTorqueLimits() const {return _torqueLimitFunction->getTorqueLimits();};
86 
87 private:
88  TorqueLimitFunction* createTorqueLimiFunction(const Model& model)
89  {
90  _torqueLimitFunction = new TorqueLimitFunction(model);
91  return _torqueLimitFunction;
92  }
93 
94  TorqueLimitFunction* _torqueLimitFunction;
95 };
96  // end group constraint
98 
99 }
100 
101 
102 #endif
Declaration file of the Model class.
Model class.
Definition: Model.h:38
LinearFunction class.
Optimization-based Robot Controller namespace. a library of classes to write and solve optimization p...
Constraint class.
Definition: Constraint.h:100
Create a linear function that represents the torque limit function.
Declaration file of the LinearFunction class.
TorqueLimitFunction(const Model &model)
TorqueLimitConstraint(const Model &model, const Eigen::VectorXd &torqueLimits)
Declaration file of the Constraint class.
TorqueLimitConstraint(const Model &model)
const Eigen::VectorXd & getTorqueLimits() const
void setTorqueLimits(const Eigen::VectorXd &torqueLimits)
const Eigen::VectorXd & getTorqueLimits() const
void setTorqueLimits(const Eigen::VectorXd &torqueLimits)