Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add BUILD_ONLY_PYTHON_INTERFACE option #658

Draft
wants to merge 5 commits into
base: devel
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions .github/workflows/ros_ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,9 @@ jobs:
strategy:
matrix:
env:
- {ROS_DISTRO: noetic}
- {ROS_DISTRO: iron}
- {ROS_DISTRO: jazzy}
- {ROS_DISTRO: humble}
#- {ROS_DISTRO: rolling}
- {ROS_DISTRO: rolling}
env:
#CCACHE_DIR: /github/home/.ccache # Enable ccache
BUILDER: colcon
Expand Down
27 changes: 17 additions & 10 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ set(
"Coal, The Collision Detection Library. Previously known as HPP-FCL, fork of FCL -- The Flexible Collision Library"
)
set(PROJECT_URL "https://github.com/coal-library/coal")
set(PROJECT_USE_CMAKE_EXPORT TRUE)
set(PROJECT_COMPATIBILITY_VERSION AnyNewerVersion)
# To enable jrl-cmakemodules compatibility with workspace we must define the two
# following lines
Expand Down Expand Up @@ -149,7 +148,6 @@ SET_DEFAULT_CMAKE_BUILD_TYPE("RelWithDebInfo")
# If needed, fix CMake policy for APPLE systems
APPLY_DEFAULT_APPLE_CONFIGURATION()

option(BUILD_PYTHON_INTERFACE "Build the python bindings" ON)
cmake_dependent_option(
GENERATE_PYTHON_STUBS
"Generate the Python stubs associated to the Python library"
Expand All @@ -161,6 +159,9 @@ cmake_dependent_option(
ADD_PROJECT_DEPENDENCY(Eigen3 REQUIRED PKG_CONFIG_REQUIRES "eigen3 >= 3.0.0")

if(BUILD_PYTHON_INTERFACE)
if(BUILD_ONLY_PYTHON_INTERFACE)
ADD_PROJECT_DEPENDENCY(${PROJECT_NAME} REQUIRED CONFIG)
endif()
set(PYTHON_COMPONENTS Interpreter Development NumPy)
FINDPYTHON(REQUIRED)
ADD_PROJECT_PRIVATE_DEPENDENCY(eigenpy 2.9.2 REQUIRED)
Expand Down Expand Up @@ -194,7 +195,7 @@ else()
endif()

# Optional dependencies
ADD_PROJECT_DEPENDENCY(octomap PKG_CONFIG_REQUIRES "octomap >= 1.6")
ADD_PROJECT_DEPENDENCY(octomap 1.8.0 PKG_CONFIG_REQUIRES "octomap >= 1.8")
if(octomap_FOUND)
set(COAL_HAS_OCTOMAP TRUE)
string(REPLACE "." ";" VERSION_LIST ${octomap_VERSION})
Expand Down Expand Up @@ -495,10 +496,12 @@ if(COAL_BACKWARD_COMPATIBILITY_WITH_HPP_FCL)
include/hpp/fcl/warning.hh
)
list(APPEND ${PROJECT_NAME}_HEADERS ${HPP_FCL_BACKWARD_COMPATIBILITY_HEADERS})
HEADER_INSTALL(
COMPONENT hpp-fcl-compatibility
${HPP_FCL_BACKWARD_COMPATIBILITY_HEADERS}
)
if(NOT BUILD_ONLY_PYTHON_INTERFACE)
HEADER_INSTALL(
COMPONENT hpp-fcl-compatibility
${HPP_FCL_BACKWARD_COMPATIBILITY_HEADERS}
)
endif()
endif()

if(COAL_HAS_OCTOMAP)
Expand All @@ -512,7 +515,9 @@ if(COAL_HAS_OCTOMAP)
endif(COAL_HAS_OCTOMAP)

add_subdirectory(doc)
add_subdirectory(src)
if(NOT BUILD_ONLY_PYTHON_INTERFACE)
add_subdirectory(src)
endif()
if(BUILD_PYTHON_INTERFACE)
add_subdirectory(python)
endif()
Expand All @@ -529,9 +534,11 @@ if(COAL_HAS_OCTOMAP)
endif(COAL_HAS_OCTOMAP)

# Install catkin package.xml
install(FILES package.xml DESTINATION share/${PROJECT_NAME})
if(NOT BUILD_ONLY_PYTHON_INTERFACE)
install(FILES package.xml DESTINATION share/${PROJECT_NAME})
endif()

if(COAL_BACKWARD_COMPATIBILITY_WITH_HPP_FCL)
if(COAL_BACKWARD_COMPATIBILITY_WITH_HPP_FCL AND NOT BUILD_ONLY_PYTHON_INTERFACE)
include(CMakePackageConfigHelpers)
write_basic_package_version_file(
hpp-fclConfigVersion.cmake
Expand Down
2 changes: 1 addition & 1 deletion cmake
Submodule cmake updated 323 files
8 changes: 4 additions & 4 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

46 changes: 40 additions & 6 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,7 @@

inputs = {
flake-parts.url = "github:hercules-ci/flake-parts";
# TODO: switch back to nixos-unstable after
# https://github.com/NixOS/nixpkgs/pull/357705
nixpkgs.url = "github:NixOS/nixpkgs/refs/pull/357705/head";
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
};

outputs =
Expand All @@ -19,10 +17,27 @@
type = "app";
program = pkgs.python3.withPackages (_: [ self'.packages.default ]);
};
devShells.default = pkgs.mkShell { inputsFrom = [ self'.packages.default ]; };
devShells.default =
with pkgs;
mkShell {
inputsFrom = [ pkgs.python3Packages.coal ];
packages =
let
py = p: [
p.boost
p.eigenpy
p.numpy
p.scipy
];
in
[
(python312.withPackages py)
(python313.withPackages py)
];
};
packages = {
default = self'.packages.coal;
coal = pkgs.python3Packages.coal.overrideAttrs (_: {
coal = pkgs.coal.overrideAttrs {
src = pkgs.lib.fileset.toSource {
root = ./.;
fileset = pkgs.lib.fileset.unions [
Expand All @@ -36,7 +51,26 @@
./test
];
};
});
};
py-coal =
(self'.packages.coal.override {
inherit (pkgs) python3Packages;
pythonSupport = true;
}).overrideAttrs
(super: {
cmakeFlags = super.cmakeFlags ++ [
"-DBUILD_ONLY_PYTHON_PYTHON_INTERFACE=ON"
];
propagatedBuildInputs = super.propagatedBuildInputs ++ [
self'.packages.coal
];
});
py312-coal = self'.packages.py-coal.override {
python3Packages = pkgs.python312Packages;
};
py313-coal = self'.packages.py-coal.override {
python3Packages = pkgs.python313Packages;
};
};
};
};
Expand Down
16 changes: 0 additions & 16 deletions include/coal/octree.h
Original file line number Diff line number Diff line change
Expand Up @@ -238,39 +238,23 @@ class COAL_DLLAPI OcTree : public CollisionGeometry {

/// @return ptr to child number childIdx of node
OcTreeNode* getNodeChild(OcTreeNode* node, unsigned int childIdx) {
#if OCTOMAP_VERSION_AT_LEAST(1, 8, 0)
return tree->getNodeChild(node, childIdx);
#else
return node->getChild(childIdx);
#endif
}

/// @return const ptr to child number childIdx of node
const OcTreeNode* getNodeChild(const OcTreeNode* node,
unsigned int childIdx) const {
#if OCTOMAP_VERSION_AT_LEAST(1, 8, 0)
return tree->getNodeChild(node, childIdx);
#else
return node->getChild(childIdx);
#endif
}

/// @brief return true if the child at childIdx exists
bool nodeChildExists(const OcTreeNode* node, unsigned int childIdx) const {
#if OCTOMAP_VERSION_AT_LEAST(1, 8, 0)
return tree->nodeChildExists(node, childIdx);
#else
return node->childExists(childIdx);
#endif
}

/// @brief return true if node has at least one child
bool nodeHasChildren(const OcTreeNode* node) const {
#if OCTOMAP_VERSION_AT_LEAST(1, 8, 0)
return tree->nodeHasChildren(node);
#else
return node->hasChildren();
#endif
}

/// @brief return object type, it is an octree
Expand Down
2 changes: 1 addition & 1 deletion python/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ endif()

target_link_libraries(
${PYTHON_LIB_NAME}
PUBLIC ${PROJECT_NAME} eigenpy::eigenpy Boost::system
PUBLIC ${PROJECT_NAME}::${PROJECT_NAME} eigenpy::eigenpy Boost::system
)

set_target_properties(
Expand Down
146 changes: 74 additions & 72 deletions test/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,89 +1,91 @@
# Find Boost.UnitTestFramework
find_package(Boost REQUIRED COMPONENTS unit_test_framework filesystem)
if(NOT BUILD_ONLY_PYTHON_INTERFACE)
find_package(Boost REQUIRED COMPONENTS unit_test_framework filesystem)

CONFIG_FILES(fcl_resources/config.h)
CONFIG_FILES(fcl_resources/config.h)

function(add_coal_test test_name source)
set(target_name ${PROJECT_NAME}-${test_name})
ADD_UNIT_TEST(${target_name} ${source})
set_standard_output_directory(${target_name})
target_link_libraries(
${target_name}
PUBLIC ${LIBRARY_NAME} Boost::filesystem ${utility_target}
)
CXX_FLAGS_BY_COMPILER_FRONTEND(
GNU "-Wno-c99-extensions"
OUTPUT PRIVATE_OPTIONS
)
target_compile_options(${target_name} PRIVATE ${PRIVATE_OPTIONS})
if(COAL_HAS_QHULL)
target_compile_options(${target_name} PRIVATE -DCOAL_HAS_QHULL)
endif()
endfunction()
function(add_coal_test test_name source)
set(target_name ${PROJECT_NAME}-${test_name})
ADD_UNIT_TEST(${target_name} ${source})
set_standard_output_directory(${target_name})
target_link_libraries(
${target_name}
PUBLIC ${LIBRARY_NAME} Boost::filesystem ${utility_target}
)
CXX_FLAGS_BY_COMPILER_FRONTEND(
GNU "-Wno-c99-extensions"
OUTPUT PRIVATE_OPTIONS
)
target_compile_options(${target_name} PRIVATE ${PRIVATE_OPTIONS})
if(COAL_HAS_QHULL)
target_compile_options(${target_name} PRIVATE -DCOAL_HAS_QHULL)
endif()
endfunction()

include_directories(${CMAKE_CURRENT_BINARY_DIR})
include_directories(${CMAKE_CURRENT_BINARY_DIR})

set(utility_target ${PROJECT_NAME}-utility)
add_library(${utility_target} STATIC utility.cpp)
set_standard_output_directory(${utility_target})
target_link_libraries(${utility_target} PUBLIC ${PROJECT_NAME})
set(utility_target ${PROJECT_NAME}-utility)
add_library(${utility_target} STATIC utility.cpp)
set_standard_output_directory(${utility_target})
target_link_libraries(${utility_target} PUBLIC ${PROJECT_NAME})

add_coal_test(math math.cpp)
add_coal_test(math math.cpp)

add_coal_test(collision collision.cpp)
add_coal_test(contact_patch contact_patch.cpp)
add_coal_test(distance distance.cpp)
add_coal_test(swept_sphere_radius swept_sphere_radius.cpp)
add_coal_test(normal_and_nearest_points normal_and_nearest_points.cpp)
add_coal_test(distance_lower_bound distance_lower_bound.cpp)
add_coal_test(security_margin security_margin.cpp)
add_coal_test(geometric_shapes geometric_shapes.cpp)
add_coal_test(shape_inflation shape_inflation.cpp)
#add_coal_test(shape_mesh_consistency shape_mesh_consistency.cpp)
add_coal_test(gjk_asserts gjk_asserts.cpp)
add_coal_test(frontlist frontlist.cpp)
set_tests_properties(${PROJECT_NAME}-frontlist PROPERTIES TIMEOUT 7200)
add_coal_test(collision collision.cpp)
add_coal_test(contact_patch contact_patch.cpp)
add_coal_test(distance distance.cpp)
add_coal_test(swept_sphere_radius swept_sphere_radius.cpp)
add_coal_test(normal_and_nearest_points normal_and_nearest_points.cpp)
add_coal_test(distance_lower_bound distance_lower_bound.cpp)
add_coal_test(security_margin security_margin.cpp)
add_coal_test(geometric_shapes geometric_shapes.cpp)
add_coal_test(shape_inflation shape_inflation.cpp)
#add_coal_test(shape_mesh_consistency shape_mesh_consistency.cpp)
add_coal_test(gjk_asserts gjk_asserts.cpp)
add_coal_test(frontlist frontlist.cpp)
set_tests_properties(${PROJECT_NAME}-frontlist PROPERTIES TIMEOUT 7200)

# add_coal_test(sphere_capsule sphere_capsule.cpp)
add_coal_test(capsule_capsule capsule_capsule.cpp)
add_coal_test(box_box_distance box_box_distance.cpp)
add_coal_test(box_box_collision box_box_collision.cpp)
add_coal_test(simple simple.cpp)
add_coal_test(capsule_box_1 capsule_box_1.cpp)
add_coal_test(capsule_box_2 capsule_box_2.cpp)
add_coal_test(obb obb.cpp)
add_coal_test(convex convex.cpp)
# add_coal_test(sphere_capsule sphere_capsule.cpp)
add_coal_test(capsule_capsule capsule_capsule.cpp)
add_coal_test(box_box_distance box_box_distance.cpp)
add_coal_test(box_box_collision box_box_collision.cpp)
add_coal_test(simple simple.cpp)
add_coal_test(capsule_box_1 capsule_box_1.cpp)
add_coal_test(capsule_box_2 capsule_box_2.cpp)
add_coal_test(obb obb.cpp)
add_coal_test(convex convex.cpp)

add_coal_test(bvh_models bvh_models.cpp)
add_coal_test(collision_node_asserts collision_node_asserts.cpp)
add_coal_test(hfields hfields.cpp)
add_coal_test(bvh_models bvh_models.cpp)
add_coal_test(collision_node_asserts collision_node_asserts.cpp)
add_coal_test(hfields hfields.cpp)

add_coal_test(profiling profiling.cpp)
add_coal_test(profiling profiling.cpp)

add_coal_test(gjk gjk.cpp)
add_coal_test(accelerated_gjk accelerated_gjk.cpp)
add_coal_test(gjk_convergence_criterion gjk_convergence_criterion.cpp)
if(COAL_HAS_OCTOMAP)
add_coal_test(octree octree.cpp)
endif(COAL_HAS_OCTOMAP)
add_coal_test(gjk gjk.cpp)
add_coal_test(accelerated_gjk accelerated_gjk.cpp)
add_coal_test(gjk_convergence_criterion gjk_convergence_criterion.cpp)
if(COAL_HAS_OCTOMAP)
add_coal_test(octree octree.cpp)
endif(COAL_HAS_OCTOMAP)

add_coal_test(serialization serialization.cpp)
add_coal_test(serialization serialization.cpp)

# Broadphase
add_coal_test(broadphase broadphase.cpp)
set_tests_properties(${PROJECT_NAME}-broadphase PROPERTIES WILL_FAIL TRUE)
add_coal_test(broadphase_dynamic_AABB_tree broadphase_dynamic_AABB_tree.cpp)
add_coal_test(broadphase_collision_1 broadphase_collision_1.cpp)
add_coal_test(broadphase_collision_2 broadphase_collision_2.cpp)
# Broadphase
add_coal_test(broadphase broadphase.cpp)
set_tests_properties(${PROJECT_NAME}-broadphase PROPERTIES WILL_FAIL TRUE)
add_coal_test(broadphase_dynamic_AABB_tree broadphase_dynamic_AABB_tree.cpp)
add_coal_test(broadphase_collision_1 broadphase_collision_1.cpp)
add_coal_test(broadphase_collision_2 broadphase_collision_2.cpp)

## Benchmark
set(test_benchmark_target ${PROJECT_NAME}-test-benchmark)
add_executable(${test_benchmark_target} benchmark.cpp)
set_standard_output_directory(${test_benchmark_target})
target_link_libraries(
${test_benchmark_target}
PUBLIC ${utility_target} Boost::filesystem ${PROJECT_NAME}
)
## Benchmark
set(test_benchmark_target ${PROJECT_NAME}-test-benchmark)
add_executable(${test_benchmark_target} benchmark.cpp)
set_standard_output_directory(${test_benchmark_target})
target_link_libraries(
${test_benchmark_target}
PUBLIC ${utility_target} Boost::filesystem ${PROJECT_NAME}
)
endif()

## Python tests
if(BUILD_PYTHON_INTERFACE)
Expand Down
Loading