-
Notifications
You must be signed in to change notification settings - Fork 30
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Manual binding for minimal set of aikido components * Update readme * Fix typo * Add Skeleton, MetaSkeleton, WorldInteractiveMarkerViewer, TSRMarker, World, ConcreteManipulator, CollisionFree to pybind11 * update python binding install guide * update pybinding for conda-managed python * remove swp file * Update README.md * Skeleton code for aikidopy using pybind11 (#528)
- Loading branch information
Showing
43 changed files
with
676 additions
and
367 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
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
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
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
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
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,7 @@ | ||
#include "robot/ConcreteManipulator.hpp" | ||
#include "robot/ConcreteRobot.hpp" | ||
#include "robot/GrabMetadata.hpp" | ||
#include "robot/Hand.hpp" | ||
#include "robot/Manipulator.hpp" | ||
#include "robot/Robot.hpp" | ||
#include "robot/util.hpp" |
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 |
---|---|---|
@@ -1,10 +1,10 @@ | ||
#include "rviz/BodyNodeMarker.hpp" | ||
#include "rviz/FrameMarker.hpp" | ||
#include "rviz/InteractiveMarkerViewer.hpp" | ||
#include "rviz/pointers.hpp" | ||
#include "rviz/ResourceServer.hpp" | ||
#include "rviz/shape_conversions.hpp" | ||
#include "rviz/ShapeFrameMarker.hpp" | ||
#include "rviz/SkeletonMarker.hpp" | ||
#include "rviz/SmartPointers.hpp" | ||
#include "rviz/TSRMarker.hpp" | ||
#include "rviz/WorldInteractiveMarkerViewer.hpp" | ||
#include "rviz/shape_conversions.hpp" |
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,4 @@ | ||
set(AIKIDOPY_BUILD_DIR "${CMAKE_CURRENT_BINARY_DIR}/aikidopy") | ||
|
||
add_subdirectory(aikidopy) | ||
add_subdirectory(tests) |
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,55 @@ | ||
# aikidopy | ||
|
||
This folder contains manual bindings for aikidopy using pybind11. The installation guide have been tested on | ||
- sudo apt installed Python 2.7 and Python 3.4. | ||
- anaconda managed Python 3.6 | ||
|
||
0. If you use system installed Python, ensure you have `python2.7-dev` or `python3-dev` correspondingly. Run `$ sudo apt-get install python3-dev` to obtain it. | ||
|
||
|
||
1. Install [pybind11](https://github.com/pybind/pybind11.git) **from source** following these [instructions](https://pybind11.readthedocs.io/en/master/basics.html#compiling-the-test-cases). (Need version >= 2.2.0). | ||
|
||
``` | ||
$ git clone https://github.com/pybind/pybind11.git | ||
$ cd pybind11 | ||
$ mkdir build | ||
$ cd build | ||
$ cmake .. | ||
$ make -j 4 | ||
``` | ||
|
||
- For system managed python: `$ sudo make install`; | ||
- For anaconda: `$ pip install -e .`. | ||
|
||
You should be able to load `pybind11` in your python. | ||
|
||
``` | ||
$ python | ||
>>> import pybind11 | ||
``` | ||
|
||
2. Build aikido and source the setup file. | ||
``` | ||
$ catkin build aikido | ||
$ source workspace/devel/setup.bash | ||
``` | ||
|
||
3. Create a folder `workspace/src/aikido/python/build` (instead of `workspace/src/aikido/build`). Build and install the python binding, passing the desired python version using `-DAIKIDOPY_PYTHON_VERSION`. | ||
|
||
``` | ||
$ cd build | ||
$ cmake .. -DAIKIDOPY_PYTHON_VERSION=2.7 # or 3.4, 3.6 etc | ||
$ make -j | ||
$ sudo make install | ||
``` | ||
|
||
Read the output of `sudo make install` and ensure that `aikidopy.so` get installed in the python library path (i.e. `/usr/lib/python2.7/dist-packages/aikidopy.so` or `anaconda3/envs/YOUR_ENV/lib/python3.6/site-packages/aikidopy.so`). | ||
|
||
4. Try loading. | ||
``` | ||
$ python | ||
>>> import aikidopy | ||
``` | ||
|
||
## Tips | ||
- If you have multiple python environment, ensure that `which python` and the python version you passed to cmake refers to the same python. |
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,101 @@ | ||
cmake_minimum_required(VERSION 2.8.12) | ||
|
||
if(NOT AIKIDOPY_PYTHON_VERSION) | ||
set(AIKIDOPY_PYTHON_VERSION 3.4 CACHE STRING "Choose the target Python version (e.g., 3.4, 2.7)" FORCE) | ||
endif() | ||
|
||
find_package(PythonInterp ${AIKIDOPY_PYTHON_VERSION} REQUIRED) | ||
execute_process(COMMAND ${PYTHON_EXECUTABLE} -c | ||
"from distutils.sysconfig import get_python_lib;\ | ||
print(get_python_lib(plat_specific=True, prefix=''))" | ||
OUTPUT_VARIABLE PYTHON_SITE_PACKAGES | ||
OUTPUT_STRIP_TRAILING_WHITESPACE | ||
) | ||
if(NOT PythonInterp_FOUND) | ||
message(STATUS "BUILD_PYTHON is ON, but failed to find PythonInterp. " | ||
"Disabling aikidopy." | ||
) | ||
return() | ||
endif() | ||
|
||
find_package(PythonLibs ${AIKIDOPY_PYTHON_VERSION} QUIET) | ||
if(NOT PythonLibs_FOUND) | ||
message(STATUS "BUILD_AIKIDOPY is ON, but failed to find PythonLibs. " | ||
"Disabling aikidopy." | ||
) | ||
return() | ||
endif() | ||
|
||
# Find pybind11 | ||
# Needs to set PYBIND11_PYTHON_VERSION before finding pybind11 | ||
set(PYBIND11_PYTHON_VERSION ${AIKIDOPY_PYTHON_VERSION}) | ||
find_package(pybind11 2.2.0 QUIET) | ||
if(NOT pybind11_FOUND) | ||
message(STATUS "BUILD_PYTHON is ON, but failed to find pybind11 >= " | ||
"2.2.0. Disabling aikidopy." | ||
) | ||
return() | ||
endif() | ||
|
||
#================================================================================ | ||
# Dependencies | ||
# | ||
|
||
#================================================================================ | ||
|
||
file(GLOB_RECURSE aikidopy_headers "*.h" "*.hpp") | ||
file(GLOB_RECURSE aikidopy_sources "*.cpp") | ||
|
||
# Build a Python extension module: | ||
# pybind11_add_module(<name> [MODULE | SHARED] [EXCLUDE_FROM_ALL] | ||
# [NO_EXTRAS] [SYSTEM] [THIN_LTO] source1 [source2 ...]) | ||
# | ||
pybind11_add_module(aikidopy | ||
MODULE | ||
${aikidopy_headers} | ||
${aikidopy_sources} | ||
) | ||
|
||
target_include_directories(aikidopy | ||
SYSTEM PUBLIC | ||
${PYTHON_INCLUDE_DIRS} | ||
${pybind11_INCLUDE_DIRS} | ||
PRIVATE | ||
${CMAKE_CURRENT_SOURCE_DIR} | ||
) | ||
|
||
target_link_libraries(aikidopy | ||
PUBLIC | ||
aikido_common | ||
aikido_constraint | ||
aikido_control | ||
aikido_distance | ||
aikido_io | ||
aikido_planner | ||
aikido_robot | ||
aikido_statespace | ||
aikido_trajectory | ||
${PYTHON_LIBRARIES} | ||
) | ||
if(TARGET aikido_control_ros) | ||
target_link_libraries(aikidopy PUBLIC aikido_control_ros) | ||
endif() | ||
if(TARGET aikido_perception) | ||
target_link_libraries(aikidopy PUBLIC aikido_perception) | ||
endif() | ||
if(TARGET aikido_rviz) | ||
target_link_libraries(aikidopy PUBLIC aikido_rviz) | ||
endif() | ||
|
||
set_target_properties(aikidopy | ||
PROPERTIES | ||
PREFIX "" | ||
SUFFIX ".so" # python uses '.so' extension even on macOS | ||
DEBUG_POSTFIX "" | ||
) | ||
|
||
install(TARGETS aikidopy | ||
LIBRARY DESTINATION "${PYTHON_SITE_PACKAGES}" | ||
) | ||
|
||
clang_format_add_sources(${aikidopy_headers} ${aikidopy_sources}) |
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,37 @@ | ||
#include <pybind11/pybind11.h> | ||
|
||
namespace py = pybind11; | ||
|
||
namespace aikido { | ||
namespace python { | ||
|
||
void eigen_geometry(py::module& m); | ||
|
||
void aikidopy_common(py::module& m); | ||
void aikidopy_statespace(py::module& m); | ||
void aikidopy_constraint(py::module& m); | ||
void aikidopy_planner(py::module& m); | ||
void aikidopy_robot(py::module& m); | ||
#ifdef AIKIDO_HAS_RVIZ | ||
void aikidopy_rviz(py::module& m); | ||
#endif // AIKIDO_HAS_RVIZ | ||
|
||
PYBIND11_MODULE(aikidopy, m) | ||
{ | ||
py::module::import("numpy"); | ||
|
||
m.doc() = "aikidopy is a Python library for solving robotic motion planning " | ||
"and decision making problems."; | ||
|
||
aikidopy_common(m); | ||
aikidopy_statespace(m); | ||
aikidopy_constraint(m); | ||
aikidopy_planner(m); | ||
aikidopy_robot(m); | ||
#ifdef AIKIDO_HAS_RVIZ | ||
aikidopy_rviz(m); | ||
#endif // AIKIDO_HAS_RVIZ | ||
} | ||
|
||
} // namespace python | ||
} // namespace aikido |
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,14 @@ | ||
#include <pybind11/pybind11.h> | ||
|
||
namespace py = pybind11; | ||
|
||
namespace aikido { | ||
namespace python { | ||
|
||
void aikidopy_common(py::module& m) | ||
{ | ||
auto sm = m.def_submodule("common"); | ||
} | ||
|
||
} // namespace python | ||
} // namespace aikido |
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,16 @@ | ||
#include <pybind11/pybind11.h> | ||
#include <aikido/constraint.hpp> | ||
#include <aikido/constraint/dart/CollisionFree.hpp> | ||
|
||
namespace py = pybind11; | ||
|
||
namespace aikido { | ||
namespace python { | ||
|
||
void CollisionFree(py::module& m) | ||
{ | ||
py::class_<aikido::constraint::dart::CollisionFree, std::shared_ptr<aikido::constraint::dart::CollisionFree>>(m, "CollisionFree"); | ||
} | ||
|
||
} // namespace python | ||
} // namespace aikido |
Oops, something went wrong.