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 |
|
|
#ifndef __tsid_python_task_actuation_bounds_hpp__ |
19 |
|
|
#define __tsid_python_task_actuation_bounds_hpp__ |
20 |
|
|
|
21 |
|
|
#include "tsid/bindings/python/fwd.hpp" |
22 |
|
|
|
23 |
|
|
#include "tsid/tasks/task-actuation-bounds.hpp" |
24 |
|
|
#include "tsid/robots/robot-wrapper.hpp" |
25 |
|
|
#include "tsid/math/constraint-inequality.hpp" |
26 |
|
|
#include "tsid/math/constraint-base.hpp" |
27 |
|
|
|
28 |
|
|
namespace tsid { |
29 |
|
|
namespace python { |
30 |
|
|
namespace bp = boost::python; |
31 |
|
|
|
32 |
|
|
template <typename Task> |
33 |
|
|
struct TaskActuationBoundsPythonVisitor |
34 |
|
|
: public boost::python::def_visitor< |
35 |
|
|
TaskActuationBoundsPythonVisitor<Task> > { |
36 |
|
|
template <class PyClass> |
37 |
|
|
|
38 |
|
7 |
void visit(PyClass& cl) const { |
39 |
|
7 |
cl.def(bp::init<std::string, robots::RobotWrapper&>( |
40 |
|
|
(bp::arg("name"), bp::arg("robot")), "Default Constructor")) |
41 |
✓✗✓✗ ✓✗✓✗
|
14 |
.add_property("dim", &Task::dim, "return dimension size") |
42 |
|
14 |
.add_property("mask", |
43 |
|
|
bp::make_function( |
44 |
|
|
&TaskActuationBoundsPythonVisitor::getmask, |
45 |
|
|
bp::return_value_policy<bp::copy_const_reference>()), |
46 |
|
|
"Return mask") |
47 |
✓✗✓✗ ✓✗ |
14 |
.def("setMask", &TaskActuationBoundsPythonVisitor::setmask, |
48 |
|
|
bp::arg("mask")) |
49 |
✓✗✓✗
|
14 |
.def("setBounds", &TaskActuationBoundsPythonVisitor::setBounds, |
50 |
|
|
bp::args("lower", "upper")) |
51 |
✓✗✓✗
|
14 |
.def("compute", &TaskActuationBoundsPythonVisitor::compute, |
52 |
|
|
bp::args("t", "q", "v", "data")) |
53 |
✓✗✓✗
|
14 |
.def("getConstraint", &TaskActuationBoundsPythonVisitor::getConstraint) |
54 |
✓✗ |
7 |
.add_property("getLowerBounds", |
55 |
|
|
bp::make_function( |
56 |
|
|
&TaskActuationBoundsPythonVisitor::getLowerBounds, |
57 |
|
|
bp::return_value_policy<bp::copy_const_reference>())) |
58 |
✓✗✓✗
|
14 |
.add_property("getUpperBounds", |
59 |
|
|
bp::make_function( |
60 |
|
|
&TaskActuationBoundsPythonVisitor::getUpperBounds, |
61 |
|
|
bp::return_value_policy<bp::copy_const_reference>())) |
62 |
✓✗✓✗ ✓✗ |
7 |
.add_property("name", &TaskActuationBoundsPythonVisitor::name); |
63 |
|
7 |
} |
64 |
|
|
static std::string name(Task& self) { |
65 |
|
|
std::string name = self.name(); |
66 |
|
|
return name; |
67 |
|
|
} |
68 |
|
|
static math::ConstraintInequality compute(Task& self, const double t, |
69 |
|
|
const Eigen::VectorXd& q, |
70 |
|
|
const Eigen::VectorXd& v, |
71 |
|
|
pinocchio::Data& data) { |
72 |
|
|
self.compute(t, q, v, data); |
73 |
|
|
math::ConstraintInequality cons( |
74 |
|
|
self.getConstraint().name(), self.getConstraint().matrix(), |
75 |
|
|
self.getConstraint().lowerBound(), self.getConstraint().upperBound()); |
76 |
|
|
return cons; |
77 |
|
|
} |
78 |
|
|
static math::ConstraintInequality getConstraint(const Task& self) { |
79 |
|
|
math::ConstraintInequality cons( |
80 |
|
|
self.getConstraint().name(), self.getConstraint().matrix(), |
81 |
|
|
self.getConstraint().lowerBound(), self.getConstraint().upperBound()); |
82 |
|
|
return cons; |
83 |
|
|
} |
84 |
|
|
static const Eigen::VectorXd& getmask(const Task& self) { |
85 |
|
|
return self.mask(); |
86 |
|
|
} |
87 |
|
|
static void setmask(Task& self, const Eigen::VectorXd mask) { |
88 |
|
|
return self.mask(mask); |
89 |
|
|
} |
90 |
|
|
static const Eigen::VectorXd& getLowerBounds(const Task& self) { |
91 |
|
|
return self.getLowerBounds(); |
92 |
|
|
} |
93 |
|
|
static const Eigen::VectorXd& getUpperBounds(const Task& self) { |
94 |
|
|
return self.getUpperBounds(); |
95 |
|
|
} |
96 |
|
|
static void setBounds(Task& self, const Eigen::VectorXd lower, |
97 |
|
|
const Eigen::VectorXd upper) { |
98 |
|
|
return self.setBounds(lower, upper); |
99 |
|
|
} |
100 |
|
7 |
static void expose(const std::string& class_name) { |
101 |
✓✗ |
7 |
std::string doc = "Task info."; |
102 |
✓✗✓✗
|
7 |
bp::class_<Task>(class_name.c_str(), doc.c_str(), bp::no_init) |
103 |
|
|
.def(TaskActuationBoundsPythonVisitor<Task>()); |
104 |
|
7 |
} |
105 |
|
|
}; |
106 |
|
|
} // namespace python |
107 |
|
|
} // namespace tsid |
108 |
|
|
|
109 |
|
|
#endif // ifndef __tsid_python_task_actuation_bounds_hpp__ |