4 #ifndef __multicontact_api_python_geometry_linear_cone_hpp__
5 #define __multicontact_api_python_geometry_linear_cone_hpp__
7 #include <eigenpy/eigenpy.hpp>
8 #include <pinocchio/fwd.hpp>
16 namespace bp = boost::python;
18 template <
typename LC>
20 :
public boost::python::def_visitor<LCPythonVisitor<LC> > {
27 typedef typename LC::Index
Index;
29 template <
class PyClass>
31 cl.def(bp::init<>(
"Default constructor."))
32 .def(bp::init<MatrixDx>((bp::arg(
"rays"),
"Init from a set of rays.")))
33 .def(bp::init<Index>(bp::args(
"size"),
"Init with a given size."))
34 .def(bp::init<LC>(bp::args(
"other"),
"Copy constructor."))
36 .add_property(
"size", &LC::size,
"Returns the size of the set of rays.")
37 .add_static_property(
"dim", &
dim,
"Dimension of the linear cone.")
40 "Matrix of rays of the linear cone.")
43 (
bool(LC::*)(
const LC &,
const Scalar &)
const) & LC::isApprox,
44 bp::args(
"other",
"prec"),
45 "Returns true if *this is approximately equal to other, within "
46 "the precision determined by prec.")
47 .def(
"stack", &LC::template stack<MatrixDx>, bp::args(
"rays"),
48 "Stack new rays to the set of rays.")
49 .def(
"stack", &LC::template stack<Scalar, LC::Options>,
50 bp::args(
"cone"),
"Stack the rays of one to the set of rays.")
52 .def(bp::self == bp::self)
53 .def(bp::self != bp::self);
56 static PyClass &
expose(
const std::string &class_name, std::string doc =
"") {
58 doc =
"Linear Cone of dimension " + LC::dim;
59 doc +=
" defined by its rays.";
62 static PyClass cl_ =
PyClass(class_name.c_str(), doc.c_str(), bp::no_init);
66 ENABLE_SPECIFIC_MATRIX_TYPE(
MatrixDx);
67 ENABLE_SPECIFIC_MATRIX_TYPE(
VectorD);
82 static int dim() {
return LC::dim; }
85 template <
typename ForceCone>
87 :
public boost::python::def_visitor<ForceConePythonVisitor<ForceCone> > {
88 typedef typename ForceCone::Scalar
Scalar;
89 typedef typename ForceCone::Vector3
Vector3;
90 typedef typename ForceCone::VectorD
VectorD;
92 typedef typename ForceCone::Index
Index;
95 template <
class _PyClass>
96 void visit(_PyClass &cl)
const {
97 cl.def(bp::init<>(
"Default constructor."))
98 .def(bp::init<Matrix3x>(
99 (bp::arg(
"rays"),
"Init from a matrix of rays.")))
100 .def(bp::init<Index>(bp::args(
"size"),
"Init with a given size."))
101 .def(bp::init<ForceCone>(bp::args(
"other"),
"Copy constructor."))
103 .def(
"SE3ActOn", &ForceCone::SE3ActOn, bp::args(
"M"),
104 "Returns the action of SE3 on *this, i.e. a WrenchCone.")
105 .def(
"toWrenchCone", &
toWrenchCone,
"Returns *this as a WrenchCone.")
109 ForceCone::RegularCone,
110 bp::args(
"mu",
"direction",
"num rays"),
111 "Generates a regular linear cone from a given number of rays, a "
112 "main direction and a friction "
117 ForceCone::RegularCone,
118 bp::args(
"mu",
"direction",
"num rays",
"angle offset"),
119 "Generates a regular linear cone from a given number of rays, a "
120 "main direction and a friction "
121 "coefficient, with an offset on the orientation.")
122 .staticmethod(
"RegularCone");
125 static void expose(
const std::string &class_name) {
126 std::string doc =
"Force Cone of dimension 3";
127 doc +=
" defined by its rays.";
131 bp::class_<ForceCone, bp::bases<typename ForceCone::Base> >(
132 class_name.c_str(), doc.c_str(), bp::no_init)
141 template <
typename WrenchCone>
143 :
public boost::python::def_visitor<WrenchConePythonVisitor<WrenchCone> > {
146 typedef typename WrenchCone::Index
Index;
148 template <
class _PyClass>
150 cl.def(bp::init<>(
"Default constructor."))
151 .def(bp::init<Matrix6x>(
152 (bp::arg(
"rays"),
"Init from a matrix of rays.")))
153 .def(bp::init<Index>(bp::args(
"size"),
"Init with a given size."))
154 .def(bp::init<WrenchCone>(bp::args(
"other"),
"Copy constructor."))
156 .def(
"SE3ActOn", &WrenchCone::SE3ActOn, bp::args(
"M"),
157 "Returns the action of SE3 on *this, i.e. a WrenchCone.")
158 .def(
"linear", &
getLinear,
"Returns the linear block of *this.")
159 .def(
"angular", &
getAngular,
"Returns the angular block of *this.");
162 static void expose(
const std::string &class_name) {
163 std::string doc =
"Linear Wrench Cone";
167 bp::class_<WrenchCone, bp::bases<typename WrenchCone::Base> >(
168 class_name.c_str(), doc.c_str(), bp::no_init)