| Directory: | ./ |
|---|---|
| File: | bindings/python/math/expose-eigen-types.cpp |
| Date: | 2025-02-12 21:03:38 |
| Exec | Total | Coverage | |
|---|---|---|---|
| Lines: | 19 | 21 | 90.5% |
| 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 | 65 | static void run() {}; | |
| 36 | }; | ||
| 37 | |||
| 38 | template<typename Scalar> | ||
| 39 | struct exposeTypeAlgo<Scalar, false> | ||
| 40 | { | ||
| 41 | 4 | static void run() | |
| 42 | { | ||
| 43 | 4 | eigenpy::exposeType<context::Scalar>(); | |
| 44 | 4 | eigenpy::exposeType<context::Scalar, Eigen::RowMajor>(); | |
| 45 | 4 | }; | |
| 46 | }; | ||
| 47 | |||
| 48 | template<typename Scalar> | ||
| 49 | 69 | void exposeType() | |
| 50 | { | ||
| 51 | 69 | exposeTypeAlgo<Scalar>::run(); | |
| 52 | 69 | } | |
| 53 | } // namespace internal | ||
| 54 | |||
| 55 | 69 | void exposeEigenTypes() | |
| 56 | { | ||
| 57 | #ifndef PINOCCHIO_PYTHON_SKIP_COMPARISON_OPERATIONS | ||
| 58 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 65 times.
|
65 | if (!register_symbolic_link_to_registered_type<context::Quaternion>()) |
| 59 | ✗ | eigenpy::expose<context::Quaternion>(); | |
| 60 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 65 times.
|
65 | 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 | 69 | internal::exposeType<context::Scalar>(); | |
| 70 | 69 | eigenpy::enableEigenPySpecific<context::Matrix1s>(); | |
| 71 | 69 | eigenpy::enableEigenPySpecific<Matrix6s>(); | |
| 72 | 69 | eigenpy::enableEigenPySpecific<Vector6s>(); | |
| 73 | 69 | eigenpy::enableEigenPySpecific<context::Vector7s>(); | |
| 74 | 69 | eigenpy::enableEigenPySpecific<Matrix6xs>(); | |
| 75 | 69 | eigenpy::enableEigenPySpecific<Matrix3xs>(); | |
| 76 | 69 | } | |
| 77 | |||
| 78 | } // namespace python | ||
| 79 | } // namespace pinocchio | ||
| 80 |