Directory: | ./ |
---|---|
File: | include/tsid/bindings/python/tasks/task-two-frames-equality.hpp |
Date: | 2024-11-10 01:12:44 |
Exec | Total | Coverage | |
---|---|---|---|
Lines: | 34 | 65 | 52.3% |
Branches: | 38 | 112 | 33.9% |
Line | Branch | Exec | Source |
---|---|---|---|
1 | // | ||
2 | // Copyright (c) 2023 MIPT | ||
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_frames_hpp__ | ||
19 | #define __tsid_python_task_frames_hpp__ | ||
20 | |||
21 | #include "tsid/bindings/python/fwd.hpp" | ||
22 | |||
23 | #include "tsid/tasks/task-two-frames-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 TaskFrames> | ||
33 | struct TaskTwoFramesEqualityPythonVisitor | ||
34 | : public boost::python::def_visitor< | ||
35 | TaskTwoFramesEqualityPythonVisitor<TaskFrames> > { | ||
36 | template <class PyClass> | ||
37 | |||
38 | 7 | void visit(PyClass& cl) const { | |
39 |
5/10✓ 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.
✓ Branch 10 taken 7 times.
✗ Branch 11 not taken.
✓ Branch 13 taken 7 times.
✗ Branch 14 not taken.
|
21 | cl.def(bp::init<std::string, robots::RobotWrapper&, std::string, |
40 |
1/2✓ Branch 2 taken 7 times.
✗ Branch 3 not taken.
|
14 | std::string>((bp::arg("name"), bp::arg("robot"), |
41 |
2/4✓ Branch 1 taken 7 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 7 times.
✗ Branch 5 not taken.
|
21 | bp::arg("framename1"), bp::arg("framename2")), |
42 | "Default Constructor")) | ||
43 | 14 | .add_property("dim", &TaskFrames::dim, "return dimension size") | |
44 |
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 | .add_property( |
45 | "getDesiredAcceleration", | ||
46 | bp::make_function( | ||
47 | &TaskTwoFramesEqualityPythonVisitor::getDesiredAcceleration, | ||
48 | 7 | bp::return_value_policy<bp::copy_const_reference>()), | |
49 | "Return Acc_desired") | ||
50 |
1/2✓ Branch 1 taken 7 times.
✗ Branch 2 not taken.
|
7 | .def("getAcceleration", |
51 | &TaskTwoFramesEqualityPythonVisitor::getAcceleration, | ||
52 |
1/2✓ Branch 1 taken 7 times.
✗ Branch 2 not taken.
|
14 | bp::arg("dv")) |
53 |
2/4✓ Branch 1 taken 7 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 7 times.
✗ Branch 5 not taken.
|
7 | .add_property("position_error", |
54 | bp::make_function( | ||
55 | &TaskTwoFramesEqualityPythonVisitor::position_error, | ||
56 | 7 | bp::return_value_policy<bp::copy_const_reference>())) | |
57 |
2/4✓ Branch 1 taken 7 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 7 times.
✗ Branch 5 not taken.
|
7 | .add_property("velocity_error", |
58 | bp::make_function( | ||
59 | &TaskTwoFramesEqualityPythonVisitor::velocity_error, | ||
60 | 7 | bp::return_value_policy<bp::copy_const_reference>())) | |
61 |
2/4✓ Branch 1 taken 7 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 7 times.
✗ Branch 5 not taken.
|
7 | .add_property("Kp", |
62 | bp::make_function( | ||
63 | &TaskTwoFramesEqualityPythonVisitor::Kp, | ||
64 | 7 | bp::return_value_policy<bp::copy_const_reference>())) | |
65 |
2/4✓ Branch 1 taken 7 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 7 times.
✗ Branch 5 not taken.
|
7 | .add_property("Kd", |
66 | bp::make_function( | ||
67 | &TaskTwoFramesEqualityPythonVisitor::Kd, | ||
68 | 7 | bp::return_value_policy<bp::copy_const_reference>())) | |
69 |
2/4✓ Branch 1 taken 7 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 7 times.
✗ Branch 5 not taken.
|
14 | .def("setKp", &TaskTwoFramesEqualityPythonVisitor::setKp, bp::arg("Kp")) |
70 |
2/4✓ Branch 1 taken 7 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 7 times.
✗ Branch 5 not taken.
|
14 | .def("setKd", &TaskTwoFramesEqualityPythonVisitor::setKd, bp::arg("Kd")) |
71 |
2/4✓ Branch 1 taken 7 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 7 times.
✗ Branch 5 not taken.
|
7 | .add_property("mask", |
72 | bp::make_function( | ||
73 | &TaskTwoFramesEqualityPythonVisitor::getMask, | ||
74 | 7 | bp::return_value_policy<bp::copy_const_reference>()), | |
75 | "Return mask") | ||
76 |
1/2✓ Branch 1 taken 7 times.
✗ Branch 2 not taken.
|
7 | .def("setMask", &TaskTwoFramesEqualityPythonVisitor::setMask, |
77 |
1/2✓ Branch 1 taken 7 times.
✗ Branch 2 not taken.
|
14 | bp::arg("mask")) |
78 |
2/4✓ Branch 1 taken 7 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 7 times.
✗ Branch 5 not taken.
|
14 | .def("compute", &TaskTwoFramesEqualityPythonVisitor::compute, |
79 | bp::args("t", "q", "v", "data")) | ||
80 |
1/2✓ Branch 1 taken 7 times.
✗ Branch 2 not taken.
|
7 | .def("getConstraint", |
81 | &TaskTwoFramesEqualityPythonVisitor::getConstraint) | ||
82 | 14 | .add_property("frame_id1", &TaskFrames::frame_id1, "frame id 1 return") | |
83 |
1/2✓ Branch 1 taken 7 times.
✗ Branch 2 not taken.
|
7 | .add_property("frame_id2", &TaskFrames::frame_id2, "frame id 2 return") |
84 |
2/4✓ Branch 1 taken 7 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 7 times.
✗ Branch 5 not taken.
|
7 | .add_property("name", &TaskTwoFramesEqualityPythonVisitor::name); |
85 | 7 | } | |
86 | ✗ | static std::string name(TaskFrames& self) { | |
87 | ✗ | std::string name = self.name(); | |
88 | ✗ | return name; | |
89 | } | ||
90 | ✗ | static math::ConstraintEquality compute(TaskFrames& self, const double t, | |
91 | const Eigen::VectorXd& q, | ||
92 | const Eigen::VectorXd& v, | ||
93 | pinocchio::Data& data) { | ||
94 | ✗ | self.compute(t, q, v, data); | |
95 | ✗ | math::ConstraintEquality cons(self.getConstraint().name(), | |
96 | ✗ | self.getConstraint().matrix(), | |
97 | ✗ | self.getConstraint().vector()); | |
98 | ✗ | return cons; | |
99 | } | ||
100 | ✗ | static math::ConstraintEquality getConstraint(const TaskFrames& self) { | |
101 | ✗ | math::ConstraintEquality cons(self.getConstraint().name(), | |
102 | ✗ | self.getConstraint().matrix(), | |
103 | ✗ | self.getConstraint().vector()); | |
104 | ✗ | return cons; | |
105 | } | ||
106 | ✗ | static const Eigen::VectorXd& getDesiredAcceleration(const TaskFrames& self) { | |
107 | ✗ | return self.getDesiredAcceleration(); | |
108 | } | ||
109 | ✗ | static Eigen::VectorXd getAcceleration(TaskFrames& self, | |
110 | const Eigen::VectorXd dv) { | ||
111 | ✗ | return self.getAcceleration(dv); | |
112 | } | ||
113 | ✗ | static const Eigen::VectorXd& position_error(const TaskFrames& self) { | |
114 | ✗ | return self.position_error(); | |
115 | } | ||
116 | ✗ | static const Eigen::VectorXd& velocity_error(const TaskFrames& self) { | |
117 | ✗ | return self.velocity_error(); | |
118 | } | ||
119 | ✗ | static const Eigen::VectorXd& Kp(TaskFrames& self) { return self.Kp(); } | |
120 | ✗ | static const Eigen::VectorXd& Kd(TaskFrames& self) { return self.Kd(); } | |
121 | ✗ | static void setKp(TaskFrames& self, const ::Eigen::VectorXd Kp) { | |
122 | ✗ | return self.Kp(Kp); | |
123 | } | ||
124 | ✗ | static void setKd(TaskFrames& self, const ::Eigen::VectorXd Kv) { | |
125 | ✗ | return self.Kd(Kv); | |
126 | } | ||
127 | ✗ | static void getMask(TaskFrames& self) { self.getMask(); } | |
128 | ✗ | static void setMask(TaskFrames& self, const ::Eigen::VectorXd mask) { | |
129 | ✗ | self.setMask(mask); | |
130 | } | ||
131 | static Eigen::VectorXd frame_id1(TaskFrames& self) { | ||
132 | return self.frame_id1(); | ||
133 | } | ||
134 | static Eigen::VectorXd frame_id2(TaskFrames& self) { | ||
135 | return self.frame_id2(); | ||
136 | } | ||
137 | |||
138 | 7 | static void expose(const std::string& class_name) { | |
139 |
1/2✓ Branch 2 taken 7 times.
✗ Branch 3 not taken.
|
7 | std::string doc = "TaskFrames info."; |
140 |
1/2✓ Branch 3 taken 7 times.
✗ Branch 4 not taken.
|
7 | bp::class_<TaskFrames>(class_name.c_str(), doc.c_str(), bp::no_init) |
141 |
1/2✓ Branch 1 taken 7 times.
✗ Branch 2 not taken.
|
7 | .def(TaskTwoFramesEqualityPythonVisitor<TaskFrames>()); |
142 | |||
143 | // bp::register_ptr_to_python< boost::shared_ptr<math::ConstraintBase> >(); | ||
144 | 7 | } | |
145 | }; | ||
146 | } // namespace python | ||
147 | } // namespace tsid | ||
148 | |||
149 | #endif // ifndef __tsid_python_task_frames_hpp__ | ||
150 |