| Line |
Branch |
Exec |
Source |
| 1 |
|
|
// |
| 2 |
|
|
// Copyright (c) 2017 CNRS |
| 3 |
|
|
// |
| 4 |
|
|
// This file is part of tsid |
| 5 |
|
|
// tsid is free software: you can redistribute it |
| 6 |
|
|
// and/or modify it under the terms of the GNU Lesser General Public |
| 7 |
|
|
// License as published by the Free Software Foundation, either version |
| 8 |
|
|
// 3 of the License, or (at your option) any later version. |
| 9 |
|
|
// tsid is distributed in the hope that it will be |
| 10 |
|
|
// useful, but WITHOUT ANY WARRANTY; without even the implied warranty |
| 11 |
|
|
// of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 12 |
|
|
// General Lesser Public License for more details. You should have |
| 13 |
|
|
// received a copy of the GNU Lesser General Public License along with |
| 14 |
|
|
// tsid If not, see |
| 15 |
|
|
// <http://www.gnu.org/licenses/>. |
| 16 |
|
|
// |
| 17 |
|
|
|
| 18 |
|
|
#ifndef __invdyn_math_constraint_base_hpp__ |
| 19 |
|
|
#define __invdyn_math_constraint_base_hpp__ |
| 20 |
|
|
|
| 21 |
|
|
#include "tsid/math/fwd.hpp" |
| 22 |
|
|
#include <string> |
| 23 |
|
|
#include <pinocchio/macros.hpp> |
| 24 |
|
|
|
| 25 |
|
|
namespace tsid { |
| 26 |
|
|
namespace math { |
| 27 |
|
|
|
| 28 |
|
|
/** |
| 29 |
|
|
* @brief Abstract class representing a linear equality/inequality constraint. |
| 30 |
|
|
* Equality constraints are represented by a matrix A and a vector b: A*x = b |
| 31 |
|
|
* Inequality constraints are represented by a matrix A and two vectors |
| 32 |
|
|
* lb and ub: lb <= A*x <= ub |
| 33 |
|
|
* Bounds are represented by two vectors lb and ub: lb <= x <= ub |
| 34 |
|
|
*/ |
| 35 |
|
|
class ConstraintBase { |
| 36 |
|
|
public: |
| 37 |
|
|
EIGEN_MAKE_ALIGNED_OPERATOR_NEW |
| 38 |
|
|
|
| 39 |
|
|
ConstraintBase(const std::string& name); |
| 40 |
|
|
|
| 41 |
|
|
ConstraintBase(const std::string& name, const unsigned int rows, |
| 42 |
|
|
const unsigned int cols); |
| 43 |
|
|
|
| 44 |
|
|
ConstraintBase(const std::string& name, ConstRefMatrix A); |
| 45 |
|
20078 |
virtual ~ConstraintBase() = default; |
| 46 |
|
|
|
| 47 |
|
|
virtual const std::string& name() const; |
| 48 |
|
|
virtual unsigned int rows() const = 0; |
| 49 |
|
|
virtual unsigned int cols() const = 0; |
| 50 |
|
|
virtual void resize(const unsigned int r, const unsigned int c) = 0; |
| 51 |
|
|
|
| 52 |
|
|
virtual bool isEquality() const = 0; |
| 53 |
|
|
virtual bool isInequality() const = 0; |
| 54 |
|
|
virtual bool isBound() const = 0; |
| 55 |
|
|
|
| 56 |
|
|
virtual const Matrix& matrix() const; |
| 57 |
|
|
virtual const Vector& vector() const = 0; |
| 58 |
|
|
virtual const Vector& lowerBound() const = 0; |
| 59 |
|
|
virtual const Vector& upperBound() const = 0; |
| 60 |
|
|
|
| 61 |
|
|
virtual Matrix& matrix(); |
| 62 |
|
|
virtual Vector& vector() = 0; |
| 63 |
|
|
virtual Vector& lowerBound() = 0; |
| 64 |
|
|
virtual Vector& upperBound() = 0; |
| 65 |
|
|
|
| 66 |
|
|
virtual bool setMatrix(ConstRefMatrix A); |
| 67 |
|
|
virtual bool setVector(ConstRefVector b) = 0; |
| 68 |
|
|
virtual bool setLowerBound(ConstRefVector lb) = 0; |
| 69 |
|
|
virtual bool setUpperBound(ConstRefVector ub) = 0; |
| 70 |
|
|
|
| 71 |
|
|
virtual bool checkConstraint(ConstRefVector x, double tol = 1e-6) const = 0; |
| 72 |
|
|
|
| 73 |
|
|
protected: |
| 74 |
|
|
std::string m_name; |
| 75 |
|
|
Matrix m_A; |
| 76 |
|
|
}; |
| 77 |
|
|
|
| 78 |
|
|
} // namespace math |
| 79 |
|
|
} // namespace tsid |
| 80 |
|
|
|
| 81 |
|
|
#endif // ifndef __invdyn_math_constraint_base_hpp__ |
| 82 |
|
|
|