Skip to content

Instantly share code, notes, and snippets.

@mjcarroll
Last active June 3, 2024 20:51
Show Gist options
  • Save mjcarroll/056b5f5c34a666095a0127c704b5ca28 to your computer and use it in GitHub Desktop.
Save mjcarroll/056b5f5c34a666095a0127c704b5ca28 to your computer and use it in GitHub Desktop.
cmake_minimum_required(VERSION 3.5)
project(sdk_examples_ros)
# Default to C++17
if(NOT CMAKE_CXX_STANDARD)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
endif()
if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang")
add_compile_options(-Wall -Wextra -Wpedantic)
endif()
# ROS Dependencies
find_package(ament_cmake REQUIRED)
find_package(cv_bridge REQUIRED)
find_package(geometry_msgs REQUIRED)
find_package(sensor_msgs REQUIRED)
find_package(std_msgs REQUIRED)
find_package(rclcpp REQUIRED)
find_package(rclcpp_action REQUIRED)
find_package(rclcpp_components REQUIRED)
find_package(rosidl_default_generators REQUIRED)
find_package(tf2 REQUIRED)
# Generate interfaces
rosidl_generate_interfaces(${PROJECT_NAME}
"msg/Feature.msg"
"msg/FeaturesStamped.msg"
"srv/DetectFeatures.srv"
DEPENDENCIES
std_msgs sensor_msgs geometry_msgs
)
ament_export_dependencies(rosidl_default_runtime)
rosidl_get_typesupport_target(cpp_typesupport_target
${PROJECT_NAME} rosidl_typesupport_cpp)
# Create ROS Node
add_library(feature_detector_node SHARED
src/node/feature_detector_node.cpp)
rclcpp_components_register_node(feature_detector_node
PLUGIN "sdk_examples_ros::FeatureDetectorNode"
EXECUTABLE feature_detector_node_main)
target_include_directories(feature_detector_node PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
$<INSTALL_INTERFACE:include/${PROJECT_NAME}>
)
ament_target_dependencies(feature_detector_node "rclcpp" "rclcpp_action" "rclcpp_components" "cv_bridge" "tf2")
target_link_libraries(feature_detector_node "${cpp_typesupport_target}")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment