-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[python/gar] Separate out how utils are exposed
- Loading branch information
1 parent
d09bdc6
commit c7cae5b
Showing
2 changed files
with
40 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
#include "aligator/python/fwd.hpp" | ||
#include "aligator/gar/utils.hpp" | ||
|
||
namespace aligator::python { | ||
using namespace gar; | ||
|
||
using context::Scalar; | ||
using lqr_t = LQRProblemTpl<context::Scalar>; | ||
|
||
bp::dict lqr_sol_initialize_wrap(const lqr_t &problem) { | ||
bp::dict out; | ||
auto ss = lqrInitializeSolution(problem); | ||
auto &[xs, us, vs, lbdas] = ss; | ||
out["xs"] = xs; | ||
out["us"] = us; | ||
out["vs"] = vs; | ||
out["lbdas"] = lbdas; | ||
return out; | ||
} | ||
|
||
void exposeGarUtils() { | ||
|
||
bp::def( | ||
"lqrDenseMatrix", | ||
+[](const lqr_t &problem, Scalar mudyn, Scalar mueq) { | ||
auto mat_rhs = lqrDenseMatrix(problem, mudyn, mueq); | ||
return bp::make_tuple(std::get<0>(mat_rhs), std::get<1>(mat_rhs)); | ||
}, | ||
("problem"_a, "mudyn", "mueq")); | ||
|
||
bp::def("lqrCreateSparseMatrix", lqrCreateSparseMatrix<Scalar>, | ||
("problem"_a, "mudyn", "mueq", "mat", "rhs", "update"), | ||
"Create or update a sparse matrix from an LQRProblem."); | ||
|
||
bp::def("lqrInitializeSolution", lqr_sol_initialize_wrap, ("problem"_a)); | ||
} | ||
} // namespace aligator::python |