diff --git a/.gitignore b/.gitignore index 4c14ae29..93980a8b 100644 --- a/.gitignore +++ b/.gitignore @@ -1,7 +1,8 @@ build/ -build-wasm/ +build*/ .cache/ compile_commands.json +*.so *.out.* *.swp *.swo diff --git a/README.md b/README.md index 5e448bb2..56d849f7 100644 --- a/README.md +++ b/README.md @@ -83,6 +83,8 @@ pip install vamp-planner > [!IMPORTANT] > VAMP comes with precompiled robots! If you want to add your own, use [cricket](https://github.com/CoMMALab/cricket) and follow the instructions there. +> +> **`pip install .` builds Panda, UR5, Fetch and Baxter by default**, because every robot adds a large header to the build. To change the set, for example `pip install . -C cmake.define.VAMP_ROBOTS="ur5;panda;fetch;baxter;sphere"`, or `-C cmake.define.VAMP_ROBOTS=all` for everything (`sphere`, `ur5`, `panda`, `fetch`, `baxter`). VAMP requires the following system dependencies: - [CMake](https://cmake.org/) version 3.16 or greater. diff --git a/cmake/CompilerSettings.cmake b/cmake/CompilerSettings.cmake index 7f9219d2..980c7455 100644 --- a/cmake/CompilerSettings.cmake +++ b/cmake/CompilerSettings.cmake @@ -25,6 +25,8 @@ if(CMAKE_SYSTEM_PROCESSOR STREQUAL "x86_64") # x86 supports additional flags string(APPEND VAMP_FAST_ARGS " -fassociative-math") if(CMAKE_CXX_COMPILER_ID STREQUAL "Clang") # Clang supports additional fine-grained flags over GCC string(APPEND VAMP_FAST_ARGS " -fno-honor-infinities -fno-honor-nans") + # The code uses infinity as a sentinel; silence the resulting warning (one per use, per translation unit). + string(APPEND VAMP_FAST_ARGS " -Wno-nan-infinity-disabled") if (CMAKE_CXX_COMPILER_VERSION VERSION_GREATER 11.0.0) # clang 11 does not support -fapprox-func string(APPEND VAMP_FAST_ARGS " -fapprox-func") endif() diff --git a/cmake/Python.cmake b/cmake/Python.cmake index b4f56335..8cf75911 100644 --- a/cmake/Python.cmake +++ b/cmake/Python.cmake @@ -7,31 +7,57 @@ if(VAMP_BUILD_PYTHON_BINDINGS) REQUIRED COMPONENTS Interpreter Development.Module OPTIONAL_COMPONENTS Development.SABIModule) - CPMAddPackage("gh:wjakob/nanobind#9a25aed8a7edfe60ef9ad1c911e57667bc4916c4") - - # Check if Python is available if(NOT Python_FOUND) message(FATAL_ERROR "VAMP_BUILD_PYTHON_BINDINGS is ON but Python was not found") endif() - if(NOT VAMP_ROBOT_MODULES) - list(APPEND VAMP_ROBOT_MODULES - sphere - ur5 - panda - fetch - baxter - ) + find_package(nanobind CONFIG QUIET) + if(NOT nanobind_FOUND) + CPMAddPackage("gh:wjakob/nanobind#9a25aed8a7edfe60ef9ad1c911e57667bc4916c4") + endif() - list(APPEND VAMP_ROBOT_STRUCTS - Sphere - UR5 - Panda - Fetch - Baxter - ) + # By defaul, build bindings only for known robots and not all + set(VAMP_KNOWN_ROBOTS + sphere=Sphere + ur5=UR5 + panda=Panda + fetch=Fetch + baxter=Baxter + ) + + if(NOT VAMP_ROBOT_MODULES) + if(NOT VAMP_ROBOTS) + set(VAMP_ROBOTS "all") + endif() + + set(_vamp_requested ${VAMP_ROBOTS}) + if(VAMP_ROBOTS STREQUAL "all") + set(_vamp_requested "") + foreach(_entry ${VAMP_KNOWN_ROBOTS}) + string(REGEX REPLACE "=.*$" "" _name "${_entry}") + list(APPEND _vamp_requested "${_name}") + endforeach() + endif() + + foreach(_robot ${_vamp_requested}) + set(_struct "") + foreach(_entry ${VAMP_KNOWN_ROBOTS}) + if(_entry MATCHES "^${_robot}=(.*)$") + set(_struct "${CMAKE_MATCH_1}") + endif() + endforeach() + + if(_struct STREQUAL "") + message(FATAL_ERROR "VAMP_ROBOTS: unknown robot '${_robot}'. Known: ${VAMP_KNOWN_ROBOTS} (name=Struct)") + endif() + + list(APPEND VAMP_ROBOT_MODULES ${_robot}) + list(APPEND VAMP_ROBOT_STRUCTS ${_struct}) + endforeach() endif() + message(STATUS "Python robot modules: ${VAMP_ROBOT_MODULES}") + foreach(robot ${VAMP_ROBOT_MODULES}) string(APPEND VAMP_ROBOT_INITS " vb::init_${robot}(pymodule);\n") string(APPEND VAMP_ROBOT_DECLS " void init_${robot}(nanobind::module_ &pymodule);\n") @@ -57,6 +83,8 @@ if(VAMP_BUILD_PYTHON_BINDINGS) src/impl/vamp/bindings/python/settings.cc ${CMAKE_CURRENT_BINARY_DIR}/python.cc ) + + foreach(robot_name robot_struct IN ZIP_LISTS VAMP_ROBOT_MODULES VAMP_ROBOT_STRUCTS) configure_file( src/impl/vamp/bindings/python/robot.cc.in @@ -87,6 +115,7 @@ if(VAMP_BUILD_PYTHON_BINDINGS) Eigen3::Eigen ) + if($ENV{GITHUB_ACTIONS}) set(STUB_PREFIX "") else() diff --git a/pyproject.toml b/pyproject.toml index 40625266..4e9c8eae 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -34,5 +34,4 @@ cmake.build-type = "Release" [tool.scikit-build.cmake.define] VAMP_LTO = "OFF" -VAMP_ROBOT_MODULES="sphere;ur5;panda;fetch;baxter" -VAMP_ROBOT_STRUCTS="Sphere;UR5;Panda;Fetch;Baxter" +VAMP_ROBOTS = "ur5;panda;fetch;baxter"