constraint-equality.hpp
Go to the documentation of this file.
1 //
2 // Copyright (c) 2018 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 
19 #ifndef __tsid_python_constriant_equality_hpp__
20 #define __tsid_python_constriant_equality_hpp__
21 
23 
25 
26 namespace tsid
27 {
28  namespace python
29  {
30  namespace bp = boost::python;
31 
32  template<typename ConstraintEquality>
34  : public boost::python::def_visitor< ConstraintEqPythonVisitor<ConstraintEquality> >
35  {
36  template<class PyClass>
37 
38  void visit(PyClass& cl) const
39  {
40  cl
41  .def(bp::init<std::string>((bp::arg("name")), "Default constructor with name."))
42  .def(bp::init<std::string, unsigned int, unsigned int>((bp::arg("name"), bp::arg("row"), bp::arg("col")), "Default constructor with name and size."))
43  .def(bp::init<std::string, Eigen::MatrixXd, Eigen::VectorXd>((bp::arg("name"), bp::arg("A"), bp::arg("b")), "Default constructor with name and constraint."))
44 
45  .add_property("rows", &ConstraintEquality::rows)
46  .add_property("cols", &ConstraintEquality::cols)
47  .def("resize",&ConstraintEquality::resize, (bp::arg("r"), bp::arg("c")),"Resize constraint size.")
48 
49  .add_property("isEquality", &ConstraintEquality::isEquality)
50  .add_property("isInequality", &ConstraintEquality::isInequality)
51  .add_property("isBound", &ConstraintEquality::isBound)
52 
53  .add_property("matrix", &ConstraintEqPythonVisitor::matrix)
54  .add_property("vector", &ConstraintEqPythonVisitor::vector)
55  .add_property("lowerBound", &ConstraintEqPythonVisitor::lowerBound)
56  .add_property("upperBound", &ConstraintEqPythonVisitor::upperBound)
57 
58  .def("setMatrix", (bool (ConstraintEquality::*)(const Eigen::MatrixXd &) const) &ConstraintEquality::setMatrix, bp::args("matrix"), "Set Matrix")
59  .def("setVector", (bool (ConstraintEquality::*)(const Eigen::VectorXd &) const) &ConstraintEquality::setVector, bp::args("vector"), "Set Vector")
60  .def("setLowerBound", (bool (ConstraintEquality::*)(const Eigen::VectorXd &) const) &ConstraintEquality::setLowerBound, bp::args("lb"), "Set LowerBound")
61  .def("setUpperBound", (bool (ConstraintEquality::*)(const Eigen::VectorXd &) const) &ConstraintEquality::setUpperBound, bp::args("ub"), "Set UpperBound")
62 
63  ;
64  }
65  static Eigen::MatrixXd matrix (const ConstraintEquality & self) {return self.matrix();}
66  static Eigen::VectorXd vector (const ConstraintEquality & self) {return self.vector();}
67  static Eigen::VectorXd lowerBound (const ConstraintEquality & self) {return self.lowerBound();}
68  static Eigen::VectorXd upperBound (const ConstraintEquality & self) {return self.upperBound();}
69 
70  static void expose(const std::string & class_name)
71  {
72  std::string doc = "Constraint Equality info.";
73  bp::class_<ConstraintEquality>(class_name.c_str(),
74  doc.c_str(),
75  bp::no_init)
77 
78  eigenpy::enableEigenPySpecific<Eigen::MatrixXd>();
79  }
80  };
81  }
82 }
83 
84 
85 #endif // ifndef __tsid_python_constriant_equality_hpp__
static Eigen::MatrixXd matrix(const ConstraintEquality &self)
Definition: constraint-equality.hpp:65
static Eigen::VectorXd upperBound(const ConstraintEquality &self)
Definition: constraint-equality.hpp:68
static void expose(const std::string &class_name)
Definition: constraint-equality.hpp:70
static Eigen::VectorXd lowerBound(const ConstraintEquality &self)
Definition: constraint-equality.hpp:67
static Eigen::VectorXd vector(const ConstraintEquality &self)
Definition: constraint-equality.hpp:66
Definition: constraint-equality.hpp:33
void visit(PyClass &cl) const
Definition: constraint-equality.hpp:38
Definition: constraint-bound.hpp:26