Directory: | ./ |
---|---|
File: | include/tsid/bindings/python/tasks/task-joint-posVelAcc-bounds.hpp |
Date: | 2024-11-10 01:12:44 |
Exec | Total | Coverage | |
---|---|---|---|
Lines: | 37 | 82 | 45.1% |
Branches: | 66 | 186 | 35.5% |
Line | Branch | Exec | Source |
---|---|---|---|
1 | // | ||
2 | // Copyright (c) 2022 INRIA | ||
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_joint_posVelAcc_bounds_hpp__ | ||
19 | #define __tsid_python_task_joint_posVelAcc_bounds_hpp__ | ||
20 | |||
21 | #include "tsid/bindings/python/fwd.hpp" | ||
22 | |||
23 | #include "tsid/tasks/task-joint-posVelAcc-bounds.hpp" | ||
24 | #include "tsid/robots/robot-wrapper.hpp" | ||
25 | #include "tsid/math/constraint-bound.hpp" | ||
26 | #include "tsid/math/constraint-base.hpp" | ||
27 | |||
28 | namespace tsid { | ||
29 | namespace python { | ||
30 | namespace bp = boost::python; | ||
31 | typedef math::ConstRefVector ConstRefVector; | ||
32 | |||
33 | template <typename Task> | ||
34 | struct TaskJointPosVelAccBoundsPythonVisitor | ||
35 | : public boost::python::def_visitor< | ||
36 | TaskJointPosVelAccBoundsPythonVisitor<Task>> { | ||
37 | template <class PyClass> | ||
38 | |||
39 | 7 | void visit(PyClass& cl) const { | |
40 |
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&, double, |
41 | bp::optional<bool>>( | ||
42 |
2/4✓ Branch 2 taken 7 times.
✗ Branch 3 not taken.
✓ Branch 5 taken 7 times.
✗ Branch 6 not taken.
|
21 | (bp::arg("name"), bp::arg("robot"), bp::arg("Time step"), |
43 |
1/2✓ Branch 1 taken 7 times.
✗ Branch 2 not taken.
|
14 | bp::arg("verbose")), |
44 | "Default Constructor")) | ||
45 | 14 | .add_property("dim", &Task::dim, "return dimension size") | |
46 |
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.
|
14 | .def("setTimeStep", &TaskJointPosVelAccBoundsPythonVisitor::setTimeStep, |
47 | bp::args("dt")) | ||
48 |
2/4✓ Branch 1 taken 7 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 7 times.
✗ Branch 5 not taken.
|
14 | .def("setPositionBounds", |
49 | &TaskJointPosVelAccBoundsPythonVisitor::setPositionBounds, | ||
50 | bp::args("lower", "upper")) | ||
51 |
2/4✓ Branch 1 taken 7 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 7 times.
✗ Branch 5 not taken.
|
14 | .def("setVelocityBounds", |
52 | &TaskJointPosVelAccBoundsPythonVisitor::setVelocityBounds, | ||
53 | bp::args("upper")) | ||
54 |
2/4✓ Branch 1 taken 7 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 7 times.
✗ Branch 5 not taken.
|
14 | .def("setAccelerationBounds", |
55 | &TaskJointPosVelAccBoundsPythonVisitor::setAccelerationBounds, | ||
56 | bp::args("upper")) | ||
57 |
2/4✓ Branch 1 taken 7 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 7 times.
✗ Branch 5 not taken.
|
14 | .def("compute", &TaskJointPosVelAccBoundsPythonVisitor::compute, |
58 | bp::args("t", "q", "v", "data")) | ||
59 |
1/2✓ Branch 1 taken 7 times.
✗ Branch 2 not taken.
|
7 | .def("getConstraint", |
60 | &TaskJointPosVelAccBoundsPythonVisitor::getConstraint) | ||
61 |
2/4✓ Branch 1 taken 7 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 7 times.
✗ Branch 5 not taken.
|
14 | .def("setVerbose", &TaskJointPosVelAccBoundsPythonVisitor::setVerbose, |
62 | bp::args("verbose")) | ||
63 |
2/4✓ Branch 1 taken 7 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 7 times.
✗ Branch 5 not taken.
|
14 | .def("setImposeBounds", |
64 | &TaskJointPosVelAccBoundsPythonVisitor::setImposeBounds, | ||
65 | bp::args("impose_position_bounds", "impose_velocity_bounds", | ||
66 | "impose_viability_bounds", "impose_acceleration_bounds")) | ||
67 |
2/4✓ Branch 1 taken 7 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 7 times.
✗ Branch 5 not taken.
|
14 | .def("isStateViable", |
68 | &TaskJointPosVelAccBoundsPythonVisitor::isStateViable, | ||
69 |
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 | (bp::arg("q"), bp::arg("dq"), bp::arg("verbose") = true)) |
70 |
2/4✓ Branch 1 taken 7 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 7 times.
✗ Branch 5 not taken.
|
14 | .def("computeAccLimitsFromPosLimits", |
71 | &TaskJointPosVelAccBoundsPythonVisitor:: | ||
72 | computeAccLimitsFromPosLimits, | ||
73 |
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 | (bp::arg("q"), bp::arg("dq"), bp::arg("verbose") = true)) |
74 |
2/4✓ Branch 1 taken 7 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 7 times.
✗ Branch 5 not taken.
|
14 | .def("computeAccLimitsFromViability", |
75 | &TaskJointPosVelAccBoundsPythonVisitor:: | ||
76 | computeAccLimitsFromViability, | ||
77 |
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 | (bp::arg("q"), bp::arg("dq"), bp::arg("verbose") = true)) |
78 |
2/4✓ Branch 1 taken 7 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 7 times.
✗ Branch 5 not taken.
|
14 | .def("computeAccLimits", |
79 | &TaskJointPosVelAccBoundsPythonVisitor::computeAccLimits, | ||
80 |
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 | (bp::arg("q"), bp::arg("dq"), bp::arg("verbose") = true)) |
81 |
2/4✓ Branch 1 taken 7 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 7 times.
✗ Branch 5 not taken.
|
14 | .def("setMask", &TaskJointPosVelAccBoundsPythonVisitor::setMask, |
82 | bp::args("mask")) | ||
83 |
2/4✓ Branch 1 taken 7 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 7 times.
✗ Branch 5 not taken.
|
7 | .add_property( |
84 | "getAccelerationBounds", | ||
85 | bp::make_function( | ||
86 | &TaskJointPosVelAccBoundsPythonVisitor::getAccelerationBounds, | ||
87 | 7 | bp::return_value_policy<bp::copy_const_reference>())) | |
88 |
2/4✓ Branch 1 taken 7 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 7 times.
✗ Branch 5 not taken.
|
7 | .add_property( |
89 | "getVelocityBounds", | ||
90 | bp::make_function( | ||
91 | &TaskJointPosVelAccBoundsPythonVisitor::getVelocityBounds, | ||
92 | 7 | bp::return_value_policy<bp::copy_const_reference>())) | |
93 |
2/4✓ Branch 1 taken 7 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 7 times.
✗ Branch 5 not taken.
|
7 | .add_property( |
94 | "getPositionLowerBounds", | ||
95 | bp::make_function( | ||
96 | &TaskJointPosVelAccBoundsPythonVisitor::getPositionLowerBounds, | ||
97 | 7 | bp::return_value_policy<bp::copy_const_reference>())) | |
98 |
2/4✓ Branch 1 taken 7 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 7 times.
✗ Branch 5 not taken.
|
14 | .add_property( |
99 | "getPositionUpperBounds", | ||
100 | bp::make_function( | ||
101 | &TaskJointPosVelAccBoundsPythonVisitor::getPositionUpperBounds, | ||
102 | 7 | bp::return_value_policy<bp::copy_const_reference>())) | |
103 |
1/2✓ Branch 1 taken 7 times.
✗ Branch 2 not taken.
|
7 | .add_property("name", &TaskJointPosVelAccBoundsPythonVisitor::name); |
104 | 7 | } | |
105 | ✗ | static std::string name(Task& self) { | |
106 | ✗ | std::string name = self.name(); | |
107 | ✗ | return name; | |
108 | } | ||
109 | ✗ | static math::ConstraintBound compute(Task& self, const double t, | |
110 | const Eigen::VectorXd& q, | ||
111 | const Eigen::VectorXd& v, | ||
112 | pinocchio::Data& data) { | ||
113 | ✗ | self.compute(t, q, v, data); | |
114 | ✗ | math::ConstraintBound cons(self.getConstraint().name(), | |
115 | ✗ | self.getConstraint().lowerBound(), | |
116 | ✗ | self.getConstraint().upperBound()); | |
117 | ✗ | return cons; | |
118 | } | ||
119 | ✗ | static math::ConstraintBound getConstraint(const Task& self) { | |
120 | ✗ | math::ConstraintBound cons(self.getConstraint().name(), | |
121 | ✗ | self.getConstraint().lowerBound(), | |
122 | ✗ | self.getConstraint().upperBound()); | |
123 | ✗ | return cons; | |
124 | } | ||
125 | ✗ | static const Eigen::VectorXd& getAccelerationBounds(const Task& self) { | |
126 | ✗ | return self.getAccelerationBounds(); | |
127 | } | ||
128 | ✗ | static const Eigen::VectorXd& getVelocityBounds(const Task& self) { | |
129 | ✗ | return self.getVelocityBounds(); | |
130 | } | ||
131 | ✗ | static const Eigen::VectorXd& getPositionLowerBounds(const Task& self) { | |
132 | ✗ | return self.getPositionLowerBounds(); | |
133 | } | ||
134 | ✗ | static const Eigen::VectorXd& getPositionUpperBounds(const Task& self) { | |
135 | ✗ | return self.getPositionUpperBounds(); | |
136 | } | ||
137 | ✗ | static void setTimeStep(Task& self, const double dt) { | |
138 | ✗ | return self.setTimeStep(dt); | |
139 | } | ||
140 | ✗ | static void setPositionBounds(Task& self, const Eigen::VectorXd lower, | |
141 | const Eigen::VectorXd upper) { | ||
142 | ✗ | return self.setPositionBounds(lower, upper); | |
143 | } | ||
144 | ✗ | static void setVelocityBounds(Task& self, const Eigen::VectorXd upper) { | |
145 | ✗ | return self.setVelocityBounds(upper); | |
146 | } | ||
147 | ✗ | static void setAccelerationBounds(Task& self, const Eigen::VectorXd upper) { | |
148 | ✗ | return self.setAccelerationBounds(upper); | |
149 | } | ||
150 | 7 | static void expose(const std::string& class_name) { | |
151 |
1/2✓ Branch 2 taken 7 times.
✗ Branch 3 not taken.
|
7 | std::string doc = "Task info."; |
152 |
1/2✓ Branch 3 taken 7 times.
✗ Branch 4 not taken.
|
7 | bp::class_<Task>(class_name.c_str(), doc.c_str(), bp::no_init) |
153 |
1/2✓ Branch 1 taken 7 times.
✗ Branch 2 not taken.
|
7 | .def(TaskJointPosVelAccBoundsPythonVisitor<Task>()); |
154 | 7 | } | |
155 | ✗ | static void setVerbose(Task& self, bool verbose) { | |
156 | ✗ | return self.setVerbose(verbose); | |
157 | } | ||
158 | ✗ | static void setImposeBounds(Task& self, bool impose_position_bounds, | |
159 | bool impose_velocity_bounds, | ||
160 | bool impose_viability_bounds, | ||
161 | bool impose_acceleration_bounds) { | ||
162 | ✗ | return self.setImposeBounds(impose_position_bounds, impose_velocity_bounds, | |
163 | impose_viability_bounds, | ||
164 | ✗ | impose_acceleration_bounds); | |
165 | } | ||
166 | |||
167 | ✗ | static void isStateViable(Task& self, ConstRefVector q, ConstRefVector dq, | |
168 | bool verbose = true) { | ||
169 | ✗ | return self.isStateViable(q, dq, verbose); | |
170 | } | ||
171 | ✗ | static void computeAccLimitsFromPosLimits(Task& self, ConstRefVector q, | |
172 | ConstRefVector dq, | ||
173 | bool verbose = true) { | ||
174 | ✗ | return self.computeAccLimitsFromPosLimits(q, dq, verbose); | |
175 | } | ||
176 | ✗ | static void computeAccLimitsFromViability(Task& self, ConstRefVector q, | |
177 | ConstRefVector dq, | ||
178 | bool verbose = true) { | ||
179 | ✗ | return self.computeAccLimitsFromViability(q, dq, verbose); | |
180 | } | ||
181 | ✗ | static void computeAccLimits(Task& self, ConstRefVector q, ConstRefVector dq, | |
182 | bool verbose = true) { | ||
183 | ✗ | return self.computeAccLimits(q, dq, verbose); | |
184 | } | ||
185 | ✗ | static void setMask(Task& self, math::ConstRefVector mask) { | |
186 | ✗ | return self.setMask(mask); | |
187 | } | ||
188 | }; | ||
189 | } // namespace python | ||
190 | } // namespace tsid | ||
191 | |||
192 | #endif // ifndef __tsid_python_task_actuation_bounds_hpp__ | ||
193 |