From c57c788cd0b85c7ee4a7c918a8fd22ad530a9b14 Mon Sep 17 00:00:00 2001 From: ManifoldFR Date: Fri, 8 Nov 2024 12:54:14 +0100 Subject: [PATCH] [python/gar] return tuple for lqrCreateSparseMatrix() --- bindings/python/src/gar/expose-utils.cpp | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/bindings/python/src/gar/expose-utils.cpp b/bindings/python/src/gar/expose-utils.cpp index 0eed5e5e5..2e481f0a6 100644 --- a/bindings/python/src/gar/expose-utils.cpp +++ b/bindings/python/src/gar/expose-utils.cpp @@ -7,6 +7,7 @@ namespace aligator::python { using namespace gar; using context::Scalar; +using context::VectorXs; using lqr_t = LQRProblemTpl; bp::dict lqr_sol_initialize_wrap(const lqr_t &problem) { @@ -20,6 +21,15 @@ bp::dict lqr_sol_initialize_wrap(const lqr_t &problem) { return out; } +bp::tuple lqr_create_sparse_wrap(const lqr_t &problem, const Scalar mudyn, + const Scalar mueq, bool update) { + Eigen::SparseMatrix mat; + VectorXs rhs; + lqrCreateSparseMatrix(problem, mudyn, mueq, mat, rhs, update); + mat.makeCompressed(); + return bp::make_tuple(mat, rhs); +} + void exposeGarUtils() { bp::def( @@ -30,8 +40,8 @@ void exposeGarUtils() { }, ("problem"_a, "mudyn", "mueq")); - bp::def("lqrCreateSparseMatrix", lqrCreateSparseMatrix, - ("problem"_a, "mudyn", "mueq", "mat", "rhs", "update"), + bp::def("lqrCreateSparseMatrix", lqr_create_sparse_wrap, + ("problem"_a, "mudyn", "mueq", "update"), "Create or update a sparse matrix from an LQRProblem."); bp::def("lqrInitializeSolution", lqr_sol_initialize_wrap, ("problem"_a));