5#ifndef __pinocchio_python_spatial_symmetric3_hpp__
6#define __pinocchio_python_spatial_symmetric3_hpp__
8#include <eigenpy/exception.hpp>
9#include <eigenpy/memory.hpp>
10#include <eigenpy/eigen-to-python.hpp>
11#include <boost/python/tuple.hpp>
13#include "pinocchio/spatial/symmetric3.hpp"
15#include "pinocchio/bindings/python/utils/cast.hpp"
16#include "pinocchio/bindings/python/utils/copyable.hpp"
17#include "pinocchio/bindings/python/utils/printable.hpp"
23 namespace bp = boost::python;
25 template<
typename Symmetric3>
26 struct Symmetric3PythonVisitor
27 :
public boost::python::def_visitor<Symmetric3PythonVisitor<Symmetric3>>
31 Options = Symmetric3::Options
33 typedef typename Symmetric3::Scalar Scalar;
34 typedef typename Symmetric3::Vector3 Vector3;
35 typedef typename Symmetric3::Vector6 Vector6;
36 typedef typename Symmetric3::Matrix3 Matrix3;
37 typedef typename Symmetric3::Matrix2 Matrix2;
38 typedef typename Symmetric3::Matrix32 Matrix32;
40 typedef Eigen::Matrix<Scalar, 3, 1, Options> Vector3Like;
41 typedef Eigen::Matrix<Scalar, 3, 3, Options> Matrix3Like;
42 typedef typename Symmetric3::SkewSquare SkewSquare;
43 typedef typename Symmetric3::AlphaSkewSquare AlphaSkewSquare;
46 template<
class PyClass>
47 void visit(PyClass & cl)
const
49 static const Scalar dummy_precision = Eigen::NumTraits<Scalar>::dummy_precision();
50 PINOCCHIO_COMPILER_DIAGNOSTIC_PUSH
51 PINOCCHIO_COMPILER_DIAGNOSTIC_IGNORED_SELF_ASSIGN_OVERLOADED
52 cl.def(bp::init<>((bp::arg(
"self")),
"Default constructor."))
53 .def(bp::init<const Matrix3 &>(
54 (bp::arg(
"self"), bp::arg(
"I")),
"Initialize from symmetrical matrix I of size 3x3."))
55 .def(bp::init<const Vector6 &>(
56 (bp::arg(
"self"), bp::arg(
"I")),
"Initialize from vector I of size 6."))
58 const Scalar &,
const Scalar &,
const Scalar &,
const Scalar &,
const Scalar &,
60 (bp::arg(
"self"), bp::arg(
"a0"), bp::arg(
"a1"), bp::arg(
"a2"), bp::arg(
"a3"),
61 bp::arg(
"a4"), bp::arg(
"a5")),
62 "Initialize from 6 scalar values."))
64 bp::init<const Symmetric3 &>((bp::arg(
"self"), bp::arg(
"other")),
"Copy constructor."))
65 .def(
"Zero", &Symmetric3::Zero,
"Returns a zero 3x3 matrix.")
68 "setZero", &Symmetric3::setZero, bp::arg(
"self"),
69 "Set all the components of *this to zero.")
70 .def(
"Random", &Symmetric3::Random,
"Returns a random symmetric 3x3 matrix.")
71 .staticmethod(
"Random")
73 "setRandom", &Symmetric3::setRandom, bp::arg(
"self"),
74 "Set all the components of *this randomly.")
75 .def(
"Identity", &Symmetric3::Identity,
"Returns identity matrix.")
76 .staticmethod(
"Identity")
78 "setIdentity", &Symmetric3::setIdentity, bp::arg(
"self"),
79 "Set the components of *this to identity.")
80#ifndef PINOCCHIO_PYTHON_SKIP_COMPARISON_OPERATIONS
81 .def(bp::self == bp::self)
82 .def(bp::self != bp::self)
84#ifndef PINOCCHIO_PYTHON_SKIP_COMPARISON_OPERATIONS
86 "isApprox", &Symmetric3::isApprox,
87 (bp::arg(
"self"), bp::arg(
"other"), bp::arg(
"prec") = dummy_precision),
88 "Returns true if *this is approximately equal to other, within the precision given "
91 "isZero", &Symmetric3::isZero, (bp::arg(
"self"), bp::arg(
"prec") = dummy_precision),
92 "Returns true if *this is approximately equal to the zero matrix, within the "
93 "precision given by prec.")
96 "setDiagonal", &Symmetric3::template setDiagonal<Vector3Like>, bp::args(
"self",
"diag"),
97 "Set the diagonal elements of 3x3 matrix.")
99 "inverse", &Symmetric3::template inverse<Matrix3Like>, bp::args(
"self",
"res"),
100 "Invert the symmetrical 3x3 matrix.")
101 .def(
"fill", &Symmetric3::fill, bp::args(
"self",
"value"))
102 .def(bp::self - bp::other<SkewSquare>())
103 .def(bp::self -= bp::other<SkewSquare>())
104 .def(bp::self - bp::other<AlphaSkewSquare>())
105 .def(bp::self -= bp::other<AlphaSkewSquare>())
107 "data", &Symmetric3PythonVisitor::getData, &Symmetric3PythonVisitor::setData,
108 "6D vector containing the data of the symmetric 3x3 matrix.")
110 "matrix", &Symmetric3::matrix, bp::arg(
"self"),
111 "Returns a matrix representation of the data.")
112 .def(
"vtiv", &Symmetric3::vtiv, bp::args(
"self",
"v"))
114 "vxs", &Symmetric3::template vxs<Vector3>, bp::args(
"v",
"S3"),
115 "Performs the operation \f$ M = [v]_{\times} S_{3} \f$., Apply the cross product of "
116 "v on each column of S and return result matrix M.")
119 "svx", &Symmetric3::template vxs<Vector3>, bp::args(
"v",
"S3"),
120 "Performs the operation \f$ M = S_{3} [v]_{\times} \f$.")
123 "rhsMult", &Symmetric3::template rhsMult<Vector3, Vector3>,
124 bp::args(
"SE3",
"vin",
"vout"))
125 .staticmethod(
"rhsMult")
127 .def(bp::self + bp::self)
128 .def(bp::self += bp::self)
129 .def(bp::self - bp::self)
130 .def(bp::self -= bp::self)
131 .def(bp::self *= bp::other<Scalar>())
132 .def(bp::self * bp::other<Vector3Like>())
133 .def(bp::self - bp::other<Matrix3Like>())
134 .def(bp::self + bp::other<Matrix3Like>())
138 "Computes L for a symmetric matrix S.")
140 "rotate", &Symmetric3::template rotate<Matrix3>, bp::args(
"self",
"R"),
143#ifndef PINOCCHIO_PYTHON_NO_SERIALIZATION
144 .def_pickle(Pickle())
147 PINOCCHIO_COMPILER_DIAGNOSTIC_POP
150 static Vector6 getData(
const Symmetric3 & self)
154 static void setData(Symmetric3 & self, Vector6 data)
161 bp::class_<Symmetric3>(
163 "This class represents symmetric 3x3 matrices.\n\n"
164 "Supported operations ...",
166 .def(Symmetric3PythonVisitor<Symmetric3>())
167 .def(CastVisitor<Symmetric3>())
168 .def(ExposeConstructorByCastVisitor<Symmetric3, ::pinocchio::Symmetric3>())
169 .def(CopyableVisitor<Symmetric3>())
170 .def(PrintableVisitor<Symmetric3>());
174 struct Pickle : bp::pickle_suite
176 static boost::python::tuple getinitargs(
const Symmetric3 & I)
178 return bp::make_tuple(I);
Matrix32 decomposeltI() const
Computes L for a symmetric matrix A.
Main pinocchio namespace.