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

Switch nav2_waypoint_follower to modern CMake idioms. #4648

Merged
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
168 changes: 114 additions & 54 deletions nav2_waypoint_follower/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,87 +1,126 @@
cmake_minimum_required(VERSION 3.5)
project(nav2_waypoint_follower)

# Try for OpenCV 4.X, but settle for whatever is installed
find_package(OpenCV 4 QUIET)
if(NOT OpenCV_FOUND)
find_package(OpenCV REQUIRED)
endif()
message(STATUS "Found OpenCV version ${OpenCV_VERSION}")

find_package(image_transport REQUIRED)
find_package(cv_bridge REQUIRED)
find_package(ament_cmake REQUIRED)
find_package(cv_bridge REQUIRED)
find_package(geographic_msgs REQUIRED)
find_package(geometry_msgs REQUIRED)
find_package(image_transport REQUIRED)
find_package(nav2_common REQUIRED)
find_package(rclcpp REQUIRED)
find_package(rclcpp_action REQUIRED)
find_package(rclcpp_lifecycle REQUIRED)
find_package(rclcpp_components REQUIRED)
find_package(nav_msgs REQUIRED)
find_package(nav2_core REQUIRED)
find_package(nav2_msgs REQUIRED)
find_package(nav2_util REQUIRED)
find_package(tf2_ros REQUIRED)
find_package(nav2_core REQUIRED)
find_package(nav_msgs REQUIRED)
find_package(OpenCV REQUIRED)
find_package(pluginlib REQUIRED)
find_package(rclcpp REQUIRED)
find_package(rclcpp_action REQUIRED)
find_package(rclcpp_components REQUIRED)
find_package(rclcpp_lifecycle REQUIRED)
find_package(robot_localization REQUIRED)
find_package(geographic_msgs REQUIRED)
find_package(sensor_msgs REQUIRED)
find_package(std_msgs REQUIRED)
find_package(tf2_ros REQUIRED)

nav2_package()

include_directories(
include
)

set(executable_name waypoint_follower)

add_executable(${executable_name}
src/main.cpp
)

set(library_name ${executable_name}_core)

add_library(${library_name} SHARED
src/waypoint_follower.cpp
)

set(dependencies
rclcpp
rclcpp_action
rclcpp_lifecycle
rclcpp_components
nav_msgs
nav2_msgs
nav2_util
tf2_ros
nav2_core
pluginlib
image_transport
cv_bridge
OpenCV
robot_localization
target_include_directories(${library_name} PUBLIC
"$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>"
"$<INSTALL_INTERFACE:include/${PROJECT_NAME}>"
)

ament_target_dependencies(${executable_name}
${dependencies}
target_link_libraries(${library_name} PUBLIC
${geographic_msgs_TARGETS}
nav2_core::nav2_core
${nav2_msgs_TARGETS}
nav2_util::nav2_util_core
${nav_msgs_TARGETS}
pluginlib::pluginlib
rclcpp::rclcpp
rclcpp_action::rclcpp_action
rclcpp_lifecycle::rclcpp_lifecycle
robot_localization::rl_lib
tf2_ros::tf2_ros
)
target_link_libraries(${library_name} PRIVATE
rclcpp_components::component
)

target_link_libraries(${executable_name} ${library_name})

ament_target_dependencies(${library_name}
${dependencies}
add_executable(${executable_name}
src/main.cpp
)
target_include_directories(${executable_name} PRIVATE
"$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>"
"$<INSTALL_INTERFACE:include/${PROJECT_NAME}>"
)
target_link_libraries(${executable_name} PRIVATE
${library_name}
rclcpp::rclcpp
)

add_library(wait_at_waypoint SHARED plugins/wait_at_waypoint.cpp)
ament_target_dependencies(wait_at_waypoint ${dependencies})
target_include_directories(wait_at_waypoint PUBLIC
"$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>"
"$<INSTALL_INTERFACE:include/${PROJECT_NAME}>"
)
target_link_libraries(wait_at_waypoint PUBLIC
${geometry_msgs_TARGETS}
rclcpp::rclcpp
rclcpp_lifecycle::rclcpp_lifecycle
nav2_core::nav2_core
)
target_link_libraries(wait_at_waypoint PRIVATE
pluginlib::pluginlib
nav2_util::nav2_util_core
)

add_library(photo_at_waypoint SHARED plugins/photo_at_waypoint.cpp)
ament_target_dependencies(photo_at_waypoint ${dependencies})
target_include_directories(photo_at_waypoint PUBLIC
"$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>"
"$<INSTALL_INTERFACE:include/${PROJECT_NAME}>"
)
target_link_libraries(photo_at_waypoint PUBLIC
cv_bridge::cv_bridge
${geometry_msgs_TARGETS}
image_transport::image_transport
nav2_core::nav2_core
opencv_core
rclcpp::rclcpp
rclcpp_lifecycle::rclcpp_lifecycle
${sensor_msgs_TARGETS}
)
target_link_libraries(photo_at_waypoint PRIVATE
nav2_util::nav2_util_core
pluginlib::pluginlib
)

add_library(input_at_waypoint SHARED plugins/input_at_waypoint.cpp)
ament_target_dependencies(input_at_waypoint ${dependencies})
target_include_directories(input_at_waypoint PUBLIC
"$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>"
"$<INSTALL_INTERFACE:include/${PROJECT_NAME}>"
)
target_link_libraries(input_at_waypoint PUBLIC
${geometry_msgs_TARGETS}
nav2_core::nav2_core
rclcpp::rclcpp
rclcpp_lifecycle::rclcpp_lifecycle
${std_msgs_TARGETS}
)
target_link_libraries(input_at_waypoint PRIVATE
pluginlib::pluginlib
nav2_util::nav2_util_core
)

rclcpp_components_register_nodes(${library_name} "nav2_waypoint_follower::WaypointFollower")

install(TARGETS ${library_name} wait_at_waypoint photo_at_waypoint input_at_waypoint
EXPORT ${PROJECT_NAME}
ARCHIVE DESTINATION lib
LIBRARY DESTINATION lib
RUNTIME DESTINATION bin
Expand All @@ -92,19 +131,40 @@ install(TARGETS ${executable_name}
)

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

if(BUILD_TESTING)
find_package(ament_lint_auto REQUIRED)
find_package(ament_cmake_gtest REQUIRED)
ament_lint_auto_find_test_dependencies()

ament_find_gtest()
add_subdirectory(test)
endif()

ament_export_include_directories(include)
ament_export_include_directories(include/${PROJECT_NAME})
ament_export_libraries(wait_at_waypoint photo_at_waypoint input_at_waypoint ${library_name})
ament_export_dependencies(${dependencies})
ament_export_dependencies(
cv_bridge
geographic_msgs
geometry_msgs
image_transport
nav2_core
nav2_msgs
nav2_util
nav_msgs
OpenCV
pluginlib
rclcpp
rclcpp_action
rclcpp_lifecycle
robot_localization
sensor_msgs
std_msgs
tf2_ros
)
ament_export_targets(${PROJECT_NAME})
pluginlib_export_plugin_description_file(nav2_waypoint_follower plugins.xml)

ament_package()
Original file line number Diff line number Diff line change
Expand Up @@ -15,20 +15,12 @@
#ifndef NAV2_WAYPOINT_FOLLOWER__PLUGINS__PHOTO_AT_WAYPOINT_HPP_
#define NAV2_WAYPOINT_FOLLOWER__PLUGINS__PHOTO_AT_WAYPOINT_HPP_

/**
* While C++17 isn't the project standard. We have to force LLVM/CLang
* to ignore deprecated declarations
*/
#define _LIBCPP_NO_EXPERIMENTAL_DEPRECATION_WARNING_FILESYSTEM


#include <filesystem>
#include <mutex>
#include <string>
#include <exception>

#include "rclcpp/rclcpp.hpp"
#include "rclcpp_components/register_node_macro.hpp"

#include "sensor_msgs/msg/image.hpp"
#include "nav2_core/waypoint_task_executor.hpp"
Expand Down
27 changes: 15 additions & 12 deletions nav2_waypoint_follower/package.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,26 +8,29 @@
<license>Apache-2.0</license>

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

<depend>nav2_common</depend>
<depend>cv_bridge</depend>
<depend>pluginlib</depend>
<depend>geographic_msgs</depend>
<depend>geometry_msgs</depend>
<depend>image_transport</depend>
<depend>nav2_core</depend>
<depend>nav2_msgs</depend>
<depend>nav2_util</depend>
<depend>nav_msgs</depend>
<depend>pluginlib</depend>
<depend>rclcpp</depend>
<depend>rclcpp_action</depend>
<depend>rclcpp_components</depend>
<depend>rclcpp_lifecycle</depend>
<depend>nav_msgs</depend>
<depend>nav2_msgs</depend>
<depend>nav2_util</depend>
<depend>nav2_core</depend>
<depend>tf2_ros</depend>
<depend>robot_localization</depend>
<depend>geographic_msgs</depend>

<test_depend>ament_lint_common</test_depend>
<test_depend>ament_lint_auto</test_depend>
<depend>sensor_msgs</depend>
<depend>std_msgs</depend>
<depend>tf2_ros</depend>

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

<export>
<build_type>ament_cmake</build_type>
Expand Down
19 changes: 12 additions & 7 deletions nav2_waypoint_follower/test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,25 @@
ament_add_gtest(test_task_executors
test_task_executors.cpp
)
ament_target_dependencies(test_task_executors
${dependencies}
)
target_link_libraries(test_task_executors
${library_name} wait_at_waypoint photo_at_waypoint input_at_waypoint
${library_name}
wait_at_waypoint
photo_at_waypoint
input_at_waypoint
${geometry_msgs_TARGETS}
nav2_util::nav2_util_core
rclcpp::rclcpp
rclcpp_lifecycle::rclcpp_lifecycle
${sensor_msgs_TARGETS}
)

# Test dynamic parameters
ament_add_gtest(test_dynamic_parameters
test_dynamic_parameters.cpp
)
ament_target_dependencies(test_dynamic_parameters
${dependencies}
)
target_link_libraries(test_dynamic_parameters
${library_name}
nav2_util::nav2_util_core
rclcpp::rclcpp
rclcpp_lifecycle::rclcpp_lifecycle
)
Loading