6 #ifndef __pinocchio_python_spatial_se3_hpp__
7 #define __pinocchio_python_spatial_se3_hpp__
11 #include <boost/python/tuple.hpp>
26 #if EIGENPY_VERSION_AT_MOST(2, 8, 1)
36 template<
typename SE3>
55 template<
class PyClass>
58 static const Scalar dummy_precision = Eigen::NumTraits<Scalar>::dummy_precision();
60 cl.def(bp::init<const Matrix3 &, const Vector3 &>(
61 (bp::arg(
"self"), bp::arg(
"rotation"), bp::arg(
"translation")),
62 "Initialize from a rotation matrix and a translation vector."))
63 .def(bp::init<const Quaternion &, const Vector3 &>(
64 (bp::arg(
"self"), bp::arg(
"quat"), bp::arg(
"translation")),
65 "Initialize from a quaternion and a translation vector."))
66 .def(bp::init<int>((bp::arg(
"self"), bp::arg(
"int")),
"Init to identity."))
67 .def(bp::init<const Matrix4 &>(
68 (bp::arg(
"self"), bp::arg(
"array")),
"Initialize from an homogeneous matrix."))
69 .def(bp::init<const SE3 &>((bp::arg(
"self"), bp::arg(
"clone")),
"Copy constructor"))
75 bp::return_internal_reference<>()),
77 "The rotation part of the transformation.")
82 bp::return_internal_reference<>()),
84 "The translation part of the transformation.")
87 "homogeneous", &SE3::toHomogeneousMatrix,
88 "Returns the equivalent homegeneous matrix (acting on SE3).")
91 "Returns the related action matrix (acting on Motion).")
94 bp::arg(
"self"),
"Returns the related action matrix (acting on Motion).")
97 "Returns the inverse of the action matrix (acting on Motion).\n"
98 "This is equivalent to do m.inverse().action")
102 "Returns the inverse of the action matrix (acting on Motion).\n"
103 "This is equivalent to do m.inverse().toActionMatrix()")
106 "Returns the related dual action matrix (acting on Force).")
109 bp::arg(
"self"),
"Returns the related dual action matrix (acting on Force).")
113 "Set *this to the identity placement.")
116 "Set *this to a random placement.")
118 .def(
"inverse", &
SE3::inverse, bp::arg(
"self"),
"Returns the inverse transform")
122 "Returns a point which is the result of the entry point transforms by *this.")
125 bp::args(
"self",
"point"),
126 "Returns a point which is the result of the entry point by the inverse of *this.")
130 "Returns the result of *this * M.")
132 "actInv", (
SE3(
SE3::*)(
const SE3 & other)
const)&SE3::actInv, bp::args(
"self",
"M"),
133 "Returns the result of the inverse of *this times M.")
137 "Returns the result action of *this onto a Motion.")
140 bp::args(
"self",
"motion"),
"Returns the result of the inverse of *this onto a Motion.")
144 "Returns the result of *this onto a Force.")
146 "actInv", (
Force(
SE3::*)(
const Force &)
const)&SE3::actInv, bp::args(
"self",
"force"),
147 "Returns the result of the inverse of *this onto an Inertia.")
151 "Returns the result of *this onto a Force.")
154 bp::args(
"self",
"inertia"),
155 "Returns the result of the inverse of *this onto an Inertia.")
157 #ifndef PINOCCHIO_PYTHON_SKIP_COMPARISON_OPERATIONS
159 "isApprox", &SE3::isApprox,
160 (bp::arg(
"self"), bp::arg(
"other"), bp::arg(
"prec") = dummy_precision),
161 "Returns true if *this is approximately equal to other, within the precision given "
165 "isIdentity", &
SE3::isIdentity, (bp::arg(
"self"), bp::arg(
"prec") = dummy_precision),
166 "Returns true if *this is approximately equal to the identity placement, within the "
167 "precision given by prec.")
170 .def(
"__invert__", &
SE3::inverse,
"Returns the inverse of *this.")
171 .def(bp::self * bp::self)
172 .def(
"__mul__", &__mul__<Motion>)
173 .def(
"__mul__", &__mul__<Force>)
174 .def(
"__mul__", &__mul__<Inertia>)
175 .def(
"__mul__", &__mul__<Vector3>)
176 .add_property(
"np", &SE3::toHomogeneousMatrix)
178 #ifndef PINOCCHIO_PYTHON_SKIP_COMPARISON_OPERATIONS
179 .def(bp::self == bp::self)
180 .def(bp::self != bp::self)
183 .def(
"Identity", &
SE3::Identity,
"Returns the identity transformation.")
184 .staticmethod(
"Identity")
185 .def(
"Random", &
SE3::Random,
"Returns a random transformation.")
186 .staticmethod(
"Random")
188 "Interpolate", &SE3::template Interpolate<Scalar>, bp::args(
"A",
"B",
"alpha"),
189 "Linear interpolation on the SE3 manifold.\n\n"
190 "This method computes the linear interpolation between A and B, such that the "
191 "result C = A + (B-A)*t if it would be applied on classic Euclidian space.\n"
192 "This operation is very similar to the SLERP operation on Rotations.\n"
194 "\tA: Initial transformation\n"
195 "\tB: Target transformation\n"
196 "\talpha: Interpolation factor")
197 .staticmethod(
"Interpolate")
199 .def(
"__array__", &SE3::toHomogeneousMatrix)
202 (bp::arg(
"self"), bp::arg(
"dtype") = bp::object(), bp::arg(
"copy") = bp::object()))
204 #ifndef PINOCCHIO_PYTHON_NO_SERIALIZATION
212 static std::string scope_name;
218 #if PY_MAJOR_VERSION == 3 && PY_MINOR_VERSION == 6 && EIGENPY_VERSION_AT_LEAST(2, 9, 0)
221 typedef ::boost::python::detail::not_specified HolderType;
223 bp::class_<SE3, HolderType>(
224 "SE3",
"SE3 transformation defined by a 3d vector and a rotation matrix.",
225 bp::init<>(bp::arg(
"self"),
"Default constructor."))
230 .def(bp::self_ns::str(bp::self_ns::self))
231 .def(
"__repr__", &
repr);
237 return self.toHomogeneousMatrix();
262 template<
typename Spatial>
263 static Spatial
__mul__(
const SE3 &
self,
const Spatial & other)
265 return self.act(other);
280 bp::object py_homogeneous(
282 std::string homegeneous_repr = bp::extract<std::string>(py_homogeneous.attr(
"__repr__")());
283 replace(homegeneous_repr,
"\n",
"");
284 replace(homegeneous_repr,
" ",
"");
286 std::stringstream ss_repr;
288 ss_repr << homegeneous_repr;
291 return ss_repr.str();
298 #endif // ifndef __pinocchio_python_spatial_se3_hpp__