pinocchio  3.7.0
A fast and flexible implementation of Rigid Body Dynamics algorithms and their analytical derivatives
 
Loading...
Searching...
No Matches
coulomb-friction-cone.hpp
1//
2// Copyright (c) 2022 INRIA
3//
4
5#ifndef __pinocchio_python_algorithm_constraints_coulomb_friction_cone_hpp__
6#define __pinocchio_python_algorithm_constraints_coulomb_friction_cone_hpp__
7
8#include "pinocchio/algorithm/constraints/coulomb-friction-cone.hpp"
9
10#include "pinocchio/bindings/python/utils/cast.hpp"
11#include "pinocchio/bindings/python/utils/copyable.hpp"
12
13namespace pinocchio
14{
15 namespace python
16 {
17 namespace bp = boost::python;
18
19 template<typename CoulombFrictionCone>
20 struct CoulombFrictionConePythonVisitor
21 : public boost::python::def_visitor<CoulombFrictionConePythonVisitor<CoulombFrictionCone>>
22 {
23 typedef typename CoulombFrictionCone::Scalar Scalar;
24 typedef CoulombFrictionCone Self;
25
26 template<class PyClass>
27 void visit(PyClass & cl) const
28 {
29 cl.def(bp::init<const Scalar &>(bp::args("self", "mu"), "Default constructor"))
30 .def(bp::init<const Self &>(bp::args("self", "other"), "Copy constructor"))
31
32 .def_readwrite("mu", &Self::mu, "Friction coefficient.")
33
34 .def(
35 "isInside", &Self::template isInside<context::Vector3s>, bp::args("self", "f"),
36 "Check whether a vector x lies within the cone.")
37
38 .def(
39 "project", &Self::template project<context::Vector3s>, bp::args("self", "f"),
40 "Normal projection of a vector f onto the cone.")
41 .def(
42 "weightedProject", &Self::template weightedProject<context::Vector3s>,
43 bp::args("self", "f", "R"), "Weighted projection of a vector f onto the cone.")
44 .def(
45 "computeNormalCorrection", &Self::template computeNormalCorrection<context::Vector3s>,
46 bp::args("self", "v"),
47 "Compute the complementary shift associted to the Coulomb friction cone for "
48 "complementarity satisfaction in complementary problems.")
49 .def(
50 "computeRadialProjection", &Self::template computeRadialProjection<context::Vector3s>,
51 bp::args("self", "f"),
52 "Compute the radial projection associted to the Coulomb friction cone.")
53
54 .def("dual", &Self::dual, bp::arg("self"), "Returns the dual cone associated to this")
55
56 .def("dim", Self::dim, "Returns the dimension of the cone.")
57 .staticmethod("dim")
58
59#ifndef PINOCCHIO_PYTHON_SKIP_COMPARISON_OPERATIONS
60 .def(bp::self == bp::self)
61 .def(bp::self != bp::self)
62#endif
63 ;
64 }
65
66 static void expose()
67 {
68 bp::class_<CoulombFrictionCone>(
69 "CoulombFrictionCone", "3d Coulomb friction cone.\n", bp::no_init)
70 .def(CoulombFrictionConePythonVisitor())
71 // .def(CastVisitor<CoulombFrictionCone>())
72 // .def(ExposeConstructorByCastVisitor<CoulombFrictionCone,::pinocchio::CoulombFrictionCone>())
73 .def(CopyableVisitor<CoulombFrictionCone>());
74 }
75 };
76
77 template<typename DualCoulombFrictionCone>
78 struct DualCoulombFrictionConePythonVisitor
79 : public boost::python::def_visitor<
80 DualCoulombFrictionConePythonVisitor<DualCoulombFrictionCone>>
81 {
82 typedef typename DualCoulombFrictionCone::Scalar Scalar;
83 typedef DualCoulombFrictionCone Self;
84
85 template<class PyClass>
86 void visit(PyClass & cl) const
87 {
88 cl.def(bp::init<const Scalar &>(bp::args("self", "mu"), "Default constructor"))
89 .def(bp::init<const Self &>(bp::args("self", "other"), "Copy constructor"))
90
91 .def_readwrite("mu", &Self::mu, "Friction coefficient.")
92
93 .def(
94 "isInside", &Self::template isInside<context::Vector3s>, bp::args("self", "v"),
95 "Check whether a vector x lies within the cone.")
96
97 .def(
98 "project", &Self::template project<context::Vector3s>, bp::args("self", "v"),
99 "Project a vector v onto the cone.")
100
101 .def("dual", &Self::dual, bp::arg("self"), "Returns the dual cone associated to this.")
102
103 .def("dim", Self::dim, "Returns the dimension of the cone.")
104 .staticmethod("dim")
105
106#ifndef PINOCCHIO_PYTHON_SKIP_COMPARISON_OPERATIONS
107 .def(bp::self == bp::self)
108 .def(bp::self != bp::self)
109#endif
110 ;
111 }
112
113 static void expose()
114 {
115 bp::class_<DualCoulombFrictionCone>(
116 "DualCoulombFrictionCone", "Dual cone of the 3d Coulomb friction cone.\n", bp::no_init)
117 .def(DualCoulombFrictionConePythonVisitor())
118 // .def(CastVisitor<DualCoulombFrictionCone>())
119 // .def(ExposeConstructorByCastVisitor<DualCoulombFrictionCone,::pinocchio::DualCoulombFrictionCone>())
120 .def(CopyableVisitor<DualCoulombFrictionCone>());
121 }
122 };
123
124 } // namespace python
125} // namespace pinocchio
126
127#endif // ifndef __pinocchio_python_algorithm_constraints_coulomb_friction_cone_hpp__
Main pinocchio namespace.
Definition treeview.dox:11