|
| 1 | +/** |
| 2 | + * @file hpp_fcl_discrete_managers.h |
| 3 | + * @brief Tesseract ROS HPP-FCL contact checker implementation. |
| 4 | + * |
| 5 | + * @author Levi Armstrong |
| 6 | + * @date Dec 18, 2017 |
| 7 | + * @version TODO |
| 8 | + * @bug No known bugs |
| 9 | + * |
| 10 | + * @copyright Copyright (c) 2017, Southwest Research Institute |
| 11 | + * |
| 12 | + * @par License |
| 13 | + * Software License Agreement (BSD) |
| 14 | + * @par |
| 15 | + * All rights reserved. |
| 16 | + * @par |
| 17 | + * Redistribution and use in source and binary forms, with or without |
| 18 | + * modification, are permitted provided that the following conditions |
| 19 | + * are met: |
| 20 | + * @par |
| 21 | + * * Redistributions of source code must retain the above copyright |
| 22 | + * notice, this list of conditions and the following disclaimer. |
| 23 | + * * Redistributions in binary form must reproduce the above |
| 24 | + * copyright notice, this list of conditions and the following |
| 25 | + * disclaimer in the documentation and/or other materials provided |
| 26 | + * with the distribution. |
| 27 | + * @par |
| 28 | + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
| 29 | + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
| 30 | + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS |
| 31 | + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE |
| 32 | + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, |
| 33 | + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, |
| 34 | + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; |
| 35 | + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER |
| 36 | + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT |
| 37 | + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN |
| 38 | + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
| 39 | + * POSSIBILITY OF SUCH DAMAGE. |
| 40 | + */ |
| 41 | + |
| 42 | +#ifndef TESSERACT_COLLISION_HPP_FCL_DISCRETE_MANAGERS_H |
| 43 | +#define TESSERACT_COLLISION_HPP_FCL_DISCRETE_MANAGERS_H |
| 44 | + |
| 45 | +#include <tesseract_collision/core/discrete_contact_manager.h> |
| 46 | +#include <tesseract_collision/hpp_fcl/hpp_fcl_utils.h> |
| 47 | + |
| 48 | +namespace tesseract_collision::tesseract_collision_hpp_fcl |
| 49 | +{ |
| 50 | +/** @brief A HPP-FCL implementation of the discrete contact manager */ |
| 51 | +class HPP_FCLDiscreteBVHManager : public DiscreteContactManager |
| 52 | +{ |
| 53 | +public: |
| 54 | + using Ptr = std::shared_ptr<HPP_FCLDiscreteBVHManager>; |
| 55 | + using ConstPtr = std::shared_ptr<const HPP_FCLDiscreteBVHManager>; |
| 56 | + using UPtr = std::unique_ptr<HPP_FCLDiscreteBVHManager>; |
| 57 | + using ConstUPtr = std::unique_ptr<const HPP_FCLDiscreteBVHManager>; |
| 58 | + |
| 59 | + HPP_FCLDiscreteBVHManager(std::string name = "HPP_FCLDiscreteBVHManager"); |
| 60 | + ~HPP_FCLDiscreteBVHManager() override = default; |
| 61 | + HPP_FCLDiscreteBVHManager(const HPP_FCLDiscreteBVHManager&) = delete; |
| 62 | + HPP_FCLDiscreteBVHManager& operator=(const HPP_FCLDiscreteBVHManager&) = delete; |
| 63 | + HPP_FCLDiscreteBVHManager(HPP_FCLDiscreteBVHManager&&) = delete; |
| 64 | + HPP_FCLDiscreteBVHManager& operator=(HPP_FCLDiscreteBVHManager&&) = delete; |
| 65 | + |
| 66 | + std::string getName() const override final; |
| 67 | + |
| 68 | + DiscreteContactManager::UPtr clone() const override final; |
| 69 | + |
| 70 | + bool addCollisionObject(const std::string& name, |
| 71 | + const int& mask_id, |
| 72 | + const CollisionShapesConst& shapes, |
| 73 | + const tesseract_common::VectorIsometry3d& shape_poses, |
| 74 | + bool enabled = true) override final; |
| 75 | + |
| 76 | + const CollisionShapesConst& getCollisionObjectGeometries(const std::string& name) const override final; |
| 77 | + |
| 78 | + const tesseract_common::VectorIsometry3d& |
| 79 | + getCollisionObjectGeometriesTransforms(const std::string& name) const override final; |
| 80 | + |
| 81 | + bool hasCollisionObject(const std::string& name) const override final; |
| 82 | + |
| 83 | + bool removeCollisionObject(const std::string& name) override final; |
| 84 | + |
| 85 | + bool enableCollisionObject(const std::string& name) override final; |
| 86 | + |
| 87 | + bool disableCollisionObject(const std::string& name) override final; |
| 88 | + |
| 89 | + bool isCollisionObjectEnabled(const std::string& name) const override final; |
| 90 | + |
| 91 | + void setCollisionObjectsTransform(const std::string& name, const Eigen::Isometry3d& pose) override final; |
| 92 | + |
| 93 | + void setCollisionObjectsTransform(const std::vector<std::string>& names, |
| 94 | + const tesseract_common::VectorIsometry3d& poses) override final; |
| 95 | + |
| 96 | + void setCollisionObjectsTransform(const tesseract_common::TransformMap& transforms) override final; |
| 97 | + |
| 98 | + const std::vector<std::string>& getCollisionObjects() const override final; |
| 99 | + |
| 100 | + void setActiveCollisionObjects(const std::vector<std::string>& names) override final; |
| 101 | + |
| 102 | + const std::vector<std::string>& getActiveCollisionObjects() const override final; |
| 103 | + |
| 104 | + void setCollisionMarginData( |
| 105 | + CollisionMarginData collision_margin_data, |
| 106 | + CollisionMarginOverrideType override_type = CollisionMarginOverrideType::REPLACE) override final; |
| 107 | + |
| 108 | + void setDefaultCollisionMarginData(double default_collision_margin) override final; |
| 109 | + |
| 110 | + void setPairCollisionMarginData(const std::string& name1, |
| 111 | + const std::string& name2, |
| 112 | + double collision_margin) override final; |
| 113 | + |
| 114 | + const CollisionMarginData& getCollisionMarginData() const override final; |
| 115 | + |
| 116 | + void setIsContactAllowedFn(IsContactAllowedFn fn) override final; |
| 117 | + |
| 118 | + IsContactAllowedFn getIsContactAllowedFn() const override final; |
| 119 | + |
| 120 | + void contactTest(ContactResultMap& collisions, const ContactRequest& request) override final; |
| 121 | + |
| 122 | + /** |
| 123 | + * @brief Add a fcl collision object to the manager |
| 124 | + * @param cow The tesseract fcl collision object |
| 125 | + */ |
| 126 | + void addCollisionObject(const COW::Ptr& cow); |
| 127 | + |
| 128 | +private: |
| 129 | + std::string name_; |
| 130 | + |
| 131 | + /** @brief Broad-phase Collision Manager for active collision objects */ |
| 132 | + std::unique_ptr<hpp::fcl::BroadPhaseCollisionManager> static_manager_; |
| 133 | + |
| 134 | + /** @brief Broad-phase Collision Manager for active collision objects */ |
| 135 | + std::unique_ptr<hpp::fcl::BroadPhaseCollisionManager> dynamic_manager_; |
| 136 | + |
| 137 | + Link2COW link2cow_; /**< @brief A map of all (static and active) collision objects being managed */ |
| 138 | + std::vector<std::string> active_; /**< @brief A list of the active collision objects */ |
| 139 | + std::vector<std::string> collision_objects_; /**< @brief A list of the collision objects */ |
| 140 | + CollisionMarginData collision_margin_data_; /**< @brief The contact distance threshold */ |
| 141 | + IsContactAllowedFn fn_; /**< @brief The is allowed collision function */ |
| 142 | + std::size_t fcl_co_count_{ 0 }; /**< @brief The number fcl collision objects */ |
| 143 | + |
| 144 | + /** @brief This is used to store static collision objects to update */ |
| 145 | + std::vector<CollisionObjectRawPtr> static_update_; |
| 146 | + |
| 147 | + /** @brief This is used to store dynamic collision objects to update */ |
| 148 | + std::vector<CollisionObjectRawPtr> dynamic_update_; |
| 149 | + |
| 150 | + /** @brief This function will update internal data when margin data has changed */ |
| 151 | + void onCollisionMarginDataChanged(); |
| 152 | +}; |
| 153 | + |
| 154 | +} // namespace tesseract_collision::tesseract_collision_hpp_fcl |
| 155 | +#endif // TESSERACT_COLLISION_HPP_FCL_DISCRETE_MANAGERS_H |
0 commit comments