aligator  0.16.0
A versatile and efficient C++ library for real-time constrained trajectory optimization.
Loading...
Searching...
No Matches
expose-gar.cpp
Go to the documentation of this file.
1
6
9
10#include <eigenpy/std-array.hpp>
11
12namespace aligator::python {
13using namespace gar;
14
15using context::Scalar;
19
20using context::MatrixXs;
21using RowMatrixXs = Eigen::Transpose<MatrixXs>::PlainMatrix;
22using context::VectorXs;
23
25
26static void exposeBlockMatrices() {
31 "BlockRowMatrix41");
33 "BlockRowMatrix21");
34 eigenpy::StdArrayPythonVisitor<std::array<long, 1>, true>::expose(
35 "StdArr1_long");
36 eigenpy::StdArrayPythonVisitor<std::array<long, 2>, true>::expose(
37 "StdArr2_long");
38 eigenpy::StdArrayPythonVisitor<std::array<long, 4>, true>::expose(
39 "StdArr4_long");
40}
41
42// fwd-declare exposeParallelSolver()
44// fwd-declare exposeDenseSolver()
46// fwd-declare exposeProxRiccati()
48// fwd-declare exposeGarUtils()
49void exposeGarUtils();
50
51void exposeGAR() {
52
53 bp::scope ns = get_namespace("gar");
54
56
57 bp::class_<knot_t>("LqrKnot", bp::no_init)
58 .def(bp::init<uint, uint, uint>(("self"_a, "nx", "nu", "nc")))
59 .def(bp::init<uint, uint, uint, uint, uint>(
60 ("self"_a, "nx"_a, "nu", "nc", "nx2", "nth"_a = 0)))
61 .def_readonly("nx", &knot_t::nx)
62 .def_readonly("nu", &knot_t::nu)
63 .def_readonly("nc", &knot_t::nc)
64 .def_readonly("nx2", &knot_t::nx2)
65 .def_readonly("nth", &knot_t::nth)
66 //
67 .def_readwrite("Q", &knot_t::Q)
68 .def_readwrite("S", &knot_t::S)
69 .def_readwrite("R", &knot_t::R)
70 .def_readwrite("q", &knot_t::q)
71 .def_readwrite("r", &knot_t::r)
72 //
73 .def_readwrite("A", &knot_t::A)
74 .def_readwrite("B", &knot_t::B)
75 .def_readwrite("f", &knot_t::f)
76 //
77 .def_readwrite("C", &knot_t::C)
78 .def_readwrite("D", &knot_t::D)
79 .def_readwrite("d", &knot_t::d)
80 //
81 .def_readwrite("Gth", &knot_t::Gth)
82 .def_readwrite("Gx", &knot_t::Gx)
83 .def_readwrite("Gu", &knot_t::Gu)
84 .def_readwrite("gamma", &knot_t::gamma)
85 //
86 .def("isApprox", &knot_t::isApprox,
87 ("self"_a, "prec"_a = std::numeric_limits<Scalar>::epsilon()))
88 //
91
92 StdVectorPythonVisitor<knot_vec_t, false>::expose("StdVec_LqrKnot");
93
94 bp::class_<lqr_t, boost::noncopyable>("LqrProblem", bp::no_init)
95 .def(bp::init<const knot_vec_t &, long>(("self"_a, "stages", "nc0")))
96 .def_readwrite("stages", &lqr_t::stages)
97 .add_property("horizon", &lqr_t::horizon)
98 .def_readwrite("G0", &lqr_t::G0)
99 .def_readwrite("g0", &lqr_t::g0)
100 .add_property("isInitialized", &lqr_t::isInitialized,
101 "Whether the problem is initialized.")
102 .add_property("isParameterized", &lqr_t::isParameterized,
103 "Whether the problem is parameterized.")
104 .def("addParameterization", &lqr_t::addParameterization,
105 ("self"_a, "nth"))
106 .add_property("ntheta", &lqr_t::ntheta)
107 .def("evaluate", &lqr_t::evaluate,
108 ("self"_a, "xs", "us", "theta"_a = std::nullopt),
109 "Evaluate the problem objective.");
110
111 bp::class_<riccati_base_t, boost::noncopyable>("RiccatiSolverBase",
112 bp::no_init)
113 .def("backward", &riccati_base_t::backward, ("self"_a, "mueq"))
114 .def("forward", &riccati_base_t::forward,
115 ("self"_a, "xs", "us", "vs", "lbdas", "theta"_a = std::nullopt));
116
121}
122
123} // namespace aligator::python
virtual bool forward(std::vector< VectorXs > &xs, std::vector< VectorXs > &us, std::vector< VectorXs > &vs, std::vector< VectorXs > &lbdas, const std::optional< ConstVectorRef > &theta_=std::nullopt) const=0
virtual bool backward(const Scalar mueq)=0
The Python bindings.
Definition blk-matrix.hpp:5
Eigen::Transpose< MatrixXs >::PlainMatrix RowMatrixXs
LqrKnotTpl< context::Scalar > knot_t
void exposeGAR()
Expose GAR module.
RiccatiSolverBase< Scalar > riccati_base_t
bp::object get_namespace(const std::string &name)
Create or retrieve a Python scope (that is, a class or module namespace).
Definition utils.hpp:22
LqrProblemTpl< context::Scalar > lqr_t
lqr_t::KnotVector knot_vec_t
static void exposeBlockMatrices()
Struct describing a stage of a constrained LQ problem.
bool isApprox(const LqrKnotTpl &other, Scalar prec=std::numeric_limits< Scalar >::epsilon()) const
Scalar evaluate(const VectorOfVectors &xs, const VectorOfVectors &us, const std::optional< ConstVectorRef > &theta) const