53 static constexpr int Options = traits<Motion>::Options;
55 typedef typename Motion::Scalar Scalar;
56 typedef ForceTpl<Scalar, Options> Force;
57 typedef typename Motion::Vector6 Vector6;
58 typedef typename Motion::Vector3 Vector3;
60 typedef typename Eigen::Map<Vector3> MapVector3;
61 typedef typename Eigen::Ref<Vector3> RefVector3;
64 template<
class PyClass>
65 void visit(PyClass & cl)
const 67 static const Scalar dummy_precision = Eigen::NumTraits<Scalar>::dummy_precision();
68 PINOCCHIO_COMPILER_DIAGNOSTIC_PUSH
69 PINOCCHIO_COMPILER_DIAGNOSTIC_IGNORED_SELF_ASSIGN_OVERLOADED
70 cl.def(bp::init<>(bp::arg(
"self"),
"Default constructor"))
72 bp::init<const Vector3 &, const Vector3 &>(
73 (bp::arg(
"self"), bp::arg(
"linear"), bp::arg(
"angular")),
74 "Initialize from linear and angular components of a Motion vector (don't mix the " 77 bp::init<const Vector6 &>(
78 (bp::arg(
"self"), bp::arg(
"array")),
79 "Init from a vector 6 [linear velocity, angular velocity]"))
80 .def(bp::init<const Motion &>((bp::arg(
"self"), bp::arg(
"clone")),
"Copy constructor"))
85 &MotionPythonVisitor::getLinear, bp::with_custodian_and_ward_postcall<0, 1>()),
86 &MotionPythonVisitor::setLinear,
87 "Linear part of a *this, corresponding to the linear velocity in case of a Spatial " 92 &MotionPythonVisitor::getAngular, bp::with_custodian_and_ward_postcall<0, 1>()),
93 &MotionPythonVisitor::setAngular,
94 "Angular part of a *this, corresponding to the angular velocity in case of a Spatial " 99 (
typename Motion::ToVectorReturnType (Motion::*)())&Motion::toVector,
100 bp::return_internal_reference<>()),
101 &MotionPythonVisitor::setVector,
"Returns the components of *this as a 6d vector.")
103 "np", bp::make_function(
104 (
typename Motion::ToVectorReturnType (Motion::*)())&Motion::toVector,
105 bp::return_internal_reference<>()))
108 "se3Action", &Motion::template se3Action<Scalar, Options>, bp::args(
"self",
"M"),
109 "Returns the result of the action of M on *this.")
111 "se3ActionInverse", &Motion::template se3ActionInverse<Scalar, Options>,
112 bp::args(
"self",
"M"),
"Returns the result of the action of the inverse of M on *this.")
115 "action", &Motion::toActionMatrix,
116 "Returns the action matrix of *this (acting on Motion).")
118 "dualAction", &Motion::toDualActionMatrix,
119 "Returns the dual action matrix of *this (acting on Force).")
121 "homogeneous", &Motion::toHomogeneousMatrix,
122 "Equivalent homogeneous representation of the Motion vector")
125 "setZero", &MotionPythonVisitor::setZero, bp::arg(
"self"),
126 "Set the linear and angular components of *this to zero.")
128 "setRandom", &MotionPythonVisitor::setRandom, bp::arg(
"self"),
129 "Set the linear and angular components of *this to random values.")
132 "dot", (Scalar (Motion::*)(
const ForceBase<Force> &)
const) & Motion::dot,
133 bp::args(
"self",
"f"),
"Dot product between *this and a Force f.")
136 "cross", (Motion (Motion::*)(
const Motion &)
const) & Motion::cross,
137 bp::args(
"self",
"m"),
"Action of *this onto another Motion m. Returns ยจ*this x m.")
139 "cross", (Force (Motion::*)(
const Force &)
const) & Motion::cross,
140 bp::args(
"self",
"f"),
"Dual action of *this onto a Force f. Returns *this x* f.")
142 .def(bp::self + bp::self)
143 .def(bp::self += bp::self)
144 .def(bp::self - bp::self)
145 .def(bp::self -= bp::self)
147 .def(bp::self ^ bp::self)
148 .def(bp::self ^ Force())
150#ifndef PINOCCHIO_PYTHON_SKIP_COMPARISON_OPERATIONS 151 .def(bp::self == bp::self)
152 .def(bp::self != bp::self)
155 .def(bp::self * Scalar())
156 .def(Scalar() * bp::self)
157 .def(bp::self / Scalar())
159#ifndef PINOCCHIO_PYTHON_SKIP_COMPARISON_OPERATIONS 162 (bp::arg(
"self"), bp::arg(
"other"), bp::arg(
"prec") = dummy_precision),
163 "Returns true if *this is approximately equal to other, within the precision given by " 168 "Returns true if *this is approximately equal to the zero Motion, within the precision " 172 .def(
"Random", &Motion::Random,
"Returns a random Motion.")
173 .staticmethod(
"Random")
174 .def(
"Zero", &Motion::Zero,
"Returns a zero Motion.")
175 .staticmethod(
"Zero")
178 "__array__", bp::make_function(
179 (
typename Motion::ToVectorReturnType (Motion::*)())&Motion::toVector,
180 bp::return_internal_reference<>()))
182 "__array__", &__array__,
183 (bp::arg(
"self"), bp::arg(
"dtype") = bp::object(), bp::arg(
"copy") = bp::object()),
184 bp::return_internal_reference<>())
185#ifndef PINOCCHIO_PYTHON_NO_SERIALIZATION 186 .def_pickle(Pickle())
189 PINOCCHIO_COMPILER_DIAGNOSTIC_POP
194 typedef pinocchio::MotionBase<Motion> MotionBase;
195 bp::objects::register_dynamic_id<MotionBase>();
196 bp::objects::register_conversion<Motion, MotionBase>(
false);
198 typedef pinocchio::MotionDense<Motion> MotionDense;
199 bp::objects::register_dynamic_id<MotionDense>();
200 bp::objects::register_conversion<Motion, MotionDense>(
false);
202 typedef ::boost::python::detail::not_specified HolderType;
203 bp::class_<Motion, HolderType>(
205 "Motion vectors, in se3 == M^6.\n\n" 206 "Supported operations ...",
211 .def(::eigenpy::CopyableVisitor<Motion>())
216 static typename Motion::ToVectorConstReturnType
217 __array__(
const Motion & self, bp::object, bp::object)
219 return self.toVector();
222 struct Pickle : bp::pickle_suite
224 static boost::python::tuple getinitargs(
const Motion & m)
226 return bp::make_tuple((Vector3)m.linear(), (Vector3)m.angular());
229 static bool getstate_manages_dict()
235 static RefVector3 getLinear(Motion & self)
237 return self.linear();
239 static void setLinear(Motion & self,
const Vector3 & v)
243 static RefVector3 getAngular(Motion & self)
245 return self.angular();
247 static void setAngular(Motion & self,
const Vector3 & w)
252 static void setVector(Motion & self,
const Vector6 & v)
257 static void setZero(Motion & self)
261 static void setRandom(Motion & self)