GCC Code Coverage Report


Directory: ./
File: include/tsid/bindings/python/tasks/task-actuation-bounds.hpp
Date: 2024-08-26 20:29:39
Exec Total Coverage
Lines: 22 46 47.8%
Branches: 22 88 25.0%

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_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
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", &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.
7 .add_property("mask",
43 bp::make_function(
44 &TaskActuationBoundsPythonVisitor::getmask,
45 7 bp::return_value_policy<bp::copy_const_reference>()),
46 "Return mask")
47
1/2
✓ Branch 1 taken 7 times.
✗ Branch 2 not taken.
7 .def("setMask", &TaskActuationBoundsPythonVisitor::setmask,
48
1/2
✓ Branch 1 taken 7 times.
✗ Branch 2 not taken.
14 bp::arg("mask"))
49
2/4
✓ Branch 1 taken 7 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 7 times.
✗ Branch 5 not taken.
14 .def("setBounds", &TaskActuationBoundsPythonVisitor::setBounds,
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("compute", &TaskActuationBoundsPythonVisitor::compute,
52 bp::args("t", "q", "v", "data"))
53
1/2
✓ Branch 1 taken 7 times.
✗ Branch 2 not taken.
7 .def("getConstraint", &TaskActuationBoundsPythonVisitor::getConstraint)
54
2/4
✓ Branch 1 taken 7 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 7 times.
✗ Branch 5 not taken.
7 .add_property("getLowerBounds",
55 bp::make_function(
56 &TaskActuationBoundsPythonVisitor::getLowerBounds,
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.
14 .add_property("getUpperBounds",
59 bp::make_function(
60 &TaskActuationBoundsPythonVisitor::getUpperBounds,
61 7 bp::return_value_policy<bp::copy_const_reference>()))
62
1/2
✓ Branch 1 taken 7 times.
✗ Branch 2 not taken.
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
1/2
✓ Branch 2 taken 7 times.
✗ Branch 3 not taken.
7 std::string doc = "Task info.";
102
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)
103
1/2
✓ Branch 1 taken 7 times.
✗ Branch 2 not taken.
7 .def(TaskActuationBoundsPythonVisitor<Task>());
104 7 }
105 };
106 } // namespace python
107 } // namespace tsid
108
109 #endif // ifndef __tsid_python_task_actuation_bounds_hpp__
110