Directory: | ./ |
---|---|
File: | bindings/python/crocoddyl/core/constraints/constraint-manager.cpp |
Date: | 2025-03-26 19:23:43 |
Exec | Total | Coverage | |
---|---|---|---|
Lines: | 70 | 75 | 93.3% |
Branches: | 145 | 292 | 49.7% |
Line | Branch | Exec | Source |
---|---|---|---|
1 | /////////////////////////////////////////////////////////////////////////////// | ||
2 | // BSD 3-Clause License | ||
3 | // | ||
4 | // Copyright (C) 2020-2025, University of Edinburgh, Heriot-Watt University | ||
5 | // Copyright note valid unless otherwise stated in individual files. | ||
6 | // All rights reserved. | ||
7 | /////////////////////////////////////////////////////////////////////////////// | ||
8 | |||
9 | #include "crocoddyl/core/constraints/constraint-manager.hpp" | ||
10 | |||
11 | #include <functional> | ||
12 | #include <map> | ||
13 | #include <memory> | ||
14 | #include <string> | ||
15 | #include <utility> | ||
16 | |||
17 | #include "python/crocoddyl/core/action-base.hpp" | ||
18 | #include "python/crocoddyl/core/core.hpp" | ||
19 | #include "python/crocoddyl/core/diff-action-base.hpp" | ||
20 | #include "python/crocoddyl/utils/map-converter.hpp" | ||
21 | #include "python/crocoddyl/utils/set-converter.hpp" | ||
22 | |||
23 | namespace crocoddyl { | ||
24 | namespace python { | ||
25 | |||
26 | template <typename Model> | ||
27 | struct ConstraintItemVisitor | ||
28 | : public bp::def_visitor<ConstraintItemVisitor<Model>> { | ||
29 | template <class PyClass> | ||
30 | 40 | void visit(PyClass& cl) const { | |
31 |
1/2✓ Branch 1 taken 20 times.
✗ Branch 2 not taken.
|
40 | cl.def_readwrite("name", &Model::name, "constraint name") |
32 |
2/4✓ Branch 1 taken 20 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 20 times.
✗ Branch 5 not taken.
|
40 | .add_property( |
33 | "constraint", | ||
34 | bp::make_getter(&Model::constraint, | ||
35 | ✗ | bp::return_value_policy<bp::return_by_value>()), | |
36 | "constraint model") | ||
37 |
1/2✓ Branch 1 taken 20 times.
✗ Branch 2 not taken.
|
40 | .def_readwrite("active", &Model::active, "constraint status"); |
38 | 40 | } | |
39 | }; | ||
40 | |||
41 | template <typename Model> | ||
42 | struct ConstraintModelManagerVisitor | ||
43 | : public bp::def_visitor<ConstraintModelManagerVisitor<Model>> { | ||
44 |
0/2✗ Branch 2 not taken.
✗ Branch 3 not taken.
|
40 | BOOST_PYTHON_MEMBER_FUNCTION_OVERLOADS( |
45 | ConstraintModelManager_addConstraint_wrap, Model::addConstraint, 2, 3) | ||
46 | typedef typename Model::ConstraintDataManager Data; | ||
47 | typedef typename Model::StateAbstract State; | ||
48 | typedef typename Model::VectorXs VectorXs; | ||
49 | template <class PyClass> | ||
50 | 40 | void visit(PyClass& cl) const { | |
51 |
2/4✓ Branch 2 taken 20 times.
✗ Branch 3 not taken.
✓ Branch 5 taken 20 times.
✗ Branch 6 not taken.
|
40 | cl.def(bp::init<std::shared_ptr<State>, std::size_t>( |
52 | bp::args("self", "state", "nu"), | ||
53 | "Initialize the total constraint model.\n\n" | ||
54 | "For this case the default nu is equals to model.nv.\n" | ||
55 | ":param state: state description\n" | ||
56 | ":param nu: dimension of control vector")) | ||
57 |
3/6✓ Branch 1 taken 20 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 20 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 20 times.
✗ Branch 8 not taken.
|
80 | .def(bp::init<std::shared_ptr<State>>( |
58 | bp::args("self", "state"), | ||
59 | "Initialize the total constraint model.\n\n" | ||
60 | "For this case the default nu is equals to model.nv.\n" | ||
61 | ":param state: state description")) | ||
62 | 80 | .def("addConstraint", &Model::addConstraint, | |
63 |
2/4✓ Branch 1 taken 20 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 20 times.
✗ Branch 5 not taken.
|
80 | ConstraintModelManager_addConstraint_wrap( |
64 | bp::args("self", "name", "constraint", "active"), | ||
65 | "Add a constraint item.\n\n" | ||
66 | ":param name: constraint name\n" | ||
67 | ":param constraint: constraint model\n" | ||
68 | ":param active: True if the constraint is activated (default " | ||
69 | "true)")) | ||
70 |
2/4✓ Branch 1 taken 20 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 20 times.
✗ Branch 5 not taken.
|
80 | .def("removeConstraint", &Model::removeConstraint, |
71 | bp::args("self", "name"), | ||
72 | "Remove a constraint item.\n\n" | ||
73 | ":param name: constraint name") | ||
74 |
2/4✓ Branch 1 taken 20 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 20 times.
✗ Branch 5 not taken.
|
80 | .def("changeConstraintStatus", &Model::changeConstraintStatus, |
75 | bp::args("self", "name", "active"), | ||
76 | "Change the constraint status.\n\n" | ||
77 | ":param name: constraint name\n" | ||
78 | ":param active: constraint status (true for active and false for " | ||
79 | "inactive)") | ||
80 |
2/4✓ Branch 1 taken 20 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 20 times.
✗ Branch 5 not taken.
|
80 | .def( |
81 | "calc", | ||
82 | static_cast<void (Model::*)( | ||
83 | const std::shared_ptr<Data>&, const Eigen::Ref<const VectorXs>&, | ||
84 | const Eigen::Ref<const VectorXs>&)>(&Model::calc), | ||
85 | bp::args("self", "data", "x", "u"), | ||
86 | "Compute the total constraint.\n\n" | ||
87 | ":param data: constraint-manager data\n" | ||
88 | ":param x: state point (dim. state.nx)\n" | ||
89 | ":param u: control input (dim. nu)") | ||
90 |
2/4✓ Branch 1 taken 20 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 20 times.
✗ Branch 5 not taken.
|
80 | .def("calc", |
91 | static_cast<void (Model::*)(const std::shared_ptr<Data>&, | ||
92 | const Eigen::Ref<const VectorXs>&)>( | ||
93 | &Model::calc), | ||
94 | bp::args("self", "data", "x"), | ||
95 | "Compute the total constraint value for nodes that depends only " | ||
96 | "on the state.\n\n" | ||
97 | "It updates the total constraint based on the state only. This " | ||
98 | "function is used in the terminal nodes of an optimal control " | ||
99 | "problem.\n" | ||
100 | ":param data: constraint-manager data\n" | ||
101 | ":param x: state point (dim. state.nx)") | ||
102 |
2/4✓ Branch 1 taken 20 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 20 times.
✗ Branch 5 not taken.
|
80 | .def( |
103 | "calcDiff", | ||
104 | static_cast<void (Model::*)( | ||
105 | const std::shared_ptr<Data>&, const Eigen::Ref<const VectorXs>&, | ||
106 | const Eigen::Ref<const VectorXs>&)>(&Model::calcDiff), | ||
107 | bp::args("self", "data", "x", "u"), | ||
108 | "Compute the derivatives of the total constraint.\n\n" | ||
109 | "It assumes that calc has been run first.\n" | ||
110 | ":param data: constraint-manager data\n" | ||
111 | ":param x: state point (dim. state.nx)\n" | ||
112 | ":param u: control input (dim. nu)\n") | ||
113 |
2/4✓ Branch 1 taken 20 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 20 times.
✗ Branch 5 not taken.
|
80 | .def("calcDiff", |
114 | static_cast<void (Model::*)(const std::shared_ptr<Data>&, | ||
115 | const Eigen::Ref<const VectorXs>&)>( | ||
116 | &Model::calcDiff), | ||
117 | bp::args("self", "data", "x"), | ||
118 | "Compute the Jacobian of the total constraint for nodes that " | ||
119 | "depends on the state only.\n\n" | ||
120 | "It updates the Jacobian of the total constraint based on the " | ||
121 | "state only. This function is used in the terminal nodes of an " | ||
122 | "optimal control problem.\n" | ||
123 | ":param data: constraint-manager data\n" | ||
124 | ":param x: state point (dim. state.nx)") | ||
125 |
2/4✓ Branch 1 taken 20 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 20 times.
✗ Branch 5 not taken.
|
80 | .def("createData", &Model::createData, |
126 | ✗ | bp::with_custodian_and_ward_postcall<0, 2>(), | |
127 | bp::args("self", "data"), | ||
128 | "Create the total constraint data.\n\n" | ||
129 | ":param data: shared data\n" | ||
130 | ":return total constraint data.") | ||
131 |
3/6✓ Branch 1 taken 20 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 20 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 20 times.
✗ Branch 8 not taken.
|
40 | .add_property( |
132 | "state", | ||
133 | bp::make_function(&Model::get_state, | ||
134 | 40 | bp::return_value_policy<bp::return_by_value>()), | |
135 | "state description") | ||
136 |
2/4✓ Branch 1 taken 20 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 20 times.
✗ Branch 5 not taken.
|
40 | .add_property( |
137 | "constraints", | ||
138 | bp::make_function(&Model::get_constraints, | ||
139 | 40 | bp::return_value_policy<bp::return_by_value>()), | |
140 | "stack of constraints") | ||
141 |
2/4✓ Branch 1 taken 20 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 20 times.
✗ Branch 5 not taken.
|
80 | .add_property("nu", bp::make_function(&Model::get_nu), |
142 | "dimension of control vector") | ||
143 |
2/4✓ Branch 1 taken 20 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 20 times.
✗ Branch 5 not taken.
|
80 | .add_property("ng", bp::make_function(&Model::get_ng), |
144 | "number of active inequality constraints") | ||
145 |
2/4✓ Branch 1 taken 20 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 20 times.
✗ Branch 5 not taken.
|
80 | .add_property("nh", bp::make_function(&Model::get_nh), |
146 | "number of active equality constraints") | ||
147 |
2/4✓ Branch 1 taken 20 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 20 times.
✗ Branch 5 not taken.
|
80 | .add_property("ng_T", bp::make_function(&Model::get_ng_T), |
148 | "number of active inequality terminal constraints") | ||
149 |
2/4✓ Branch 1 taken 20 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 20 times.
✗ Branch 5 not taken.
|
80 | .add_property("nh_T", bp::make_function(&Model::get_nh_T), |
150 | "number of active equality terminal constraints") | ||
151 |
2/4✓ Branch 1 taken 20 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 20 times.
✗ Branch 5 not taken.
|
40 | .add_property( |
152 | "active_set", | ||
153 | bp::make_function(&Model::get_active_set, | ||
154 | 40 | bp::return_value_policy<bp::return_by_value>()), | |
155 | "name of the active set of constraint items") | ||
156 |
2/4✓ Branch 1 taken 20 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 20 times.
✗ Branch 5 not taken.
|
40 | .add_property( |
157 | "inactive_set", | ||
158 | bp::make_function(&Model::get_inactive_set, | ||
159 | 40 | bp::return_value_policy<bp::return_by_value>()), | |
160 | "name of the inactive set of constraint items") | ||
161 |
2/4✓ Branch 1 taken 20 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 20 times.
✗ Branch 5 not taken.
|
40 | .add_property("g_lb", |
162 | bp::make_function(&Model::get_lb, | ||
163 | 40 | bp::return_internal_reference<>()), | |
164 | "lower bound of the inequality constraints") | ||
165 |
2/4✓ Branch 1 taken 20 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 20 times.
✗ Branch 5 not taken.
|
40 | .add_property("g_ub", |
166 | bp::make_function(&Model::get_ub, | ||
167 | 40 | bp::return_internal_reference<>()), | |
168 | "upper bound of the inequality constraints") | ||
169 |
2/4✓ Branch 1 taken 20 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 20 times.
✗ Branch 5 not taken.
|
40 | .def("getConstraintStatus", &Model::getConstraintStatus, |
170 | bp::args("self", "name"), | ||
171 | "Return the constraint status of a given constraint name.\n\n" | ||
172 | ":param name: constraint name"); | ||
173 | 40 | } | |
174 | }; | ||
175 | |||
176 | template <typename Data> | ||
177 | struct ConstraintDataManagerVisitor | ||
178 | : public bp::def_visitor<ConstraintDataManagerVisitor<Data>> { | ||
179 | 40 | BOOST_PYTHON_MEMBER_FUNCTION_OVERLOADS(ConstraintDataManager_resizeConst_wrap, | |
180 | Data::resize, 1, 2) | ||
181 | 80 | BOOST_PYTHON_MEMBER_FUNCTION_OVERLOADS(ConstraintDataManager_resize_wrap, | |
182 | Data::resize, 2, 3) | ||
183 | typedef typename Data::Scalar Scalar; | ||
184 | typedef ConstraintModelManagerTpl<Scalar> Model; | ||
185 | typedef DifferentialActionModelAbstractTpl<Scalar> DifferentialActionModel; | ||
186 | typedef DifferentialActionDataAbstractTpl<Scalar> DifferentialActionData; | ||
187 | typedef ActionModelAbstractTpl<Scalar> ActionModel; | ||
188 | typedef ActionDataAbstractTpl<Scalar> ActionData; | ||
189 | template <class PyClass> | ||
190 | 40 | void visit(PyClass& cl) const { | |
191 | 40 | cl.def( | |
192 | "shareMemory", &Data::template shareMemory<DifferentialActionData>, | ||
193 | bp::args("self", "data"), | ||
194 | "Share memory with a given differential action data\n\n" | ||
195 | ":param model: differential action data that we want to share memory") | ||
196 |
2/4✓ Branch 1 taken 20 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 20 times.
✗ Branch 5 not taken.
|
80 | .def("shareMemory", &Data::template shareMemory<ActionData>, |
197 | bp::args("self", "data"), | ||
198 | "Share memory with a given action data\n\n" | ||
199 | ":param model: action data that we want to share memory") | ||
200 |
1/2✓ Branch 1 taken 20 times.
✗ Branch 2 not taken.
|
40 | .def("resize", &Data::template resize<Model>, |
201 | ✗ | bp::with_custodian_and_ward_postcall<0, 1>(), | |
202 |
2/4✓ Branch 1 taken 20 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 20 times.
✗ Branch 5 not taken.
|
80 | ConstraintDataManager_resizeConst_wrap( |
203 | bp::args("self", "model", "running_node"), | ||
204 | "Resize the data given differential action data\n\n" | ||
205 | ":param model: constraint manager model that defines how to " | ||
206 | "resize " | ||
207 | "the data\n" | ||
208 | ":param running_node: true if we are resizing for a running " | ||
209 | "node, false for terminal ones (default true)")) | ||
210 |
1/2✓ Branch 1 taken 20 times.
✗ Branch 2 not taken.
|
40 | .def( |
211 | "resize", | ||
212 | &Data::template resize<DifferentialActionModel, | ||
213 | DifferentialActionData>, | ||
214 | ✗ | bp::with_custodian_and_ward_postcall<0, 2>(), | |
215 |
2/4✓ Branch 1 taken 20 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 20 times.
✗ Branch 5 not taken.
|
80 | ConstraintDataManager_resize_wrap( |
216 | bp::args("self", "model", "data", "running_node"), | ||
217 | "Resize the data given differential action data\n\n" | ||
218 | ":param model: differential action model that defines how to " | ||
219 | "resize " | ||
220 | "the data\n" | ||
221 | ":param data: differential action data that we want to resize\n" | ||
222 | ":param running_node: true if we are resizing for a running " | ||
223 | "node, false for terminal ones (default true)")) | ||
224 |
1/2✓ Branch 1 taken 20 times.
✗ Branch 2 not taken.
|
40 | .def("resize", &Data::template resize<ActionModel, ActionData>, |
225 | ✗ | bp::with_custodian_and_ward_postcall<0, 2>(), | |
226 |
2/4✓ Branch 1 taken 20 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 20 times.
✗ Branch 5 not taken.
|
80 | ConstraintDataManager_resize_wrap( |
227 | bp::args("self", "model", "data", "running_node"), | ||
228 | "Resize the data given action data\n\n" | ||
229 | ":param model: action model that defines how to resize the " | ||
230 | "data\n" | ||
231 | ":param data: action data that we want to resize\n" | ||
232 | ":param running_node: true if we are resizing for a running " | ||
233 | "node, false for terminal ones (default true)")) | ||
234 |
3/6✓ Branch 1 taken 20 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 20 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 20 times.
✗ Branch 8 not taken.
|
40 | .add_property( |
235 | "constraints", | ||
236 | bp::make_getter(&Data::constraints, | ||
237 | 40 | bp::return_value_policy<bp::return_by_value>()), | |
238 | "stack of constraints data") | ||
239 |
2/4✓ Branch 1 taken 20 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 20 times.
✗ Branch 5 not taken.
|
40 | .add_property( |
240 | "shared", | ||
241 | 40 | bp::make_getter(&Data::shared, bp::return_internal_reference<>()), | |
242 | "shared data") | ||
243 |
3/6✓ Branch 1 taken 20 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 20 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 20 times.
✗ Branch 8 not taken.
|
80 | .add_property( |
244 | "g", | ||
245 | bp::make_function(&Data::get_g, | ||
246 | 40 | bp::return_value_policy<bp::return_by_value>()), | |
247 | bp::make_function(&Data::set_g), "Inequality constraint residual") | ||
248 |
3/6✓ Branch 1 taken 20 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 20 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 20 times.
✗ Branch 8 not taken.
|
80 | .add_property( |
249 | "Gx", | ||
250 | bp::make_function(&Data::get_Gx, | ||
251 | 40 | bp::return_value_policy<bp::return_by_value>()), | |
252 | bp::make_function(&Data::set_Gx), | ||
253 | "Jacobian of the inequality constraint") | ||
254 |
3/6✓ Branch 1 taken 20 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 20 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 20 times.
✗ Branch 8 not taken.
|
80 | .add_property( |
255 | "Gu", | ||
256 | bp::make_function(&Data::get_Gu, | ||
257 | 40 | bp::return_value_policy<bp::return_by_value>()), | |
258 | bp::make_function(&Data::set_Gu), | ||
259 | "Jacobian of the inequality constraint") | ||
260 |
3/6✓ Branch 1 taken 20 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 20 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 20 times.
✗ Branch 8 not taken.
|
80 | .add_property( |
261 | "h", | ||
262 | bp::make_function(&Data::get_h, | ||
263 | 40 | bp::return_value_policy<bp::return_by_value>()), | |
264 | bp::make_function(&Data::set_h), "Equality constraint residual") | ||
265 |
3/6✓ Branch 1 taken 20 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 20 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 20 times.
✗ Branch 8 not taken.
|
80 | .add_property( |
266 | "Hx", | ||
267 | bp::make_function(&Data::get_Hx, | ||
268 | 40 | bp::return_value_policy<bp::return_by_value>()), | |
269 | bp::make_function(&Data::set_Hx), | ||
270 | "Jacobian of the equality constraint") | ||
271 |
3/6✓ Branch 1 taken 20 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 20 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 20 times.
✗ Branch 8 not taken.
|
80 | .add_property( |
272 | "Hu", | ||
273 | bp::make_function(&Data::get_Hu, | ||
274 | 40 | bp::return_value_policy<bp::return_by_value>()), | |
275 | bp::make_function(&Data::set_Hu), | ||
276 | "Jacobian of the equality constraint"); | ||
277 | 40 | } | |
278 | }; | ||
279 | |||
280 | #define CROCODDYL_CONSTRAINT_ITEM_PYTHON_BINDINGS(Scalar) \ | ||
281 | typedef ConstraintItemTpl<Scalar> Model; \ | ||
282 | typedef Model::ConstraintModelAbstract ConstraintModel; \ | ||
283 | typedef std::shared_ptr<Model> ConstraintItemPtr; \ | ||
284 | StdMapPythonVisitor< \ | ||
285 | std::string, ConstraintItemPtr, std::less<std::string>, \ | ||
286 | std::allocator<std::pair<const std::string, ConstraintItemPtr>>, \ | ||
287 | true>::expose("StdMap_ConstraintItem"); \ | ||
288 | typedef ConstraintDataAbstractTpl<Scalar> ConstraintData; \ | ||
289 | typedef std::shared_ptr<ConstraintData> ConstraintDataPtr; \ | ||
290 | StdMapPythonVisitor< \ | ||
291 | std::string, ConstraintDataPtr, std::less<std::string>, \ | ||
292 | std::allocator<std::pair<const std::string, ConstraintDataPtr>>, \ | ||
293 | true>::expose("StdMap_ConstraintData"); \ | ||
294 | bp::register_ptr_to_python<std::shared_ptr<Model>>(); \ | ||
295 | bp::class_<Model>("ConstraintItem", "Describe a constraint item.\n\n", \ | ||
296 | bp::init<std::string, std::shared_ptr<ConstraintModel>, \ | ||
297 | bp::optional<bool>>( \ | ||
298 | bp::args("self", "name", "constraint", "active"), \ | ||
299 | "Initialize the constraint item.\n\n" \ | ||
300 | ":param name: constraint name\n" \ | ||
301 | ":param constraint: constraint model\n" \ | ||
302 | ":param active: True if the constraint is activated " \ | ||
303 | "(default true)")) \ | ||
304 | .def(ConstraintItemVisitor<Model>()) \ | ||
305 | .def(CastVisitor<Model>()) \ | ||
306 | .def(PrintableVisitor<Model>()) \ | ||
307 | .def(CopyableVisitor<Model>()); | ||
308 | |||
309 | #define CROCODDYL_CONSTRAINT_MODEL_MANAGER_PYTHON_BINDINGS(Scalar) \ | ||
310 | typedef ConstraintModelManagerTpl<Scalar> Model; \ | ||
311 | typedef Model::StateAbstract State; \ | ||
312 | bp::register_ptr_to_python<std::shared_ptr<Model>>(); \ | ||
313 | bp::class_<Model>("ConstraintModelManager", \ | ||
314 | bp::init<std::shared_ptr<State>, std::size_t>( \ | ||
315 | bp::args("self", "state", "nu"), \ | ||
316 | "Initialize the total constraint model.\n\n" \ | ||
317 | ":param state: state description\n" \ | ||
318 | ":param nu: dimension of control vector")) \ | ||
319 | .def(ConstraintModelManagerVisitor<Model>()) \ | ||
320 | .def(CastVisitor<Model>()) \ | ||
321 | .def(PrintableVisitor<Model>()) \ | ||
322 | .def(CopyableVisitor<Model>()); | ||
323 | |||
324 | #define CROCODDYL_CONSTRAINT_DATA_MANAGER_PYTHON_BINDINGS(Scalar) \ | ||
325 | typedef ConstraintDataManagerTpl<Scalar> Data; \ | ||
326 | typedef ConstraintModelManagerTpl<Scalar> Model; \ | ||
327 | typedef Model::DataCollectorAbstract DataCollector; \ | ||
328 | bp::register_ptr_to_python<std::shared_ptr<Data>>(); \ | ||
329 | bp::class_<Data>( \ | ||
330 | "ConstraintDataManager", "Class for total constraint data.\n\n", \ | ||
331 | bp::init<Model*, DataCollector*>( \ | ||
332 | bp::args("self", "model", "data"), \ | ||
333 | "Create total constraint data.\n\n" \ | ||
334 | ":param model: total constraint model\n" \ | ||
335 | ":param data: shared data")[bp::with_custodian_and_ward<1, 3>()]) \ | ||
336 | .def(ConstraintDataManagerVisitor<Data>()) \ | ||
337 | .def(CopyableVisitor<Data>()); | ||
338 | |||
339 | 10 | void exposeConstraintManager() { | |
340 |
29/58✓ Branch 2 taken 10 times.
✗ Branch 3 not taken.
✓ Branch 6 taken 10 times.
✗ Branch 7 not taken.
✓ Branch 9 taken 10 times.
✗ Branch 10 not taken.
✓ Branch 17 taken 10 times.
✗ Branch 18 not taken.
✓ Branch 21 taken 10 times.
✗ Branch 22 not taken.
✓ Branch 24 taken 10 times.
✗ Branch 25 not taken.
✓ Branch 33 taken 10 times.
✗ Branch 34 not taken.
✓ Branch 36 taken 10 times.
✗ Branch 37 not taken.
✓ Branch 39 taken 10 times.
✗ Branch 40 not taken.
✓ Branch 42 taken 10 times.
✗ Branch 43 not taken.
✓ Branch 45 taken 10 times.
✗ Branch 46 not taken.
✓ Branch 48 taken 10 times.
✗ Branch 49 not taken.
✓ Branch 54 taken 10 times.
✗ Branch 55 not taken.
✓ Branch 57 taken 10 times.
✗ Branch 58 not taken.
✓ Branch 60 taken 10 times.
✗ Branch 61 not taken.
✓ Branch 66 taken 10 times.
✗ Branch 67 not taken.
✓ Branch 70 taken 10 times.
✗ Branch 71 not taken.
✓ Branch 73 taken 10 times.
✗ Branch 74 not taken.
✓ Branch 81 taken 10 times.
✗ Branch 82 not taken.
✓ Branch 85 taken 10 times.
✗ Branch 86 not taken.
✓ Branch 88 taken 10 times.
✗ Branch 89 not taken.
✓ Branch 95 taken 10 times.
✗ Branch 96 not taken.
✓ Branch 98 taken 10 times.
✗ Branch 99 not taken.
✓ Branch 101 taken 10 times.
✗ Branch 102 not taken.
✓ Branch 104 taken 10 times.
✗ Branch 105 not taken.
✓ Branch 107 taken 10 times.
✗ Branch 108 not taken.
✓ Branch 110 taken 10 times.
✗ Branch 111 not taken.
✓ Branch 113 taken 10 times.
✗ Branch 114 not taken.
✓ Branch 116 taken 10 times.
✗ Branch 117 not taken.
|
20 | CROCODDYL_PYTHON_SCALARS(CROCODDYL_CONSTRAINT_ITEM_PYTHON_BINDINGS) |
341 |
17/34✓ Branch 3 taken 10 times.
✗ Branch 4 not taken.
✓ Branch 6 taken 10 times.
✗ Branch 7 not taken.
✓ Branch 9 taken 10 times.
✗ Branch 10 not taken.
✓ Branch 12 taken 10 times.
✗ Branch 13 not taken.
✓ Branch 15 taken 10 times.
✗ Branch 16 not taken.
✓ Branch 18 taken 10 times.
✗ Branch 19 not taken.
✓ Branch 24 taken 10 times.
✗ Branch 25 not taken.
✓ Branch 27 taken 10 times.
✗ Branch 28 not taken.
✓ Branch 30 taken 10 times.
✗ Branch 31 not taken.
✓ Branch 35 taken 10 times.
✗ Branch 36 not taken.
✓ Branch 38 taken 10 times.
✗ Branch 39 not taken.
✓ Branch 41 taken 10 times.
✗ Branch 42 not taken.
✓ Branch 44 taken 10 times.
✗ Branch 45 not taken.
✓ Branch 47 taken 10 times.
✗ Branch 48 not taken.
✓ Branch 50 taken 10 times.
✗ Branch 51 not taken.
✓ Branch 53 taken 10 times.
✗ Branch 54 not taken.
✓ Branch 56 taken 10 times.
✗ Branch 57 not taken.
|
20 | CROCODDYL_PYTHON_SCALARS(CROCODDYL_CONSTRAINT_MODEL_MANAGER_PYTHON_BINDINGS) |
342 |
15/30✓ Branch 3 taken 10 times.
✗ Branch 4 not taken.
✓ Branch 6 taken 10 times.
✗ Branch 7 not taken.
✓ Branch 9 taken 10 times.
✗ Branch 10 not taken.
✓ Branch 12 taken 10 times.
✗ Branch 13 not taken.
✓ Branch 15 taken 10 times.
✗ Branch 16 not taken.
✓ Branch 21 taken 10 times.
✗ Branch 22 not taken.
✓ Branch 24 taken 10 times.
✗ Branch 25 not taken.
✓ Branch 27 taken 10 times.
✗ Branch 28 not taken.
✓ Branch 32 taken 10 times.
✗ Branch 33 not taken.
✓ Branch 35 taken 10 times.
✗ Branch 36 not taken.
✓ Branch 38 taken 10 times.
✗ Branch 39 not taken.
✓ Branch 41 taken 10 times.
✗ Branch 42 not taken.
✓ Branch 44 taken 10 times.
✗ Branch 45 not taken.
✓ Branch 47 taken 10 times.
✗ Branch 48 not taken.
✓ Branch 50 taken 10 times.
✗ Branch 51 not taken.
|
20 | CROCODDYL_PYTHON_SCALARS(CROCODDYL_CONSTRAINT_DATA_MANAGER_PYTHON_BINDINGS) |
343 | 10 | } | |
344 | |||
345 | } // namespace python | ||
346 | } // namespace crocoddyl | ||
347 |