Directory: | ./ |
---|---|
File: | include/pinocchio/bindings/python/algorithm/constraints/coulomb-friction-cone.hpp |
Date: | 2025-02-12 21:03:38 |
Exec | Total | Coverage | |
---|---|---|---|
Lines: | 37 | 37 | 100.0% |
Branches: | 42 | 84 | 50.0% |
Line | Branch | Exec | Source |
---|---|---|---|
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 | |||
13 | namespace 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 | 65 | void visit(PyClass & cl) const | |
28 | { | ||
29 |
2/4✓ Branch 2 taken 65 times.
✗ Branch 3 not taken.
✓ Branch 5 taken 65 times.
✗ Branch 6 not taken.
|
65 | cl.def(bp::init<const Scalar &>(bp::args("self", "mu"), "Default constructor")) |
30 |
3/6✓ Branch 1 taken 65 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 65 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 65 times.
✗ Branch 8 not taken.
|
130 | .def(bp::init<const Self &>(bp::args("self", "other"), "Copy constructor")) |
31 | |||
32 |
1/2✓ Branch 1 taken 65 times.
✗ Branch 2 not taken.
|
65 | .def_readwrite("mu", &Self::mu, "Friction coefficient.") |
33 | |||
34 |
1/2✓ Branch 1 taken 65 times.
✗ Branch 2 not taken.
|
130 | .def( |
35 | "isInside", &Self::template isInside<context::Vector3s>, bp::args("self", "f"), | ||
36 | "Check whether a vector x lies within the cone.") | ||
37 | |||
38 |
2/4✓ Branch 1 taken 65 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 65 times.
✗ Branch 5 not taken.
|
130 | .def( |
39 | "project", &Self::template project<context::Vector3s>, bp::args("self", "f"), | ||
40 | "Normal projection of a vector f onto the cone.") | ||
41 |
2/4✓ Branch 1 taken 65 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 65 times.
✗ Branch 5 not taken.
|
130 | .def( |
42 | "weightedProject", &Self::template weightedProject<context::Vector3s>, | ||
43 | bp::args("self", "f", "R"), "Weighted projection of a vector f onto the cone.") | ||
44 |
2/4✓ Branch 1 taken 65 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 65 times.
✗ Branch 5 not taken.
|
130 | .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 |
2/4✓ Branch 1 taken 65 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 65 times.
✗ Branch 5 not taken.
|
130 | .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 |
2/4✓ Branch 1 taken 65 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 65 times.
✗ Branch 5 not taken.
|
130 | .def("dual", &Self::dual, bp::arg("self"), "Returns the dual cone associated to this") |
55 | |||
56 |
2/4✓ Branch 1 taken 65 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 65 times.
✗ Branch 5 not taken.
|
65 | .def("dim", Self::dim, "Returns the dimension of the cone.") |
57 |
1/2✓ Branch 1 taken 65 times.
✗ Branch 2 not taken.
|
65 | .staticmethod("dim") |
58 | |||
59 | #ifndef PINOCCHIO_PYTHON_SKIP_COMPARISON_OPERATIONS | ||
60 |
1/2✓ Branch 2 taken 65 times.
✗ Branch 3 not taken.
|
65 | .def(bp::self == bp::self) |
61 |
1/2✓ Branch 2 taken 65 times.
✗ Branch 3 not taken.
|
65 | .def(bp::self != bp::self) |
62 | #endif | ||
63 | ; | ||
64 | 65 | } | |
65 | |||
66 | 65 | static void expose() | |
67 | { | ||
68 | 65 | bp::class_<CoulombFrictionCone>( | |
69 | "CoulombFrictionCone", "3d Coulomb friction cone.\n", bp::no_init) | ||
70 |
1/2✓ Branch 1 taken 65 times.
✗ Branch 2 not taken.
|
65 | .def(CoulombFrictionConePythonVisitor()) |
71 | // .def(CastVisitor<CoulombFrictionCone>()) | ||
72 | // .def(ExposeConstructorByCastVisitor<CoulombFrictionCone,::pinocchio::CoulombFrictionCone>()) | ||
73 |
1/2✓ Branch 1 taken 65 times.
✗ Branch 2 not taken.
|
65 | .def(CopyableVisitor<CoulombFrictionCone>()); |
74 | 65 | } | |
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 | 65 | void visit(PyClass & cl) const | |
87 | { | ||
88 |
2/4✓ Branch 2 taken 65 times.
✗ Branch 3 not taken.
✓ Branch 5 taken 65 times.
✗ Branch 6 not taken.
|
65 | cl.def(bp::init<const Scalar &>(bp::args("self", "mu"), "Default constructor")) |
89 |
3/6✓ Branch 1 taken 65 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 65 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 65 times.
✗ Branch 8 not taken.
|
130 | .def(bp::init<const Self &>(bp::args("self", "other"), "Copy constructor")) |
90 | |||
91 |
1/2✓ Branch 1 taken 65 times.
✗ Branch 2 not taken.
|
65 | .def_readwrite("mu", &Self::mu, "Friction coefficient.") |
92 | |||
93 |
1/2✓ Branch 1 taken 65 times.
✗ Branch 2 not taken.
|
130 | .def( |
94 | "isInside", &Self::template isInside<context::Vector3s>, bp::args("self", "v"), | ||
95 | "Check whether a vector x lies within the cone.") | ||
96 | |||
97 |
2/4✓ Branch 1 taken 65 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 65 times.
✗ Branch 5 not taken.
|
130 | .def( |
98 | "project", &Self::template project<context::Vector3s>, bp::args("self", "v"), | ||
99 | "Project a vector v onto the cone.") | ||
100 | |||
101 |
2/4✓ Branch 1 taken 65 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 65 times.
✗ Branch 5 not taken.
|
130 | .def("dual", &Self::dual, bp::arg("self"), "Returns the dual cone associated to this.") |
102 | |||
103 |
2/4✓ Branch 1 taken 65 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 65 times.
✗ Branch 5 not taken.
|
65 | .def("dim", Self::dim, "Returns the dimension of the cone.") |
104 |
1/2✓ Branch 1 taken 65 times.
✗ Branch 2 not taken.
|
65 | .staticmethod("dim") |
105 | |||
106 | #ifndef PINOCCHIO_PYTHON_SKIP_COMPARISON_OPERATIONS | ||
107 |
1/2✓ Branch 2 taken 65 times.
✗ Branch 3 not taken.
|
65 | .def(bp::self == bp::self) |
108 |
1/2✓ Branch 2 taken 65 times.
✗ Branch 3 not taken.
|
65 | .def(bp::self != bp::self) |
109 | #endif | ||
110 | ; | ||
111 | 65 | } | |
112 | |||
113 | 65 | static void expose() | |
114 | { | ||
115 | 65 | bp::class_<DualCoulombFrictionCone>( | |
116 | "DualCoulombFrictionCone", "Dual cone of the 3d Coulomb friction cone.\n", bp::no_init) | ||
117 |
1/2✓ Branch 1 taken 65 times.
✗ Branch 2 not taken.
|
65 | .def(DualCoulombFrictionConePythonVisitor()) |
118 | // .def(CastVisitor<DualCoulombFrictionCone>()) | ||
119 | // .def(ExposeConstructorByCastVisitor<DualCoulombFrictionCone,::pinocchio::DualCoulombFrictionCone>()) | ||
120 |
1/2✓ Branch 1 taken 65 times.
✗ Branch 2 not taken.
|
65 | .def(CopyableVisitor<DualCoulombFrictionCone>()); |
121 | 65 | } | |
122 | }; | ||
123 | |||
124 | } // namespace python | ||
125 | } // namespace pinocchio | ||
126 | |||
127 | #endif // ifndef __pinocchio_python_algorithm_constraints_coulomb_friction_cone_hpp__ | ||
128 |