Skip to content

Commit

Permalink
[python/gar] return tuple for lqrCreateSparseMatrix()
Browse files Browse the repository at this point in the history
  • Loading branch information
ManifoldFR committed Nov 8, 2024
1 parent f7dbec5 commit c57c788
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions bindings/python/src/gar/expose-utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ namespace aligator::python {
using namespace gar;

using context::Scalar;
using context::VectorXs;
using lqr_t = LQRProblemTpl<context::Scalar>;

bp::dict lqr_sol_initialize_wrap(const lqr_t &problem) {
Expand All @@ -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<Scalar> mat;
VectorXs rhs;
lqrCreateSparseMatrix(problem, mudyn, mueq, mat, rhs, update);
mat.makeCompressed();
return bp::make_tuple(mat, rhs);
}

void exposeGarUtils() {

bp::def(
Expand All @@ -30,8 +40,8 @@ void exposeGarUtils() {
},
("problem"_a, "mudyn", "mueq"));

bp::def("lqrCreateSparseMatrix", lqrCreateSparseMatrix<Scalar>,
("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));
Expand Down

0 comments on commit c57c788

Please sign in to comment.