expose-skew.cpp 2.57 KB
Newer Older
1
//
Justin Carpentier's avatar
Justin Carpentier committed
2
// Copyright (c) 2015-2021 CNRS INRIA
3
// Copyright (c) 2020 Wandercraft
4
5
//

6
7
#include "pinocchio/bindings/python/fwd.hpp"
#include "pinocchio/spatial/se3.hpp"
8
9
10
11
12
13
14
#include "pinocchio/spatial/skew.hpp"

namespace pinocchio
{
  namespace python
  {
    namespace bp = boost::python;
15
  
16
17
18
19
20
21
22
23
24
25
26
27
28
29
    // We need to resort to another call, because it seems that Boost.Python is not aligning the Eigen::MatrixBase. TODO: fix it!
    template<typename Vector3>
    Eigen::Matrix<typename Vector3::Scalar,3,3,Vector3::Options> skew(const Vector3 & v)
    {
      return pinocchio::skew(v);
    }
  
    // We need to resort to another call, because it seems that Boost.Python is not aligning the Eigen::MatrixBase. TODO: fix it!
    template<typename Vector3>
    Eigen::Matrix<typename Vector3::Scalar,3,3,Vector3::Options> skewSquare(const Vector3 & u, const Vector3 & v)
    {
      return pinocchio::skewSquare(u,v);
    }
  
30
31
32
    // We need to resort to another call, because it seems that Boost.Python is not aligning the Eigen::MatrixBase. TODO: fix it!
    template<typename Matrix3>
    Eigen::Matrix<typename Matrix3::Scalar,3,1,Matrix3::Options> unSkew(const Matrix3 & mat)
33
    {
34
      return pinocchio::unSkew(mat);
35
    }
36
  
37
38
    void exposeSkew()
    {
39
40
41
42
43
44
45
46
47
48
      typedef SE3::Matrix3 Matrix3;
      typedef SE3::Vector3 Vector3;
      
      bp::def("skew",&skew<Vector3>,
              bp::arg("u"),
              "Computes the skew representation of a given 3d vector, "
              "i.e. the antisymmetric matrix representation of the cross product operator, aka U = [u]x.\n"
              "Parameters:\n"
              "\tu: the input vector of dimension 3");
      
49
      bp::def("skewSquare",&skewSquare<Vector3>,
50
51
52
53
54
55
56
57
58
59
60
61
62
63
              bp::args("u","v"),
              "Computes the skew square representation of two given 3d vectors, "
              "i.e. the antisymmetric matrix representation of the chained cross product operator, u x (v x w), where w is another 3d vector.\n"
              "Parameters:\n"
              "\tu: the first input vector of dimension 3\n"
              "\tv: the second input vector of dimension 3");

      bp::def("unSkew",&unSkew<Matrix3>,
              bp::arg("U"),
              "Inverse of skew operator. From a given skew symmetric matrix U (i.e U = -U.T)"
              "of dimension 3x3, it extracts the supporting vector, i.e. the entries of U.\n"
              "Mathematically speacking, it computes v such that U.dot(x) = cross(u, x).\n"
              "Parameters:\n"
              "\tU: the input skew symmetric matrix of dimension 3x3.");
64
65
66
67
    }

  } // namespace python
} // namespace pinocchio