aligator
0.19.0
A versatile and efficient C++ library for real-time constrained trajectory optimization.
Toggle main menu visibility
Loading...
Searching...
No Matches
expose-manifold.cpp
Go to the documentation of this file.
1
#include "
aligator/python/fwd.hpp
"
2
3
#include "
aligator/core/manifold-base.hpp
"
4
#include "
aligator/core/vector-space.hpp
"
5
#include "
aligator/modelling/spaces/cartesian-product.hpp
"
6
#include "
aligator/modelling/spaces/tangent-bundle.hpp
"
7
8
#include <eigenpy/std-vector.hpp>
9
10
namespace
aligator::python
{
11
using
context::ConstVectorRef;
12
using
context::Manifold
;
13
using
context::MatrixRef;
14
using
context::MatrixXs;
15
using
context::Scalar
;
16
using
context::VectorRef;
17
using
context::VectorSpace
;
18
using
context::VectorXs;
19
using
PolyManifold
= xyz::polymorphic<Manifold>;
20
using
CartesianProduct
=
CartesianProductTpl<Scalar>
;
21
22
void
exposeCartesianProduct
();
23
24
void
exposeManifolds
() {
25
register_polymorphic_to_python<PolyManifold>
();
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"
)))
118
.def(
PolymorphicVisitor<PolyManifold>
())
119
.enable_pickling_(
true
);
120
121
exposeCartesianProduct
();
122
}
123
124
}
// namespace aligator::python
fwd.hpp
cartesian-product.hpp
manifold-base.hpp
aligator::context::Manifold
ManifoldAbstractTpl< Scalar > Manifold
Definition
context.hpp:14
aligator::context::Scalar
double Scalar
Definition
context.hpp:9
aligator::context::VectorSpace
VectorSpaceTpl< Scalar, Eigen::Dynamic > VectorSpace
Definition
context.hpp:15
aligator::python
The Python bindings.
Definition
blk-matrix.hpp:7
aligator::python::PolyManifold
xyz::polymorphic< Manifold > PolyManifold
Definition
expose-manifold.cpp:19
aligator::python::CartesianProduct
CartesianProductTpl< Scalar > CartesianProduct
Definition
expose-cartesian-product.cpp:12
aligator::python::exposeCartesianProduct
void exposeCartesianProduct()
Definition
expose-cartesian-product.cpp:21
aligator::python::exposeManifolds
void exposeManifolds()
Expose manifolds.
Definition
expose-manifold.cpp:24
aligator::python::register_polymorphic_to_python
void register_polymorphic_to_python()
Expose a polymorphic value type, e.g. xyz::polymorphic<T, A>.
Definition
polymorphic.hpp:23
aligator::CartesianProductTpl
The cartesian product of two or more manifolds.
Definition
cartesian-product.hpp:13
aligator::ManifoldAbstractTpl::rand
VectorXs rand() const
Sample a random point on the manifold.
Definition
manifold-base.hpp:41
aligator::ManifoldAbstractTpl< Scalar >::difference
void difference(const ConstVectorRef &x0, const ConstVectorRef &x1, VectorRef out) const
aligator::ManifoldAbstractTpl< Scalar >::Jintegrate
void Jintegrate(const ConstVectorRef &x, const ConstVectorRef &v, MatrixRef Jout, int arg) const
aligator::ManifoldAbstractTpl< Scalar >::nx
int nx() const
Definition
manifold-base.hpp:25
aligator::ManifoldAbstractTpl< Scalar >::interpolate
void interpolate(const ConstVectorRef &x0, const ConstVectorRef &x1, const Scalar &u, VectorRef out) const
aligator::ManifoldAbstractTpl< Scalar >::ndx
int ndx() const
Definition
manifold-base.hpp:27
aligator::ManifoldAbstractTpl< Scalar >::integrate
void integrate(const ConstVectorRef &x, const ConstVectorRef &v, VectorRef out) const
aligator::ManifoldAbstractTpl::neutral
VectorXs neutral() const
Get the neutral element from the manifold (if this makes sense).
Definition
manifold-base.hpp:31
aligator::ManifoldAbstractTpl< Scalar >::JintegrateTransport
void JintegrateTransport(const ConstVectorRef &x, const ConstVectorRef &v, MatrixRef Jout, int arg) const
Definition
manifold-base.hpp:71
aligator::ManifoldAbstractTpl< Scalar >::tangentSpace
TangentSpaceType tangentSpace() const
Definition
manifold-base.hpp:55
aligator::ManifoldAbstractTpl< Scalar >::Jdifference
void Jdifference(const ConstVectorRef &x0, const ConstVectorRef &x1, MatrixRef Jout, int arg) const
aligator::ManifoldAbstractTpl< Scalar >::isNormalized
virtual bool isNormalized(const ConstVectorRef &) const
Definition
manifold-base.hpp:52
aligator::python::PolymorphicVisitor
Definition
polymorphic.hpp:30
tangent-bundle.hpp
vector-space.hpp
bindings
python
src
expose-manifold.cpp
Generated by
1.17.0