51 static constexpr int Options = traits<Force>::Options;
53 typedef typename Force::Vector6 Vector6;
54 typedef typename Force::Vector3 Vector3;
55 typedef typename Force::Scalar Scalar;
57 typedef typename Eigen::Map<Vector3> MapVector3;
58 typedef typename Eigen::Ref<Vector3> RefVector3;
60 template<
class PyClass>
61 void visit(PyClass & cl)
const 63 static const Scalar dummy_precision = Eigen::NumTraits<Scalar>::dummy_precision();
64 PINOCCHIO_COMPILER_DIAGNOSTIC_PUSH
65 PINOCCHIO_COMPILER_DIAGNOSTIC_IGNORED_SELF_ASSIGN_OVERLOADED
66 cl.def(bp::init<>(bp::arg(
"self"),
"Default constructor"))
68 bp::init<const Vector3 &, const Vector3 &>(
69 (bp::arg(
"self"), bp::arg(
"linear"), bp::arg(
"angular")),
70 "Initialize from linear and angular components of a Wrench vector (don't mix the " 73 bp::init<const Vector6 &>(
74 (bp::args(
"self",
"array")),
"Init from a vector 6 [force,torque]"))
75 .def(bp::init<const Force &>((bp::arg(
"self"), bp::arg(
"clone")),
"Copy constructor"))
80 &ForcePythonVisitor::getLinear, bp::with_custodian_and_ward_postcall<0, 1>()),
81 &ForcePythonVisitor::setLinear,
82 "Linear part of a *this, corresponding to the linear velocity in case of a Spatial " 87 &ForcePythonVisitor::getAngular, bp::with_custodian_and_ward_postcall<0, 1>()),
88 &ForcePythonVisitor::setAngular,
89 "Angular part of a *this, corresponding to the angular velocity in case of a Spatial " 94 (
typename Force::ToVectorReturnType (Force::*)())&Force::toVector,
95 bp::return_internal_reference<>()),
96 &ForcePythonVisitor::setVector,
"Returns the components of *this as a 6d vector.")
98 "np", bp::make_function(
99 (
typename Force::ToVectorReturnType (Force::*)())&Force::toVector,
100 bp::return_internal_reference<>()))
103 "se3Action", &Force::template se3Action<Scalar, Options>, bp::args(
"self",
"M"),
104 "Returns the result of the dual action of M on *this.")
106 "se3ActionInverse", &Force::template se3ActionInverse<Scalar, Options>,
107 bp::args(
"self",
"M"),
108 "Returns the result of the dual action of the inverse of M on *this.")
111 "setZero", &ForcePythonVisitor::setZero, bp::arg(
"self"),
112 "Set the linear and angular components of *this to zero.")
114 "setRandom", &ForcePythonVisitor::setRandom, bp::arg(
"self"),
115 "Set the linear and angular components of *this to random values.")
118 "dot", (Scalar (Force::*)(
const MotionDense<context::Motion> &)
const) & Force::dot,
119 bp::args(
"self",
"m"),
"Dot product between *this and a Motion m.")
121 .def(bp::self + bp::self)
122 .def(bp::self += bp::self)
123 .def(bp::self - bp::self)
124 .def(bp::self -= bp::self)
127#ifndef PINOCCHIO_PYTHON_SKIP_COMPARISON_OPERATIONS 128 .def(bp::self == bp::self)
129 .def(bp::self != bp::self)
132 .def(bp::self * Scalar())
133 .def(Scalar() * bp::self)
134 .def(bp::self / Scalar())
136#ifndef PINOCCHIO_PYTHON_SKIP_COMPARISON_OPERATIONS 139 (bp::arg(
"self"), bp::arg(
"other"), bp::arg(
"prec") = dummy_precision),
140 "Returns true if *this is approximately equal to other, within the precision given by " 145 "Returns true if *this is approximately equal to the zero Force, within the precision " 149 .def(
"Random", &Force::Random,
"Returns a random Force.")
150 .staticmethod(
"Random")
151 .def(
"Zero", &Force::Zero,
"Returns a zero Force.")
152 .staticmethod(
"Zero")
155 "__array__", bp::make_function(
156 (
typename Force::ToVectorReturnType (Force::*)())&Force::toVector,
157 bp::return_internal_reference<>()))
159 "__array__", &__array__,
160 (bp::arg(
"self"), bp::arg(
"dtype") = bp::object(), bp::arg(
"copy") = bp::object()),
161 bp::return_internal_reference<>())
162#ifndef PINOCCHIO_PYTHON_NO_SERIALIZATION 163 .def_pickle(Pickle())
166 PINOCCHIO_COMPILER_DIAGNOSTIC_POP
171 typedef pinocchio::ForceBase<Force> ForceBase;
172 bp::objects::register_dynamic_id<ForceBase>();
173 bp::objects::register_conversion<Force, ForceBase>(
false);
175 typedef pinocchio::ForceDense<Force> ForceDense;
176 bp::objects::register_dynamic_id<ForceBase>();
177 bp::objects::register_conversion<Force, ForceDense>(
false);
179 typedef ::boost::python::detail::not_specified HolderType;
180 bp::class_<Force, HolderType>(
182 "Force vectors, in se3* == F^6.\n\n" 183 "Supported operations ...",
188 .def(::eigenpy::CopyableVisitor<Force>())
193 static typename Force::ToVectorConstReturnType
194 __array__(
const Force & self, bp::object, bp::object)
196 return self.toVector();
199 struct Pickle : bp::pickle_suite
201 static boost::python::tuple getinitargs(
const Force & f)
203 return bp::make_tuple((Vector3)f.linear(), (Vector3)f.angular());
206 static bool getstate_manages_dict()
212 static RefVector3 getLinear(Force & self)
214 return self.linear();
216 static void setLinear(Force & self,
const Vector3 & f)
220 static RefVector3 getAngular(Force & self)
222 return self.angular();
224 static void setAngular(Force & self,
const Vector3 & n)
229 static void setZero(Force & self)
233 static void setRandom(Force & self)
238 static void setVector(Force & self,
const Vector6 & f)