Directory: | ./ |
---|---|
File: | bindings/python/math/expose-eigen-types.cpp |
Date: | 2024-08-27 18:20:05 |
Exec | Total | Coverage | |
---|---|---|---|
Lines: | 15 | 17 | 88.2% |
Branches: | 2 | 4 | 50.0% |
Line | Branch | Exec | Source |
---|---|---|---|
1 | // | ||
2 | // Copyright (c) 2020-2021 INRIA | ||
3 | // | ||
4 | |||
5 | #include "pinocchio/bindings/python/fwd.hpp" | ||
6 | #include "pinocchio/bindings/python/utils/registration.hpp" | ||
7 | #include "pinocchio/bindings/python/utils/std-vector.hpp" | ||
8 | |||
9 | #include <eigenpy/eigenpy.hpp> | ||
10 | #include <eigenpy/memory.hpp> | ||
11 | |||
12 | #include <Eigen/Geometry> | ||
13 | #include <eigenpy/geometry.hpp> | ||
14 | #include <eigenpy/quaternion.hpp> | ||
15 | #include <eigenpy/angle-axis.hpp> | ||
16 | |||
17 | #include <eigenpy/user-type.hpp> | ||
18 | #include <eigenpy/ufunc.hpp> | ||
19 | |||
20 | namespace pinocchio | ||
21 | { | ||
22 | namespace python | ||
23 | { | ||
24 | |||
25 | namespace bp = boost::python; | ||
26 | |||
27 | namespace internal | ||
28 | { | ||
29 | template< | ||
30 | typename Scalar, | ||
31 | bool is_numpy_native_type = | ||
32 | ((int)::eigenpy::NumpyEquivalentType<Scalar>::type_code != NPY_USERDEF)> | ||
33 | struct exposeTypeAlgo | ||
34 | { | ||
35 | 20 | static void run() {}; | |
36 | }; | ||
37 | |||
38 | template<typename Scalar> | ||
39 | struct exposeTypeAlgo<Scalar, false> | ||
40 | { | ||
41 | static void run() | ||
42 | { | ||
43 | eigenpy::exposeType<context::Scalar>(); | ||
44 | eigenpy::exposeType<context::Scalar, Eigen::RowMajor>(); | ||
45 | }; | ||
46 | }; | ||
47 | |||
48 | template<typename Scalar> | ||
49 | 20 | void exposeType() | |
50 | { | ||
51 | 20 | exposeTypeAlgo<Scalar>::run(); | |
52 | 20 | } | |
53 | } // namespace internal | ||
54 | |||
55 | 20 | void exposeEigenTypes() | |
56 | { | ||
57 | #ifndef PINOCCHIO_PYTHON_SKIP_COMPARISON_OPERATIONS | ||
58 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 20 times.
|
20 | if (!register_symbolic_link_to_registered_type<context::Quaternion>()) |
59 | ✗ | eigenpy::expose<context::Quaternion>(); | |
60 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 20 times.
|
20 | if (!register_symbolic_link_to_registered_type<context::AngleAxis>()) |
61 | ✗ | eigenpy::expose<context::AngleAxis>(); | |
62 | #endif | ||
63 | |||
64 | typedef Eigen::Matrix<context::Scalar, 6, 6, context::Options> Matrix6s; | ||
65 | typedef Eigen::Matrix<context::Scalar, 6, 1, context::Options> Vector6s; | ||
66 | typedef Eigen::Matrix<context::Scalar, 6, Eigen::Dynamic, context::Options> Matrix6xs; | ||
67 | typedef Eigen::Matrix<context::Scalar, 3, Eigen::Dynamic, context::Options> Matrix3xs; | ||
68 | |||
69 | 20 | internal::exposeType<context::Scalar>(); | |
70 | 20 | eigenpy::enableEigenPySpecific<context::Matrix1s>(); | |
71 | 20 | eigenpy::enableEigenPySpecific<Matrix6s>(); | |
72 | 20 | eigenpy::enableEigenPySpecific<Vector6s>(); | |
73 | 20 | eigenpy::enableEigenPySpecific<context::Vector7s>(); | |
74 | 20 | eigenpy::enableEigenPySpecific<Matrix6xs>(); | |
75 | 20 | eigenpy::enableEigenPySpecific<Matrix3xs>(); | |
76 | 20 | } | |
77 | |||
78 | } // namespace python | ||
79 | } // namespace pinocchio | ||
80 |