task-cop-equality.hpp
Go to the documentation of this file.
1 //
2 // Copyright (c) 2021 University of Trento
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 __tsid_python_task_cop_hpp__
19 #define __tsid_python_task_cop_hpp__
20 
22 
28 namespace tsid
29 {
30  namespace python
31  {
32  namespace bp = boost::python;
33 
34  template<typename TaskCOP>
36  : public boost::python::def_visitor< TaskCOPEqualityPythonVisitor<TaskCOP> >
37  {
38 
39  template<class PyClass>
40 
41 
42  void visit(PyClass& cl) const
43  {
44  cl
45  .def(bp::init<std::string, robots::RobotWrapper &> ((bp::arg("name"), bp::arg("robot")), "Default Constructor"))
46  .add_property("dim", &TaskCOP::dim, "return dimension size")
47  .def("setReference", &TaskCOPEqualityPythonVisitor::setReference, bp::arg("ref"))
48  .def("setContactNormal", &TaskCOPEqualityPythonVisitor::setContactNormal, bp::arg("normal"))
49  .def("compute", &TaskCOPEqualityPythonVisitor::compute, bp::args("t", "q", "v", "data"))
50  .def("getConstraint", &TaskCOPEqualityPythonVisitor::getConstraint)
51  .add_property("name", &TaskCOPEqualityPythonVisitor::name)
52  ;
53  }
54  static std::string name(TaskCOP & self){
55  std::string name = self.name();
56  return name;
57  }
58  static math::ConstraintEquality compute(TaskCOP & self, const double t, const Eigen::VectorXd & q, const Eigen::VectorXd & v, pinocchio::Data & data){
59  self.compute(t, q, v, data);
60  math::ConstraintEquality cons(self.getConstraint().name(), self.getConstraint().matrix(), self.getConstraint().vector());
61  return cons;
62  }
63  static math::ConstraintEquality getConstraint(const TaskCOP & self){
64  math::ConstraintEquality cons(self.getConstraint().name(), self.getConstraint().matrix(), self.getConstraint().vector());
65  return cons;
66  }
67  static void setReference(TaskCOP & self, const Eigen::Vector3d & ref){
68  self.setReference(ref);
69  }
70  static void setContactNormal(TaskCOP & self, const Eigen::Vector3d & n){
71  self.setContactNormal(n);
72  }
73  static void expose(const std::string & class_name)
74  {
75  std::string doc = "TaskCOPEqualityPythonVisitor info.";
76  bp::class_<TaskCOP>(class_name.c_str(),
77  doc.c_str(),
78  bp::no_init)
80  }
81  };
82  }
83 }
84 
85 
86 #endif // ifndef __tsid_python_task_cop_hpp__
Definition: constraint-equality.hpp:28
static std::string name(TaskCOP &self)
Definition: task-cop-equality.hpp:54
static void expose(const std::string &class_name)
Definition: task-cop-equality.hpp:73
Definition: task-cop-equality.hpp:35
void visit(PyClass &cl) const
Definition: task-cop-equality.hpp:42
static void setContactNormal(TaskCOP &self, const Eigen::Vector3d &n)
Definition: task-cop-equality.hpp:70
static void setReference(TaskCOP &self, const Eigen::Vector3d &ref)
Definition: task-cop-equality.hpp:67
static math::ConstraintEquality compute(TaskCOP &self, const double t, const Eigen::VectorXd &q, const Eigen::VectorXd &v, pinocchio::Data &data)
Definition: task-cop-equality.hpp:58
Definition: constraint-bound.hpp:26
static math::ConstraintEquality getConstraint(const TaskCOP &self)
Definition: task-cop-equality.hpp:63
pinocchio::Data Data
Definition: inverse-dynamics-formulation-acc-force.cpp:29