Skip to content

Commit

Permalink
Switch nav2_regulated_pure_pursuit_controller to modern CMake idioms. (
Browse files Browse the repository at this point in the history
…ros-navigation#4597)

Signed-off-by: Chris Lalancette <clalancette@gmail.com>
Signed-off-by: Joseph Duchesne <josephgeek@gmail.com>
  • Loading branch information
clalancette authored and josephduchesne committed Dec 10, 2024
1 parent 7d369e0 commit db4ce09
Show file tree
Hide file tree
Showing 3 changed files with 75 additions and 41 deletions.
85 changes: 53 additions & 32 deletions nav2_regulated_pure_pursuit_controller/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,72 +3,93 @@ project(nav2_regulated_pure_pursuit_controller)

find_package(ament_cmake REQUIRED)
find_package(angles 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_util REQUIRED)
find_package(rclcpp REQUIRED)
find_package(geometry_msgs REQUIRED)
find_package(nav_msgs REQUIRED)
find_package(pluginlib REQUIRED)
find_package(rclcpp REQUIRED)
find_package(rclcpp_lifecycle REQUIRED)
find_package(rcl_interfaces REQUIRED)
find_package(std_msgs REQUIRED)
find_package(tf2 REQUIRED)
find_package(tf2_geometry_msgs REQUIRED)
find_package(tf2_ros REQUIRED)

nav2_package()
set(CMAKE_CXX_STANDARD 17)

include_directories(
include
)

set(dependencies
rclcpp
geometry_msgs
nav2_costmap_2d
pluginlib
nav_msgs
angles
nav2_util
nav2_core
tf2
tf2_geometry_msgs
)

set(library_name nav2_regulated_pure_pursuit_controller)

add_library(${library_name} SHARED
src/regulated_pure_pursuit_controller.cpp
src/collision_checker.cpp
src/parameter_handler.cpp
src/path_handler.cpp)

ament_target_dependencies(${library_name}
${dependencies}
src/regulated_pure_pursuit_controller.cpp
src/collision_checker.cpp
src/parameter_handler.cpp
src/path_handler.cpp)
target_include_directories(${library_name}
PUBLIC
"$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>"
"$<INSTALL_INTERFACE:include/${PROJECT_NAME}>"
)
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}
pluginlib::pluginlib
rclcpp::rclcpp
rclcpp_lifecycle::rclcpp_lifecycle
${rcl_interfaces_TARGETS}
${std_msgs_TARGETS}
tf2::tf2
tf2_ros::tf2_ros
)
target_link_libraries(${library_name} PRIVATE
angles::angles
)

install(TARGETS ${library_name}
EXPORT ${library_name}
ARCHIVE DESTINATION lib
LIBRARY DESTINATION lib
RUNTIME DESTINATION bin
)

install(DIRECTORY include/
DESTINATION include/
DESTINATION include/${PROJECT_NAME}
)

if(BUILD_TESTING)
find_package(ament_lint_auto REQUIRED)
# the following line skips the linter which checks for copyrights
set(ament_cmake_copyright_FOUND TRUE)
ament_lint_auto_find_test_dependencies()

find_package(tf2_geometry_msgs REQUIRED)

ament_find_gtest()
add_subdirectory(test)
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_2d
nav2_util
nav_msgs
pluginlib
rclcpp
rclcpp_lifecycle
rcl_interfaces
std_msgs
tf2
tf2_ros
)
ament_export_targets(${library_name})

pluginlib_export_plugin_description_file(nav2_core nav2_regulated_pure_pursuit_controller.xml)

ament_package()

14 changes: 9 additions & 5 deletions nav2_regulated_pure_pursuit_controller/package.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,22 +9,26 @@
<license>Apache-2.0</license>

<buildtool_depend>ament_cmake</buildtool_depend>
<build_depend>nav2_common</build_depend>

<depend>angles</depend>
<depend>nav2_common</depend>
<depend>geometry_msgs</depend>
<depend>nav2_core</depend>
<depend>nav2_util</depend>
<depend>nav2_costmap_2d</depend>
<depend>rclcpp</depend>
<depend>geometry_msgs</depend>
<depend>nav2_msgs</depend>
<depend>nav2_util</depend>
<depend>pluginlib</depend>
<depend>rclcpp</depend>
<depend>rclcpp_lifecycle</depend>
<depend>rcl_interfaces</depend>
<depend>std_msgs</depend>
<depend>tf2</depend>
<depend>tf2_geometry_msgs</depend>
<depend>tf2_ros</depend>

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

<export>
<build_type>ament_cmake</build_type>
Expand Down
17 changes: 13 additions & 4 deletions nav2_regulated_pure_pursuit_controller/test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,22 @@ ament_add_gtest(test_regulated_pp
test_regulated_pp.cpp
path_utils/path_utils.cpp
)
ament_target_dependencies(test_regulated_pp
${dependencies}
)
target_link_libraries(test_regulated_pp
${library_name}
${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
)

# Path utils test
ament_add_gtest(test_path_utils path_utils/test_path_utils.cpp path_utils/path_utils.cpp)
ament_target_dependencies(test_path_utils nav_msgs geometry_msgs tf2_geometry_msgs)
target_link_libraries(test_path_utils
${nav_msgs_TARGETS}
${geometry_msgs_TARGETS}
tf2::tf2
tf2_geometry_msgs::tf2_geometry_msgs
)

0 comments on commit db4ce09

Please sign in to comment.