| Directory: | ./ |
|---|---|
| File: | include/tsid/bindings/python/tasks/task-actuation-equality.hpp |
| Date: | 2025-05-10 01:12:46 |
| Exec | Total | Coverage | |
|---|---|---|---|
| Lines: | 24 | 48 | 50.0% |
| Branches: | 22 | 76 | 28.9% |
| Line | Branch | Exec | Source |
|---|---|---|---|
| 1 | /* | ||
| 2 | * Author: Ram Charan Teja Thota | ||
| 3 | * Date: August 1, 2024 | ||
| 4 | * | ||
| 5 | * Description: | ||
| 6 | * this file contain boost python binding for task acutation equality | ||
| 7 | */ | ||
| 8 | // | ||
| 9 | // Copyright (c) 2018 CNRS | ||
| 10 | // | ||
| 11 | // This file is part of tsid | ||
| 12 | // tsid is free software: you can redistribute it | ||
| 13 | // and/or modify it under the terms of the GNU Lesser General Public | ||
| 14 | // License as published by the Free Software Foundation, either version | ||
| 15 | // 3 of the License, or (at your option) any later version. | ||
| 16 | // tsid is distributed in the hope that it will be | ||
| 17 | // useful, but WITHOUT ANY WARRANTY; without even the implied warranty | ||
| 18 | // of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
| 19 | // General Lesser Public License for more details. You should have | ||
| 20 | // received a copy of the GNU Lesser General Public License along with | ||
| 21 | // tsid If not, see | ||
| 22 | // <http://www.gnu.org/licenses/>. | ||
| 23 | // | ||
| 24 | |||
| 25 | #ifndef __tsid_python_task_actuation_equality_hpp__ | ||
| 26 | #define __tsid_python_task_actuation_equality_hpp__ | ||
| 27 | |||
| 28 | #include "tsid/bindings/python/fwd.hpp" | ||
| 29 | |||
| 30 | #include "tsid/math/constraint-base.hpp" | ||
| 31 | #include "tsid/math/constraint-equality.hpp" | ||
| 32 | #include "tsid/robots/robot-wrapper.hpp" | ||
| 33 | #include "tsid/tasks/task-actuation-equality.hpp" | ||
| 34 | #include "tsid/trajectories/trajectory-base.hpp" | ||
| 35 | |||
| 36 | namespace tsid { | ||
| 37 | |||
| 38 | namespace python { | ||
| 39 | namespace bp = boost::python; | ||
| 40 | |||
| 41 | template <typename TaskAucEq> | ||
| 42 | struct TaskActuationEqualityPythonVisitor | ||
| 43 | : public boost::python::def_visitor< | ||
| 44 | TaskActuationEqualityPythonVisitor<TaskAucEq>> { | ||
| 45 | template <class PyClass> | ||
| 46 | |||
| 47 | 8 | void visit(PyClass &cl) const { | |
| 48 |
3/6✓ Branch 1 taken 8 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 8 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 8 times.
✗ Branch 8 not taken.
|
8 | cl.def(bp::init<std::string, robots::RobotWrapper &>( |
| 49 |
1/2✓ Branch 2 taken 8 times.
✗ Branch 3 not taken.
|
16 | (bp::arg("name"), bp::arg("robot")), "Default Constructor")) |
| 50 | |||
| 51 | 16 | .add_property("dim", &TaskAucEq::dim, "return dimension size") | |
| 52 | |||
| 53 |
3/6✓ Branch 1 taken 8 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 8 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 8 times.
✗ Branch 8 not taken.
|
16 | .def("compute", &TaskActuationEqualityPythonVisitor::compute, |
| 54 | bp::args("t", "q", "v", "data")) | ||
| 55 | |||
| 56 |
1/2✓ Branch 1 taken 8 times.
✗ Branch 2 not taken.
|
8 | .def("getConstraint", |
| 57 | &TaskActuationEqualityPythonVisitor::getConstraint) | ||
| 58 | |||
| 59 |
2/4✓ Branch 1 taken 8 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 8 times.
✗ Branch 5 not taken.
|
8 | .add_property("mask", |
| 60 | bp::make_function( | ||
| 61 | &TaskActuationEqualityPythonVisitor::getmask, | ||
| 62 | 8 | bp::return_value_policy<bp::copy_const_reference>()), | |
| 63 | "Return mask") | ||
| 64 | |||
| 65 |
1/2✓ Branch 1 taken 8 times.
✗ Branch 2 not taken.
|
8 | .def("setMask", &TaskActuationEqualityPythonVisitor::setmask, |
| 66 |
1/2✓ Branch 1 taken 8 times.
✗ Branch 2 not taken.
|
16 | bp::arg("mask")) |
| 67 | |||
| 68 |
1/2✓ Branch 1 taken 8 times.
✗ Branch 2 not taken.
|
8 | .def("setReference", &TaskActuationEqualityPythonVisitor::setReference, |
| 69 |
1/2✓ Branch 1 taken 8 times.
✗ Branch 2 not taken.
|
16 | bp::arg("ref")) |
| 70 |
1/2✓ Branch 1 taken 8 times.
✗ Branch 2 not taken.
|
8 | .def("getReference", &TaskActuationEqualityPythonVisitor::getReference, |
| 71 | ✗ | bp::return_value_policy<bp::copy_const_reference>()) | |
| 72 | |||
| 73 |
1/2✓ Branch 1 taken 8 times.
✗ Branch 2 not taken.
|
8 | .def("setWeightVector", |
| 74 | &TaskActuationEqualityPythonVisitor::setWeightVector, | ||
| 75 |
1/2✓ Branch 1 taken 8 times.
✗ Branch 2 not taken.
|
16 | bp::arg("weights")) |
| 76 |
1/2✓ Branch 1 taken 8 times.
✗ Branch 2 not taken.
|
8 | .def("getWeightVector", |
| 77 | &TaskActuationEqualityPythonVisitor::getWeightVector, | ||
| 78 | 8 | bp::return_value_policy<bp::copy_const_reference>()); | |
| 79 | 8 | } | |
| 80 | |||
| 81 | static std::string name(TaskAucEq &self) { | ||
| 82 | std::string name = self.name(); | ||
| 83 | return name; | ||
| 84 | } | ||
| 85 | |||
| 86 | ✗ | static math::ConstraintEquality compute(TaskAucEq &self, const double t, | |
| 87 | const Eigen::VectorXd &q, | ||
| 88 | const Eigen::VectorXd &v, | ||
| 89 | pinocchio::Data &data) { | ||
| 90 | ✗ | self.compute(t, q, v, data); | |
| 91 | ✗ | math::ConstraintEquality cons(self.getConstraint().name(), | |
| 92 | ✗ | self.getConstraint().matrix(), | |
| 93 | ✗ | self.getConstraint().vector()); | |
| 94 | ✗ | return cons; | |
| 95 | } | ||
| 96 | |||
| 97 | ✗ | static math::ConstraintEquality getConstraint(const TaskAucEq &self) { | |
| 98 | ✗ | math::ConstraintEquality cons(self.getConstraint().name(), | |
| 99 | ✗ | self.getConstraint().matrix(), | |
| 100 | ✗ | self.getConstraint().vector()); | |
| 101 | ✗ | return cons; | |
| 102 | } | ||
| 103 | |||
| 104 | //// getter and setter of reference | ||
| 105 | ✗ | static void setReference(TaskAucEq &self, const Eigen::VectorXd &ref) { | |
| 106 | ✗ | self.setReference(ref); | |
| 107 | } | ||
| 108 | |||
| 109 | ✗ | static const Eigen::VectorXd &getReference(const TaskAucEq &self) { | |
| 110 | ✗ | return self.getReference(); | |
| 111 | } | ||
| 112 | |||
| 113 | // getter and setter of weight | ||
| 114 | ✗ | static void setWeightVector(TaskAucEq &self, const Eigen::VectorXd &weights) { | |
| 115 | ✗ | self.setWeightVector(weights); | |
| 116 | } | ||
| 117 | |||
| 118 | ✗ | static const Eigen::VectorXd &getWeightVector(const TaskAucEq &self) { | |
| 119 | ✗ | return self.getWeightVector(); | |
| 120 | } | ||
| 121 | |||
| 122 | // getter and setter of mask | ||
| 123 | ✗ | static const Eigen::VectorXd &getmask(const TaskAucEq &self) { | |
| 124 | ✗ | return self.mask(); | |
| 125 | } | ||
| 126 | |||
| 127 | ✗ | static void setmask(TaskAucEq &self, const Eigen::VectorXd mask) { | |
| 128 | ✗ | return self.mask(mask); | |
| 129 | } | ||
| 130 | |||
| 131 | 8 | static void expose(const std::string &class_name) { | |
| 132 |
1/2✓ Branch 2 taken 8 times.
✗ Branch 3 not taken.
|
8 | std::string doc = "TaskActuationEqualityPythonVisitor info."; |
| 133 |
1/2✓ Branch 3 taken 8 times.
✗ Branch 4 not taken.
|
8 | bp::class_<TaskAucEq>(class_name.c_str(), doc.c_str(), bp::no_init) |
| 134 |
1/2✓ Branch 1 taken 8 times.
✗ Branch 2 not taken.
|
8 | .def(TaskActuationEqualityPythonVisitor<TaskAucEq>()); |
| 135 | |||
| 136 |
1/2✓ Branch 1 taken 8 times.
✗ Branch 2 not taken.
|
8 | bp::register_ptr_to_python<boost::shared_ptr<math::ConstraintBase>>(); |
| 137 | 8 | } | |
| 138 | }; | ||
| 139 | |||
| 140 | } // namespace python | ||
| 141 | } // namespace tsid | ||
| 142 | |||
| 143 | #endif // ifndef __tsid_python_task_actuation_equality_hpp__ | ||
| 144 |