31 typedef typename SE3::Scalar Scalar;
32 static constexpr int Options = SE3::Options;
33 typedef typename SE3::Matrix3 Matrix3;
34 typedef typename SE3::Vector3 Vector3;
35 typedef typename SE3::Matrix4 Matrix4;
36 typedef typename SE3::Quaternion Quaternion;
37 typedef typename SE3::ActionMatrixType ActionMatrixType;
39 typedef MotionTpl<Scalar, Options> Motion;
40 typedef ForceTpl<Scalar, Options> Force;
41 typedef InertiaTpl<Scalar, Options> Inertia;
44 template<
class PyClass>
45 void visit(PyClass & cl)
const 47 static const Scalar dummy_precision = Eigen::NumTraits<Scalar>::dummy_precision();
50 bp::init<const Matrix3 &, const Vector3 &>(
51 (bp::arg(
"self"), bp::arg(
"rotation"), bp::arg(
"translation")),
52 "Initialize from a rotation matrix and a translation vector."))
54 bp::init<const Quaternion &, const Vector3 &>(
55 (bp::arg(
"self"), bp::arg(
"quat"), bp::arg(
"translation")),
56 "Initialize from a quaternion and a translation vector."))
57 .def(bp::init<int>((bp::arg(
"self"), bp::arg(
"int")),
"Init to identity."))
59 bp::init<const Matrix4 &>(
60 (bp::arg(
"self"), bp::arg(
"array")),
"Initialize from an homogeneous matrix."))
61 .def(bp::init<const SE3 &>((bp::arg(
"self"), bp::arg(
"clone")),
"Copy constructor"))
66 (
typename SE3::AngularRef (SE3::*)())&SE3::rotation,
67 bp::return_internal_reference<>()),
68 (
void (SE3::*)(
const Matrix3 &))&SE3::rotation,
69 "The rotation part of the transformation.")
73 (
typename SE3::LinearRef (SE3::*)())&SE3::translation,
74 bp::return_internal_reference<>()),
75 (
void (SE3::*)(
const Vector3 &))&SE3::translation,
76 "The translation part of the transformation.")
79 "homogeneous", &SE3::toHomogeneousMatrix,
80 "Returns the equivalent homegeneous matrix (acting on SE3).")
82 "action", (ActionMatrixType (SE3::*)()
const) & SE3::toActionMatrix,
83 "Returns the related action matrix (acting on Motion).")
85 "toActionMatrix", (ActionMatrixType (SE3::*)()
const) & SE3::toActionMatrix,
86 bp::arg(
"self"),
"Returns the related action matrix (acting on Motion).")
88 "actionInverse", (ActionMatrixType (SE3::*)()
const) & SE3::toActionMatrixInverse,
89 "Returns the inverse of the action matrix (acting on Motion).\n" 90 "This is equivalent to do m.inverse().action")
92 "toActionMatrixInverse",
93 (ActionMatrixType (SE3::*)()
const) & SE3::toActionMatrixInverse, bp::arg(
"self"),
94 "Returns the inverse of the action matrix (acting on Motion).\n" 95 "This is equivalent to do m.inverse().toActionMatrix()")
97 "dualAction", (ActionMatrixType (SE3::*)()
const) & SE3::toDualActionMatrix,
98 "Returns the related dual action matrix (acting on Force).")
100 "toDualActionMatrix", (ActionMatrixType (SE3::*)()
const) & SE3::toDualActionMatrix,
101 bp::arg(
"self"),
"Returns the related dual action matrix (acting on Force).")
104 "setIdentity", &SE3PythonVisitor::setIdentity, bp::arg(
"self"),
105 "Set *this to the identity placement.")
107 "setRandom", &SE3PythonVisitor::setRandom, bp::arg(
"self"),
108 "Set *this to a random placement.")
110 .def(
"inverse", &SE3::inverse, bp::arg(
"self"),
"Returns the inverse transform")
113 "act", (Vector3 (SE3::*)(
const Vector3 &)
const) & SE3::act, bp::args(
"self",
"point"),
114 "Returns a point which is the result of the entry point transforms by *this.")
116 "actInv", (Vector3 (SE3::*)(
const Vector3 &)
const) & SE3::actInv,
117 bp::args(
"self",
"point"),
118 "Returns a point which is the result of the entry point by the inverse of *this.")
121 "act", (SE3 (SE3::*)(
const SE3 & other)
const) & SE3::act, bp::args(
"self",
"M"),
122 "Returns the result of *this * M.")
124 "actInv", (SE3 (SE3::*)(
const SE3 & other)
const) & SE3::actInv, bp::args(
"self",
"M"),
125 "Returns the result of the inverse of *this times M.")
128 "act", (Motion (SE3::*)(
const Motion &)
const) & SE3::act, bp::args(
"self",
"motion"),
129 "Returns the result action of *this onto a Motion.")
131 "actInv", (Motion (SE3::*)(
const Motion &)
const) & SE3::actInv,
132 bp::args(
"self",
"motion"),
"Returns the result of the inverse of *this onto a Motion.")
135 "act", (Force (SE3::*)(
const Force &)
const) & SE3::act, bp::args(
"self",
"force"),
136 "Returns the result of *this onto a Force.")
138 "actInv", (Force (SE3::*)(
const Force &)
const) & SE3::actInv,
139 bp::args(
"self",
"force"),
140 "Returns the result of the inverse of *this onto an Inertia.")
143 "act", (Inertia (SE3::*)(
const Inertia &)
const) & SE3::act,
144 bp::args(
"self",
"inertia"),
"Returns the result of *this onto a Force.")
146 "actInv", (Inertia (SE3::*)(
const Inertia &)
const) & SE3::actInv,
147 bp::args(
"self",
"inertia"),
148 "Returns the result of the inverse of *this onto an Inertia.")
150#ifndef PINOCCHIO_PYTHON_SKIP_COMPARISON_OPERATIONS 152 "isApprox", &SE3::isApprox,
153 (bp::arg(
"self"), bp::arg(
"other"), bp::arg(
"prec") = dummy_precision),
154 "Returns true if *this is approximately equal to other, within the precision given by " 158 "isIdentity", &SE3::isIdentity, (bp::arg(
"self"), bp::arg(
"prec") = dummy_precision),
159 "Returns true if *this is approximately equal to the identity placement, within the " 160 "precision given by prec.")
163 .def(
"__invert__", &SE3::inverse,
"Returns the inverse of *this.")
164 .def(bp::self * bp::self)
165 .def(
"__mul__", &__mul__<Motion>)
166 .def(
"__mul__", &__mul__<Force>)
167 .def(
"__mul__", &__mul__<Inertia>)
168 .def(
"__mul__", &__mul__<Vector3>)
169 .add_property(
"np", &SE3::toHomogeneousMatrix)
171#ifndef PINOCCHIO_PYTHON_SKIP_COMPARISON_OPERATIONS 172 .def(bp::self == bp::self)
173 .def(bp::self != bp::self)
176 .def(
"Identity", &SE3::Identity,
"Returns the identity transformation.")
177 .staticmethod(
"Identity")
178 .def(
"Random", &SE3::Random,
"Returns a random transformation.")
179 .staticmethod(
"Random")
181 "Interpolate", &SE3::template Interpolate<Scalar>, bp::args(
"A",
"B",
"alpha"),
182 "Linear interpolation on the SE3 manifold.\n\n" 183 "This method computes the linear interpolation between A and B, such that the result C " 184 "= A + (B-A)*t if it would be applied on classic Euclidian space.\n" 185 "This operation is very similar to the SLERP operation on Rotations.\n" 187 "\tA: Initial transformation\n" 188 "\tB: Target transformation\n" 189 "\talpha: Interpolation factor")
190 .staticmethod(
"Interpolate")
192 .def(
"__array__", &SE3::toHomogeneousMatrix)
194 "__array__", &__array__,
195 (bp::arg(
"self"), bp::arg(
"dtype") = bp::object(), bp::arg(
"copy") = bp::object()))
197#ifndef PINOCCHIO_PYTHON_NO_SERIALIZATION 198 .def_pickle(Pickle())
203 static std::string scopeName()
205 static std::string scope_name;
211 typedef ::boost::python::detail::not_specified HolderType;
212 bp::class_<SE3, HolderType>(
213 "SE3",
"SE3 transformation defined by a 3d vector and a rotation matrix.",
214 bp::init<>(bp::arg(
"self"),
"Default constructor."))
218 .def(::eigenpy::CopyableVisitor<SE3>())
219 .def(bp::self_ns::str(bp::self_ns::self))
220 .def(
"__repr__", &repr);
224 static Matrix4 __array__(
const SE3 & self, bp::object, bp::object)
226 return self.toHomogeneousMatrix();
229 struct Pickle : bp::pickle_suite
231 static boost::python::tuple getinitargs(
const SE3 & M)
233 return bp::make_tuple((Matrix3)M.rotation(), (Vector3)M.translation());
236 static bool getstate_manages_dict()
242 static void setIdentity(SE3 & self)
246 static void setRandom(SE3 & self)
251 template<
typename Spatial>
252 static Spatial __mul__(
const SE3 & self,
const Spatial & other)
254 return self.act(other);
257 static std::string repr(
const SE3 & self)
269 bp::object py_homogeneous(
270 bp::handle<>(eigenpy::EigenToPy<Matrix4, Scalar>::convert(self.toHomogeneousMatrix())));
271 std::string homegeneous_repr = bp::extract<std::string>(py_homogeneous.attr(
"__repr__")());
272 replace(homegeneous_repr,
"\n",
"");
273 replace(homegeneous_repr,
" ",
"");
275 std::stringstream ss_repr;
277 ss_repr << homegeneous_repr;
280 return ss_repr.str();