ORCA: Optimization-based framework for Robotic Control Applications
GenericConstraint.h
Go to the documentation of this file.
1 //| This file is a part of the ORCA framework.
2 //|
3 //| Copyright 2018, Fuzzy Logic Robotics
4 //| Copyright 2017, ISIR / Universite Pierre et Marie Curie (UPMC)
5 //|
6 //| Main contributor(s): Antoine Hoarau, Ryan Lober, and
7 //| Fuzzy Logic Robotics <info@fuzzylogicrobotics.com>
8 //|
9 //| ORCA is a whole-body reactive controller framework for robotics.
10 //|
11 //| This software is governed by the CeCILL-C license under French law and
12 //| abiding by the rules of distribution of free software. You can use,
13 //| modify and/ or redistribute the software under the terms of the CeCILL-C
14 //| license as circulated by CEA, CNRS and INRIA at the following URL
15 //| "http://www.cecill.info".
16 //|
17 //| As a counterpart to the access to the source code and rights to copy,
18 //| modify and redistribute granted by the license, users are provided only
19 //| with a limited warranty and the software's author, the holder of the
20 //| economic rights, and the successive licensors have only limited
21 //| liability.
22 //|
23 //| In this respect, the user's attention is drawn to the risks associated
24 //| with loading, using, modifying and/or developing or reproducing the
25 //| software by the user in light of its specific status of free software,
26 //| that may mean that it is complicated to manipulate, and that also
27 //| therefore means that it is reserved for developers and experienced
28 //| professionals having in-depth computer knowledge. Users are therefore
29 //| encouraged to load and test the software's suitability as regards their
30 //| requirements in conditions enabling the security of their systems and/or
31 //| data to be ensured and, more generally, to use and operate it in the
32 //| same conditions as regards security.
33 //|
34 //| The fact that you are presently reading this means that you have had
35 //| knowledge of the CeCILL-C license and that you accept its terms.
36 
37 
38 #pragma once
39 #include "orca/utils/Utils.h"
40 #include "orca/robot/RobotModel.h"
42 #include "orca/common/TaskBase.h"
43 
44 namespace orca
45 {
46 namespace constraint
47 {
48 
56 {
57 public:
58  using Ptr = std::shared_ptr<GenericConstraint>;
66  GenericConstraint(const std::string& name,optim::ControlVariable control_var);
67 
72  virtual ~GenericConstraint();
73 
74  virtual void print() const;
75 
81  math::Size getSize() const;
82 
88  int rows() const;
89 
95  int cols() const;
96 
102  virtual const Eigen::VectorXd& getLowerBound() const;
103 
109  virtual const Eigen::VectorXd& getUpperBound() const;
110 
116  virtual const Eigen::MatrixXd& getConstraintMatrix() const;
117 
124 
125 protected:
126  virtual void onResize() = 0;
127  virtual void onCompute(double current_time, double dt);
128  virtual void onUpdateConstraintFunction(double current_time, double dt) = 0;
134  void setConstraintMatrix(const Eigen::MatrixXd& newC);
135 
141  void setLowerBound(const Eigen::VectorXd& low);
142 
148  void setUpperBound(const Eigen::VectorXd& up);
149 
155  Eigen::MatrixXd& constraintMatrix();
156  Eigen::VectorXd& upperBound();
157  Eigen::VectorXd& lowerBound();
158 
165 
166 private:
167  math::ConstraintFunction constraint_function_;
168 };
169 
170 }
171 }
virtual ~GenericConstraint()
Destructor. Also removes from problem if still active/inserted.
Definition: GenericConstraint.cc:14
virtual const Eigen::VectorXd & getUpperBound() const
Returns the upperbound from the constraint function (alias)
Definition: GenericConstraint.cc:45
int rows() const
Get the number of rows of the constraint matrix.
Definition: GenericConstraint.cc:30
virtual const Eigen::MatrixXd & getConstraintMatrix() const
Returns the constraint matrix from the constraint function (alias)
Definition: GenericConstraint.cc:50
math::ConstraintFunction & constraintFunction()
Get a reference the underlying constraint function containing the 2 bound vectors and the constraint ...
Definition: GenericConstraint.cc:85
virtual void onCompute(double current_time, double dt)
Definition: GenericConstraint.cc:95
std::shared_ptr< ConfigurableOrcaObject > Ptr
Definition: ConfigurableOrcaObject.h:17
Definition: ConstraintFunction.h:48
math::Size getSize() const
Get the size of the constraint matrix (rows,cols)
Definition: GenericConstraint.cc:25
virtual const Eigen::VectorXd & getLowerBound() const
Returns the lower bound from the constraint function (alias)
Definition: GenericConstraint.cc:40
Eigen::VectorXd & lowerBound()
Definition: GenericConstraint.cc:80
GenericConstraint(const std::string &name, optim::ControlVariable control_var)
Construct the double bounded function, and set its default state : activated. The lowerBound is set t...
Definition: GenericConstraint.cc:8
void setUpperBound(const Eigen::VectorXd &up)
Replace the upper bound with a new one.
Definition: GenericConstraint.cc:65
virtual void onUpdateConstraintFunction(double current_time, double dt)=0
Builds a double bounded function : l < C.x < u With x the control variable, l = lowerBound, u = upperBound, and C the constraint matrix.
Definition: GenericConstraint.h:55
Eigen::MatrixXd & constraintMatrix()
Returns a reference to the constraint matrix from the constraint function (alias) ...
Definition: GenericConstraint.cc:70
int cols() const
Get the number of column (it should be the size of the control variable chosen) of the constraint mat...
Definition: GenericConstraint.cc:35
Definition: CartesianAccelerationPID.h:44
ControlVariable
Definition: ControlVariable.h:44
Eigen::VectorXd & upperBound()
Definition: GenericConstraint.cc:75
void setConstraintMatrix(const Eigen::MatrixXd &newC)
Replace the constraint matrix with a new one.
Definition: GenericConstraint.cc:55
Definition: Utils.h:105
virtual void print() const
Definition: GenericConstraint.cc:19
The common base class for tasks and constraints.
Definition: TaskBase.h:59
void setLowerBound(const Eigen::VectorXd &low)
Replace the lower bound with a new one.
Definition: GenericConstraint.cc:60
const math::ConstraintFunction & getConstraintFunction() const
Get the underlying constraint function containing the 2 bound vectors and the constraint matrix...
Definition: GenericConstraint.cc:90