diff --git a/.github/workflows/colcon.yml b/.github/workflows/colcon.yml new file mode 100644 index 00000000..c8afe194 --- /dev/null +++ b/.github/workflows/colcon.yml @@ -0,0 +1,29 @@ +name: colcon + +on: [push, pull_request] + +jobs: + # build on Ubuntu docker images + build: + name: "${{ matrix.image }} (${{ matrix.ros }})" + + runs-on: ubuntu-latest + + strategy: + matrix: + include: + - {image: "ubuntu:22.04", ros: humble} + - {image: "ubuntu:24.04", ros: jazzy} + - {image: "ubuntu:26.04", ros: lyrical} + + container: + image: ${{ matrix.image }} + + steps: + - uses: actions/checkout@v6 + + - uses: ros-tooling/setup-ros@v0.7 + + - uses: ros-tooling/action-ros-ci@v0.4 + with: + target-ros2-distro: ${{ matrix.ros }} diff --git a/orbbec_camera/CMakeLists.txt b/orbbec_camera/CMakeLists.txt index 56dc49fd..dcc00996 100644 --- a/orbbec_camera/CMakeLists.txt +++ b/orbbec_camera/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 3.8) +cmake_minimum_required(VERSION 3.22) project(orbbec_camera) set(CMAKE_CXX_STANDARD 17) @@ -13,6 +13,8 @@ option(INSTALL_UDEV_RULES "Install udev rule for Orbbec cameras" ON) if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang") add_compile_options(-Wall -Wextra -Werror -Wno-pedantic -Wno-array-bounds) + add_compile_options(-Wno-error=deprecated-declarations) + add_link_options("-Wl,-z,relro,-z,now,-z,defs") endif() # find dependencies @@ -26,6 +28,7 @@ set(dependencies camera_info_manager image_transport image_publisher + message_filters OpenCV orbbec_camera_msgs rclcpp @@ -52,6 +55,14 @@ endforeach() find_package(PkgConfig REQUIRED) find_package(OpenSSL REQUIRED) +if(message_filters_VERSION VERSION_GREATER_EQUAL 5.0) + add_compile_definitions(message_filters_QoS) +endif() + +if(image_transport_VERSION VERSION_GREATER_EQUAL 6.4) + add_compile_definitions(image_transport_NODE_INTERFACE) +endif() + if(USE_RK_HW_DECODER) pkg_search_module(RK_MPP REQUIRED rockchip_mpp) if(NOT RK_MPP_FOUND) @@ -100,26 +111,8 @@ set(COMMON_INCLUDE_DIRS $ ${ORBBEC_INCLUDE_DIR} ${OpenCV_INCLUDED_DIRS} ${CMAKE_CURRENT_SOURCE_DIR}/tools ) -set(COMMON_LIBRARIES - ${ORBBEC_SDK_LIBRARIES} - ${OpenCV_LIBS} - Eigen3::Eigen - -lOrbbecSDK - -L${ORBBEC_LIBS_DIR} - Threads::Threads - -lrt - -ldw - yaml-cpp - OpenSSL::Crypto +set(EXTRA_TARGETS ) -if(USE_RK_HW_DECODER) - list(APPEND COMMON_LIBRARIES ${RK_MPP_LIBRARIES} ${RGA_LIBRARIES}) - -endif() - -if(USE_NV_HW_DECODER) - list(APPEND COMMON_LIBRARIES ${NV_LIBRARIES}) -endif() set(SOURCE_FILES src/d2c_viewer.cpp @@ -140,15 +133,16 @@ if(USE_RK_HW_DECODER) add_definitions(-DUSE_RK_HW_DECODER) list(APPEND SOURCE_FILES src/rk_mpp_decoder.cpp) list(APPEND COMMON_INCLUDE_DIRS ${RK_MPP_INCLUDE_DIRS} ${RGA_INCLUDE_DIRS}) - list(APPEND COMMON_LIBRARIES ${RGA_LIBRARIES} ${RK_MPP_LIBRARIES}) + list(APPEND EXTRA_TARGETS ${RGA_LIBRARIES} ${RK_MPP_LIBRARIES}) if(NOT RGA_FOUND) - list(APPEND COMMON_LIBRARIES -lyuv) + list(APPEND EXTRA_TARGETS yuv) endif() endif() if(USE_NV_HW_DECODER) list(APPEND SOURCE_FILES src/jetson_nv_decoder.cpp) list(APPEND COMMON_INCLUDE_DIRS ${JETSON_MULTI_MEDIA_API_INCLUDE_DIR} ${LIBJPEG8B_INCLUDE_DIR}) + list(APPEND EXTRA_TARGETS ${NV_LIBRARIES}) # append jetson_multimedia_api source files list( APPEND @@ -171,16 +165,42 @@ endif() macro(add_orbbec_executable TARGET SOURCE) add_executable(${TARGET} ${SOURCE}) target_include_directories(${TARGET} PUBLIC ${COMMON_INCLUDE_DIRS}) - target_link_libraries(${TARGET} ${COMMON_LIBRARIES} ${PROJECT_NAME}) - ament_target_dependencies(${TARGET} ${dependencies}) + target_link_directories(${TARGET} PRIVATE + ${ORBBEC_LIBS_DIR} + ) + target_link_libraries(${TARGET} + ${OpenCV_LIBS} + ${PROJECT_NAME} + OrbbecSDK + yaml-cpp + ) endmacro() # Define library and nodes add_library(${PROJECT_NAME} SHARED ${SOURCE_FILES}) -ament_target_dependencies(${PROJECT_NAME} ${dependencies}) -target_include_directories(${PROJECT_NAME} PUBLIC ${COMMON_INCLUDE_DIRS}) -target_link_libraries(${PROJECT_NAME} ${COMMON_LIBRARIES}) +target_include_directories(${PROJECT_NAME} PUBLIC ${COMMON_INCLUDE_DIRS} ${image_publisher_INCLUDE_DIRS}) +target_link_directories(${PROJECT_NAME} PRIVATE ${ORBBEC_LIBS_DIR}) +target_link_libraries(${PROJECT_NAME} + ${OpenCV_LIBS} + ${orbbec_camera_msgs_TARGETS} + ${sensor_msgs_TARGETS} + ${std_srvs_TARGETS} + ament_index_cpp::ament_index_cpp + camera_info_manager::camera_info_manager + cv_bridge::cv_bridge + diagnostic_updater::diagnostic_updater + Eigen3::Eigen + image_transport::image_transport + message_filters::message_filters + OpenSSL::Crypto + OrbbecSDK + rclcpp::rclcpp + rclcpp_components::component + tf2::tf2 + tf2_ros::tf2_ros + ${EXTRA_TARGETS} +) rclcpp_components_register_node( ${PROJECT_NAME} PLUGIN "orbbec_camera::OBCameraNodeDriver" EXECUTABLE orbbec_camera_node @@ -207,24 +227,57 @@ install( add_library(frame_latency SHARED tools/frame_latency.cpp) target_include_directories(frame_latency PUBLIC ${COMMON_INCLUDE_DIRS}) -target_link_libraries(frame_latency ${COMMON_LIBRARIES}) -ament_target_dependencies(frame_latency ${dependencies}) +target_link_libraries(frame_latency + ${orbbec_camera_msgs_TARGETS} + ${sensor_msgs_TARGETS} + ${tf2_msgs_TARGETS} + diagnostic_updater::diagnostic_updater + rclcpp::rclcpp + rclcpp_components::component +) rclcpp_components_register_node(frame_latency PLUGIN "orbbec_camera::FrameLatencyNode" EXECUTABLE frame_latency_node) add_library(start_benchmark SHARED tools/start_benchmark.cpp) -target_include_directories(start_benchmark PUBLIC ${COMMON_INCLUDE_DIRS}) -target_link_libraries(start_benchmark ${COMMON_LIBRARIES}) -ament_target_dependencies(start_benchmark ${dependencies}) +target_include_directories(start_benchmark PUBLIC ${COMMON_INCLUDE_DIRS} ${image_publisher_INCLUDE_DIRS}) +target_link_libraries(start_benchmark + ${OpenCV_LIBS} + ${orbbec_camera_msgs_TARGETS} + ${sensor_msgs_TARGETS} + ${std_srvs_TARGETS} + camera_info_manager::camera_info_manager + diagnostic_updater::diagnostic_updater + Eigen3::Eigen + image_transport::image_transport + rclcpp::rclcpp + rclcpp_components::component + tf2_ros::tf2_ros +) rclcpp_components_register_node( start_benchmark PLUGIN "orbbec_camera::tools::StartBenchmark" EXECUTABLE start_benchmark_node ) add_library(multi_save_rgbir SHARED tools/multi_save_rgbir.cpp src/utils.cpp) -target_include_directories(multi_save_rgbir PUBLIC ${COMMON_INCLUDE_DIRS}) -target_link_libraries(multi_save_rgbir ${COMMON_LIBRARIES}) -ament_target_dependencies(multi_save_rgbir ${dependencies}) +target_include_directories(multi_save_rgbir PUBLIC ${COMMON_INCLUDE_DIRS} ${image_publisher_INCLUDE_DIRS}) +target_link_directories(multi_save_rgbir PRIVATE ${ORBBEC_LIBS_DIR}) +target_link_libraries(multi_save_rgbir + ${OpenCV_LIBS} + ${orbbec_camera_msgs_TARGETS} + ${sensor_msgs_TARGETS} + ${std_srvs_TARGETS} + camera_info_manager::camera_info_manager + cv_bridge::cv_bridge + diagnostic_updater::diagnostic_updater + Eigen3::Eigen + image_transport::image_transport + OpenSSL::Crypto + OrbbecSDK + rclcpp::rclcpp + rclcpp_components::component + tf2::tf2 + tf2_ros::tf2_ros +) rclcpp_components_register_node( multi_save_rgbir PLUGIN "orbbec_camera::tools::MultiCameraSubscriber" EXECUTABLE multi_save_rgbir_node diff --git a/orbbec_camera/examples/multi_camera_time_sync/image_sync_example_node.cpp b/orbbec_camera/examples/multi_camera_time_sync/image_sync_example_node.cpp old mode 100644 new mode 100755 index 1085e66c..f87032f1 --- a/orbbec_camera/examples/multi_camera_time_sync/image_sync_example_node.cpp +++ b/orbbec_camera/examples/multi_camera_time_sync/image_sync_example_node.cpp @@ -1,8 +1,8 @@ #include #include -#include -#include -#include +#include +#include +#include #if __has_include() #include @@ -56,14 +56,20 @@ class ImageSyncNode : public rclcpp::Node { rclcpp::QoS qos(rclcpp::KeepLast(10)); qos.reliable(); - camera_01_color_sub_.subscribe(this, "/camera_01/color/image_raw", qos.get_rmw_qos_profile()); - camera_01_depth_sub_.subscribe(this, "/camera_01/depth/image_raw", qos.get_rmw_qos_profile()); - camera_02_color_sub_.subscribe(this, "/camera_02/color/image_raw", qos.get_rmw_qos_profile()); - camera_02_depth_sub_.subscribe(this, "/camera_02/depth/image_raw", qos.get_rmw_qos_profile()); - camera_03_color_sub_.subscribe(this, "/camera_03/color/image_raw", qos.get_rmw_qos_profile()); - camera_03_depth_sub_.subscribe(this, "/camera_03/depth/image_raw", qos.get_rmw_qos_profile()); - camera_04_color_sub_.subscribe(this, "/camera_04/color/image_raw", qos.get_rmw_qos_profile()); - camera_04_depth_sub_.subscribe(this, "/camera_04/depth/image_raw", qos.get_rmw_qos_profile()); +#ifdef message_filters_QoS + const rclcpp::QoS qos_prof = qos; +#else + const rmw_qos_profile_t qos_prof = qos.get_rmw_qos_profile(); +#endif + + camera_01_color_sub_.subscribe(this, "/camera_01/color/image_raw", qos_prof); + camera_01_depth_sub_.subscribe(this, "/camera_01/depth/image_raw", qos_prof); + camera_02_color_sub_.subscribe(this, "/camera_02/color/image_raw", qos_prof); + camera_02_depth_sub_.subscribe(this, "/camera_02/depth/image_raw", qos_prof); + camera_03_color_sub_.subscribe(this, "/camera_03/color/image_raw", qos_prof); + camera_03_depth_sub_.subscribe(this, "/camera_03/depth/image_raw", qos_prof); + camera_04_color_sub_.subscribe(this, "/camera_04/color/image_raw", qos_prof); + camera_04_depth_sub_.subscribe(this, "/camera_04/depth/image_raw", qos_prof); sync_ = std::make_shared(SyncPolicy(10), camera_01_color_sub_, camera_01_depth_sub_, diff --git a/orbbec_camera/include/orbbec_camera/d2c_viewer.h b/orbbec_camera/include/orbbec_camera/d2c_viewer.h index 54886a6b..f3e93e39 100644 --- a/orbbec_camera/include/orbbec_camera/d2c_viewer.h +++ b/orbbec_camera/include/orbbec_camera/d2c_viewer.h @@ -14,10 +14,10 @@ * limitations under the License. *******************************************************************************/ #pragma once -#include -#include -#include -#include +#include +#include +#include +#include #include #include diff --git a/orbbec_camera/include/orbbec_camera/ob_camera_node.h b/orbbec_camera/include/orbbec_camera/ob_camera_node.h index e6674459..85340831 100644 --- a/orbbec_camera/include/orbbec_camera/ob_camera_node.h +++ b/orbbec_camera/include/orbbec_camera/ob_camera_node.h @@ -29,11 +29,11 @@ #include #include #include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include #include #include #include @@ -47,7 +47,6 @@ #include "libobsensor/ObSensor.hpp" #include "orbbec_camera_msgs/msg/device_info.hpp" -#include "orbbec_camera_msgs/msg/depth_filter_param.hpp" #include "orbbec_camera_msgs/msg/depth_filter_state.hpp" #include "orbbec_camera_msgs/msg/depth_filters_status.hpp" #include "orbbec_camera_msgs/srv/get_device_info.hpp" diff --git a/orbbec_camera/include/orbbec_camera/ob_lidar_node.h b/orbbec_camera/include/orbbec_camera/ob_lidar_node.h index 06da6341..80115989 100644 --- a/orbbec_camera/include/orbbec_camera/ob_lidar_node.h +++ b/orbbec_camera/include/orbbec_camera/ob_lidar_node.h @@ -31,11 +31,11 @@ #include #include #include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include #include #include #include @@ -48,10 +48,8 @@ #include #include "libobsensor/ObSensor.hpp" -#include "orbbec_camera_msgs/msg/device_info.hpp" #include "orbbec_camera_msgs/srv/get_device_info.hpp" #include "orbbec_camera_msgs/msg/extrinsics.hpp" -#include "orbbec_camera_msgs/msg/metadata.hpp" #include "orbbec_camera_msgs/msg/imu_info.hpp" #include "orbbec_camera_msgs/srv/get_int32.hpp" #include "orbbec_camera_msgs/srv/get_string.hpp" diff --git a/orbbec_camera/include/orbbec_camera/utils.h b/orbbec_camera/include/orbbec_camera/utils.h index 9ed44f82..95ef6cf6 100644 --- a/orbbec_camera/include/orbbec_camera/utils.h +++ b/orbbec_camera/include/orbbec_camera/utils.h @@ -17,7 +17,7 @@ #pragma once #include #include -#include +#include #include #include "libobsensor/ObSensor.hpp" diff --git a/orbbec_camera/package.xml b/orbbec_camera/package.xml index 591f7b70..5c3312d1 100644 --- a/orbbec_camera/package.xml +++ b/orbbec_camera/package.xml @@ -14,10 +14,11 @@ backward_ros image_transport image_publisher + message_filters rclcpp_components cv_bridge camera_info_manager - orbbec_camera_msgs + orbbec_camera_msgs builtin_interfaces rclcpp sensor_msgs diff --git a/orbbec_camera/src/d2c_viewer.cpp b/orbbec_camera/src/d2c_viewer.cpp index d8a52802..0637f3f5 100644 --- a/orbbec_camera/src/d2c_viewer.cpp +++ b/orbbec_camera/src/d2c_viewer.cpp @@ -30,9 +30,21 @@ D2CViewer::D2CViewer(rclcpp::Node* const node, rmw_qos_profile_t rgb_qos, rmw_qos_profile_t depth_qos, bool use_intra_process) : node_(node), logger_(rclcpp::get_logger("d2c_viewer")), is_active_(true) { rgb_sub_ = std::make_shared>( - node_, "color/image_raw", rgb_qos); + node_, "color/image_raw", +#ifdef message_filters_QoS + rclcpp::QoS{rclcpp::QoSInitialization::from_rmw(rgb_qos), rgb_qos} +#else + rgb_qos +#endif + ); depth_sub_ = std::make_shared>( - node_, "depth/image_raw", depth_qos); + node_, "depth/image_raw", +#ifdef message_filters_QoS + rclcpp::QoS{rclcpp::QoSInitialization::from_rmw(depth_qos), depth_qos} +#else + depth_qos +#endif + ); sync_ = std::make_shared>(MySyncPolicy(10), *rgb_sub_, *depth_sub_); sync_->setMaxIntervalDuration(rclcpp::Duration::from_seconds(1.0)); // 1s diff --git a/orbbec_camera/src/image_publisher.cpp b/orbbec_camera/src/image_publisher.cpp index a68d1513..3c90e2af 100644 --- a/orbbec_camera/src/image_publisher.cpp +++ b/orbbec_camera/src/image_publisher.cpp @@ -36,7 +36,19 @@ image_transport_publisher::image_transport_publisher(rclcpp::Node& node, const std::string& topic_name, const rmw_qos_profile_t& qos) { image_publisher_impl = std::make_shared( - image_transport::create_publisher(&node, topic_name, qos)); + image_transport::create_publisher( +#ifdef image_transport_NODE_INTERFACE + image_transport::RequiredInterfaces{node}, +#else + &node, +#endif + topic_name, +#ifdef message_filters_QoS + rclcpp::QoS{rclcpp::QoSInitialization::from_rmw(qos)} +#else + qos +#endif + )); } void image_transport_publisher::publish(sensor_msgs::msg::Image::UniquePtr image_ptr) { image_publisher_impl->publish(*image_ptr); diff --git a/orbbec_camera/tools/multi_save_rgbir.cpp b/orbbec_camera/tools/multi_save_rgbir.cpp index 5efa13be..6496787a 100644 --- a/orbbec_camera/tools/multi_save_rgbir.cpp +++ b/orbbec_camera/tools/multi_save_rgbir.cpp @@ -5,9 +5,9 @@ #include #include "orbbec_camera/ob_camera_node.h" #include "orbbec_camera_msgs/msg/metadata.hpp" -#include -#include -#include +#include +#include +#include #include #include #include diff --git a/orbbec_camera/tools/ob_benchmark.cpp b/orbbec_camera/tools/ob_benchmark.cpp index deccf68d..ccf00993 100644 --- a/orbbec_camera/tools/ob_benchmark.cpp +++ b/orbbec_camera/tools/ob_benchmark.cpp @@ -3,9 +3,9 @@ #include #include #include "orbbec_camera_msgs/msg/metadata.hpp" -#include -#include -#include +#include +#include +#include #include namespace orbbec_camera { diff --git a/orbbec_camera/tools/start_benchmark.cpp b/orbbec_camera/tools/start_benchmark.cpp index b2f76171..084bc863 100644 --- a/orbbec_camera/tools/start_benchmark.cpp +++ b/orbbec_camera/tools/start_benchmark.cpp @@ -3,9 +3,9 @@ #include #include #include "orbbec_camera_msgs/msg/metadata.hpp" -#include -#include -#include +#include +#include +#include #include namespace orbbec_camera { diff --git a/orbbec_camera_msgs/CMakeLists.txt b/orbbec_camera_msgs/CMakeLists.txt index 09dfbf50..f1096ffc 100644 --- a/orbbec_camera_msgs/CMakeLists.txt +++ b/orbbec_camera_msgs/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 3.8) +cmake_minimum_required(VERSION 3.22) project(orbbec_camera_msgs) if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang") diff --git a/orbbec_description/CMakeLists.txt b/orbbec_description/CMakeLists.txt index 7fd8a452..8310ce57 100644 --- a/orbbec_description/CMakeLists.txt +++ b/orbbec_description/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 3.5) +cmake_minimum_required(VERSION 3.22) project(orbbec_description) find_package(ament_cmake REQUIRED)