6 #ifndef __pinocchio_python_spatial_force_hpp__ 7 #define __pinocchio_python_spatial_force_hpp__ 11 #include <boost/python/tuple.hpp> 13 #include "pinocchio/spatial/se3.hpp" 14 #include "pinocchio/spatial/force.hpp" 27 template<
typename T>
struct call;
29 template<
typename Scalar,
int Options>
34 static bool isApprox(
const Force &
self,
const Force & other,
35 const Scalar & prec = Eigen::NumTraits<Scalar>::dummy_precision())
37 return self.isApprox(other,prec);
40 static bool isZero(
const Force &
self,
41 const Scalar & prec = Eigen::NumTraits<Scalar>::dummy_precision())
43 return self.isZero(prec);
50 template<
typename Force>
52 :
public boost::python::def_visitor< ForcePythonVisitor<Force> >
63 template<
class PyClass>
67 .def(bp::init<>(bp::arg(
"self"),
"Default constructor"))
68 .def(bp::init<Vector3,Vector3>
69 (bp::args(
"self",
"linear",
"angular"),
70 "Initialize from linear and angular components of a Wrench vector (don't mix the order)."))
71 .def(bp::init<Vector6>((bp::args(
"self",
"array")),
"Init from a vector 6 [force,torque]"))
72 .def(bp::init<Force>((bp::args(
"self",
"other")),
"Copy constructor."))
74 .add_property(
"linear",
76 bp::with_custodian_and_ward_postcall<0,1>()),
78 "Linear part of a *this, corresponding to the linear velocity in case of a Spatial velocity.")
79 .add_property(
"angular",
81 bp::with_custodian_and_ward_postcall<0,1>()),
83 "Angular part of a *this, corresponding to the angular velocity in case of a Spatial velocity.")
84 .add_property(
"vector",
85 bp::make_function((
typename Force::ToVectorReturnType (Force::*)())&
Force::toVector,
86 bp::return_internal_reference<>()),
88 "Returns the components of *this as a 6d vector.")
90 bp::make_function((
typename Force::ToVectorReturnType (Force::*)())&
Force::toVector,
91 bp::return_internal_reference<>()))
93 .def(
"se3Action",&Force::template se3Action<Scalar,Options>,
94 bp::args(
"self",
"M"),
"Returns the result of the dual action of M on *this.")
95 .def(
"se3ActionInverse",&Force::template se3ActionInverse<Scalar,Options>,
96 bp::args(
"self",
"M"),
"Returns the result of the dual action of the inverse of M on *this.")
99 "Set the linear and angular components of *this to zero.")
101 "Set the linear and angular components of *this to random values.")
103 .def(bp::self + bp::self)
104 .def(bp::self += bp::self)
105 .def(bp::self - bp::self)
106 .def(bp::self -= bp::self)
109 .def(bp::self == bp::self)
110 .def(bp::self != bp::self)
118 isApproxForce_overload(bp::args(
"self",
"other",
"prec"),
119 "Returns true if *this is approximately equal to other, within the precision given by prec."))
123 isZero_overload(bp::args(
"self",
"prec"),
124 "Returns true if *this is approximately equal to the zero Force, within the precision given by prec."))
127 .staticmethod(
"Random")
129 .staticmethod(
"Zero")
131 .def(
"__array__",bp::make_function((
typename Force::ToVectorReturnType (Force::*)())&
Force::toVector,
132 bp::return_internal_reference<>()))
140 #if PY_MAJOR_VERSION == 3 && PY_MINOR_VERSION == 6 && EIGENPY_VERSION_AT_LEAST(2,9,0) 143 typedef ::boost::python::detail::not_specified HolderType;
145 bp::class_<Force,HolderType>(
"Force",
146 "Force vectors, in se3* == F^6.\n\n" 147 "Supported operations ...",
163 {
return bp::make_tuple((Vector3)f.
linear(),(Vector3)f.
angular()); }
168 static RefVector3
getLinear(Force &
self ) {
return self.linear(); }
169 static void setLinear(Force &
self,
const Vector3 & f) {
self.linear(f); }
170 static RefVector3
getAngular(Force &
self) {
return self.angular(); }
171 static void setAngular(Force &
self,
const Vector3 &
n) {
self.angular(n); }
173 static void setZero(Force &
self) {
self.setZero(); }
174 static void setRandom(Force &
self) {
self.setRandom(); }
176 static void setVector(Force &
self,
const Vector6 & f) {
self = f; }
183 #endif // ifndef __pinocchio_python_spatial_force_hpp__ static void setZero(Force &self)
static bool isZero(const Force &self, const Scalar &prec=Eigen::NumTraits< Scalar >::dummy_precision())
static bool getstate_manages_dict()
ToVectorConstReturnType toVector() const
Return the force as an Eigen vector.
ForceTpl< Scalar, Options > Force
Set the Python method str and repr to use the overloading operator<<.
void def(const char *name, Func func)
BOOST_PYTHON_FUNCTION_OVERLOADS(computeKKTContactDynamicMatrixInverse_overload, computeKKTContactDynamicMatrixInverse_proxy, 4, 5) static const Eigen
ConstAngularType angular() const
Return the angular part of the force vector.
Eigen::Map< Vector3 > MapVector3
Eigen::Ref< Vector3 > RefVector3
static void setRandom(Force &self)
void visit(PyClass &cl) const
static RefVector3 getLinear(Force &self)
static void setLinear(Force &self, const Vector3 &f)
static void setVector(Force &self, const Vector6 &f)
#define PINOCCHIO_SHARED_PTR_HOLDER_TYPE(T)
Add the Python method copy to allow a copy of this by calling the copy constructor.
static bool isApprox(const Force &self, const Force &other, const Scalar &prec=Eigen::NumTraits< Scalar >::dummy_precision())
ConstLinearType linear() const
Return the linear part of the force vector.
Main pinocchio namespace.
static boost::python::tuple getinitargs(const Force &f)
Common traits structure to fully define base classes for CRTP.
static RefVector3 getAngular(Force &self)
#define EIGENPY_DEFINE_STRUCT_ALLOCATOR_SPECIALIZATION(...)
static void setAngular(Force &self, const Vector3 &n)