Skip to content

Commit

Permalink
Switch dwb_critics to modern CMake idioms. (#4611)
Browse files Browse the repository at this point in the history
Signed-off-by: Chris Lalancette <[email protected]>
  • Loading branch information
clalancette authored Aug 9, 2024
1 parent 4d2c2c6 commit 5321e00
Show file tree
Hide file tree
Showing 3 changed files with 79 additions and 52 deletions.
92 changes: 49 additions & 43 deletions nav2_dwb_controller/dwb_critics/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,68 +2,66 @@ cmake_minimum_required(VERSION 3.5)
project(dwb_critics)

find_package(ament_cmake REQUIRED)
find_package(nav2_common REQUIRED)
find_package(angles REQUIRED)
find_package(nav2_costmap_2d REQUIRED)
find_package(costmap_queue REQUIRED)
find_package(dwb_core REQUIRED)
find_package(dwb_msgs REQUIRED)
find_package(geometry_msgs REQUIRED)
find_package(nav2_common REQUIRED)
find_package(nav2_costmap_2d REQUIRED)
find_package(nav2_util REQUIRED)
find_package(nav_2d_msgs REQUIRED)
find_package(nav_2d_utils REQUIRED)
find_package(pluginlib REQUIRED)
find_package(rclcpp REQUIRED)
find_package(sensor_msgs REQUIRED)
find_package(nav2_util REQUIRED)

nav2_package()

include_directories(
include
)

add_library(${PROJECT_NAME} SHARED
src/alignment_util.cpp
src/map_grid.cpp
src/goal_dist.cpp
src/path_dist.cpp
src/goal_align.cpp
src/path_align.cpp
src/base_obstacle.cpp
src/obstacle_footprint.cpp
src/oscillation.cpp
src/prefer_forward.cpp
src/rotate_to_goal.cpp
src/twirling.cpp
src/alignment_util.cpp
src/map_grid.cpp
src/goal_dist.cpp
src/path_dist.cpp
src/goal_align.cpp
src/path_align.cpp
src/base_obstacle.cpp
src/obstacle_footprint.cpp
src/oscillation.cpp
src/prefer_forward.cpp
src/rotate_to_goal.cpp
src/twirling.cpp
)

set(dependencies
angles
nav2_costmap_2d
costmap_queue
dwb_core
geometry_msgs
nav_2d_msgs
nav_2d_utils
pluginlib
rclcpp
sensor_msgs
nav2_util
target_include_directories(${PROJECT_NAME} PUBLIC
"$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>"
"$<INSTALL_INTERFACE:include/${PROJECT_NAME}>"
)

ament_target_dependencies(${PROJECT_NAME}
${dependencies}
target_link_libraries(${PROJECT_NAME} PUBLIC
costmap_queue::costmap_queue
dwb_core::dwb_core
${dwb_msgs_TARGETS}
${geometry_msgs_TARGETS}
nav2_costmap_2d::nav2_costmap_2d_core
${nav_2d_msgs_TARGETS}
rclcpp::rclcpp
)
target_link_libraries(${PROJECT_NAME} PRIVATE
angles::angles
nav2_util::nav2_util_core
nav_2d_utils::path_ops
pluginlib::pluginlib
)

install(TARGETS ${PROJECT_NAME}
ARCHIVE DESTINATION lib
LIBRARY DESTINATION lib
RUNTIME DESTINATION bin
EXPORT ${PROJECT_NAME}
ARCHIVE DESTINATION lib
LIBRARY DESTINATION lib
RUNTIME DESTINATION bin
)
install(DIRECTORY include/
DESTINATION include/
DESTINATION include/${PROJECT_NAME}
)
install(FILES default_critics.xml
DESTINATION share/${PROJECT_NAME}
DESTINATION share/${PROJECT_NAME}
)

if(BUILD_TESTING)
Expand All @@ -72,15 +70,23 @@ if(BUILD_TESTING)
set(ament_cmake_copyright_FOUND TRUE)
ament_lint_auto_find_test_dependencies()
find_package(ament_cmake_gtest REQUIRED)
ament_find_gtest()

add_subdirectory(test)
endif()

ament_export_include_directories(include)
ament_export_include_directories(include/${PROJECT_NAME})
ament_export_libraries(${PROJECT_NAME})
ament_export_dependencies(
${dependencies}
costmap_queue
dwb_core
dwb_msgs
geometry_msgs
nav2_costmap_2d
nav_2d_msgs
rclcpp
)
ament_export_targets(${PROJECT_NAME})

pluginlib_export_plugin_description_file(dwb_core default_critics.xml)

Expand Down
8 changes: 4 additions & 4 deletions nav2_dwb_controller/dwb_critics/package.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,20 +10,20 @@
<build_depend>nav2_common</build_depend>

<depend>angles</depend>
<depend>nav2_costmap_2d</depend>
<depend>nav2_util</depend>
<depend>costmap_queue</depend>
<depend>dwb_core</depend>
<depend>dwb_msgs</depend>
<depend>geometry_msgs</depend>
<depend>nav2_costmap_2d</depend>
<depend>nav2_util</depend>
<depend>nav_2d_msgs</depend>
<depend>nav_2d_utils</depend>
<depend>pluginlib</depend>
<depend>rclcpp</depend>
<depend>sensor_msgs</depend>

<test_depend>ament_cmake_gtest</test_depend>
<test_depend>ament_lint_common</test_depend>
<test_depend>ament_lint_auto</test_depend>
<test_depend>ament_cmake_gtest</test_depend>

<export>
<build_type>ament_cmake</build_type>
Expand Down
31 changes: 26 additions & 5 deletions nav2_dwb_controller/dwb_critics/test/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,14 +1,35 @@
ament_add_gtest(prefer_forward_tests prefer_forward_test.cpp)
target_link_libraries(prefer_forward_tests dwb_critics)
target_link_libraries(prefer_forward_tests
dwb_critics
nav2_costmap_2d::nav2_costmap_2d_core
nav2_util::nav2_util_core
rclcpp::rclcpp
)

ament_add_gtest(base_obstacle_tests base_obstacle_test.cpp)
target_link_libraries(base_obstacle_tests dwb_critics)
target_link_libraries(base_obstacle_tests
dwb_critics
dwb_core::dwb_core
rclcpp::rclcpp
)

ament_add_gtest(obstacle_footprint_tests obstacle_footprint_test.cpp)
target_link_libraries(obstacle_footprint_tests dwb_critics)
target_link_libraries(obstacle_footprint_tests
dwb_critics
dwb_core::dwb_core
rclcpp::rclcpp
)

ament_add_gtest(alignment_util_tests alignment_util_test.cpp)
target_link_libraries(alignment_util_tests dwb_critics)
target_link_libraries(alignment_util_tests
dwb_critics
dwb_core::dwb_core
rclcpp::rclcpp
)

ament_add_gtest(twirling_tests twirling_test.cpp)
target_link_libraries(twirling_tests dwb_critics)
target_link_libraries(twirling_tests
dwb_critics
dwb_core::dwb_core
rclcpp::rclcpp
)

0 comments on commit 5321e00

Please sign in to comment.