Directory: | ./ |
---|---|
File: | include/tsid/bindings/python/tasks/task-joint-bounds.hpp |
Date: | 2024-11-10 01:12:44 |
Exec | Total | Coverage | |
---|---|---|---|
Lines: | 24 | 52 | 46.2% |
Branches: | 28 | 92 | 30.4% |
Line | Branch | Exec | Source |
---|---|---|---|
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_joint_bounds_hpp__ | ||
19 | #define __tsid_python_task_joint_bounds_hpp__ | ||
20 | |||
21 | #include "tsid/bindings/python/fwd.hpp" | ||
22 | |||
23 | #include "tsid/tasks/task-joint-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 | |||
32 | template <typename Task> | ||
33 | struct TaskJointBoundsPythonVisitor | ||
34 | : public boost::python::def_visitor<TaskJointBoundsPythonVisitor<Task> > { | ||
35 | template <class PyClass> | ||
36 | |||
37 | 7 | void visit(PyClass& cl) const { | |
38 |
4/8✓ 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.
|
14 | cl.def(bp::init<std::string, robots::RobotWrapper&, double>( |
39 |
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")), |
40 | "Default Constructor")) | ||
41 | 14 | .add_property("dim", &Task::dim, "return dimension size") | |
42 |
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", &TaskJointBoundsPythonVisitor::setTimeStep, |
43 | bp::args("dt")) | ||
44 |
2/4✓ Branch 1 taken 7 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 7 times.
✗ Branch 5 not taken.
|
14 | .def("setVelocityBounds", |
45 | &TaskJointBoundsPythonVisitor::setVelocityBounds, | ||
46 | bp::args("lower", "upper")) | ||
47 |
2/4✓ Branch 1 taken 7 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 7 times.
✗ Branch 5 not taken.
|
14 | .def("setAccelerationBounds", |
48 | &TaskJointBoundsPythonVisitor::setAccelerationBounds, | ||
49 | bp::args("lower", "upper")) | ||
50 |
2/4✓ Branch 1 taken 7 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 7 times.
✗ Branch 5 not taken.
|
14 | .def("compute", &TaskJointBoundsPythonVisitor::compute, |
51 | bp::args("t", "q", "v", "data")) | ||
52 |
1/2✓ Branch 1 taken 7 times.
✗ Branch 2 not taken.
|
7 | .def("getConstraint", &TaskJointBoundsPythonVisitor::getConstraint) |
53 |
2/4✓ Branch 1 taken 7 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 7 times.
✗ Branch 5 not taken.
|
7 | .add_property( |
54 | "getAccelerationLowerBounds", | ||
55 | bp::make_function( | ||
56 | &TaskJointBoundsPythonVisitor::getAccelerationLowerBounds, | ||
57 | 7 | bp::return_value_policy<bp::copy_const_reference>())) | |
58 |
2/4✓ Branch 1 taken 7 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 7 times.
✗ Branch 5 not taken.
|
7 | .add_property( |
59 | "getAccelerationUpperBounds", | ||
60 | bp::make_function( | ||
61 | &TaskJointBoundsPythonVisitor::getAccelerationUpperBounds, | ||
62 | 7 | bp::return_value_policy<bp::copy_const_reference>())) | |
63 |
2/4✓ Branch 1 taken 7 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 7 times.
✗ Branch 5 not taken.
|
7 | .add_property("getVelocityLowerBounds", |
64 | bp::make_function( | ||
65 | &TaskJointBoundsPythonVisitor::getVelocityLowerBounds, | ||
66 | 7 | bp::return_value_policy<bp::copy_const_reference>())) | |
67 |
2/4✓ Branch 1 taken 7 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 7 times.
✗ Branch 5 not taken.
|
14 | .add_property("getVelocityUpperBounds", |
68 | bp::make_function( | ||
69 | &TaskJointBoundsPythonVisitor::getVelocityUpperBounds, | ||
70 | 7 | bp::return_value_policy<bp::copy_const_reference>())) | |
71 |
1/2✓ Branch 1 taken 7 times.
✗ Branch 2 not taken.
|
7 | .add_property("name", &TaskJointBoundsPythonVisitor::name); |
72 | 7 | } | |
73 | ✗ | static std::string name(Task& self) { | |
74 | ✗ | std::string name = self.name(); | |
75 | ✗ | return name; | |
76 | } | ||
77 | ✗ | static math::ConstraintBound compute(Task& self, const double t, | |
78 | const Eigen::VectorXd& q, | ||
79 | const Eigen::VectorXd& v, | ||
80 | pinocchio::Data& data) { | ||
81 | ✗ | self.compute(t, q, v, data); | |
82 | ✗ | math::ConstraintBound cons(self.getConstraint().name(), | |
83 | ✗ | self.getConstraint().lowerBound(), | |
84 | ✗ | self.getConstraint().upperBound()); | |
85 | ✗ | return cons; | |
86 | } | ||
87 | ✗ | static math::ConstraintBound getConstraint(const Task& self) { | |
88 | ✗ | math::ConstraintBound cons(self.getConstraint().name(), | |
89 | ✗ | self.getConstraint().lowerBound(), | |
90 | ✗ | self.getConstraint().upperBound()); | |
91 | ✗ | return cons; | |
92 | } | ||
93 | ✗ | static const Eigen::VectorXd& getAccelerationLowerBounds(const Task& self) { | |
94 | ✗ | return self.getAccelerationLowerBounds(); | |
95 | } | ||
96 | ✗ | static const Eigen::VectorXd& getAccelerationUpperBounds(const Task& self) { | |
97 | ✗ | return self.getAccelerationUpperBounds(); | |
98 | } | ||
99 | ✗ | static const Eigen::VectorXd& getVelocityLowerBounds(const Task& self) { | |
100 | ✗ | return self.getVelocityLowerBounds(); | |
101 | } | ||
102 | ✗ | static const Eigen::VectorXd& getVelocityUpperBounds(const Task& self) { | |
103 | ✗ | return self.getVelocityUpperBounds(); | |
104 | } | ||
105 | ✗ | static void setTimeStep(Task& self, const double dt) { | |
106 | ✗ | return self.setTimeStep(dt); | |
107 | } | ||
108 | ✗ | static void setVelocityBounds(Task& self, const Eigen::VectorXd lower, | |
109 | const Eigen::VectorXd upper) { | ||
110 | ✗ | return self.setVelocityBounds(lower, upper); | |
111 | } | ||
112 | ✗ | static void setAccelerationBounds(Task& self, const Eigen::VectorXd lower, | |
113 | const Eigen::VectorXd upper) { | ||
114 | ✗ | return self.setAccelerationBounds(lower, upper); | |
115 | } | ||
116 | 7 | static void expose(const std::string& class_name) { | |
117 |
1/2✓ Branch 2 taken 7 times.
✗ Branch 3 not taken.
|
7 | std::string doc = "Task info."; |
118 |
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) |
119 |
1/2✓ Branch 1 taken 7 times.
✗ Branch 2 not taken.
|
7 | .def(TaskJointBoundsPythonVisitor<Task>()); |
120 | 7 | } | |
121 | }; | ||
122 | } // namespace python | ||
123 | } // namespace tsid | ||
124 | |||
125 | #endif // ifndef __tsid_python_task_actuation_bounds_hpp__ | ||
126 |