Skip to content

Commit b49e460

Browse files
committed
[python/gar] return tuple for lqrCreateSparseMatrix()
1 parent 178e768 commit b49e460

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

bindings/python/src/gar/expose-utils.cpp

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ namespace aligator::python {
77
using namespace gar;
88

99
using context::Scalar;
10+
using context::VectorXs;
1011
using lqr_t = LQRProblemTpl<context::Scalar>;
1112

1213
bp::dict lqr_sol_initialize_wrap(const lqr_t &problem) {
@@ -20,6 +21,15 @@ bp::dict lqr_sol_initialize_wrap(const lqr_t &problem) {
2021
return out;
2122
}
2223

24+
bp::tuple lqr_create_sparse_wrap(const lqr_t &problem, const Scalar mudyn,
25+
const Scalar mueq, bool update) {
26+
Eigen::SparseMatrix<Scalar> mat;
27+
VectorXs rhs;
28+
lqrCreateSparseMatrix(problem, mudyn, mueq, mat, rhs, update);
29+
mat.makeCompressed();
30+
return bp::make_tuple(mat, rhs);
31+
}
32+
2333
void exposeGarUtils() {
2434

2535
bp::def(
@@ -30,8 +40,8 @@ void exposeGarUtils() {
3040
},
3141
("problem"_a, "mudyn", "mueq"));
3242

33-
bp::def("lqrCreateSparseMatrix", lqrCreateSparseMatrix<Scalar>,
34-
("problem"_a, "mudyn", "mueq", "mat", "rhs", "update"),
43+
bp::def("lqrCreateSparseMatrix", lqr_create_sparse_wrap,
44+
("problem"_a, "mudyn", "mueq", "update"),
3545
"Create or update a sparse matrix from an LQRProblem.");
3646

3747
bp::def("lqrInitializeSolution", lqr_sol_initialize_wrap, ("problem"_a));

0 commit comments

Comments
 (0)