moveit2
The MoveIt Motion Planning Framework for ROS 2.
collision_common.cpp
Go to the documentation of this file.
1 /*********************************************************************
2  * Software License Agreement (BSD License)
3  *
4  * Copyright (c) 2022, Peter David Fagan
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 PickNik Inc. 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: Peter David Fagan */
36 
37 #include "collision_common.h"
38 
39 namespace moveit_py
40 {
41 namespace bind_collision_detection
42 {
43 void initCollisionRequest(py::module& m)
44 {
45  py::module collision_detection = m.def_submodule("collision_detection");
46 
47  py::class_<collision_detection::CollisionRequest>(collision_detection, "CollisionRequest", R"(
48  Representation of a collision checking request.
49  )")
50 
51  .def(py::init<>())
52 
53  .def_readwrite("joint_model_group_name", &collision_detection::CollisionRequest::group_name,
54  R"(
55  str: The group name to check collisions for (optional; if empty, assume the complete robot)
56  )")
57 
58  .def_readwrite("distance", &collision_detection::CollisionRequest::distance,
59  R"(
60  bool: If true, compute proximity distance.
61  )")
62 
63  .def_readwrite("cost", &collision_detection::CollisionRequest::cost,
64  R"(
65  bool: If true, a collision cost is computed.
66  )")
67 
68  .def_readwrite("contacts", &collision_detection::CollisionRequest::contacts,
69  R"(
70  bool: If true, compute contacts.
71  )")
72 
73  .def_readwrite("max_contacts", &collision_detection::CollisionRequest::max_contacts,
74  R"(
75  int: Overall maximum number of contacts to compute.
76  )")
77 
78  .def_readwrite("max_contacts_per_pair", &collision_detection::CollisionRequest::max_contacts_per_pair,
79  R"(
80  int: Maximum number of contacts to compute per pair of bodies (multiple bodies may be in contact at different configurations).
81  )")
82 
83  .def_readwrite("max_cost_sources", &collision_detection::CollisionRequest::max_cost_sources,
84  R"(
85  int: When costs are computed, this value defines how many of the top cost sources should be returned.
86  )")
87 
88  // TODO (peterdavidfagan): define is_done as function call.
89  //.def_readwrite("is_done", &collision_detection::CollisionRequest::is_done,
90  // R"(
91  // )")
92 
93  .def_readwrite("verbose", &collision_detection::CollisionRequest::verbose,
94  R"(
95  bool: Flag indicating whether information about detected collisions should be reported.
96  )");
97 }
98 
99 void initCollisionResult(py::module& m)
100 {
101  py::module collision_detection = m.def_submodule("collision_detection");
102 
103  py::class_<collision_detection::CollisionResult>(collision_detection, "CollisionResult", R"(
104  Representation of a collision checking result.
105  )")
106 
107  .def(py::init<>())
108 
109  .def_readwrite("collision", &collision_detection::CollisionResult::collision,
110  R"(
111  bool: True if collision was found, false otherwise.
112  )")
113 
114  .def_readwrite("distance", &collision_detection::CollisionResult::distance,
115  R"(
116  float: Closest distance between two bodies.
117  )")
118 
119  .def_readwrite("contact_count", &collision_detection::CollisionResult::contact_count,
120  R"(
121  int: Number of contacts returned.
122  )")
123 
124  // TODO (peterdavidfagan): define binding and test for ContactMap.
125  .def_readwrite("contacts", &collision_detection::CollisionResult::contacts,
126  R"(
127  dict: A dict returning the pairs of ids of the bodies in contact, plus information about the contacts themselves.
128  )")
129 
130  .def_readwrite("cost_sources", &collision_detection::CollisionResult::cost_sources,
131  R"(
132  dict: The individual cost sources from computed costs.
133  )");
134 }
135 } // namespace bind_collision_detection
136 } // namespace moveit_py
std::string group_name
The group name to check collisions for (optional; if empty, assume the complete robot)....
bool verbose
Flag indicating whether information about detected collisions should be reported.
std::size_t max_cost_sources
When costs are computed, this value defines how many of the top cost sources should be returned.
bool contacts
If true, compute contacts. Otherwise only a binary collision yes/no is reported.
bool cost
If true, a collision cost is computed.
std::size_t max_contacts
Overall maximum number of contacts to compute.
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...
bool distance
If true, compute proximity distance.
std::set< CostSource > cost_sources
These are the individual cost sources when costs are computed.
double distance
Closest distance between two bodies.
bool collision
True if collision was found, false otherwise.
std::size_t contact_count
Number of contacts returned.