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-pinocchio-manifolds.cpp
Go to the documentation of this file.
1
#ifdef ALIGATOR_WITH_PINOCCHIO
2
3
// Boost.Python 1.74 include manually mpl/vector/vector20.hpp
4
// that prevent us to define mpl::list and mpl::vector with
5
// the right size.
6
// To avoid this issue this header should be included first.
7
#include <pinocchio/fwd.hpp>
8
9
#include "
aligator/python/fwd.hpp
"
10
#include "
aligator/python/utils.hpp
"
11
12
#include "
aligator/modelling/spaces/multibody.hpp
"
13
#include "
aligator/modelling/spaces/pinocchio-groups.hpp
"
14
15
namespace
aligator::python
{
16
using
context::Manifold
;
17
using
context::Scalar
;
18
using
PolyManifold
= xyz::polymorphic<Manifold>;
19
22
template
<
typename
LieGroup>
23
void
exposeLieGroup
(
const
char
*name,
const
char
*docstring) {
24
using
wrapper_t =
PinocchioLieGroup<LieGroup>
;
25
bp::class_<wrapper_t, bp::bases<Manifold>>(name, docstring,
26
bp::init<>(
"self"
_a))
27
.add_property(
"lg"
, &wrapper_t::lieGroup)
28
.def(
PolymorphicVisitor<PolyManifold>
())
29
.enable_pickling_(
true
);
30
}
31
33
template
<
typename
M>
34
bp::class_<TangentBundleTpl<M>, bp::bases<Manifold>>
35
exposeTangentBundle
(
const
char
*name,
const
char
*docstring) {
36
using
OutType =
TangentBundleTpl<M>
;
37
return
bp::class_<OutType, bp::bases<Manifold>>(
38
name, docstring, bp::init<const M &>((
"self"
_a,
"base"
)))
39
.add_property(
"base"
,
40
bp::make_function(&OutType::getBaseSpace,
41
bp::return_internal_reference<>()),
42
"Get the base space."
)
43
.def(
PolymorphicVisitor<PolyManifold>
());
44
}
45
47
template
<
typename
M,
class
Init>
48
bp::class_<TangentBundleTpl<M>, bp::bases<Manifold>>
49
exposeTangentBundle
(
const
char
*name,
const
char
*docstring, Init init) {
50
return
exposeTangentBundle<M>
(name, docstring).def(init);
51
}
52
53
void
exposePinocchioSpaces
() {
54
bp::scope scope =
get_namespace
(
"manifolds"
);
55
56
namespace
pin = pinocchio;
57
using
pin::ModelTpl;
58
using
pin::SpecialEuclideanOperationTpl;
59
using
pin::SpecialOrthogonalOperationTpl;
60
using
pin::VectorSpaceOperationTpl;
61
62
using
DynSizeEuclideanSpace = VectorSpaceOperationTpl<Eigen::Dynamic, Scalar>;
63
bp::class_<PinocchioLieGroup<DynSizeEuclideanSpace>, bp::bases<Manifold>>(
64
"EuclideanSpace"
,
"Pinocchio's n-dimensional Euclidean vector space."
,
65
bp::no_init)
66
.def(bp::init<int>((
"self"
_a,
"dim"
)))
67
.def(
PolymorphicVisitor<PolyManifold>
());
68
69
exposeLieGroup<VectorSpaceOperationTpl<1, Scalar>
>(
70
"R"
,
"One-dimensional Euclidean space AKA real number line."
);
71
exposeLieGroup<VectorSpaceOperationTpl<2, Scalar>
>(
72
"R2"
,
"Two-dimensional Euclidean space."
);
73
exposeLieGroup<VectorSpaceOperationTpl<3, Scalar>
>(
74
"R3"
,
"Three-dimensional Euclidean space."
);
75
exposeLieGroup<VectorSpaceOperationTpl<4, Scalar>
>(
76
"R4"
,
"Four-dimensional Euclidean space."
);
77
exposeLieGroup<SpecialOrthogonalOperationTpl<2, Scalar>
>(
78
"SO2"
,
"SO(2) special orthogonal group."
);
79
exposeLieGroup<SpecialOrthogonalOperationTpl<3, Scalar>
>(
80
"SO3"
,
"SO(3) special orthogonal group."
);
81
exposeLieGroup<SpecialEuclideanOperationTpl<2, Scalar>
>(
82
"SE2"
,
"SE(2) special Euclidean group."
);
83
exposeLieGroup<SpecialEuclideanOperationTpl<3, Scalar>
>(
84
"SE3"
,
"SE(3) special Euclidean group."
);
85
86
using
SO2 =
PinocchioLieGroup<SpecialOrthogonalOperationTpl<2, Scalar>
>;
87
using
SO3 =
PinocchioLieGroup<SpecialOrthogonalOperationTpl<3, Scalar>
>;
88
using
SE2 =
PinocchioLieGroup<SpecialEuclideanOperationTpl<2, Scalar>
>;
89
using
SE3 =
PinocchioLieGroup<SpecialEuclideanOperationTpl<3, Scalar>
>;
90
91
/* Expose tangent bundles */
92
93
exposeTangentBundle<SO2>
(
"TSO2"
,
"Tangent bundle of the SO(2) group."
)
94
.def(bp::init<>(bp::args(
"self"
)));
95
exposeTangentBundle<SO3>
(
"TSO3"
,
"Tangent bundle of the SO(3) group."
)
96
.def(bp::init<>(bp::args(
"self"
)));
97
exposeTangentBundle<SE2>
(
"TSE2"
,
"Tangent bundle of the SE(2) group."
)
98
.def(bp::init<>(bp::args(
"self"
)));
99
exposeTangentBundle<SE3>
(
"TSE3"
,
"Tangent bundle of the SE(3) group."
)
100
.def(bp::init<>(bp::args(
"self"
)));
101
102
/* Groups associated w/ Pinocchio models */
103
using
Multibody =
MultibodyConfiguration<Scalar>
;
104
using
Model = ModelTpl<Scalar>;
105
bp::class_<Multibody, bp::bases<Manifold>>(
106
"MultibodyConfiguration"
,
"Configuration group of a multibody"
,
107
bp::init<const Model &>(bp::args(
"self"
,
"model"
)))
108
.add_property(
"model"
,
109
bp::make_function(&Multibody::getModel,
110
bp::return_internal_reference<>()),
111
"Return the Pinocchio model instance."
)
112
.def(
PolymorphicVisitor<PolyManifold>
())
113
.enable_pickling_(
true
);
114
115
using
MultiPhase =
MultibodyPhaseSpace<Scalar>
;
116
bp::class_<MultiPhase, bp::bases<Manifold>>(
117
"MultibodyPhaseSpace"
,
118
"Tangent space of the multibody configuration group."
,
119
bp::init<const Model &>((
"self"
_a,
"model"
)))
120
.add_property(
"model"
,
121
bp::make_function(&MultiPhase::getModel,
122
bp::return_internal_reference<>()),
123
"Return the Pinocchio model instance."
)
124
.add_property(
"base"
, bp::make_function(
125
+[](
const
MultiPhase &m) ->
const
Multibody & {
126
return
m.getBaseSpace();
127
},
128
bp::return_internal_reference<>()))
129
.def(
PolymorphicVisitor<PolyManifold>
())
130
.enable_pickling_(
true
);
131
}
132
133
}
// namespace aligator::python
134
135
#endif
// ifdef ALIGATOR_WITH_PINOCCHIO
fwd.hpp
utils.hpp
multibody.hpp
aligator::context::Manifold
ManifoldAbstractTpl< Scalar > Manifold
Definition
context.hpp:14
aligator::context::Scalar
double Scalar
Definition
context.hpp:9
aligator::context::MultibodyPhaseSpace
MultibodyPhaseSpace< Scalar > MultibodyPhaseSpace
Definition
fwd.hpp:29
aligator::python
The Python bindings.
Definition
blk-matrix.hpp:7
aligator::python::PolyManifold
xyz::polymorphic< Manifold > PolyManifold
Definition
expose-manifold.cpp:19
aligator::python::exposeLieGroup
void exposeLieGroup(const char *name, const char *docstring)
Definition
expose-pinocchio-manifolds.cpp:23
aligator::python::exposeTangentBundle
bp::class_< TangentBundleTpl< M >, bp::bases< Manifold > > exposeTangentBundle(const char *name, const char *docstring)
Expose the tangent bundle of a manifold type M.
Definition
expose-pinocchio-manifolds.cpp:35
aligator::python::get_namespace
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
aligator::python::exposePinocchioSpaces
void exposePinocchioSpaces()
Definition
expose-pinocchio-manifolds.cpp:53
pinocchio-groups.hpp
aligator::MultibodyConfiguration
Multibody configuration group , defined using the Pinocchio library.
Definition
multibody.hpp:17
aligator::PinocchioLieGroup
Wrap a Pinocchio Lie group into a ManifoldAbstractTpl object.
Definition
pinocchio-groups.hpp:23
aligator::TangentBundleTpl
Tangent bundle of a base manifold M.
Definition
tangent-bundle.hpp:9
aligator::python::PolymorphicVisitor
Definition
polymorphic.hpp:30
bindings
python
src
modelling
multibody
expose-pinocchio-manifolds.cpp
Generated by
1.17.0