GCC Code Coverage Report


Directory: ./
File: bindings/python/spatial/expose-skew.cpp
Date: 2024-08-27 18:20:05
Exec Total Coverage
Lines: 8 14 57.1%
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 Eigen::Matrix<typename Vector3::Scalar, 3, 3, Vector3::Options> skew(const Vector3 & v)
20 {
21 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 skewSquare(const Vector3 & u, const Vector3 & v)
29 {
30 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 Eigen::Matrix<typename Matrix3::Scalar, 3, 1, Matrix3::Options> unSkew(const Matrix3 & mat)
37 {
38 return pinocchio::unSkew(mat);
39 }
40
41 20 void exposeSkew()
42 {
43 typedef context::SE3::Matrix3 Matrix3;
44 typedef context::SE3::Vector3 Vector3;
45
46
1/2
✓ Branch 1 taken 20 times.
✗ Branch 2 not taken.
20 bp::def(
47 40 "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 20 times.
✗ Branch 2 not taken.
20 bp::def(
55 40 "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 20 times.
✗ Branch 2 not taken.
20 bp::def(
64 40 "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 20 }
71
72 } // namespace python
73 } // namespace pinocchio
74