6 #ifndef __pinocchio_python_spatial_motion_hpp__
7 #define __pinocchio_python_spatial_motion_hpp__
11 #include <boost/python/tuple.hpp>
12 #include <boost/python/implicit.hpp>
22 #if EIGENPY_VERSION_AT_MOST(2, 8, 1)
35 template<
typename Scalar,
int Options>
43 const Scalar & prec = Eigen::NumTraits<Scalar>::dummy_precision())
45 return self.isApprox(other, prec);
51 return self.isZero(prec);
55 template<
typename Motion>
72 template<
class PyClass>
75 static const Scalar dummy_precision = Eigen::NumTraits<Scalar>::dummy_precision();
78 cl.def(bp::init<>(bp::arg(
"self"),
"Default constructor"))
79 .def(bp::init<const Vector3 &, const Vector3 &>(
80 (bp::arg(
"self"), bp::arg(
"linear"), bp::arg(
"angular")),
81 "Initialize from linear and angular components of a Motion vector (don't mix the "
83 .def(bp::init<const Vector6 &>(
84 (bp::arg(
"self"), bp::arg(
"array")),
85 "Init from a vector 6 [linear velocity, angular velocity]"))
86 .def(bp::init<const Motion &>((bp::arg(
"self"), bp::arg(
"clone")),
"Copy constructor"))
93 "Linear part of a *this, corresponding to the linear velocity in case of a "
100 "Angular part of a *this, corresponding to the angular velocity in case of "
101 "a Spatial velocity.")
105 (
typename Motion::ToVectorReturnType(
Motion::*)()) & Motion::toVector,
106 bp::return_internal_reference<>()),
109 "np", bp::make_function(
110 (
typename Motion::ToVectorReturnType(
Motion::*)()) & Motion::toVector,
111 bp::return_internal_reference<>()))
114 "se3Action", &Motion::template se3Action<Scalar, Options>, bp::args(
"self",
"M"),
115 "Returns the result of the action of M on *this.")
117 "se3ActionInverse", &Motion::template se3ActionInverse<Scalar, Options>,
118 bp::args(
"self",
"M"),
"Returns the result of the action of the inverse of M on *this.")
121 "action", &Motion::toActionMatrix,
122 "Returns the action matrix of *this (acting on Motion).")
124 "dualAction", &Motion::toDualActionMatrix,
125 "Returns the dual action matrix of *this (acting on Force).")
127 "homogeneous", &Motion::toHomogeneousMatrix,
128 "Equivalent homogeneous representation of the Motion vector")
132 "Set the linear and angular components of *this to zero.")
135 "Set the linear and angular components of *this to random values.")
139 bp::args(
"self",
"f"),
"Dot product between *this and a Force f.")
143 "Action of *this onto another Motion m. Returns ยจ*this x m.")
146 "Dual action of *this onto a Force f. Returns *this x* f.")
148 .def(bp::self + bp::self)
149 .def(bp::self += bp::self)
150 .def(bp::self - bp::self)
151 .def(bp::self -= bp::self)
153 .def(bp::self ^ bp::self)
154 .def(bp::self ^
Force())
156 #ifndef PINOCCHIO_PYTHON_SKIP_COMPARISON_OPERATIONS
157 .def(bp::self == bp::self)
158 .def(bp::self != bp::self)
165 #ifndef PINOCCHIO_PYTHON_SKIP_COMPARISON_OPERATIONS
168 (bp::arg(
"self"), bp::arg(
"other"), bp::arg(
"prec") = dummy_precision),
169 "Returns true if *this is approximately equal to other, within the precision given "
174 "Returns true if *this is approximately equal to the zero Motion, within the "
175 "precision given by prec.")
179 .staticmethod(
"Random")
181 .staticmethod(
"Zero")
184 "__array__", bp::make_function(
185 (
typename Motion::ToVectorReturnType(
Motion::*)()) & Motion::toVector,
186 bp::return_internal_reference<>()))
189 (bp::arg(
"self"), bp::arg(
"dtype") = bp::object(), bp::arg(
"copy") = bp::object()),
190 bp::return_internal_reference<>())
191 #ifndef PINOCCHIO_PYTHON_NO_SERIALIZATION
201 bp::objects::register_dynamic_id<MotionBase>();
202 bp::objects::register_conversion<Motion, MotionBase>(
false);
205 bp::objects::register_dynamic_id<MotionDense>();
206 bp::objects::register_conversion<Motion, MotionDense>(
false);
208 #if PY_MAJOR_VERSION == 3 && PY_MINOR_VERSION == 6 && EIGENPY_VERSION_AT_LEAST(2, 9, 0)
211 typedef ::boost::python::detail::not_specified HolderType;
213 bp::class_<Motion, HolderType>(
215 "Motion vectors, in se3 == M^6.\n\n"
216 "Supported operations ...",
226 static typename Motion::ToVectorConstReturnType
229 return self.toVector();
247 return self.linear();
255 return self.angular();
280 #endif // ifndef __pinocchio_python_spatial_motion_hpp__