| Line | Branch | Exec | Source |
|---|---|---|---|
| 1 | /* | ||
| 2 | * Software License Agreement (BSD License) | ||
| 3 | * | ||
| 4 | * Copyright (c) 2024, INRIA | ||
| 5 | * All rights reserved. | ||
| 6 | * | ||
| 7 | * Redistribution and use in source and binary forms, with or without | ||
| 8 | * modification, are permitted provided that the following conditions | ||
| 9 | * are met: | ||
| 10 | * | ||
| 11 | * * Redistributions of source code must retain the above copyright | ||
| 12 | * notice, this list of conditions and the following disclaimer. | ||
| 13 | * * Redistributions in binary form must reproduce the above | ||
| 14 | * copyright notice, this list of conditions and the following | ||
| 15 | * disclaimer in the documentation and/or other materials provided | ||
| 16 | * with the distribution. | ||
| 17 | * * Neither the name of INRIA nor the names of its | ||
| 18 | * contributors may be used to endorse or promote products derived | ||
| 19 | * from this software without specific prior written permission. | ||
| 20 | * | ||
| 21 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | ||
| 22 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | ||
| 23 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS | ||
| 24 | * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE | ||
| 25 | * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, | ||
| 26 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, | ||
| 27 | * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
| 28 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER | ||
| 29 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | ||
| 30 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN | ||
| 31 | * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | ||
| 32 | * POSSIBILITY OF SUCH DAMAGE. | ||
| 33 | */ | ||
| 34 | |||
| 35 | /** \author Louis Montaut */ | ||
| 36 | |||
| 37 | #ifndef COAL_CONTACT_PATCH_H | ||
| 38 | #define COAL_CONTACT_PATCH_H | ||
| 39 | |||
| 40 | #include "coal/data_types.h" | ||
| 41 | #include "coal/collision_data.h" | ||
| 42 | #include "coal/contact_patch/contact_patch_solver.h" | ||
| 43 | #include "coal/contact_patch_func_matrix.h" | ||
| 44 | |||
| 45 | namespace coal { | ||
| 46 | |||
| 47 | /// @brief Main contact patch computation interface. | ||
| 48 | /// @note Please see @ref ContactPatchRequest and @ref ContactPatchResult for | ||
| 49 | /// more info on the content of the input/output of this function. Also, please | ||
| 50 | /// read @ref ContactPatch if you want to fully understand what is meant by | ||
| 51 | /// "contact patch". | ||
| 52 | COAL_DLLAPI void computeContactPatch(const CollisionGeometry* o1, | ||
| 53 | const Transform3s& tf1, | ||
| 54 | const CollisionGeometry* o2, | ||
| 55 | const Transform3s& tf2, | ||
| 56 | const CollisionResult& collision_result, | ||
| 57 | const ContactPatchRequest& request, | ||
| 58 | ContactPatchResult& result); | ||
| 59 | |||
| 60 | /// @copydoc computeContactPatch(const CollisionGeometry*, const Transform3s&, | ||
| 61 | // const CollisionGeometry*, const Transform3s&, const CollisionResult&, const | ||
| 62 | // ContactPatchRequest&, ContactPatchResult&); | ||
| 63 | COAL_DLLAPI void computeContactPatch(const CollisionObject* o1, | ||
| 64 | const CollisionObject* o2, | ||
| 65 | const CollisionResult& collision_result, | ||
| 66 | const ContactPatchRequest& request, | ||
| 67 | ContactPatchResult& result); | ||
| 68 | |||
| 69 | /// @brief This class reduces the cost of identifying the geometry pair. | ||
| 70 | /// This is usefull for repeated shape-shape queries. | ||
| 71 | /// @note This needs to be called after `collide` or after `ComputeCollision`. | ||
| 72 | /// | ||
| 73 | /// \code | ||
| 74 | /// ComputeContactPatch calc_patch (o1, o2); | ||
| 75 | /// calc_patch(tf1, tf2, collision_result, patch_request, patch_result); | ||
| 76 | /// \endcode | ||
| 77 | class COAL_DLLAPI ComputeContactPatch { | ||
| 78 | public: | ||
| 79 | /// @brief Default constructor from two Collision Geometries. | ||
| 80 | ComputeContactPatch(const CollisionGeometry* o1, const CollisionGeometry* o2); | ||
| 81 | |||
| 82 | void operator()(const Transform3s& tf1, const Transform3s& tf2, | ||
| 83 | const CollisionResult& collision_result, | ||
| 84 | const ContactPatchRequest& request, | ||
| 85 | ContactPatchResult& result) const; | ||
| 86 | |||
| 87 | bool operator==(const ComputeContactPatch& other) const { | ||
| 88 | return this->o1 == other.o1 && this->o2 == other.o2 && | ||
| 89 | this->csolver == other.csolver; | ||
| 90 | } | ||
| 91 | |||
| 92 | bool operator!=(const ComputeContactPatch& other) const { | ||
| 93 | return !(*this == other); | ||
| 94 | } | ||
| 95 | |||
| 96 | ✗ | virtual ~ComputeContactPatch() = default; | |
| 97 | |||
| 98 | protected: | ||
| 99 | // These pointers are made mutable to let the derived classes to update | ||
| 100 | // their values when updating the collision geometry (e.g. creating a new | ||
| 101 | // one). This feature should be used carefully to avoid any mis usage (e.g, | ||
| 102 | // changing the type of the collision geometry should be avoided). | ||
| 103 | mutable const CollisionGeometry* o1; | ||
| 104 | mutable const CollisionGeometry* o2; | ||
| 105 | |||
| 106 | mutable ContactPatchSolver csolver; | ||
| 107 | |||
| 108 | ContactPatchFunctionMatrix::ContactPatchFunc func; | ||
| 109 | bool swap_geoms; | ||
| 110 | |||
| 111 | virtual void run(const Transform3s& tf1, const Transform3s& tf2, | ||
| 112 | const CollisionResult& collision_result, | ||
| 113 | const ContactPatchRequest& request, | ||
| 114 | ContactPatchResult& result) const; | ||
| 115 | |||
| 116 | public: | ||
| 117 | EIGEN_MAKE_ALIGNED_OPERATOR_NEW | ||
| 118 | }; | ||
| 119 | |||
| 120 | } // namespace coal | ||
| 121 | |||
| 122 | #endif | ||
| 123 |