forked from moveit/moveit
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Python bindings for moveit_core (moveit#2547)
Provide python bindings for basic classes of moveit_core: - collision_detection: Contact, CollisionRequest, CollisionResult, AllowedCollisionMatrix - kinematic_constraints: ConstraintEvaluationResult, KinematicConstraintSet, constructGoalConstraints - planning_scene: PlanningScene, - robot_model: RobotModel, JointModelGroup - robot_state: RobotState - transforms: Transforms
- Loading branch information
1 parent
46f1104
commit 97dcd93
Showing
29 changed files
with
1,227 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -58,3 +58,6 @@ CATKIN_IGNORE | |
.moveit_ci | ||
|
||
*.pyc | ||
|
||
_build | ||
_autosummary |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
104 changes: 104 additions & 0 deletions
104
moveit_core/collision_detection/src/pycollision_detection.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,104 @@ | ||
/********************************************************************* | ||
* Software License Agreement (BSD License) | ||
* | ||
* Copyright (c) 2021, Peter Mitrano | ||
* All rights reserved. | ||
* | ||
* Redistribution and use in source and binary forms, with or without | ||
* modification, are permitted provided that the following conditions | ||
* are met: | ||
* | ||
* * Redistributions of source code must retain the above copyright | ||
* notice, this list of conditions and the following disclaimer. | ||
* * Redistributions in binary form must reproduce the above | ||
* copyright notice, this list of conditions and the following | ||
* disclaimer in the documentation and/or other materials provided | ||
* with the distribution. | ||
* * The name of Peter Mitrano may not be used to endorse or promote | ||
* products derived from this software without specific prior | ||
* written permission. | ||
* | ||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | ||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | ||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS | ||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE | ||
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, | ||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, | ||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER | ||
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | ||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN | ||
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | ||
* POSSIBILITY OF SUCH DAMAGE. | ||
*********************************************************************/ | ||
|
||
/* Author: Peter Mitrano */ | ||
|
||
#include <pybind11/pybind11.h> | ||
#include <pybind11/stl.h> | ||
#include <pybind11/eigen.h> | ||
#include <moveit/collision_detection/world.h> | ||
#include <moveit/collision_detection/collision_matrix.h> | ||
#include <moveit/collision_detection/collision_common.h> | ||
#include <moveit/python/pybind_rosmsg_typecasters.h> | ||
|
||
namespace py = pybind11; | ||
|
||
using namespace collision_detection; | ||
|
||
void def_collision_detection_bindings(py::module& m) | ||
{ | ||
m.doc() = "contains collision detection, the world, and allowed collision matrices"; | ||
py::enum_<BodyType>(m, "BodyType") | ||
.value("ROBOT_ATTACHED", BodyType::ROBOT_ATTACHED) | ||
.value("ROBOT_LINK", BodyType::ROBOT_LINK) | ||
.value("WORLD_OBJECT", BodyType::WORLD_OBJECT) | ||
.export_values(); | ||
py::class_<Contact>(m, "Contact") | ||
.def(py::init<>()) | ||
.def_readwrite("body_name_1", &Contact::body_name_1) | ||
.def_readwrite("body_name_2", &Contact::body_name_2) | ||
.def_readwrite("body_type_1", &Contact::body_type_1) | ||
.def_readwrite("body_type_2", &Contact::body_type_2) | ||
.def_readwrite("depth", &Contact::depth) | ||
.def_property_readonly("nearest_points", | ||
[](const Contact& contact) { | ||
std::vector<Eigen::Vector3d> v{ contact.nearest_points[0], contact.nearest_points[1] }; | ||
return v; | ||
}) | ||
.def_readwrite("normal", &Contact::normal) | ||
.def_readwrite("percent_interpolation", &Contact::percent_interpolation) | ||
.def_readwrite("pos", &Contact::pos) | ||
// | ||
; | ||
py::class_<CollisionRequest>(m, "CollisionRequest") | ||
.def(py::init<>()) | ||
.def_readwrite("contacts", &CollisionRequest::contacts) | ||
.def_readwrite("cost", &CollisionRequest::cost) | ||
.def_readwrite("distance", &CollisionRequest::distance) | ||
.def_readwrite("group_name", &CollisionRequest::group_name) | ||
.def_readwrite("is_done", &CollisionRequest::is_done) | ||
.def_readwrite("max_contacts", &CollisionRequest::max_contacts) | ||
.def_readwrite("max_contacts_per_pair", &CollisionRequest::max_contacts_per_pair) | ||
.def_readwrite("max_cost_sources", &CollisionRequest::max_cost_sources) | ||
.def_readwrite("verbose", &CollisionRequest::verbose) | ||
// | ||
; | ||
py::class_<CollisionResult>(m, "CollisionResult") | ||
.def(py::init<>()) | ||
.def_readwrite("collision", &CollisionResult::collision) | ||
.def_readwrite("contact_count", &CollisionResult::contact_count) | ||
.def_readwrite("contacts", &CollisionResult::contacts) | ||
.def_readwrite("cost_sources", &CollisionResult::cost_sources) | ||
.def_readwrite("distance", &CollisionResult::distance) | ||
.def("clear", &CollisionResult::clear) | ||
// | ||
; | ||
py::class_<AllowedCollisionMatrix>(m, "AllowedCollisionMatrix") | ||
.def(py::init<>()) | ||
.def("setEntry", | ||
py::overload_cast<const std::string&, const std::string&, bool>(&AllowedCollisionMatrix::setEntry)) | ||
// | ||
; | ||
py::class_<World, WorldPtr>(m, "World").def(py::init<>()); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
{{ fullname | escape | underline}} | ||
|
||
.. currentmodule:: {{ module }} | ||
|
||
.. autoclass:: {{ objname }} | ||
:members: | ||
:show-inheritance: | ||
:inherited-members: | ||
:special-members: __call__, __add__, __mul__ | ||
|
||
{% block methods %} | ||
{% if methods %} | ||
.. rubric:: {{ _('Methods') }} | ||
|
||
.. autosummary:: | ||
:nosignatures: | ||
{% for item in methods %} | ||
{%- if not item.startswith('_') %} | ||
~{{ name }}.{{ item }} | ||
{%- endif -%} | ||
{%- endfor %} | ||
{% endif %} | ||
{% endblock %} | ||
|
||
{% block attributes %} | ||
{% if attributes %} | ||
.. rubric:: {{ _('Attributes') }} | ||
|
||
.. autosummary:: | ||
{% for item in attributes %} | ||
~{{ name }}.{{ item }} | ||
{%- endfor %} | ||
{% endif %} | ||
{% endblock %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
{{ fullname | escape | underline}} | ||
|
||
.. automodule:: {{ fullname }} | ||
|
||
{% block attributes %} | ||
{% if attributes %} | ||
.. rubric:: Module attributes | ||
|
||
.. autosummary:: | ||
:toctree: | ||
{% for item in attributes %} | ||
{{ item }} | ||
{%- endfor %} | ||
{% endif %} | ||
{% endblock %} | ||
|
||
{% block functions %} | ||
{% if functions %} | ||
.. rubric:: {{ _('Functions') }} | ||
|
||
.. autosummary:: | ||
:toctree: | ||
:nosignatures: | ||
{% for item in functions %} | ||
{{ item }} | ||
{%- endfor %} | ||
{% endif %} | ||
{% endblock %} | ||
|
||
{% block classes %} | ||
{% if classes %} | ||
.. rubric:: {{ _('Classes') }} | ||
|
||
.. autosummary:: | ||
:toctree: | ||
:template: custom-class-template.rst | ||
:nosignatures: | ||
{% for item in classes %} | ||
{{ item }} | ||
{%- endfor %} | ||
{% endif %} | ||
{% endblock %} | ||
|
||
{% block exceptions %} | ||
{% if exceptions %} | ||
.. rubric:: {{ _('Exceptions') }} | ||
|
||
.. autosummary:: | ||
:toctree: | ||
{% for item in exceptions %} | ||
{{ item }} | ||
{%- endfor %} | ||
{% endif %} | ||
{% endblock %} | ||
|
||
{% block modules %} | ||
{% if modules %} | ||
.. autosummary:: | ||
:toctree: | ||
:template: custom-module-template.rst | ||
:recursive: | ||
{% for item in modules %} | ||
{{ item }} | ||
{%- endfor %} | ||
{% endif %} | ||
{% endblock %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
.. autosummary:: | ||
:toctree: _autosummary | ||
:template: custom-module-template.rst | ||
:recursive: | ||
|
||
moveit.core |
Oops, something went wrong.