From a1d383ab725eed8f954ef86efd4ee6067eb8554d Mon Sep 17 00:00:00 2001 From: Chris Lalancette Date: Mon, 5 Aug 2024 19:53:09 +0000 Subject: [PATCH] Switch nav2_theta_star_planner to modern CMake idioms. Signed-off-by: Chris Lalancette --- nav2_theta_star_planner/CMakeLists.txt | 82 +++++++++++-------- nav2_theta_star_planner/package.xml | 15 ++-- nav2_theta_star_planner/src/theta_star.cpp | 4 + .../src/theta_star_planner.cpp | 4 + 4 files changed, 63 insertions(+), 42 deletions(-) diff --git a/nav2_theta_star_planner/CMakeLists.txt b/nav2_theta_star_planner/CMakeLists.txt index 8cf8a28c35..de6778fe2b 100644 --- a/nav2_theta_star_planner/CMakeLists.txt +++ b/nav2_theta_star_planner/CMakeLists.txt @@ -2,80 +2,94 @@ cmake_minimum_required(VERSION 3.5) project(nav2_theta_star_planner) find_package(ament_cmake REQUIRED) -find_package(builtin_interfaces REQUIRED) +find_package(geometry_msgs REQUIRED) find_package(nav2_common REQUIRED) find_package(nav2_core REQUIRED) find_package(nav2_costmap_2d REQUIRED) -find_package(nav2_msgs REQUIRED) find_package(nav2_util REQUIRED) +find_package(nav_msgs REQUIRED) find_package(pluginlib REQUIRED) find_package(rclcpp REQUIRED) -find_package(rclcpp_action REQUIRED) find_package(rclcpp_lifecycle REQUIRED) +find_package(rcl_interfaces REQUIRED) find_package(tf2_ros REQUIRED) -nav2_package() #Calls the nav2_package.cmake file -add_compile_options(-O3) - -include_directories( - include -) +nav2_package() set(library_name ${PROJECT_NAME}) -set(dependencies ament_cmake - builtin_interfaces - nav2_common - nav2_core - nav2_costmap_2d - nav2_msgs - nav2_util - pluginlib - rclcpp - rclcpp_action - rclcpp_lifecycle - tf2_ros -) - - add_library(${library_name} SHARED src/theta_star.cpp src/theta_star_planner.cpp ) - -ament_target_dependencies(${library_name} ${dependencies}) - -target_compile_definitions(${library_name} PUBLIC "PLUGINLIB_DISABLE_BOOST_FUNCTIONS") +target_include_directories(${library_name} + PUBLIC + "$" + "$") +target_link_libraries(${library_name} PUBLIC + ${geometry_msgs_TARGETS} + nav2_core::nav2_core + nav2_costmap_2d::nav2_costmap_2d_core + nav2_util::nav2_util_core + ${nav_msgs_TARGETS} + rclcpp::rclcpp + rclcpp_lifecycle::rclcpp_lifecycle + ${rcl_interfaces_TARGETS} + tf2_ros::tf2_ros +) +target_link_libraries(${library_name} PRIVATE + pluginlib::pluginlib +) +target_compile_options(${library_name} PRIVATE -O3) pluginlib_export_plugin_description_file(nav2_core theta_star_planner.xml) install(TARGETS ${library_name} + EXPORT ${library_name} ARCHIVE DESTINATION lib LIBRARY DESTINATION lib RUNTIME DESTINATION lib/${PROJECT_NAME} ) install(DIRECTORY include/ - DESTINATION include/ + DESTINATION include/${PROJECT_NAME} ) install(FILES theta_star_planner.xml DESTINATION share/${PROJECT_NAME} ) - if(BUILD_TESTING) find_package(ament_lint_auto REQUIRED) set(gtest_disable_pthreads OFF) ament_lint_auto_find_test_dependencies() + find_package(ament_cmake_gtest REQUIRED) + + ament_find_gtest() + ament_add_gtest(test_theta_star test/test_theta_star.cpp) - ament_target_dependencies(test_theta_star ${dependencies}) - target_link_libraries(test_theta_star ${library_name}) + target_link_libraries(test_theta_star + ${library_name} + ${geometry_msgs_TARGETS} + nav2_costmap_2d::nav2_costmap_2d_core + rclcpp::rclcpp + rclcpp_lifecycle::rclcpp_lifecycle + ) endif() -ament_export_include_directories(include) +ament_export_include_directories(include/${PROJECT_NAME}) ament_export_libraries(${library_name}) -ament_export_dependencies(${dependencies}) +ament_export_dependencies( + geometry_msgs + nav2_core + nav2_costmap_2dnav2_util + nav_msgs + rclcpp + rclcpp_lifecycle + rcl_interfaces + tf2_ros +) +ament_export_targets(${library_name}) ament_package() diff --git a/nav2_theta_star_planner/package.xml b/nav2_theta_star_planner/package.xml index 0fcbd0e288..0da357b581 100644 --- a/nav2_theta_star_planner/package.xml +++ b/nav2_theta_star_planner/package.xml @@ -9,26 +9,25 @@ Apache-2.0 ament_cmake + nav2_common - builtin_interfaces - nav2_common + geometry_msgs nav2_core nav2_costmap_2d - nav2_msgs nav2_util + nav_msgs pluginlib rclcpp - rclcpp_action rclcpp_lifecycle + rcl_interfaces tf2_ros - + + ament_cmake_gtest ament_lint_auto ament_lint_common - ament_cmake_gtest - + ament_cmake - diff --git a/nav2_theta_star_planner/src/theta_star.cpp b/nav2_theta_star_planner/src/theta_star.cpp index ba3629bcbf..48a3f6c1bd 100644 --- a/nav2_theta_star_planner/src/theta_star.cpp +++ b/nav2_theta_star_planner/src/theta_star.cpp @@ -12,7 +12,11 @@ // See the License for the specific language governing permissions and // limitations under the License. +#include #include + +#include "geometry_msgs/msg/pose_stamped.hpp" + #include "nav2_core/planner_exceptions.hpp" #include "nav2_theta_star_planner/theta_star.hpp" diff --git a/nav2_theta_star_planner/src/theta_star_planner.cpp b/nav2_theta_star_planner/src/theta_star_planner.cpp index 24f2b81000..5d14368cc0 100644 --- a/nav2_theta_star_planner/src/theta_star_planner.cpp +++ b/nav2_theta_star_planner/src/theta_star_planner.cpp @@ -15,6 +15,10 @@ #include #include #include + +#include "geometry_msgs/msg/pose_stamped.hpp" +#include "rclcpp/rclcpp.hpp" + #include "nav2_theta_star_planner/theta_star_planner.hpp" #include "nav2_theta_star_planner/theta_star.hpp"