|
| 1 | +# Copyright (c) 2025-present WATonomous. All rights reserved. |
| 2 | +# |
| 3 | +# Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 | +# you may not use this file except in compliance with the License. |
| 5 | +# You may obtain a copy of the License at |
| 6 | +# |
| 7 | +# http://www.apache.org/licenses/LICENSE-2.0 |
| 8 | +# |
| 9 | +# Unless required by applicable law or agreed to in writing, software |
| 10 | +# distributed under the License is distributed on an "AS IS" BASIS, |
| 11 | +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 | +# See the License for the specific language governing permissions and |
| 13 | +# limitations under the License. |
| 14 | +cmake_minimum_required(VERSION 3.8) |
| 15 | +project(camera_sync) |
| 16 | + |
| 17 | +if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang") |
| 18 | + add_compile_options(-Wall -Wextra -Wpedantic) |
| 19 | +endif() |
| 20 | + |
| 21 | +# find dependencies |
| 22 | +find_package(ament_cmake REQUIRED) |
| 23 | +find_package(rclcpp REQUIRED) |
| 24 | +find_package(rclcpp_lifecycle REQUIRED) |
| 25 | +find_package(rclcpp_components REQUIRED) |
| 26 | +find_package(lifecycle_msgs REQUIRED) |
| 27 | +find_package(sensor_msgs REQUIRED) |
| 28 | +find_package(cv_bridge REQUIRED) |
| 29 | +find_package(message_filters REQUIRED) |
| 30 | +find_package(image_transport REQUIRED) |
| 31 | +find_package(deep_msgs REQUIRED) |
| 32 | + |
| 33 | +# Create include directory |
| 34 | +include_directories(include) |
| 35 | + |
| 36 | +# Define lifecycle node support based on ROS distro |
| 37 | +get_filename_component(ROS_DISTRO_NAME "$ENV{ROS_DISTRO}" NAME) |
| 38 | +if(ROS_DISTRO_NAME STREQUAL "rolling") # Currently only Rolling supports lifecycle nodes with compressed image subs |
| 39 | + add_definitions(-DUSE_LIFECYCLE_NODE=1) |
| 40 | +else() |
| 41 | + add_definitions(-DUSE_LIFECYCLE_NODE=0) |
| 42 | +endif() |
| 43 | + |
| 44 | +# Add the multi-camera sync library for component |
| 45 | +add_library(multi_camera_sync_component SHARED src/multi_camera_sync_node.cpp) |
| 46 | +target_link_libraries(multi_camera_sync_component |
| 47 | + rclcpp::rclcpp |
| 48 | + rclcpp_lifecycle::rclcpp_lifecycle |
| 49 | + rclcpp_components::component_manager |
| 50 | + lifecycle_msgs::lifecycle_msgs__rosidl_typesupport_cpp |
| 51 | + sensor_msgs::sensor_msgs__rosidl_typesupport_cpp |
| 52 | + cv_bridge::cv_bridge |
| 53 | + message_filters::message_filters |
| 54 | + image_transport::image_transport |
| 55 | + deep_msgs::deep_msgs__rosidl_typesupport_cpp |
| 56 | +) |
| 57 | + |
| 58 | +# Register the component |
| 59 | +rclcpp_components_register_nodes(multi_camera_sync_component "camera_sync::MultiCameraSyncNode") |
| 60 | +set(node_plugins "${node_plugins}camera_sync::MultiCameraSyncNode;$<TARGET_FILE:multi_camera_sync_component>\n") |
| 61 | + |
| 62 | + |
| 63 | + |
| 64 | +# Install executables and libraries |
| 65 | +install(TARGETS |
| 66 | + multi_camera_sync_component |
| 67 | + ARCHIVE DESTINATION lib |
| 68 | + LIBRARY DESTINATION lib |
| 69 | + RUNTIME DESTINATION bin |
| 70 | +) |
| 71 | + |
| 72 | + |
| 73 | + |
| 74 | +# Install include directory |
| 75 | +install(DIRECTORY include/ |
| 76 | + DESTINATION include |
| 77 | +) |
| 78 | + |
| 79 | +# Install launch files if any |
| 80 | +install(DIRECTORY launch/ |
| 81 | + DESTINATION share/${PROJECT_NAME}/launch |
| 82 | + FILES_MATCHING PATTERN "*.py" PATTERN "*.yaml" PATTERN "*.md" |
| 83 | +) |
| 84 | + |
| 85 | +# Install config files |
| 86 | +install(DIRECTORY config/ |
| 87 | + DESTINATION share/${PROJECT_NAME}/config |
| 88 | + FILES_MATCHING PATTERN "*.yaml" |
| 89 | +) |
| 90 | + |
| 91 | + |
| 92 | +ament_package() |
0 commit comments