aligator  0.14.0
A primal-dual augmented Lagrangian-type solver for nonlinear trajectory optimization.
 
Loading...
Searching...
No Matches
expose-manifold.cpp
Go to the documentation of this file.
2
7
8#include <eigenpy/std-vector.hpp>
9
10namespace aligator::python {
11using context::ConstVectorRef;
13using context::MatrixRef;
14using context::MatrixXs;
15using context::Scalar;
16using context::VectorRef;
18using context::VectorXs;
21
23
26
27 using BinaryFunTypeRet = VectorXs (Manifold::*)(const ConstVectorRef &,
28 const ConstVectorRef &) const;
29 using BinaryFunType = void (Manifold::*)(
30 const ConstVectorRef &, const ConstVectorRef &, VectorRef) const;
31 using JacobianFunType = void (Manifold::*)(
32 const ConstVectorRef &, const ConstVectorRef &, MatrixRef, int) const;
33
34 bp::class_<Manifold, boost::noncopyable>(
35 "ManifoldAbstract", "Manifold abstract class.", bp::no_init)
36 .add_property("nx", &Manifold::nx, "Manifold representation dimension.")
37 .add_property("ndx", &Manifold::ndx, "Tangent space dimension.")
38 .def(
39 "neutral", +[](const Manifold &m) { return m.neutral(); }, "self"_a,
40 "Get the neutral point from the manifold (if a Lie group).")
41 .def(
42 "rand", +[](const Manifold &m) { return m.rand(); }, "self"_a,
43 "Sample a random point from the manifold.")
44 .def("isNormalized", &Manifold::isNormalized, ("self"_a, "x"),
45 "Check if the input vector :math:`x` is a viable element of the "
46 "manifold.")
47 .def<BinaryFunType>("integrate", &Manifold::integrate,
48 ("self"_a, "x", "v", "out"))
49 .def<BinaryFunType>("difference", &Manifold::difference,
50 ("self"_a, "x0", "x1", "out"))
51 .def<BinaryFunTypeRet>("integrate", &Manifold::integrate,
52 ("self"_a, "x", "v"))
53 .def<BinaryFunTypeRet>("difference", &Manifold::difference,
54 ("self"_a, "x0", "x1"))
55 .def("interpolate",
56 (void (Manifold::*)(const ConstVectorRef &, const ConstVectorRef &,
57 const Scalar &, VectorRef)
58 const)(&Manifold::interpolate),
59 ("self"_a, "x0", "x1", "u", "out"))
60 .def("interpolate",
61 (VectorXs (Manifold::*)(const ConstVectorRef &,
62 const ConstVectorRef &, const Scalar &)
63 const)(&Manifold::interpolate),
64 ("self"_a, "x0", "x1", "u"),
65 "Interpolate between two points on the manifold. Allocated version.")
66 .def<JacobianFunType>("Jintegrate", &Manifold::Jintegrate,
67 ("self"_a, "x", "v", "Jout", "arg"),
68 "Compute the Jacobian of the exp operator.")
69 .def<JacobianFunType>("Jdifference", &Manifold::Jdifference,
70 ("self"_a, "x0", "x1", "Jout", "arg"),
71 "Compute the Jacobian of the log operator.")
72 .def(
73 "Jintegrate",
74 +[](const Manifold &m, const ConstVectorRef x,
75 const ConstVectorRef &v, int arg) {
76 MatrixXs Jout(m.ndx(), m.ndx());
77 m.Jintegrate(x, v, Jout, arg);
78 return Jout;
79 },
80 ("self"_a, "x", "v", "arg"),
81 "Compute and return the Jacobian of the exp.")
82 .def("JintegrateTransport", &Manifold::JintegrateTransport,
83 ("self"_a, "x", "v", "J", "arg"),
84 "Perform parallel transport of matrix J expressed at point x+v to "
85 "point x.")
86 .def(
87 "Jdifference",
88 +[](const Manifold &m, const ConstVectorRef x0,
89 const ConstVectorRef &x1, int arg) {
90 MatrixXs Jout(m.ndx(), m.ndx());
91 m.Jdifference(x0, x1, Jout, arg);
92 return Jout;
93 },
94 ("self"_a, "x0", "x1", "arg"),
95 "Compute and return the Jacobian of the log.")
96 .def("tangent_space", &Manifold::tangentSpace, bp::args("self"),
97 "Returns an object representing the tangent space to this manifold.")
98 .def(
99 "__mul__",
100 +[](const PolyManifold &a, const PolyManifold &b) { return a * b; })
101 .def(
102 "__mul__", +[](const PolyManifold &a,
103 const CartesianProduct &b) { return a * b; })
104 .def(
105 "__rmul__", +[](const PolyManifold &a, const CartesianProduct &b) {
106 return a * b;
107 });
108
109 StdVectorPythonVisitor<std::vector<PolyManifold>>::expose(
110 "StdVec_Manifold",
111 eigenpy::details::overload_base_get_item_for_std_vector<
112 std::vector<PolyManifold>>());
113
114 /* Basic vector space */
115 bp::class_<VectorSpace, bp::bases<Manifold>>(
116 "VectorSpace", "Basic Euclidean vector space.", bp::no_init)
117 .def(bp::init<const int>(("self"_a, "dim")))
119 .enable_pickling_(true);
120
122}
123
124} // namespace aligator::python
ManifoldAbstractTpl< Scalar > Manifold
Definition context.hpp:14
VectorSpaceTpl< Scalar, Eigen::Dynamic > VectorSpace
Definition context.hpp:15
The Python bindings.
Definition blk-matrix.hpp:5
xyz::polymorphic< Manifold > PolyManifold
CartesianProductTpl< Scalar > CartesianProduct
void exposeManifolds()
Expose manifolds.
void register_polymorphic_to_python()
Expose a polymorphic value type, e.g. xyz::polymorphic<T, A>.
The cartesian product of two or more manifolds.
VectorXs rand() const
Sample a random point on the manifold.
void difference(const ConstVectorRef &x0, const ConstVectorRef &x1, VectorRef out) const
void Jintegrate(const ConstVectorRef &x, const ConstVectorRef &v, MatrixRef Jout, int arg) const
void interpolate(const ConstVectorRef &x0, const ConstVectorRef &x1, const Scalar &u, VectorRef out) const
void integrate(const ConstVectorRef &x, const ConstVectorRef &v, VectorRef out) const
VectorXs neutral() const
Get the neutral element from the manifold (if this makes sense).
void JintegrateTransport(const ConstVectorRef &x, const ConstVectorRef &v, MatrixRef Jout, int arg) const
void Jdifference(const ConstVectorRef &x0, const ConstVectorRef &x1, MatrixRef Jout, int arg) const
virtual bool isNormalized(const ConstVectorRef &) const