aligator  0.16.0
A versatile and efficient C++ library for real-time constrained trajectory optimization.
Loading...
Searching...
No Matches
expose-utils.cpp
Go to the documentation of this file.
3
4#include <eigenpy/std-array.hpp>
5
6namespace aligator::python {
7using namespace gar;
8
10using context::VectorXs;
12
13bp::dict lqr_sol_initialize_wrap(const lqr_t &problem) {
14 bp::dict out;
15 auto ss = lqrInitializeSolution(problem);
16 auto &[xs, us, vs, lbdas] = ss;
17 out["xs"] = xs;
18 out["us"] = us;
19 out["vs"] = vs;
20 out["lbdas"] = lbdas;
21 return out;
22}
23
24bp::tuple lqr_create_sparse_wrap(const lqr_t &problem, const Scalar mueq,
25 bool update) {
26 Eigen::SparseMatrix<Scalar> mat;
27 VectorXs rhs;
28 lqrCreateSparseMatrix(problem, mueq, mat, rhs, update);
29 mat.makeCompressed();
30 return bp::make_tuple(mat, rhs);
31}
32
34 bp::def("lqrCreateSparseMatrix", lqr_create_sparse_wrap,
35 ("problem"_a, "mueq", "update"),
36 "Create or update a sparse matrix from an LqrProblem.");
37
38 bp::def("lqrInitializeSolution", lqr_sol_initialize_wrap, ("problem"_a));
39
40 bp::def("lqrComputeKktError", lqrComputeKktError<Scalar>,
41 ("problem"_a, "xs", "us", "vs", "lbdas", "mueq", "theta",
42 "verbose"_a = false),
43 "Compute the KKT residual of the LQR problem.");
44}
45} // namespace aligator::python
void lqrCreateSparseMatrix(const LqrProblemTpl< Scalar > &problem, const Scalar mueq, Eigen::SparseMatrix< Scalar > &mat, Eigen::Matrix< Scalar, -1, 1 > &rhs, bool update)
auto lqrInitializeSolution(const LqrProblemTpl< Scalar > &problem)
Definition utils.hpp:113
std::array< Scalar, 3 > lqrComputeKktError(const LqrProblemTpl< Scalar > &problem, boost::span< const typename math_types< Scalar >::VectorXs > xs, boost::span< const typename math_types< Scalar >::VectorXs > us, boost::span< const typename math_types< Scalar >::VectorXs > vs, boost::span< const typename math_types< Scalar >::VectorXs > lbdas, const Scalar mueq, const std::optional< typename math_types< Scalar >::ConstVectorRef > &theta=std::nullopt, bool verbose=false)
The Python bindings.
Definition blk-matrix.hpp:5
bp::dict lqr_sol_initialize_wrap(const lqr_t &problem)
bp::tuple lqr_create_sparse_wrap(const lqr_t &problem, const Scalar mueq, bool update)
LqrProblemTpl< context::Scalar > lqr_t