GCC Code Coverage Report


Directory: ./
File: include/tsid/bindings/python/contacts/contact-two-frame-positions.hpp
Date: 2024-10-10 01:09:49
Exec Total Coverage
Lines: 36 82 43.9%
Branches: 50 166 30.1%

Line Branch Exec Source
1 //
2 // Copyright (c) 2023 MIPT
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_contact_two_frame_positions_hpp__
19 #define __tsid_python_contact_two_frame_positions_hpp__
20
21 #include "tsid/bindings/python/fwd.hpp"
22
23 #include "tsid/contacts/contact-two-frame-positions.hpp"
24 #include "tsid/robots/robot-wrapper.hpp"
25 #include "tsid/math/constraint-inequality.hpp"
26 #include "tsid/math/constraint-equality.hpp"
27 #include "tsid/math/constraint-base.hpp"
28
29 namespace tsid {
30 namespace python {
31 namespace bp = boost::python;
32
33 template <typename ContactTwoFramePositions>
34 struct ContactTwoFramePositionsPythonVisitor
35 : public boost::python::def_visitor<
36 ContactTwoFramePositionsPythonVisitor<ContactTwoFramePositions> > {
37 template <class PyClass>
38
39 7 void visit(PyClass& cl) const {
40 cl
41
7/14
✓ 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.
✓ Branch 16 taken 7 times.
✗ Branch 17 not taken.
✓ Branch 19 taken 7 times.
✗ Branch 20 not taken.
35 .def(bp::init<std::string, robots::RobotWrapper&, std::string,
42 std::string, double, double>(
43
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("framename1"),
44
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.
28 bp::arg("framename2"), bp::arg("minForce"), bp::arg("maxForce")),
45 "Default Constructor"))
46 14 .add_property("n_motion", &ContactTwoFramePositions::n_motion,
47 "return number of motion")
48
1/2
✓ Branch 1 taken 7 times.
✗ Branch 2 not taken.
7 .add_property("n_force", &ContactTwoFramePositions::n_force,
49 "return number of force")
50
2/4
✓ Branch 1 taken 7 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 7 times.
✗ Branch 5 not taken.
7 .add_property("name", &ContactTwoFramePositionsPythonVisitor::name,
51 "return name")
52
2/4
✓ Branch 1 taken 7 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 7 times.
✗ Branch 5 not taken.
14 .def("computeMotionTask",
53 &ContactTwoFramePositionsPythonVisitor::computeMotionTask,
54 bp::args("t", "q", "v", "data"))
55
2/4
✓ Branch 1 taken 7 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 7 times.
✗ Branch 5 not taken.
14 .def("computeForceTask",
56 &ContactTwoFramePositionsPythonVisitor::computeForceTask,
57 bp::args("t", "q", "v", "data"))
58
2/4
✓ Branch 1 taken 7 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 7 times.
✗ Branch 5 not taken.
14 .def("computeForceRegularizationTask",
59 &ContactTwoFramePositionsPythonVisitor::
60 computeForceRegularizationTask,
61 bp::args("t", "q", "v", "data"))
62
63
2/4
✓ Branch 1 taken 7 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 7 times.
✗ Branch 5 not taken.
7 .add_property(
64 "getForceGeneratorMatrix",
65 bp::make_function(
66 &ContactTwoFramePositionsPythonVisitor::getForceGeneratorMatrix,
67 7 bp::return_value_policy<bp::copy_const_reference>()))
68
69
1/2
✓ Branch 1 taken 7 times.
✗ Branch 2 not taken.
7 .def("getNormalForce",
70 &ContactTwoFramePositionsPythonVisitor::getNormalForce,
71
1/2
✓ Branch 1 taken 7 times.
✗ Branch 2 not taken.
14 bp::arg("vec"))
72 14 .add_property("getMinNormalForce",
73 &ContactTwoFramePositions::getMinNormalForce)
74
1/2
✓ Branch 1 taken 7 times.
✗ Branch 2 not taken.
7 .add_property("getMaxNormalForce",
75 &ContactTwoFramePositions::getMaxNormalForce)
76
77
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("Kp",
78 bp::make_function(
79 &ContactTwoFramePositionsPythonVisitor::Kp,
80 7 bp::return_value_policy<bp::copy_const_reference>()))
81
2/4
✓ Branch 1 taken 7 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 7 times.
✗ Branch 5 not taken.
7 .add_property("Kd",
82 bp::make_function(
83 &ContactTwoFramePositionsPythonVisitor::Kd,
84 7 bp::return_value_policy<bp::copy_const_reference>()))
85
1/2
✓ Branch 1 taken 7 times.
✗ Branch 2 not taken.
7 .def("setKp", &ContactTwoFramePositionsPythonVisitor::setKp,
86
1/2
✓ Branch 1 taken 7 times.
✗ Branch 2 not taken.
14 bp::arg("Kp"))
87
1/2
✓ Branch 1 taken 7 times.
✗ Branch 2 not taken.
7 .def("setKd", &ContactTwoFramePositionsPythonVisitor::setKd,
88
1/2
✓ Branch 1 taken 7 times.
✗ Branch 2 not taken.
14 bp::arg("Kd"))
89
2/4
✓ Branch 1 taken 7 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 7 times.
✗ Branch 5 not taken.
14 .def("setContactNormal",
90 &ContactTwoFramePositionsPythonVisitor::setContactNormal,
91 bp::args("vec"))
92
2/4
✓ Branch 1 taken 7 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 7 times.
✗ Branch 5 not taken.
14 .def("setFrictionCoefficient",
93 &ContactTwoFramePositionsPythonVisitor::setFrictionCoefficient,
94 bp::args("friction_coeff"))
95
2/4
✓ Branch 1 taken 7 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 7 times.
✗ Branch 5 not taken.
14 .def("setMinNormalForce",
96 &ContactTwoFramePositionsPythonVisitor::setMinNormalForce,
97 bp::args("min_force"))
98
2/4
✓ Branch 1 taken 7 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 7 times.
✗ Branch 5 not taken.
14 .def("setMaxNormalForce",
99 &ContactTwoFramePositionsPythonVisitor::setMaxNormalForce,
100 bp::args("max_force"))
101
2/4
✓ Branch 1 taken 7 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 7 times.
✗ Branch 5 not taken.
14 .def("setForceReference",
102 &ContactTwoFramePositionsPythonVisitor::setForceReference,
103 bp::args("f_vec"))
104
2/4
✓ Branch 1 taken 7 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 7 times.
✗ Branch 5 not taken.
7 .def("setRegularizationTaskWeightVector",
105 &ContactTwoFramePositionsPythonVisitor::
106 setRegularizationTaskWeightVector,
107 bp::args("w_vec"));
108 7 }
109 static std::string name(ContactTwoFramePositions& self) {
110 std::string name = self.name();
111 return name;
112 }
113
114 static math::ConstraintEquality computeMotionTask(
115 ContactTwoFramePositions& self, const double t, const Eigen::VectorXd& q,
116 const Eigen::VectorXd& v, pinocchio::Data& data) {
117 self.computeMotionTask(t, q, v, data);
118 math::ConstraintEquality cons(self.getMotionConstraint().name(),
119 self.getMotionConstraint().matrix(),
120 self.getMotionConstraint().vector());
121 return cons;
122 }
123 static math::ConstraintInequality computeForceTask(
124 ContactTwoFramePositions& self, const double t, const Eigen::VectorXd& q,
125 const Eigen::VectorXd& v, const pinocchio::Data& data) {
126 self.computeForceTask(t, q, v, data);
127 math::ConstraintInequality cons(self.getForceConstraint().name(),
128 self.getForceConstraint().matrix(),
129 self.getForceConstraint().lowerBound(),
130 self.getForceConstraint().upperBound());
131 return cons;
132 }
133 static math::ConstraintEquality computeForceRegularizationTask(
134 ContactTwoFramePositions& self, const double t, const Eigen::VectorXd& q,
135 const Eigen::VectorXd& v, const pinocchio::Data& data) {
136 self.computeForceRegularizationTask(t, q, v, data);
137 math::ConstraintEquality cons(self.getForceRegularizationTask().name(),
138 self.getForceRegularizationTask().matrix(),
139 self.getForceRegularizationTask().vector());
140 return cons;
141 }
142
143 static const Eigen::MatrixXd& getForceGeneratorMatrix(
144 ContactTwoFramePositions& self) {
145 return self.getForceGeneratorMatrix();
146 }
147 static const Eigen::VectorXd& Kp(ContactTwoFramePositions& self) {
148 return self.Kp();
149 }
150 static const Eigen::VectorXd& Kd(ContactTwoFramePositions& self) {
151 return self.Kd();
152 }
153 static void setKp(ContactTwoFramePositions& self,
154 const ::Eigen::VectorXd Kp) {
155 return self.Kp(Kp);
156 }
157 static void setKd(ContactTwoFramePositions& self,
158 const ::Eigen::VectorXd Kd) {
159 return self.Kd(Kd);
160 }
161 static bool setContactTwoFramePositionss(
162 ContactTwoFramePositions& self,
163 const ::Eigen::MatrixXd ContactTwoFramePositionss) {
164 return self.setContactTwoFramePositionss(ContactTwoFramePositionss);
165 }
166 static bool setContactNormal(ContactTwoFramePositions& self,
167 const ::Eigen::VectorXd contactNormal) {
168 return self.setContactNormal(contactNormal);
169 }
170 static bool setFrictionCoefficient(ContactTwoFramePositions& self,
171 const double frictionCoefficient) {
172 return self.setFrictionCoefficient(frictionCoefficient);
173 }
174 static bool setMinNormalForce(ContactTwoFramePositions& self,
175 const double minNormalForce) {
176 return self.setMinNormalForce(minNormalForce);
177 }
178 static bool setMaxNormalForce(ContactTwoFramePositions& self,
179 const double maxNormalForce) {
180 return self.setMaxNormalForce(maxNormalForce);
181 }
182 static void setForceReference(ContactTwoFramePositions& self,
183 const ::Eigen::VectorXd f_ref) {
184 self.setForceReference(f_ref);
185 }
186 static void setRegularizationTaskWeightVector(ContactTwoFramePositions& self,
187 const ::Eigen::VectorXd w) {
188 self.setRegularizationTaskWeightVector(w);
189 }
190 static double getNormalForce(ContactTwoFramePositions& self,
191 Eigen::VectorXd f) {
192 return self.getNormalForce(f);
193 }
194 7 static void expose(const std::string& class_name) {
195
1/2
✓ Branch 2 taken 7 times.
✗ Branch 3 not taken.
7 std::string doc = "ContactTwoFramePositions info.";
196
1/2
✓ Branch 3 taken 7 times.
✗ Branch 4 not taken.
7 bp::class_<ContactTwoFramePositions>(class_name.c_str(), doc.c_str(),
197 bp::no_init)
198
1/2
✓ Branch 1 taken 7 times.
✗ Branch 2 not taken.
7 .def(ContactTwoFramePositionsPythonVisitor<ContactTwoFramePositions>());
199 7 }
200 };
201 } // namespace python
202 } // namespace tsid
203
204 #endif // ifndef __tsid_python_contact_two_frame_positions_hpp__
205