From 1e89d91d2e7524733658c63969785c6a34630e63 Mon Sep 17 00:00:00 2001 From: Robert Haschke Date: Fri, 29 Nov 2024 12:49:20 +0100 Subject: [PATCH] Install headers into subdirectory (#253) * Revert "Forward port ABI compatibility workaround with OBBs to ros2 branch (#252)" This reverts commit 3bece3463e93bedca882eb2459b754eb146b1558. * Install headers into subdirectory ... following the standard defined in https://colcon.readthedocs.io/en/released/user/overriding-packages.html#install-headers-to-a-unique-include-directory * Declare missing include dependency for a test --- CMakeLists.txt | 7 ++++--- include/geometric_shapes/bodies.h | 14 ++++++-------- src/bodies.cpp | 24 ------------------------ test/CMakeLists.txt | 1 + 4 files changed, 11 insertions(+), 35 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index aa7505e6..083ad529 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -74,8 +74,6 @@ set(THIS_PACKAGE_EXPORT_DEPENDS # Set VERSION from package.xml ament_package_xml() -include_directories(include) - add_library(${PROJECT_NAME} SHARED src/aabb.cpp src/bodies.cpp @@ -89,6 +87,9 @@ add_library(${PROJECT_NAME} SHARED ) set_target_properties(${PROJECT_NAME} PROPERTIES VERSION ${${PROJECT_NAME}_VERSION} WINDOWS_EXPORT_ALL_SYMBOLS TRUE) target_compile_options(${PROJECT_NAME} PRIVATE ${PROJECT_COMPILE_OPTIONS}) +target_include_directories(${PROJECT_NAME} + PUBLIC $ + $) target_link_libraries(${PROJECT_NAME} fcl) ament_target_dependencies(${PROJECT_NAME} ${THIS_PACKAGE_EXPORT_DEPENDS} @@ -117,7 +118,7 @@ install( RUNTIME DESTINATION bin INCLUDES DESTINATION include ) -install(DIRECTORY include/ DESTINATION include) +install(DIRECTORY include/ DESTINATION include/${PROJECT_NAME}) ament_export_targets(export_${PROJECT_NAME} HAS_LIBRARY_TARGET) ament_export_dependencies(${THIS_PACKAGE_EXPORT_DEPENDS}) diff --git a/include/geometric_shapes/bodies.h b/include/geometric_shapes/bodies.h index 4a0430b4..c08a363f 100644 --- a/include/geometric_shapes/bodies.h +++ b/include/geometric_shapes/bodies.h @@ -242,10 +242,8 @@ class Body virtual void computeBoundingBox(AABB& bbox) const = 0; /** \brief Compute the oriented bounding box for the body, in its current - * pose. Scaling and padding are accounted for. - * \note This function should be pure virtual, but it can't in order to maintain ABI compatibility. - **/ - void computeBoundingBox(OBB& bbox) const; + pose. Scaling and padding are accounted for. */ + virtual void computeBoundingBox(OBB& bbox) const = 0; /** \brief Get a clone of this body, but one that is located at the pose \e pose */ inline BodyPtr cloneAt(const Eigen::Isometry3d& pose) const @@ -314,7 +312,7 @@ class Sphere : public Body void computeBoundingSphere(BoundingSphere& sphere) const override; void computeBoundingCylinder(BoundingCylinder& cylinder) const override; void computeBoundingBox(AABB& bbox) const override; - void computeBoundingBox(OBB& bbox) const; + void computeBoundingBox(OBB& bbox) const override; bool intersectsRay(const Eigen::Vector3d& origin, const Eigen::Vector3d& dir, EigenSTL::vector_Vector3d* intersections = nullptr, unsigned int count = 0) const override; @@ -367,7 +365,7 @@ class Cylinder : public Body void computeBoundingSphere(BoundingSphere& sphere) const override; void computeBoundingCylinder(BoundingCylinder& cylinder) const override; void computeBoundingBox(AABB& bbox) const override; - void computeBoundingBox(OBB& bbox) const; + void computeBoundingBox(OBB& bbox) const override; bool intersectsRay(const Eigen::Vector3d& origin, const Eigen::Vector3d& dir, EigenSTL::vector_Vector3d* intersections = nullptr, unsigned int count = 0) const override; @@ -430,7 +428,7 @@ class Box : public Body void computeBoundingSphere(BoundingSphere& sphere) const override; void computeBoundingCylinder(BoundingCylinder& cylinder) const override; void computeBoundingBox(AABB& bbox) const override; - void computeBoundingBox(OBB& bbox) const; + void computeBoundingBox(OBB& bbox) const override; bool intersectsRay(const Eigen::Vector3d& origin, const Eigen::Vector3d& dir, EigenSTL::vector_Vector3d* intersections = nullptr, unsigned int count = 0) const override; @@ -493,7 +491,7 @@ class ConvexMesh : public Body void computeBoundingSphere(BoundingSphere& sphere) const override; void computeBoundingCylinder(BoundingCylinder& cylinder) const override; void computeBoundingBox(AABB& bbox) const override; - void computeBoundingBox(OBB& bbox) const; + void computeBoundingBox(OBB& bbox) const override; bool intersectsRay(const Eigen::Vector3d& origin, const Eigen::Vector3d& dir, EigenSTL::vector_Vector3d* intersections = nullptr, unsigned int count = 0) const override; diff --git a/src/bodies.cpp b/src/bodies.cpp index 425588e7..64d22751 100644 --- a/src/bodies.cpp +++ b/src/bodies.cpp @@ -136,30 +136,6 @@ bool bodies::Body::samplePointInside(random_numbers::RandomNumberGenerator& rng, return false; } -void bodies::Body::computeBoundingBox(bodies::OBB& bbox) const -{ - // NOTE: this switch is needed only because computeBoundingBox(OBB) could not be defined virtual to keep ABI - // compatibility; if porting to new ROS (2) releases, this function should have no base implementation for a generic - // body and should be pure virtual - switch (this->getType()) - { - case shapes::SPHERE: - static_cast(this)->computeBoundingBox(bbox); - break; - case shapes::CYLINDER: - static_cast(this)->computeBoundingBox(bbox); - break; - case shapes::BOX: - static_cast(this)->computeBoundingBox(bbox); - break; - case shapes::MESH: - static_cast(this)->computeBoundingBox(bbox); - break; - default: - throw std::runtime_error("Unknown body type: " + std::to_string(this->getType())); - } -} - bool bodies::Sphere::containsPoint(const Eigen::Vector3d& p, bool /* verbose */) const { return (center_ - p).squaredNorm() <= radius2_; diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index f4ca9c7a..8078111b 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -7,6 +7,7 @@ configure_file(resources/config.h.in "${CMAKE_CURRENT_BINARY_DIR}/resources/conf include_directories(${CMAKE_CURRENT_BINARY_DIR}) ament_add_gtest(test_basics test_basics.cpp) +target_link_libraries(test_basics ${PROJECT_NAME}) ament_target_dependencies(test_basics Eigen3) ament_add_gtest(test_point_inclusion test_point_inclusion.cpp)