Directory: | ./ |
---|---|
File: | include/tsid/bindings/python/tasks/task-cop-equality.hpp |
Date: | 2024-11-10 01:12:44 |
Exec | Total | Coverage | |
---|---|---|---|
Lines: | 17 | 35 | 48.6% |
Branches: | 16 | 60 | 26.7% |
Line | Branch | Exec | Source |
---|---|---|---|
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 | |||
21 | #include "tsid/bindings/python/fwd.hpp" | ||
22 | |||
23 | #include "tsid/tasks/task-cop-equality.hpp" | ||
24 | #include "tsid/robots/robot-wrapper.hpp" | ||
25 | #include "tsid/trajectories/trajectory-base.hpp" | ||
26 | #include "tsid/math/constraint-equality.hpp" | ||
27 | #include "tsid/math/constraint-base.hpp" | ||
28 | namespace tsid { | ||
29 | namespace python { | ||
30 | namespace bp = boost::python; | ||
31 | |||
32 | template <typename TaskCOP> | ||
33 | struct TaskCOPEqualityPythonVisitor | ||
34 | : public boost::python::def_visitor< | ||
35 | TaskCOPEqualityPythonVisitor<TaskCOP> > { | ||
36 | template <class PyClass> | ||
37 | |||
38 | 7 | void visit(PyClass& cl) const { | |
39 |
3/6✓ Branch 1 taken 7 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 7 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 7 times.
✗ Branch 8 not taken.
|
7 | cl.def(bp::init<std::string, robots::RobotWrapper&>( |
40 |
1/2✓ Branch 2 taken 7 times.
✗ Branch 3 not taken.
|
14 | (bp::arg("name"), bp::arg("robot")), "Default Constructor")) |
41 | 14 | .add_property("dim", &TaskCOP::dim, "return dimension size") | |
42 |
2/4✓ Branch 1 taken 7 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 7 times.
✗ Branch 5 not taken.
|
14 | .def("setReference", &TaskCOPEqualityPythonVisitor::setReference, |
43 |
1/2✓ Branch 1 taken 7 times.
✗ Branch 2 not taken.
|
14 | bp::arg("ref")) |
44 |
1/2✓ Branch 1 taken 7 times.
✗ Branch 2 not taken.
|
7 | .def("setContactNormal", |
45 |
1/2✓ Branch 1 taken 7 times.
✗ Branch 2 not taken.
|
14 | &TaskCOPEqualityPythonVisitor::setContactNormal, bp::arg("normal")) |
46 |
2/4✓ Branch 1 taken 7 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 7 times.
✗ Branch 5 not taken.
|
14 | .def("compute", &TaskCOPEqualityPythonVisitor::compute, |
47 | bp::args("t", "q", "v", "data")) | ||
48 |
1/2✓ Branch 1 taken 7 times.
✗ Branch 2 not taken.
|
7 | .def("getConstraint", &TaskCOPEqualityPythonVisitor::getConstraint) |
49 |
1/2✓ Branch 1 taken 7 times.
✗ Branch 2 not taken.
|
7 | .add_property("name", &TaskCOPEqualityPythonVisitor::name); |
50 | 7 | } | |
51 | ✗ | static std::string name(TaskCOP& self) { | |
52 | ✗ | std::string name = self.name(); | |
53 | ✗ | return name; | |
54 | } | ||
55 | ✗ | static math::ConstraintEquality compute(TaskCOP& self, const double t, | |
56 | const Eigen::VectorXd& q, | ||
57 | const Eigen::VectorXd& v, | ||
58 | pinocchio::Data& data) { | ||
59 | ✗ | self.compute(t, q, v, data); | |
60 | ✗ | math::ConstraintEquality cons(self.getConstraint().name(), | |
61 | ✗ | self.getConstraint().matrix(), | |
62 | ✗ | self.getConstraint().vector()); | |
63 | ✗ | return cons; | |
64 | } | ||
65 | ✗ | static math::ConstraintEquality getConstraint(const TaskCOP& self) { | |
66 | ✗ | math::ConstraintEquality cons(self.getConstraint().name(), | |
67 | ✗ | self.getConstraint().matrix(), | |
68 | ✗ | self.getConstraint().vector()); | |
69 | ✗ | return cons; | |
70 | } | ||
71 | ✗ | static void setReference(TaskCOP& self, const Eigen::Vector3d& ref) { | |
72 | ✗ | self.setReference(ref); | |
73 | } | ||
74 | ✗ | static void setContactNormal(TaskCOP& self, const Eigen::Vector3d& n) { | |
75 | ✗ | self.setContactNormal(n); | |
76 | } | ||
77 | 7 | static void expose(const std::string& class_name) { | |
78 |
1/2✓ Branch 2 taken 7 times.
✗ Branch 3 not taken.
|
7 | std::string doc = "TaskCOPEqualityPythonVisitor info."; |
79 |
1/2✓ Branch 3 taken 7 times.
✗ Branch 4 not taken.
|
7 | bp::class_<TaskCOP>(class_name.c_str(), doc.c_str(), bp::no_init) |
80 |
1/2✓ Branch 1 taken 7 times.
✗ Branch 2 not taken.
|
7 | .def(TaskCOPEqualityPythonVisitor<TaskCOP>()); |
81 | 7 | } | |
82 | }; | ||
83 | } // namespace python | ||
84 | } // namespace tsid | ||
85 | |||
86 | #endif // ifndef __tsid_python_task_cop_hpp__ | ||
87 |