pycollision_detection.cpp
Go to the documentation of this file.
1 /*********************************************************************
2  * Software License Agreement (BSD License)
3  *
4  * Copyright (c) 2021, Peter Mitrano
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  * * The name of Peter Mitrano may not be used to endorse or promote
18  * products derived from this software without specific prior
19  * 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: Peter Mitrano */
36 
37 #include <pybind11/pybind11.h>
38 #include <pybind11/stl.h>
39 #include <pybind11/eigen.h>
44 
45 namespace py = pybind11;
46 
47 using namespace collision_detection;
48 
50 {
51  m.doc() = "contains collision detection, the world, and allowed collision matrices";
52  py::enum_<BodyType>(m, "BodyType")
53  .value("ROBOT_ATTACHED", BodyType::ROBOT_ATTACHED)
54  .value("ROBOT_LINK", BodyType::ROBOT_LINK)
55  .value("WORLD_OBJECT", BodyType::WORLD_OBJECT)
56  .export_values();
57  py::class_<Contact>(m, "Contact")
58  .def(py::init<>())
59  .def_readwrite("body_name_1", &Contact::body_name_1)
60  .def_readwrite("body_name_2", &Contact::body_name_2)
61  .def_readwrite("body_type_1", &Contact::body_type_1)
62  .def_readwrite("body_type_2", &Contact::body_type_2)
63  .def_readwrite("depth", &Contact::depth)
64  .def_readwrite("normal", &Contact::normal)
65  .def_readwrite("pos", &Contact::pos)
66  //
67  ;
68  py::class_<CollisionRequest>(m, "CollisionRequest")
69  .def(py::init<>())
70  .def_readwrite("contacts", &CollisionRequest::contacts)
71  .def_readwrite("cost", &CollisionRequest::cost)
72  .def_readwrite("distance", &CollisionRequest::distance)
73  .def_readwrite("group_name", &CollisionRequest::group_name)
74  .def_readwrite("is_done", &CollisionRequest::is_done)
75  .def_readwrite("max_contacts", &CollisionRequest::max_contacts)
76  .def_readwrite("max_contacts_per_pair", &CollisionRequest::max_contacts_per_pair)
77  .def_readwrite("max_cost_sources", &CollisionRequest::max_cost_sources)
78  .def_readwrite("verbose", &CollisionRequest::verbose)
79  //
80  ;
81  py::class_<CollisionResult>(m, "CollisionResult")
82  .def(py::init<>())
83  .def_readwrite("collision", &CollisionResult::collision)
84  .def_readwrite("contact_count", &CollisionResult::contact_count)
85  .def_readwrite("contacts", &CollisionResult::contacts)
86  .def_readwrite("cost_sources", &CollisionResult::cost_sources)
87  .def_readwrite("distance", &CollisionResult::distance)
88  .def("clear", &CollisionResult::clear)
89  //
90  ;
91  py::class_<AllowedCollisionMatrix>(m, "AllowedCollisionMatrix")
92  .def(py::init<>())
93  .def("setEntry",
94  py::overload_cast<const std::string&, const std::string&, bool>(&AllowedCollisionMatrix::setEntry))
95  //
96  ;
97  py::class_<World, WorldPtr>(m, "World").def(py::init<>());
98 }
BodyType body_type_2
The type of the second body involved in the contact.
void def_collision_detection_bindings(py::module &m)
ContactMap contacts
A map returning the pairs of body ids in contact, plus their contact details.
Generic interface to collision detection.
EIGEN_MAKE_ALIGNED_OPERATOR_NEW void clear()
Clear a previously stored result.
bool collision
True if collision was found, false otherwise.
std::set< CostSource > cost_sources
These are the individual cost sources when costs are computed.
boost::function< bool(const CollisionResult &)> is_done
Function call that decides whether collision detection should stop.
std::size_t max_contacts
Overall maximum number of contacts to compute.
bool verbose
Flag indicating whether information about detected collisions should be reported. ...
EIGEN_MAKE_ALIGNED_OPERATOR_NEW Eigen::Vector3d pos
contact position
std::string group_name
The group name to check collisions for (optional; if empty, assume the complete robot) ...
std::string body_name_2
The id of the second body involved in the contact.
Eigen::Vector3d normal
normal unit vector at contact
bool contacts
If true, compute contacts. Otherwise only a binary collision yes/no is reported.
std::string body_name_1
The id of the first body involved in the contact.
std::size_t max_contacts_per_pair
Maximum number of contacts to compute per pair of bodies (multiple bodies may be in contact at differ...
void setEntry(const std::string &name1, const std::string &name2, bool allowed)
Set an entry corresponding to a pair of elements.
std::size_t max_cost_sources
When costs are computed, this value defines how many of the top cost sources should be returned...
BodyType body_type_1
The type of the first body involved in the contact.


moveit_core
Author(s): Ioan Sucan , Sachin Chitta , Acorn Pooley
autogenerated on Thu Mar 17 2022 02:51:04