|
| 1 | +// |
| 2 | +// Copyright (c) 2021 LAAS-CNRS, University of Trento |
| 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_contact_force_equality_hpp__ |
| 19 | +#define __tsid_python_task_contact_force_equality_hpp__ |
| 20 | + |
| 21 | +#include "tsid/bindings/python/fwd.hpp" |
| 22 | + |
| 23 | +#include "tsid/tasks/task-contact-force-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 | +{ |
| 30 | + namespace python |
| 31 | + { |
| 32 | + namespace bp = boost::python; |
| 33 | + |
| 34 | + template<typename TaskContactForceEquality> |
| 35 | + struct TaskContactForceEqualityPythonVisitor |
| 36 | + : public boost::python::def_visitor< TaskContactForceEqualityPythonVisitor<TaskContactForceEquality> > |
| 37 | + { |
| 38 | + |
| 39 | + template<class PyClass> |
| 40 | + |
| 41 | + |
| 42 | + void visit(PyClass& cl) const |
| 43 | + { |
| 44 | + cl |
| 45 | + .def(bp::init<std::string, robots::RobotWrapper &, double, contacts::ContactBase &> ((bp::arg("name"), bp::arg("robot"), bp::arg("dt"), bp::arg("contact")), "Default Constructor")) |
| 46 | + .add_property("dim", &TaskContactForceEquality::dim, "return dimension size") |
| 47 | + .def("setReference", &TaskContactForceEqualityPythonVisitor::setReference, bp::arg("ref")) |
| 48 | + .def("setExternalForce", &TaskContactForceEqualityPythonVisitor::setExternalForce, bp::arg("f_ext")) |
| 49 | + .def("compute", &TaskContactForceEqualityPythonVisitor::compute, bp::args("t", "q", "v", "data")) |
| 50 | + .def("getConstraint", &TaskContactForceEqualityPythonVisitor::getConstraint) |
| 51 | + .add_property("name", &TaskContactForceEqualityPythonVisitor::name) |
| 52 | + .add_property("Kp", bp::make_function(&TaskContactForceEqualityPythonVisitor::Kp, bp::return_value_policy<bp::copy_const_reference>())) |
| 53 | + .add_property("Kd", bp::make_function(&TaskContactForceEqualityPythonVisitor::Kd, bp::return_value_policy<bp::copy_const_reference>())) |
| 54 | + .add_property("Ki", bp::make_function(&TaskContactForceEqualityPythonVisitor::Kd, bp::return_value_policy<bp::copy_const_reference>())) |
| 55 | + .add_property("getLeakRate", bp::make_function(&TaskContactForceEqualityPythonVisitor::getLeakRate, bp::return_value_policy<bp::copy_const_reference>())) |
| 56 | + .def("setKp", &TaskContactForceEqualityPythonVisitor::setKp, bp::arg("Kp")) |
| 57 | + .def("setKd", &TaskContactForceEqualityPythonVisitor::setKd, bp::arg("Kd")) |
| 58 | + .def("setKi", &TaskContactForceEqualityPythonVisitor::setKi, bp::arg("Ki")) |
| 59 | + .def("setLeakRate", &TaskContactForceEqualityPythonVisitor::setLeakRate, bp::arg("leak")) |
| 60 | + ; |
| 61 | + } |
| 62 | + static std::string name(TaskContactForceEquality & self){ |
| 63 | + std::string name = self.name(); |
| 64 | + return name; |
| 65 | + } |
| 66 | + static math::ConstraintEquality compute(TaskContactForceEquality & self, const double t, const Eigen::VectorXd & q, const Eigen::VectorXd & v, pinocchio::Data & data){ |
| 67 | + self.compute(t, q, v, data); |
| 68 | + math::ConstraintEquality cons(self.getConstraint().name(), self.getConstraint().matrix(), self.getConstraint().vector()); |
| 69 | + return cons; |
| 70 | + } |
| 71 | + static math::ConstraintEquality getConstraint(const TaskContactForceEquality & self){ |
| 72 | + math::ConstraintEquality cons(self.getConstraint().name(), self.getConstraint().matrix(), self.getConstraint().vector()); |
| 73 | + return cons; |
| 74 | + } |
| 75 | + static void setReference(TaskContactForceEquality & self, trajectories::TrajectorySample & ref){ |
| 76 | + self.setReference(ref); |
| 77 | + } |
| 78 | + static void setExternalForce(TaskContactForceEquality & self, trajectories::TrajectorySample & f_ext){ |
| 79 | + self.setExternalForce(f_ext); |
| 80 | + } |
| 81 | + static const Eigen::VectorXd & Kp (TaskContactForceEquality & self){ |
| 82 | + return self.Kp(); |
| 83 | + } |
| 84 | + static const Eigen::VectorXd & Kd (TaskContactForceEquality & self){ |
| 85 | + return self.Kd(); |
| 86 | + } |
| 87 | + static const Eigen::VectorXd & Ki (TaskContactForceEquality & self){ |
| 88 | + return self.Ki(); |
| 89 | + } |
| 90 | + static const double & getLeakRate (TaskContactForceEquality & self){ |
| 91 | + return self.getLeakRate(); |
| 92 | + } |
| 93 | + static void setKp (TaskContactForceEquality & self, const::Eigen::VectorXd Kp){ |
| 94 | + return self.Kp(Kp); |
| 95 | + } |
| 96 | + static void setKd (TaskContactForceEquality & self, const::Eigen::VectorXd Kd){ |
| 97 | + return self.Kd(Kd); |
| 98 | + } |
| 99 | + static void setKi (TaskContactForceEquality & self, const::Eigen::VectorXd Ki){ |
| 100 | + return self.Ki(Ki); |
| 101 | + } |
| 102 | + static void setLeakRate (TaskContactForceEquality & self, const double leak){ |
| 103 | + return self.setLeakRate(leak); |
| 104 | + } |
| 105 | + static void expose(const std::string & class_name) |
| 106 | + { |
| 107 | + std::string doc = "TaskContactForceEqualityPythonVisitor info."; |
| 108 | + bp::class_<TaskContactForceEquality>(class_name.c_str(), |
| 109 | + doc.c_str(), |
| 110 | + bp::no_init) |
| 111 | + .def(TaskContactForceEqualityPythonVisitor<TaskContactForceEquality>()); |
| 112 | + } |
| 113 | + }; |
| 114 | + } |
| 115 | +} |
| 116 | + |
| 117 | + |
| 118 | +#endif // ifndef __tsid_python_task_contact_force_equality_hpp__ |
0 commit comments