GCC Code Coverage Report | |||||||||||||||||||||
|
|||||||||||||||||||||
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_com_hpp__ |
||
19 |
#define __tsid_python_task_com_hpp__ |
||
20 |
|||
21 |
#include "tsid/bindings/python/fwd.hpp" |
||
22 |
|||
23 |
#include "tsid/tasks/task-com-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 |
namespace python { |
||
30 |
namespace bp = boost::python; |
||
31 |
|||
32 |
template <typename TaskCOM> |
||
33 |
struct TaskCOMEqualityPythonVisitor |
||
34 |
: public boost::python::def_visitor< |
||
35 |
TaskCOMEqualityPythonVisitor<TaskCOM> > { |
||
36 |
template <class PyClass> |
||
37 |
|||
38 |
7 |
void visit(PyClass& cl) const { |
|
39 |
✓✗ | 7 |
cl.def(bp::init<std::string, robots::RobotWrapper&>( |
40 |
(bp::arg("name"), bp::arg("robot")), "Default Constructor")) |
||
41 |
✓✗✓✗ ✓✗✓✗ |
14 |
.add_property("dim", &TaskCOM::dim, "return dimension size") |
42 |
14 |
.def("setReference", &TaskCOMEqualityPythonVisitor::setReference, |
|
43 |
bp::arg("ref")) |
||
44 |
✓✗✓✗ ✓✗ |
14 |
.add_property("getDesiredAcceleration", |
45 |
bp::make_function( |
||
46 |
&TaskCOMEqualityPythonVisitor::getDesiredAcceleration, |
||
47 |
bp::return_value_policy<bp::copy_const_reference>()), |
||
48 |
"Return Acc_desired") |
||
49 |
✓✗✓✗ |
14 |
.def("getAcceleration", &TaskCOMEqualityPythonVisitor::getAcceleration, |
50 |
bp::arg("dv")) |
||
51 |
✓✗✓✗ |
14 |
.add_property("position_error", |
52 |
bp::make_function( |
||
53 |
&TaskCOMEqualityPythonVisitor::position_error, |
||
54 |
bp::return_value_policy<bp::copy_const_reference>())) |
||
55 |
✓✗✓✗ |
14 |
.add_property("velocity_error", |
56 |
bp::make_function( |
||
57 |
&TaskCOMEqualityPythonVisitor::velocity_error, |
||
58 |
bp::return_value_policy<bp::copy_const_reference>())) |
||
59 |
✓✗✓✗ |
14 |
.add_property("position", |
60 |
bp::make_function( |
||
61 |
&TaskCOMEqualityPythonVisitor::position, |
||
62 |
bp::return_value_policy<bp::copy_const_reference>())) |
||
63 |
✓✗✓✗ |
14 |
.add_property("velocity", |
64 |
bp::make_function( |
||
65 |
&TaskCOMEqualityPythonVisitor::velocity, |
||
66 |
bp::return_value_policy<bp::copy_const_reference>())) |
||
67 |
✓✗✓✗ |
14 |
.add_property("position_ref", |
68 |
bp::make_function( |
||
69 |
&TaskCOMEqualityPythonVisitor::position_ref, |
||
70 |
bp::return_value_policy<bp::copy_const_reference>())) |
||
71 |
✓✗✓✗ |
14 |
.add_property("velocity_ref", |
72 |
bp::make_function( |
||
73 |
&TaskCOMEqualityPythonVisitor::velocity_ref, |
||
74 |
bp::return_value_policy<bp::copy_const_reference>())) |
||
75 |
✓✗✓✗ |
14 |
.add_property("Kp", |
76 |
bp::make_function( |
||
77 |
&TaskCOMEqualityPythonVisitor::Kp, |
||
78 |
bp::return_value_policy<bp::copy_const_reference>())) |
||
79 |
✓✗✓✗ |
14 |
.add_property("Kd", |
80 |
bp::make_function( |
||
81 |
&TaskCOMEqualityPythonVisitor::Kd, |
||
82 |
bp::return_value_policy<bp::copy_const_reference>())) |
||
83 |
✓✗✓✗ |
14 |
.def("setKp", &TaskCOMEqualityPythonVisitor::setKp, bp::arg("Kp")) |
84 |
✓✗✓✗ |
14 |
.def("setKd", &TaskCOMEqualityPythonVisitor::setKd, bp::arg("Kd")) |
85 |
✓✗✓✗ |
14 |
.def("compute", &TaskCOMEqualityPythonVisitor::compute, |
86 |
bp::args("t", "q", "v", "data")) |
||
87 |
✓✗✓✗ |
14 |
.def("getConstraint", &TaskCOMEqualityPythonVisitor::getConstraint) |
88 |
✓✗ | 7 |
.add_property("name", &TaskCOMEqualityPythonVisitor::name) |
89 |
✓✗ | 7 |
.add_property("mask", |
90 |
bp::make_function( |
||
91 |
&TaskCOMEqualityPythonVisitor::getmask, |
||
92 |
bp::return_value_policy<bp::copy_const_reference>()), |
||
93 |
"Return mask") |
||
94 |
✓✗✓✗ ✓✗ |
14 |
.def("setMask", &TaskCOMEqualityPythonVisitor::setmask, |
95 |
bp::arg("mask")); |
||
96 |
7 |
} |
|
97 |
9 |
static std::string name(TaskCOM& self) { |
|
98 |
9 |
std::string name = self.name(); |
|
99 |
9 |
return name; |
|
100 |
} |
||
101 |
1000 |
static math::ConstraintEquality compute(TaskCOM& self, const double t, |
|
102 |
const Eigen::VectorXd& q, |
||
103 |
const Eigen::VectorXd& v, |
||
104 |
pinocchio::Data& data) { |
||
105 |
✓✗✓✗ |
1000 |
self.compute(t, q, v, data); |
106 |
✓✗✓✗ ✓✗✓✗ |
3000 |
math::ConstraintEquality cons(self.getConstraint().name(), |
107 |
✓✗✓✗ |
1000 |
self.getConstraint().matrix(), |
108 |
1000 |
self.getConstraint().vector()); |
|
109 |
1000 |
return cons; |
|
110 |
} |
||
111 |
static math::ConstraintEquality getConstraint(const TaskCOM& self) { |
||
112 |
math::ConstraintEquality cons(self.getConstraint().name(), |
||
113 |
self.getConstraint().matrix(), |
||
114 |
self.getConstraint().vector()); |
||
115 |
return cons; |
||
116 |
} |
||
117 |
2000 |
static void setReference(TaskCOM& self, |
|
118 |
const trajectories::TrajectorySample& ref) { |
||
119 |
2000 |
self.setReference(ref); |
|
120 |
2000 |
} |
|
121 |
static const Eigen::VectorXd& getDesiredAcceleration(const TaskCOM& self) { |
||
122 |
return self.getDesiredAcceleration(); |
||
123 |
} |
||
124 |
static Eigen::VectorXd getAcceleration(TaskCOM& self, |
||
125 |
const Eigen::VectorXd dv) { |
||
126 |
return self.getAcceleration(dv); |
||
127 |
} |
||
128 |
1009 |
static const Eigen::VectorXd& position_error(const TaskCOM& self) { |
|
129 |
1009 |
return self.position_error(); |
|
130 |
} |
||
131 |
10 |
static const Eigen::VectorXd& velocity_error(const TaskCOM& self) { |
|
132 |
10 |
return self.velocity_error(); |
|
133 |
} |
||
134 |
static const Eigen::VectorXd& position(const TaskCOM& self) { |
||
135 |
return self.position(); |
||
136 |
} |
||
137 |
static const Eigen::VectorXd& velocity(const TaskCOM& self) { |
||
138 |
return self.velocity(); |
||
139 |
} |
||
140 |
static const Eigen::VectorXd& position_ref(const TaskCOM& self) { |
||
141 |
return self.position_ref(); |
||
142 |
} |
||
143 |
static const Eigen::VectorXd& velocity_ref(const TaskCOM& self) { |
||
144 |
return self.velocity_ref(); |
||
145 |
} |
||
146 |
1 |
static const Eigen::Vector3d& Kp(TaskCOM& self) { return self.Kp(); } |
|
147 |
1 |
static const Eigen::Vector3d& Kd(TaskCOM& self) { return self.Kd(); } |
|
148 |
2 |
static void setKp(TaskCOM& self, const ::Eigen::VectorXd Kp) { |
|
149 |
✓✗ | 2 |
return self.Kp(Kp); |
150 |
} |
||
151 |
2 |
static void setKd(TaskCOM& self, const ::Eigen::VectorXd Kv) { |
|
152 |
✓✗ | 2 |
return self.Kd(Kv); |
153 |
} |
||
154 |
static const Eigen::VectorXd& getmask(const TaskCOM& self) { |
||
155 |
return self.getMask(); |
||
156 |
} |
||
157 |
static void setmask(TaskCOM& self, const Eigen::VectorXd mask) { |
||
158 |
return self.setMask(mask); |
||
159 |
} |
||
160 |
7 |
static void expose(const std::string& class_name) { |
|
161 |
✓✗ | 14 |
std::string doc = "TaskCOMEqualityPythonVisitor info."; |
162 |
✓✗✓✗ |
7 |
bp::class_<TaskCOM>(class_name.c_str(), doc.c_str(), bp::no_init) |
163 |
.def(TaskCOMEqualityPythonVisitor<TaskCOM>()); |
||
164 |
|||
165 |
✓✗ | 7 |
bp::register_ptr_to_python<boost::shared_ptr<math::ConstraintBase> >(); |
166 |
7 |
} |
|
167 |
}; |
||
168 |
} // namespace python |
||
169 |
} // namespace tsid |
||
170 |
|||
171 |
#endif // ifndef __tsid_python_task_com_hpp__ |
Generated by: GCOVR (Version 4.2) |