| Line | Branch | Exec | Source |
|---|---|---|---|
| 1 | // | ||
| 2 | // Software License Agreement (BSD License) | ||
| 3 | // | ||
| 4 | // Copyright (c) 2020 CNRS-LAAS | ||
| 5 | // Author: Joseph Mirabel | ||
| 6 | // All rights reserved. | ||
| 7 | // | ||
| 8 | // Redistribution and use in source and binary forms, with or without | ||
| 9 | // modification, are permitted provided that the following conditions | ||
| 10 | // are met: | ||
| 11 | // | ||
| 12 | // * Redistributions of source code must retain the above copyright | ||
| 13 | // notice, this list of conditions and the following disclaimer. | ||
| 14 | // * Redistributions in binary form must reproduce the above | ||
| 15 | // copyright notice, this list of conditions and the following | ||
| 16 | // disclaimer in the documentation and/or other materials provided | ||
| 17 | // with the distribution. | ||
| 18 | // * Neither the name of CNRS-LAAS. nor the names of its | ||
| 19 | // contributors may be used to endorse or promote products derived | ||
| 20 | // from this software without specific prior written permission. | ||
| 21 | // | ||
| 22 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | ||
| 23 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | ||
| 24 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS | ||
| 25 | // FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE | ||
| 26 | // COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, | ||
| 27 | // INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, | ||
| 28 | // BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
| 29 | // LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER | ||
| 30 | // CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | ||
| 31 | // LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN | ||
| 32 | // ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | ||
| 33 | // POSSIBILITY OF SUCH DAMAGE. | ||
| 34 | |||
| 35 | #include <eigenpy/eigenpy.hpp> | ||
| 36 | |||
| 37 | #include "coal.hh" | ||
| 38 | |||
| 39 | #include "coal/fwd.hh" | ||
| 40 | #include "coal/narrowphase/gjk.h" | ||
| 41 | |||
| 42 | #ifdef COAL_HAS_DOXYGEN_AUTODOC | ||
| 43 | #include "doxygen_autodoc/functions.h" | ||
| 44 | #include "doxygen_autodoc/coal/narrowphase/gjk.h" | ||
| 45 | #endif | ||
| 46 | |||
| 47 | using namespace boost::python; | ||
| 48 | using namespace coal; | ||
| 49 | using coal::details::EPA; | ||
| 50 | using coal::details::GJK; | ||
| 51 | using coal::details::MinkowskiDiff; | ||
| 52 | using coal::details::SupportOptions; | ||
| 53 | |||
| 54 | struct MinkowskiDiffWrapper { | ||
| 55 | ✗ | static void support0(MinkowskiDiff& self, const Vec3s& dir, int& hint, | |
| 56 | bool compute_swept_sphere_support = false) { | ||
| 57 | ✗ | if (compute_swept_sphere_support) { | |
| 58 | ✗ | self.support0<SupportOptions::WithSweptSphere>(dir, hint); | |
| 59 | } else { | ||
| 60 | ✗ | self.support0<SupportOptions::NoSweptSphere>(dir, hint); | |
| 61 | } | ||
| 62 | ✗ | } | |
| 63 | |||
| 64 | ✗ | static void support1(MinkowskiDiff& self, const Vec3s& dir, int& hint, | |
| 65 | bool compute_swept_sphere_support = false) { | ||
| 66 | ✗ | if (compute_swept_sphere_support) { | |
| 67 | ✗ | self.support1<SupportOptions::WithSweptSphere>(dir, hint); | |
| 68 | } else { | ||
| 69 | ✗ | self.support1<SupportOptions::NoSweptSphere>(dir, hint); | |
| 70 | } | ||
| 71 | ✗ | } | |
| 72 | |||
| 73 | ✗ | static void set(MinkowskiDiff& self, const ShapeBase* shape0, | |
| 74 | const ShapeBase* shape1, | ||
| 75 | bool compute_swept_sphere_support = false) { | ||
| 76 | ✗ | if (compute_swept_sphere_support) { | |
| 77 | ✗ | self.set<SupportOptions::WithSweptSphere>(shape0, shape1); | |
| 78 | } else { | ||
| 79 | ✗ | self.set<SupportOptions::NoSweptSphere>(shape0, shape1); | |
| 80 | } | ||
| 81 | ✗ | } | |
| 82 | |||
| 83 | ✗ | static void set(MinkowskiDiff& self, const ShapeBase* shape0, | |
| 84 | const ShapeBase* shape1, const Transform3s& tf0, | ||
| 85 | const Transform3s& tf1, | ||
| 86 | bool compute_swept_sphere_supports = false) { | ||
| 87 | ✗ | if (compute_swept_sphere_supports) { | |
| 88 | ✗ | self.set<SupportOptions::WithSweptSphere>(shape0, shape1, tf0, tf1); | |
| 89 | } else { | ||
| 90 | ✗ | self.set<SupportOptions::NoSweptSphere>(shape0, shape1, tf0, tf1); | |
| 91 | } | ||
| 92 | ✗ | } | |
| 93 | }; | ||
| 94 | |||
| 95 | 5 | void exposeGJK() { | |
| 96 |
1/2✓ Branch 1 taken 5 times.
✗ Branch 2 not taken.
|
5 | if (!eigenpy::register_symbolic_link_to_registered_type<GJK::Status>()) { |
| 97 |
1/2✓ Branch 1 taken 5 times.
✗ Branch 2 not taken.
|
10 | enum_<GJK::Status>("GJKStatus") |
| 98 |
1/2✓ Branch 1 taken 5 times.
✗ Branch 2 not taken.
|
5 | .value("Failed", GJK::Status::Failed) |
| 99 |
1/2✓ Branch 1 taken 5 times.
✗ Branch 2 not taken.
|
5 | .value("DidNotRun", GJK::Status::DidNotRun) |
| 100 |
1/2✓ Branch 1 taken 5 times.
✗ Branch 2 not taken.
|
5 | .value("NoCollision", GJK::Status::NoCollision) |
| 101 |
1/2✓ Branch 1 taken 5 times.
✗ Branch 2 not taken.
|
5 | .value("NoCollisionEarlyStopped", GJK::Status::NoCollisionEarlyStopped) |
| 102 |
1/2✓ Branch 1 taken 5 times.
✗ Branch 2 not taken.
|
5 | .value("CollisionWithPenetrationInformation", |
| 103 | GJK::Status::CollisionWithPenetrationInformation) | ||
| 104 |
1/2✓ Branch 1 taken 5 times.
✗ Branch 2 not taken.
|
5 | .value("Collision", GJK::Status::Collision) |
| 105 |
1/2✓ Branch 1 taken 5 times.
✗ Branch 2 not taken.
|
5 | .export_values(); |
| 106 | } | ||
| 107 | |||
| 108 |
1/2✓ Branch 1 taken 5 times.
✗ Branch 2 not taken.
|
5 | if (!eigenpy::register_symbolic_link_to_registered_type<MinkowskiDiff>()) { |
| 109 |
2/4✓ Branch 1 taken 5 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 5 times.
✗ Branch 5 not taken.
|
10 | class_<MinkowskiDiff>("MinkowskiDiff", doxygen::class_doc<MinkowskiDiff>(), |
| 110 | no_init) | ||
| 111 |
1/2✓ Branch 2 taken 5 times.
✗ Branch 3 not taken.
|
5 | .def(doxygen::visitor::init<MinkowskiDiff>()) |
| 112 | 10 | .def("set", | |
| 113 | static_cast<void (*)(MinkowskiDiff&, const ShapeBase*, | ||
| 114 | const ShapeBase*, bool)>( | ||
| 115 | &MinkowskiDiffWrapper::set), | ||
| 116 |
1/2✓ Branch 2 taken 5 times.
✗ Branch 3 not taken.
|
5 | doxygen::member_func_doc(static_cast<void (MinkowskiDiff::*)( |
| 117 | const ShapeBase*, const ShapeBase*)>( | ||
| 118 | &MinkowskiDiff::set<SupportOptions::NoSweptSphere>))) | ||
| 119 | |||
| 120 | 10 | .def("set", | |
| 121 | static_cast<void (*)(MinkowskiDiff&, const ShapeBase*, | ||
| 122 | const ShapeBase*, const Transform3s&, | ||
| 123 | const Transform3s&, bool)>( | ||
| 124 | &MinkowskiDiffWrapper::set), | ||
| 125 |
1/2✓ Branch 2 taken 5 times.
✗ Branch 3 not taken.
|
5 | doxygen::member_func_doc( |
| 126 | static_cast<void (MinkowskiDiff::*)( | ||
| 127 | const ShapeBase*, const ShapeBase*, const Transform3s&, | ||
| 128 | const Transform3s&)>( | ||
| 129 | &MinkowskiDiff::set<SupportOptions::NoSweptSphere>))) | ||
| 130 | |||
| 131 | 10 | .def("support0", &MinkowskiDiffWrapper::support0, | |
| 132 |
1/2✓ Branch 2 taken 5 times.
✗ Branch 3 not taken.
|
5 | doxygen::member_func_doc( |
| 133 | &MinkowskiDiff::support0<SupportOptions::NoSweptSphere>)) | ||
| 134 | |||
| 135 | 10 | .def("support1", &MinkowskiDiffWrapper::support1, | |
| 136 |
1/2✓ Branch 2 taken 5 times.
✗ Branch 3 not taken.
|
5 | doxygen::member_func_doc( |
| 137 | &MinkowskiDiff::support1<SupportOptions::NoSweptSphere>)) | ||
| 138 | |||
| 139 | 10 | .def("support", &MinkowskiDiff::support, | |
| 140 |
1/2✓ Branch 2 taken 5 times.
✗ Branch 3 not taken.
|
5 | doxygen::member_func_doc(&MinkowskiDiff::support)) |
| 141 | |||
| 142 |
2/4✓ Branch 1 taken 5 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 5 times.
✗ Branch 5 not taken.
|
5 | .DEF_RW_CLASS_ATTRIB(MinkowskiDiff, swept_sphere_radius) |
| 143 |
2/4✓ Branch 1 taken 5 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 5 times.
✗ Branch 5 not taken.
|
5 | .DEF_RW_CLASS_ATTRIB(MinkowskiDiff, normalize_support_direction); |
| 144 | } | ||
| 145 | |||
| 146 |
1/2✓ Branch 1 taken 5 times.
✗ Branch 2 not taken.
|
5 | if (!eigenpy::register_symbolic_link_to_registered_type<GJKVariant>()) { |
| 147 |
1/2✓ Branch 1 taken 5 times.
✗ Branch 2 not taken.
|
10 | enum_<GJKVariant>("GJKVariant") |
| 148 |
1/2✓ Branch 1 taken 5 times.
✗ Branch 2 not taken.
|
5 | .value("DefaultGJK", GJKVariant::DefaultGJK) |
| 149 |
1/2✓ Branch 1 taken 5 times.
✗ Branch 2 not taken.
|
5 | .value("PolyakAcceleration", GJKVariant::PolyakAcceleration) |
| 150 |
1/2✓ Branch 1 taken 5 times.
✗ Branch 2 not taken.
|
5 | .value("NesterovAcceleration", GJKVariant::NesterovAcceleration) |
| 151 |
1/2✓ Branch 1 taken 5 times.
✗ Branch 2 not taken.
|
5 | .export_values(); |
| 152 | } | ||
| 153 | |||
| 154 |
1/2✓ Branch 1 taken 5 times.
✗ Branch 2 not taken.
|
5 | if (!eigenpy::register_symbolic_link_to_registered_type<GJKInitialGuess>()) { |
| 155 |
1/2✓ Branch 1 taken 5 times.
✗ Branch 2 not taken.
|
10 | enum_<GJKInitialGuess>("GJKInitialGuess") |
| 156 |
1/2✓ Branch 1 taken 5 times.
✗ Branch 2 not taken.
|
5 | .value("DefaultGuess", GJKInitialGuess::DefaultGuess) |
| 157 |
1/2✓ Branch 1 taken 5 times.
✗ Branch 2 not taken.
|
5 | .value("CachedGuess", GJKInitialGuess::CachedGuess) |
| 158 |
1/2✓ Branch 1 taken 5 times.
✗ Branch 2 not taken.
|
5 | .value("BoundingVolumeGuess", GJKInitialGuess::BoundingVolumeGuess) |
| 159 |
1/2✓ Branch 1 taken 5 times.
✗ Branch 2 not taken.
|
5 | .export_values(); |
| 160 | } | ||
| 161 | |||
| 162 | 5 | if (!eigenpy::register_symbolic_link_to_registered_type< | |
| 163 |
1/2✓ Branch 1 taken 5 times.
✗ Branch 2 not taken.
|
5 | GJKConvergenceCriterion>()) { |
| 164 |
1/2✓ Branch 1 taken 5 times.
✗ Branch 2 not taken.
|
10 | enum_<GJKConvergenceCriterion>("GJKConvergenceCriterion") |
| 165 |
1/2✓ Branch 1 taken 5 times.
✗ Branch 2 not taken.
|
5 | .value("Default", GJKConvergenceCriterion::Default) |
| 166 |
1/2✓ Branch 1 taken 5 times.
✗ Branch 2 not taken.
|
5 | .value("DualityGap", GJKConvergenceCriterion::DualityGap) |
| 167 |
1/2✓ Branch 1 taken 5 times.
✗ Branch 2 not taken.
|
5 | .value("Hybrid", GJKConvergenceCriterion::Hybrid) |
| 168 |
1/2✓ Branch 1 taken 5 times.
✗ Branch 2 not taken.
|
5 | .export_values(); |
| 169 | } | ||
| 170 | |||
| 171 | 5 | if (!eigenpy::register_symbolic_link_to_registered_type< | |
| 172 |
1/2✓ Branch 1 taken 5 times.
✗ Branch 2 not taken.
|
5 | GJKConvergenceCriterionType>()) { |
| 173 |
1/2✓ Branch 1 taken 5 times.
✗ Branch 2 not taken.
|
10 | enum_<GJKConvergenceCriterionType>("GJKConvergenceCriterionType") |
| 174 |
1/2✓ Branch 1 taken 5 times.
✗ Branch 2 not taken.
|
5 | .value("Absolute", GJKConvergenceCriterionType::Absolute) |
| 175 |
1/2✓ Branch 1 taken 5 times.
✗ Branch 2 not taken.
|
5 | .value("Relative", GJKConvergenceCriterionType::Relative) |
| 176 |
1/2✓ Branch 1 taken 5 times.
✗ Branch 2 not taken.
|
5 | .export_values(); |
| 177 | } | ||
| 178 | |||
| 179 |
1/2✓ Branch 1 taken 5 times.
✗ Branch 2 not taken.
|
5 | if (!eigenpy::register_symbolic_link_to_registered_type<GJK>()) { |
| 180 |
1/2✓ Branch 2 taken 5 times.
✗ Branch 3 not taken.
|
10 | class_<GJK>("GJK", doxygen::class_doc<GJK>(), no_init) |
| 181 |
1/2✓ Branch 2 taken 5 times.
✗ Branch 3 not taken.
|
5 | .def(doxygen::visitor::init<GJK, unsigned int, Scalar>()) |
| 182 |
1/2✓ Branch 2 taken 5 times.
✗ Branch 3 not taken.
|
5 | .DEF_RW_CLASS_ATTRIB(GJK, distance) |
| 183 |
1/2✓ Branch 2 taken 5 times.
✗ Branch 3 not taken.
|
5 | .DEF_RW_CLASS_ATTRIB(GJK, ray) |
| 184 |
1/2✓ Branch 2 taken 5 times.
✗ Branch 3 not taken.
|
5 | .DEF_RW_CLASS_ATTRIB(GJK, support_hint) |
| 185 |
1/2✓ Branch 2 taken 5 times.
✗ Branch 3 not taken.
|
5 | .DEF_RW_CLASS_ATTRIB(GJK, gjk_variant) |
| 186 |
1/2✓ Branch 2 taken 5 times.
✗ Branch 3 not taken.
|
5 | .DEF_RW_CLASS_ATTRIB(GJK, convergence_criterion) |
| 187 |
1/2✓ Branch 2 taken 5 times.
✗ Branch 3 not taken.
|
5 | .DEF_RW_CLASS_ATTRIB(GJK, convergence_criterion_type) |
| 188 |
2/4✓ Branch 1 taken 5 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 5 times.
✗ Branch 5 not taken.
|
5 | .DEF_CLASS_FUNC(GJK, reset) |
| 189 |
2/4✓ Branch 1 taken 5 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 5 times.
✗ Branch 5 not taken.
|
5 | .DEF_CLASS_FUNC(GJK, evaluate) |
| 190 |
2/4✓ Branch 1 taken 5 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 5 times.
✗ Branch 5 not taken.
|
5 | .DEF_CLASS_FUNC(GJK, getTolerance) |
| 191 |
2/4✓ Branch 1 taken 5 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 5 times.
✗ Branch 5 not taken.
|
5 | .DEF_CLASS_FUNC(GJK, getNumMaxIterations) |
| 192 |
2/4✓ Branch 1 taken 5 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 5 times.
✗ Branch 5 not taken.
|
5 | .DEF_CLASS_FUNC(GJK, getNumIterations) |
| 193 |
2/4✓ Branch 1 taken 5 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 5 times.
✗ Branch 5 not taken.
|
5 | .DEF_CLASS_FUNC(GJK, getNumIterationsMomentumStopped) |
| 194 |
2/4✓ Branch 1 taken 5 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 5 times.
✗ Branch 5 not taken.
|
5 | .DEF_CLASS_FUNC(GJK, hasClosestPoints) |
| 195 |
2/4✓ Branch 1 taken 5 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 5 times.
✗ Branch 5 not taken.
|
5 | .DEF_CLASS_FUNC(GJK, getWitnessPointsAndNormal) |
| 196 |
2/4✓ Branch 1 taken 5 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 5 times.
✗ Branch 5 not taken.
|
5 | .DEF_CLASS_FUNC(GJK, setDistanceEarlyBreak) |
| 197 |
2/4✓ Branch 1 taken 5 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 5 times.
✗ Branch 5 not taken.
|
5 | .DEF_CLASS_FUNC(GJK, getGuessFromSimplex); |
| 198 | } | ||
| 199 | 5 | } | |
| 200 |