ocra-recipes
Doxygen documentation for the ocra-recipes repository
JointLimitConstraint.h
Go to the documentation of this file.
1 
8 #ifndef __JOINTLIMITCONSTRAINT_H__
9 #define __JOINTLIMITCONSTRAINT_H__
10 
11 
13 
14 
15 namespace ocra
16 {
17 
73 {
74  public:
75  typedef LinearFunction functionType_t; //< alias on the type of the mother class. Needed to duplicate the function tree.
76 
77  JointLimitFunction(const Model& m, Variable& var);
79 
80  // get/set horizon of prediction
81  double getHorizonOfPrediction() const;
82  void setHorizonOfPrediction(double newHpos);
83 
84  void setJointLimits(const Eigen::VectorXd& lowerLimits, const Eigen::VectorXd& upperLimits);
85  void setJointLowerLimits(const Eigen::VectorXd& newLowerLimits);
86  void setJointUpperLimits(const Eigen::VectorXd& newUpperLimits);
87 
88  const Eigen::VectorXd& getJointLowerLimits() const;
89  const Eigen::VectorXd& getJointUpperLimits() const;
90 
91  void setJointLimit(int i, double newLowerLimit, double newUpperLimit);
92  void setJointLowerLimit(int i, double newLowerLimit);
93  void setJointUpperLimit(int i, double newUpperLimit);
94 
95  double getJointLowerLimit(int i) const;
96  double getJointUpperLimit(int i) const;
97 
98  private: // Forbid copy
100  JointLimitFunction& operator= (const JointLimitFunction&);
101 
102  protected:
103  Eigen::VectorXd jointLowerLimits;
104  Eigen::VectorXd jointUpperLimits;
105  double hpos; // the horizon of prediction for the future joint position;
106 
107  void computeFullJacobian(int varDofs, int nIDofs, Eigen::MatrixXd& fullJacobian) const;
108  void computeFullb(const Eigen::VectorXd& gpos, const Eigen::VectorXd& gvel, Eigen::VectorXd& fullb) const;
109 };
110 
111 
112 
113 
114 
115 
121 {
122  public:
123  typedef LinearFunction functionType_t; //< alias on the type of the mother class. Needed to duplicate the function tree.
124 
125  FullJointLimitFunction(const Model& model);
127 
128  protected:
129  virtual void updateb() const;
130 
131  private:
132  struct Pimpl;
133  boost::shared_ptr<Pimpl> pimpl;
134 };
135 
136 
137 
138 
139 
145 {
146  public:
147  typedef LinearFunction functionType_t; //< alias on the type of the mother class. Needed to duplicate the function tree.
148 
149  ReducedJointLimitFunction(const Model& model, const FullDynamicEquationFunction& dynamicEquation);
151 
152  protected:
153  virtual void updateJacobian() const;
154  virtual void updateb() const;
155 
156  private:
157  struct Pimpl;
158  boost::shared_ptr<Pimpl> pimpl;
159 
160  virtual void doUpdateInputSizeBegin();
161  virtual void doUpdateInputSizeEnd();
162 };
163 
164 
165 
166 
167 
168 
169 
170 
171 
172 
173 
174 
175 
177 {
178 public:
179  JointLimitConstraint(const Model& model, double hpos=.2);
180  JointLimitConstraint(const Model& model, const Eigen::VectorXd& lowerLimits, const Eigen::VectorXd& upperLimits, double hpos=.2);
181  virtual ~JointLimitConstraint() {};
182 
183  double getHorizonOfPrediction() const;
184  void setHorizonOfPrediction(double newHpos);
185 
186  void setJointLimits(const Eigen::VectorXd& lowerLimits, const Eigen::VectorXd& upperLimits);
187  void setJointLowerLimits(const Eigen::VectorXd& newLowerLimits);
188  void setJointUpperLimits(const Eigen::VectorXd& newUpperLimits);
189 
190  const Eigen::VectorXd& getJointLowerLimits() const;
191  const Eigen::VectorXd& getJointUpperLimits() const;
192 
193  void setJointLimit(int i, double newLowerLimit, double newUpperLimit);
194  void setJointLowerLimit(int i, double newLowerLimit);
195  void setJointUpperLimit(int i, double newUpperLimit);
196 
197  double getJointLowerLimit(int i) const;
198  double getJointUpperLimit(int i) const;
199 
200 protected:
201  virtual void connectToController(const FullDynamicEquationFunction& dynamicEquation, bool useReducedProblem);
202  virtual void disconnectFromController();
203 
204 
205 private:
206  JointLimitFunction* createFullJointLimitFunction(const Model& model);
207  JointLimitFunction* createReducedJointLimitFunction(const Model& model, const FullDynamicEquationFunction& dynamicEquation);
208 
209  JointLimitFunction* _jointLimitFunction;
210  const Model& _model;
211  bool _is_connected;
212 
213  double _hpos;
214  Eigen::VectorXd _lowerLimits;
215  Eigen::VectorXd _upperLimits;
216 };
217 
218 
219 
220 
221 
222 
223 
224  // end group constraint
226 
227 }
228 
229 
230 #endif
Create a linear function that represents the joint limit function for the reduced formalism...
virtual void doUpdateInputSizeEnd()
void setJointUpperLimit(int i, double newUpperLimit)
double getJointUpperLimit(int i) const
virtual void updateJacobian() const
void setJointLimit(int i, double newLowerLimit, double newUpperLimit)
JointLimitFunction(const Model &m, Variable &var)
double getJointLowerLimit(int i) const
virtual void updateb() const
void setJointLimits(const Eigen::VectorXd &lowerLimits, const Eigen::VectorXd &upperLimits)
void setHorizonOfPrediction(double newHpos)
const Eigen::VectorXd & getJointUpperLimits() const
Model class.
Definition: Model.h:38
LinearFunction class.
Optimization-based Robot Controller namespace. a library of classes to write and solve optimization p...
Create a linear function that represents the joint limit function.
Create a linear function that represents the joint limit function for the full formalism.
void computeFullb(const Eigen::VectorXd &gpos, const Eigen::VectorXd &gvel, Eigen::VectorXd &fullb) const
void setJointLowerLimit(int i, double newLowerLimit)
double getHorizonOfPrediction() const
void computeFullJacobian(int varDofs, int nIDofs, Eigen::MatrixXd &fullJacobian) const
This class represents a variable in a mathematical sense.
Definition: Variable.h:105
Create a linear function that represents the dynamic equation of motion.
const Eigen::VectorXd & getJointLowerLimits() const
void setJointUpperLimits(const Eigen::VectorXd &newUpperLimits)
virtual void doUpdateInputSizeBegin()
Definition: Function.cpp:93
Define base class that can be used as constraints in wOcra controller.
void setJointLowerLimits(const Eigen::VectorXd &newLowerLimits)