GCC Code Coverage Report | |||||||||||||||||||||
|
|||||||||||||||||||||
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 |
✓✗ | 7 |
cl |
41 |
.def(bp::init<std::string, robots::RobotWrapper&, std::string, |
||
42 |
std::string, double, double>( |
||
43 |
(bp::arg("name"), bp::arg("robot"), bp::arg("framename1"), |
||
44 |
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 |
14 |
.add_property("n_force", &ContactTwoFramePositions::n_force, |
|
49 |
"return number of force") |
||
50 |
✓✗ | 7 |
.add_property("name", &ContactTwoFramePositionsPythonVisitor::name, |
51 |
"return name") |
||
52 |
✓✗✓✗ |
7 |
.def("computeMotionTask", |
53 |
&ContactTwoFramePositionsPythonVisitor::computeMotionTask, |
||
54 |
bp::args("t", "q", "v", "data")) |
||
55 |
✓✗✓✗ |
14 |
.def("computeForceTask", |
56 |
&ContactTwoFramePositionsPythonVisitor::computeForceTask, |
||
57 |
bp::args("t", "q", "v", "data")) |
||
58 |
✓✗✓✗ |
14 |
.def("computeForceRegularizationTask", |
59 |
&ContactTwoFramePositionsPythonVisitor:: |
||
60 |
computeForceRegularizationTask, |
||
61 |
bp::args("t", "q", "v", "data")) |
||
62 |
|||
63 |
✓✗✓✗ |
14 |
.add_property( |
64 |
"getForceGeneratorMatrix", |
||
65 |
bp::make_function( |
||
66 |
&ContactTwoFramePositionsPythonVisitor::getForceGeneratorMatrix, |
||
67 |
bp::return_value_policy<bp::copy_const_reference>())) |
||
68 |
|||
69 |
✓✗✓✗ |
14 |
.def("getNormalForce", |
70 |
&ContactTwoFramePositionsPythonVisitor::getNormalForce, |
||
71 |
bp::arg("vec")) |
||
72 |
✓✗✓✗ |
14 |
.add_property("getMinNormalForce", |
73 |
&ContactTwoFramePositions::getMinNormalForce) |
||
74 |
14 |
.add_property("getMaxNormalForce", |
|
75 |
&ContactTwoFramePositions::getMaxNormalForce) |
||
76 |
|||
77 |
✓✗ | 7 |
.add_property("Kp", |
78 |
bp::make_function( |
||
79 |
&ContactTwoFramePositionsPythonVisitor::Kp, |
||
80 |
bp::return_value_policy<bp::copy_const_reference>())) |
||
81 |
✓✗✓✗ ✓✗ |
14 |
.add_property("Kd", |
82 |
bp::make_function( |
||
83 |
&ContactTwoFramePositionsPythonVisitor::Kd, |
||
84 |
bp::return_value_policy<bp::copy_const_reference>())) |
||
85 |
✓✗✓✗ |
14 |
.def("setKp", &ContactTwoFramePositionsPythonVisitor::setKp, |
86 |
bp::arg("Kp")) |
||
87 |
✓✗✓✗ |
14 |
.def("setKd", &ContactTwoFramePositionsPythonVisitor::setKd, |
88 |
bp::arg("Kd")) |
||
89 |
✓✗✓✗ |
14 |
.def("setContactNormal", |
90 |
&ContactTwoFramePositionsPythonVisitor::setContactNormal, |
||
91 |
bp::args("vec")) |
||
92 |
✓✗✓✗ |
14 |
.def("setFrictionCoefficient", |
93 |
&ContactTwoFramePositionsPythonVisitor::setFrictionCoefficient, |
||
94 |
bp::args("friction_coeff")) |
||
95 |
✓✗✓✗ |
14 |
.def("setMinNormalForce", |
96 |
&ContactTwoFramePositionsPythonVisitor::setMinNormalForce, |
||
97 |
bp::args("min_force")) |
||
98 |
✓✗✓✗ |
14 |
.def("setMaxNormalForce", |
99 |
&ContactTwoFramePositionsPythonVisitor::setMaxNormalForce, |
||
100 |
bp::args("max_force")) |
||
101 |
✓✗✓✗ |
14 |
.def("setForceReference", |
102 |
&ContactTwoFramePositionsPythonVisitor::setForceReference, |
||
103 |
bp::args("f_vec")) |
||
104 |
✓✗✓✗ ✓✗ |
14 |
.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 |
✓✗ | 7 |
std::string doc = "ContactTwoFramePositions info."; |
196 |
✓✗✓✗ |
7 |
bp::class_<ContactTwoFramePositions>(class_name.c_str(), doc.c_str(), |
197 |
bp::no_init) |
||
198 |
.def(ContactTwoFramePositionsPythonVisitor<ContactTwoFramePositions>()); |
||
199 |
7 |
} |
|
200 |
}; |
||
201 |
} // namespace python |
||
202 |
} // namespace tsid |
||
203 |
|||
204 |
#endif // ifndef __tsid_python_contact_two_frame_positions_hpp__ |
Generated by: GCOVR (Version 4.2) |