| Directory: | ./ |
|---|---|
| File: | bindings/python/spatial/expose-skew.cpp |
| Date: | 2025-02-12 21:03:38 |
| Exec | Total | Coverage | |
|---|---|---|---|
| Lines: | 14 | 14 | 100.0% |
| Branches: | 3 | 6 | 50.0% |
| Line | Branch | Exec | Source |
|---|---|---|---|
| 1 | // | ||
| 2 | // Copyright (c) 2015-2021 CNRS INRIA | ||
| 3 | // Copyright (c) 2020 Wandercraft | ||
| 4 | // | ||
| 5 | |||
| 6 | #include "pinocchio/bindings/python/fwd.hpp" | ||
| 7 | #include "pinocchio/spatial/se3.hpp" | ||
| 8 | #include "pinocchio/spatial/skew.hpp" | ||
| 9 | |||
| 10 | namespace pinocchio | ||
| 11 | { | ||
| 12 | namespace python | ||
| 13 | { | ||
| 14 | namespace bp = boost::python; | ||
| 15 | |||
| 16 | // We need to resort to another call, because it seems that Boost.Python is not aligning the | ||
| 17 | // Eigen::MatrixBase. TODO: fix it! | ||
| 18 | template<typename Vector3> | ||
| 19 | 15 | Eigen::Matrix<typename Vector3::Scalar, 3, 3, Vector3::Options> skew(const Vector3 & v) | |
| 20 | { | ||
| 21 | 15 | return pinocchio::skew(v); | |
| 22 | } | ||
| 23 | |||
| 24 | // We need to resort to another call, because it seems that Boost.Python is not aligning the | ||
| 25 | // Eigen::MatrixBase. TODO: fix it! | ||
| 26 | template<typename Vector3> | ||
| 27 | Eigen::Matrix<typename Vector3::Scalar, 3, 3, Vector3::Options> | ||
| 28 | 1 | skewSquare(const Vector3 & u, const Vector3 & v) | |
| 29 | { | ||
| 30 | 1 | return pinocchio::skewSquare(u, v); | |
| 31 | } | ||
| 32 | |||
| 33 | // We need to resort to another call, because it seems that Boost.Python is not aligning the | ||
| 34 | // Eigen::MatrixBase. TODO: fix it! | ||
| 35 | template<typename Matrix3> | ||
| 36 | 4 | Eigen::Matrix<typename Matrix3::Scalar, 3, 1, Matrix3::Options> unSkew(const Matrix3 & mat) | |
| 37 | { | ||
| 38 | 4 | return pinocchio::unSkew(mat); | |
| 39 | } | ||
| 40 | |||
| 41 | 69 | void exposeSkew() | |
| 42 | { | ||
| 43 | typedef context::SE3::Matrix3 Matrix3; | ||
| 44 | typedef context::SE3::Vector3 Vector3; | ||
| 45 | |||
| 46 |
1/2✓ Branch 1 taken 69 times.
✗ Branch 2 not taken.
|
69 | bp::def( |
| 47 | 138 | "skew", &skew<Vector3>, bp::arg("u"), | |
| 48 | "Computes the skew representation of a given 3d vector, " | ||
| 49 | "i.e. the antisymmetric matrix representation of the cross product operator, aka U = " | ||
| 50 | "[u]x.\n" | ||
| 51 | "Parameters:\n" | ||
| 52 | "\tu: the input vector of dimension 3"); | ||
| 53 | |||
| 54 |
1/2✓ Branch 1 taken 69 times.
✗ Branch 2 not taken.
|
69 | bp::def( |
| 55 | 138 | "skewSquare", &skewSquare<Vector3>, bp::args("u", "v"), | |
| 56 | "Computes the skew square representation of two given 3d vectors, " | ||
| 57 | "i.e. the antisymmetric matrix representation of the chained cross product operator, " | ||
| 58 | "u x (v x w), where w is another 3d vector.\n" | ||
| 59 | "Parameters:\n" | ||
| 60 | "\tu: the first input vector of dimension 3\n" | ||
| 61 | "\tv: the second input vector of dimension 3"); | ||
| 62 | |||
| 63 |
1/2✓ Branch 1 taken 69 times.
✗ Branch 2 not taken.
|
69 | bp::def( |
| 64 | 138 | "unSkew", &unSkew<Matrix3>, bp::arg("U"), | |
| 65 | "Inverse of skew operator. From a given skew symmetric matrix U (i.e U = -U.T)" | ||
| 66 | "of dimension 3x3, it extracts the supporting vector, i.e. the entries of U.\n" | ||
| 67 | "Mathematically speacking, it computes v such that U.dot(x) = cross(u, x).\n" | ||
| 68 | "Parameters:\n" | ||
| 69 | "\tU: the input skew symmetric matrix of dimension 3x3."); | ||
| 70 | 69 | } | |
| 71 | |||
| 72 | } // namespace python | ||
| 73 | } // namespace pinocchio | ||
| 74 |