Directory: | ./ |
---|---|
File: | bindings/python/crocoddyl/core/actions/diff-lqr.cpp |
Date: | 2025-03-26 19:23:43 |
Exec | Total | Coverage | |
---|---|---|---|
Lines: | 72 | 72 | 100.0% |
Branches: | 141 | 282 | 50.0% |
Line | Branch | Exec | Source |
---|---|---|---|
1 | /////////////////////////////////////////////////////////////////////////////// | ||
2 | // BSD 3-Clause License | ||
3 | // | ||
4 | // Copyright (C) 2019-2025, LAAS-CNRS, University of Edinburgh | ||
5 | // Heriot-Watt University | ||
6 | // Copyright note valid unless otherwise stated in individual files. | ||
7 | // All rights reserved. | ||
8 | /////////////////////////////////////////////////////////////////////////////// | ||
9 | |||
10 | #include "crocoddyl/core/actions/diff-lqr.hpp" | ||
11 | |||
12 | #include "python/crocoddyl/core/core.hpp" | ||
13 | #include "python/crocoddyl/core/diff-action-base.hpp" | ||
14 | #include "python/crocoddyl/utils/deprecate.hpp" | ||
15 | |||
16 | namespace crocoddyl { | ||
17 | namespace python { | ||
18 | |||
19 | template <typename Model> | ||
20 | struct DifferentialActionModelLQRVisitor | ||
21 | : public bp::def_visitor<DifferentialActionModelLQRVisitor<Model>> { | ||
22 | typedef typename Model::DifferentialActionDataAbstract Data; | ||
23 | typedef typename Model::Base ModelBase; | ||
24 | typedef typename Model::MatrixXs MatrixXs; | ||
25 | typedef typename Model::VectorXs VectorXs; | ||
26 | 42 | BOOST_PYTHON_FUNCTION_OVERLOADS(DifferentialActionModelLQR_Random_wrap, | |
27 | Model::Random, 2, 4) | ||
28 | template <class PyClass> | ||
29 | 40 | void visit(PyClass& cl) const { | |
30 |
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<MatrixXs, MatrixXs, MatrixXs, MatrixXs, MatrixXs, MatrixXs, |
31 | VectorXs, VectorXs, VectorXs>( | ||
32 | bp::args("self", "Aq", "Av", "B", "Q", "R", "N", "f", "q", "r"), | ||
33 | "Initialize the differential LQR action model.\n\n" | ||
34 | ":param Aq: position matrix\n" | ||
35 | ":param Av: velocity matrix\n" | ||
36 | ":param B: input matrix\n" | ||
37 | ":param Q: state weight matrix\n" | ||
38 | ":param R: input weight matrix\n" | ||
39 | ":param N: state-input weight matrix\n" | ||
40 | ":param f: dynamics drift\n" | ||
41 | ":param q: state weight vector\n" | ||
42 | ":param r: input weight vector")) | ||
43 |
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<MatrixXs, MatrixXs, MatrixXs, MatrixXs, MatrixXs, |
44 | MatrixXs, MatrixXs, MatrixXs, VectorXs, VectorXs, | ||
45 | VectorXs, VectorXs, VectorXs>( | ||
46 | bp::args("self", "Aq", "Av", "B", "Q", "R", "N", "G", "H", "f", "q", | ||
47 | "r", "g", "h"), | ||
48 | "Initialize the differential LQR action model.\n\n" | ||
49 | ":param Aq: position matrix\n" | ||
50 | ":param Av: velocity matrix\n" | ||
51 | ":param B: input matrix\n" | ||
52 | ":param Q: state weight matrix\n" | ||
53 | ":param R: input weight matrix\n" | ||
54 | ":param N: state-input weight matrix\n" | ||
55 | ":param G: state-input inequality constraint matrix\n" | ||
56 | ":param H: state-input equality constraint matrix\n" | ||
57 | ":param f: dynamics drift\n" | ||
58 | ":param q: state weight vector\n" | ||
59 | ":param r: input weight vector\n" | ||
60 | ":param g: state-input inequality constraint bias\n" | ||
61 | ":param h: state-input equality constraint bias")) | ||
62 |
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::size_t, std::size_t, bp::optional<bool>>( |
63 | bp::args("self", "nq", "nu", "driftFree"), | ||
64 | "Initialize the differential LQR action model.\n\n" | ||
65 | ":param nx: dimension of the state vector\n" | ||
66 | ":param nu: dimension of the control vector\n" | ||
67 | ":param driftFree: enable/disable the bias term of the linear " | ||
68 | "dynamics (default True)")) | ||
69 |
1/2✓ Branch 1 taken 20 times.
✗ Branch 2 not taken.
|
80 | .def( |
70 | "calc", | ||
71 | static_cast<void (Model::*)( | ||
72 | const std::shared_ptr<Data>&, const Eigen::Ref<const VectorXs>&, | ||
73 | const Eigen::Ref<const VectorXs>&)>(&Model::calc), | ||
74 | bp::args("self", "data", "x", "u"), | ||
75 | "Compute the next state and cost value.\n\n" | ||
76 | "It describes the time-continuous evolution of the LQR system. " | ||
77 | "Additionally it computes the cost value associated to this " | ||
78 | "discrete state and control pair.\n" | ||
79 | ":param data: action data\n" | ||
80 | ":param x: time-continuous state vector\n" | ||
81 | ":param u: time-continuous control input") | ||
82 |
2/4✓ Branch 1 taken 20 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 20 times.
✗ Branch 5 not taken.
|
80 | .def("calc", |
83 | static_cast<void (Model::*)(const std::shared_ptr<Data>&, | ||
84 | const Eigen::Ref<const VectorXs>&)>( | ||
85 | &Model::calc), | ||
86 | bp::args("self", "data", "x")) | ||
87 |
2/4✓ Branch 1 taken 20 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 20 times.
✗ Branch 5 not taken.
|
80 | .def( |
88 | "calcDiff", | ||
89 | static_cast<void (Model::*)( | ||
90 | const std::shared_ptr<Data>&, const Eigen::Ref<const VectorXs>&, | ||
91 | const Eigen::Ref<const VectorXs>&)>(&Model::calcDiff), | ||
92 | bp::args("self", "data", "x", "u"), | ||
93 | "Compute the derivatives of the differential LQR dynamics and cost " | ||
94 | "functions.\n\n" | ||
95 | "It computes the partial derivatives of the differential LQR " | ||
96 | "system " | ||
97 | "and the\n" | ||
98 | "cost function. It assumes that calc has been run first.\n" | ||
99 | "This function builds a quadratic approximation of the\n" | ||
100 | "action model (i.e. dynamical system and cost function).\n" | ||
101 | ":param data: action data\n" | ||
102 | ":param x: time-continuous state vector\n" | ||
103 | ":param u: time-continuous control input\n") | ||
104 |
2/4✓ Branch 1 taken 20 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 20 times.
✗ Branch 5 not taken.
|
80 | .def("calcDiff", |
105 | static_cast<void (Model::*)(const std::shared_ptr<Data>&, | ||
106 | const Eigen::Ref<const VectorXs>&)>( | ||
107 | &Model::calcDiff), | ||
108 | bp::args("self", "data", "x")) | ||
109 |
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, bp::args("self"), |
110 | "Create the differential LQR action data.") | ||
111 |
2/4✓ Branch 1 taken 20 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 20 times.
✗ Branch 5 not taken.
|
80 | .def("Random", &Model::Random, |
112 |
2/4✓ Branch 1 taken 20 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 20 times.
✗ Branch 5 not taken.
|
80 | DifferentialActionModelLQR_Random_wrap( |
113 | bp::args("nq", "nu", "ng", "nh"), | ||
114 | "Create a random LQR model.\n\n" | ||
115 | ":param: nq: position dimension\n" | ||
116 | ":param nu: control dimension\n" | ||
117 | ":param ng: inequality constraint dimension (default 0)\n" | ||
118 | ":param nh: equality constraint dimension (default 0)")) | ||
119 |
1/2✓ Branch 1 taken 20 times.
✗ Branch 2 not taken.
|
40 | .staticmethod("Random") |
120 |
1/2✓ Branch 1 taken 20 times.
✗ Branch 2 not taken.
|
80 | .def("setLQR", &Model::set_LQR, |
121 | bp::args("self", "Aq", "Av", "B", "Q", "R", "N", "f", "q", "r"), | ||
122 | "Modify the LQR action model.\n\n" | ||
123 | ":param Aq: position matrix\n" | ||
124 | ":param Av: velocity matrix\n" | ||
125 | ":param B: input matrix\n" | ||
126 | ":param Q: state weight matrix\n" | ||
127 | ":param R: input weight matrix\n" | ||
128 | ":param N: state-input weight matrix\n" | ||
129 | ":param f: dynamics drift\n" | ||
130 | ":param q: state weight vector\n" | ||
131 | ":param r: input weight vector") | ||
132 |
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("Aq", |
133 | bp::make_function(&Model::get_Aq, | ||
134 | 40 | bp::return_internal_reference<>()), | |
135 | "position matrix") | ||
136 |
2/4✓ Branch 1 taken 20 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 20 times.
✗ Branch 5 not taken.
|
40 | .add_property("Av", |
137 | bp::make_function(&Model::get_Av, | ||
138 | 40 | bp::return_internal_reference<>()), | |
139 | "velocity matrix") | ||
140 |
2/4✓ Branch 1 taken 20 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 20 times.
✗ Branch 5 not taken.
|
40 | .add_property( |
141 | "B", | ||
142 | 40 | bp::make_function(&Model::get_B, bp::return_internal_reference<>()), | |
143 | "input matrix") | ||
144 |
2/4✓ Branch 1 taken 20 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 20 times.
✗ Branch 5 not taken.
|
40 | .add_property( |
145 | "f", | ||
146 | 40 | bp::make_function(&Model::get_f, bp::return_internal_reference<>()), | |
147 | "dynamics drift") | ||
148 |
2/4✓ Branch 1 taken 20 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 20 times.
✗ Branch 5 not taken.
|
40 | .add_property( |
149 | "Q", | ||
150 | 40 | bp::make_function(&Model::get_Q, bp::return_internal_reference<>()), | |
151 | "state weight matrix") | ||
152 |
2/4✓ Branch 1 taken 20 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 20 times.
✗ Branch 5 not taken.
|
40 | .add_property( |
153 | "R", | ||
154 | 40 | bp::make_function(&Model::get_R, bp::return_internal_reference<>()), | |
155 | "input weight matrix") | ||
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 | "N", | ||
158 | 40 | bp::make_function(&Model::get_N, bp::return_internal_reference<>()), | |
159 | "state-input weight matrix") | ||
160 |
2/4✓ Branch 1 taken 20 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 20 times.
✗ Branch 5 not taken.
|
40 | .add_property( |
161 | "G", | ||
162 | 40 | bp::make_function(&Model::get_G, bp::return_internal_reference<>()), | |
163 | "state-input inequality constraint matrix") | ||
164 |
2/4✓ Branch 1 taken 20 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 20 times.
✗ Branch 5 not taken.
|
40 | .add_property( |
165 | "H", | ||
166 | 40 | bp::make_function(&Model::get_H, bp::return_internal_reference<>()), | |
167 | "state-input equality constraint matrix") | ||
168 |
2/4✓ Branch 1 taken 20 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 20 times.
✗ Branch 5 not taken.
|
40 | .add_property( |
169 | "q", | ||
170 | 40 | bp::make_function(&Model::get_q, bp::return_internal_reference<>()), | |
171 | "state weight vector") | ||
172 |
2/4✓ Branch 1 taken 20 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 20 times.
✗ Branch 5 not taken.
|
40 | .add_property( |
173 | "r", | ||
174 | 40 | bp::make_function(&Model::get_r, bp::return_internal_reference<>()), | |
175 | "input weight vector") | ||
176 |
2/4✓ Branch 1 taken 20 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 20 times.
✗ Branch 5 not taken.
|
40 | .add_property( |
177 | "g", | ||
178 | 40 | bp::make_function(&Model::get_g, bp::return_internal_reference<>()), | |
179 | "state-input inequality constraint bias") | ||
180 |
2/4✓ Branch 1 taken 20 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 20 times.
✗ Branch 5 not taken.
|
40 | .add_property( |
181 | "h", | ||
182 | 40 | bp::make_function(&Model::get_h, bp::return_internal_reference<>()), | |
183 | "state-input equality constraint bias") | ||
184 | // deprecated function | ||
185 |
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( |
186 | "Fq", | ||
187 | bp::make_function(&Model::get_Aq, | ||
188 |
2/4✓ Branch 2 taken 20 times.
✗ Branch 3 not taken.
✓ Branch 5 taken 20 times.
✗ Branch 6 not taken.
|
80 | deprecated<bp::return_internal_reference<>>( |
189 | "Deprecated. Use Aq.")), | ||
190 | bp::make_function(&Model::set_Fq, | ||
191 |
2/4✓ Branch 2 taken 20 times.
✗ Branch 3 not taken.
✓ Branch 5 taken 20 times.
✗ Branch 6 not taken.
|
80 | deprecated<>("Deprecated. Use set_LQR.")), |
192 | "position matrix") | ||
193 |
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( |
194 | "Fv", | ||
195 | bp::make_function(&Model::get_Av, | ||
196 |
2/4✓ Branch 2 taken 20 times.
✗ Branch 3 not taken.
✓ Branch 5 taken 20 times.
✗ Branch 6 not taken.
|
80 | deprecated<bp::return_internal_reference<>>( |
197 | "Deprecated. Use Av.")), | ||
198 | bp::make_function(&Model::set_Fv, | ||
199 |
2/4✓ Branch 2 taken 20 times.
✗ Branch 3 not taken.
✓ Branch 5 taken 20 times.
✗ Branch 6 not taken.
|
80 | deprecated<>("Deprecated. Use set_LQR.")), |
200 | "position matrix") | ||
201 |
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( |
202 | "Fu", | ||
203 | bp::make_function(&Model::get_B, | ||
204 |
2/4✓ Branch 2 taken 20 times.
✗ Branch 3 not taken.
✓ Branch 5 taken 20 times.
✗ Branch 6 not taken.
|
80 | deprecated<bp::return_internal_reference<>>( |
205 | "Deprecated. Use B.")), | ||
206 | bp::make_function(&Model::set_Fu, | ||
207 |
2/4✓ Branch 2 taken 20 times.
✗ Branch 3 not taken.
✓ Branch 5 taken 20 times.
✗ Branch 6 not taken.
|
80 | deprecated<>("Deprecated. Use set_LQR.")), |
208 | "input matrix") | ||
209 |
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( |
210 | "f0", | ||
211 | bp::make_function(&Model::get_f, | ||
212 |
2/4✓ Branch 2 taken 20 times.
✗ Branch 3 not taken.
✓ Branch 5 taken 20 times.
✗ Branch 6 not taken.
|
80 | deprecated<bp::return_internal_reference<>>( |
213 | "Deprecated. Use f.")), | ||
214 | bp::make_function(&Model::set_f0, | ||
215 |
2/4✓ Branch 2 taken 20 times.
✗ Branch 3 not taken.
✓ Branch 5 taken 20 times.
✗ Branch 6 not taken.
|
80 | deprecated<>("Deprecated. Use set_LQR.")), |
216 | "dynamics drift") | ||
217 |
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( |
218 | "lx", | ||
219 | bp::make_function(&Model::get_q, | ||
220 |
2/4✓ Branch 2 taken 20 times.
✗ Branch 3 not taken.
✓ Branch 5 taken 20 times.
✗ Branch 6 not taken.
|
80 | deprecated<bp::return_internal_reference<>>( |
221 | "Deprecated. Use q.")), | ||
222 | bp::make_function(&Model::set_lx, | ||
223 |
2/4✓ Branch 2 taken 20 times.
✗ Branch 3 not taken.
✓ Branch 5 taken 20 times.
✗ Branch 6 not taken.
|
80 | deprecated<>("Deprecated. Use set_LQR.")), |
224 | "state weight vector") | ||
225 |
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( |
226 | "lu", | ||
227 | bp::make_function(&Model::get_r, | ||
228 |
2/4✓ Branch 2 taken 20 times.
✗ Branch 3 not taken.
✓ Branch 5 taken 20 times.
✗ Branch 6 not taken.
|
80 | deprecated<bp::return_internal_reference<>>( |
229 | "Deprecated. Use r.")), | ||
230 | bp::make_function(&Model::set_lu, | ||
231 |
2/4✓ Branch 2 taken 20 times.
✗ Branch 3 not taken.
✓ Branch 5 taken 20 times.
✗ Branch 6 not taken.
|
80 | deprecated<>("Deprecated. Use set_LQR.")), |
232 | "input weight vector") | ||
233 |
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( |
234 | "Lxx", | ||
235 | bp::make_function(&Model::get_Q, | ||
236 |
2/4✓ Branch 2 taken 20 times.
✗ Branch 3 not taken.
✓ Branch 5 taken 20 times.
✗ Branch 6 not taken.
|
80 | deprecated<bp::return_internal_reference<>>( |
237 | "Deprecated. Use Q.")), | ||
238 | bp::make_function(&Model::set_Lxx, | ||
239 |
2/4✓ Branch 2 taken 20 times.
✗ Branch 3 not taken.
✓ Branch 5 taken 20 times.
✗ Branch 6 not taken.
|
80 | deprecated<>("Deprecated. Use set_LQR.")), |
240 | "state weight matrix") | ||
241 |
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( |
242 | "Lxu", | ||
243 | bp::make_function(&Model::get_N, | ||
244 |
2/4✓ Branch 2 taken 20 times.
✗ Branch 3 not taken.
✓ Branch 5 taken 20 times.
✗ Branch 6 not taken.
|
80 | deprecated<bp::return_internal_reference<>>( |
245 | "Deprecated. Use N.")), | ||
246 | bp::make_function(&Model::set_Lxu, | ||
247 |
2/4✓ Branch 2 taken 20 times.
✗ Branch 3 not taken.
✓ Branch 5 taken 20 times.
✗ Branch 6 not taken.
|
80 | deprecated<>("Deprecated. Use set_LQR.")), |
248 | "state-input weight matrix") | ||
249 |
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( |
250 | "Luu", | ||
251 | bp::make_function(&Model::get_R, | ||
252 |
2/4✓ Branch 2 taken 20 times.
✗ Branch 3 not taken.
✓ Branch 5 taken 20 times.
✗ Branch 6 not taken.
|
80 | deprecated<bp::return_internal_reference<>>( |
253 | "Deprecated. Use R.")), | ||
254 | bp::make_function(&Model::set_Luu, | ||
255 |
2/4✓ Branch 2 taken 20 times.
✗ Branch 3 not taken.
✓ Branch 5 taken 20 times.
✗ Branch 6 not taken.
|
80 | deprecated<>("Deprecated. Use set_LQR.")), |
256 | "input weight matrix"); | ||
257 | 40 | } | |
258 | }; | ||
259 | |||
260 | #define CROCODDYL_DIFFACTION_MODEL_LQR_PYTHON_BINDINGS(Scalar) \ | ||
261 | typedef DifferentialActionModelLQRTpl<Scalar> Model; \ | ||
262 | typedef DifferentialActionModelAbstractTpl<Scalar> ModelBase; \ | ||
263 | typedef typename ModelBase::MatrixXs MatrixXs; \ | ||
264 | bp::register_ptr_to_python<std::shared_ptr<Model>>(); \ | ||
265 | bp::class_<Model, bp::bases<ModelBase>>( \ | ||
266 | "DifferentialActionModelLQR", \ | ||
267 | "Differential action model for linear dynamics and quadratic cost.\n\n" \ | ||
268 | "This class implements a linear dynamics, quadratic costs, and linear " \ | ||
269 | "constraints (i.e. LQR action). Since the DAM is a second order " \ | ||
270 | "system, and the integrated action models are implemented as being " \ | ||
271 | "second order integrators. This class implements a second order linear " \ | ||
272 | "system given by\n" \ | ||
273 | " x = [q, v]\n" \ | ||
274 | " dv = Fq q + Fv v + Fu u + f0\n" \ | ||
275 | "where Fq, Fv, Fu and f are randomly chosen constant terms. On the " \ | ||
276 | "other hand, the cost function is given by" \ | ||
277 | " l(x,u) = 1/2 [x,u].T [Q N; N.T R] [x,u] + [q,r].T [x,u],\n" \ | ||
278 | "and the linear equality and inequality constraints has the form:\n" \ | ||
279 | " g(x,u) = G [x,u] + g<=0\n" \ | ||
280 | " h(x,u) = H [x,u] + h.", \ | ||
281 | bp::init<MatrixXs, MatrixXs, MatrixXs, MatrixXs, MatrixXs, MatrixXs>( \ | ||
282 | bp::args("self", "Aq", "Av", "B", "Q", "R", "N"), \ | ||
283 | "Initialize the differential LQR action model.\n\n" \ | ||
284 | ":param Aq: position matrix\n" \ | ||
285 | ":param Av: velocity matrix\n" \ | ||
286 | ":param B: input matrix\n" \ | ||
287 | ":param Q: state weight matrix\n" \ | ||
288 | ":param R: input weight matrix\n" \ | ||
289 | ":param N: state-input weight matrix")) \ | ||
290 | .def(DifferentialActionModelLQRVisitor<Model>()) \ | ||
291 | .def(CastVisitor<Model>()) \ | ||
292 | .def(PrintableVisitor<Model>()) \ | ||
293 | .def(CopyableVisitor<Model>()); | ||
294 | |||
295 | #define CROCODDYL_DIFFACTION_DATA_LQR_PYTHON_BINDINGS(Scalar) \ | ||
296 | typedef DifferentialActionDataLQRTpl<Scalar> Data; \ | ||
297 | typedef DifferentialActionDataAbstractTpl<Scalar> DataBase; \ | ||
298 | typedef DifferentialActionModelLQRTpl<Scalar> Model; \ | ||
299 | bp::register_ptr_to_python<std::shared_ptr<Data>>(); \ | ||
300 | bp::class_<Data, bp::bases<DataBase>>( \ | ||
301 | "DifferentialActionDataLQR", \ | ||
302 | "Action data for the differential LQR system.", \ | ||
303 | bp::init<Model*>(bp::args("self", "model"), \ | ||
304 | "Create differential LQR data.\n\n" \ | ||
305 | ":param model: differential LQR action model")) \ | ||
306 | .def(CopyableVisitor<Data>()); | ||
307 | |||
308 | 10 | void exposeDifferentialActionLQR() { | |
309 | // TODO: Remove once the deprecated update call has been removed in a future | ||
310 | // release | ||
311 | #pragma GCC diagnostic push | ||
312 | #pragma GCC diagnostic ignored "-Wdeprecated-declarations" | ||
313 | |||
314 |
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_DIFFACTION_MODEL_LQR_PYTHON_BINDINGS) |
315 |
11/22✓ 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 15 taken 10 times.
✗ Branch 16 not taken.
✓ Branch 18 taken 10 times.
✗ Branch 19 not taken.
✓ Branch 21 taken 10 times.
✗ Branch 22 not taken.
✓ Branch 26 taken 10 times.
✗ Branch 27 not taken.
✓ Branch 29 taken 10 times.
✗ Branch 30 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.
|
20 | CROCODDYL_PYTHON_SCALARS(CROCODDYL_DIFFACTION_DATA_LQR_PYTHON_BINDINGS) |
316 | |||
317 | #pragma GCC diagnostic pop | ||
318 | 10 | } | |
319 | |||
320 | } // namespace python | ||
321 | } // namespace crocoddyl | ||
322 |