From 84adf5a24ad0dd67406b02b785c90f0e5b8f1e1b Mon Sep 17 00:00:00 2001 From: Kronk Bot <4156439+kronk-bot[bot]@users.noreply.github.com> Date: Tue, 8 Sep 2026 22:00:23 +0000 Subject: [PATCH] fix: support current ROS distributions --- .github/workflows/build_and_test.yaml | 20 +++++++++++++------ CMakeLists.txt | 12 ++++++++--- .../topic_based_system.hpp | 9 +++++++++ src/topic_based_system.cpp | 6 ++++++ 4 files changed, 38 insertions(+), 9 deletions(-) diff --git a/.github/workflows/build_and_test.yaml b/.github/workflows/build_and_test.yaml index c08035a..71a3b57 100644 --- a/.github/workflows/build_and_test.yaml +++ b/.github/workflows/build_and_test.yaml @@ -3,6 +3,9 @@ name: Build and Test +permissions: + contents: read + # This determines when this workflow is run on: workflow_dispatch: @@ -16,27 +19,32 @@ on: jobs: industrial_ci: + name: industrial_ci (${{ matrix.env.ROS_DISTRO }}) strategy: fail-fast: false matrix: env: - - ROS_DISTRO: jazzy - ROS_DISTRO: humble + ROS_REPO: main + - ROS_DISTRO: jazzy + ROS_REPO: main + - ROS_DISTRO: lyrical + ROS_REPO: main - ROS_DISTRO: rolling + ROS_REPO: testing env: CCACHE_DIR: /github/home/.ccache CXXFLAGS: "-Wall -Wextra -Wwrite-strings -Wunreachable-code -Wpointer-arith -Wredundant-decls" - ROS_REPO: main runs-on: ubuntu-latest steps: - - uses: actions/checkout@v4 + - uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4 # This step will fetch/store the directory used by ccache before/after the ci run - - uses: actions/cache@v4 + - uses: actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830 # v4 with: path: ${{ env.CCACHE_DIR }} - key: ccache-{{ matrix.env.ROS_DISTRO }}-{{ matrix.env.ROS_REPO }} + key: ccache-${{ matrix.env.ROS_DISTRO }}-${{ matrix.env.ROS_REPO }} # Run industrial_ci - - uses: 'ros-industrial/industrial_ci@master' + - uses: ros-industrial/industrial_ci@125164b9f1883cdf1858897a7146d1bebf2be5c6 # master env: ${{ matrix.env }} diff --git a/CMakeLists.txt b/CMakeLists.txt index 7b8bb21..feb6b0e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -29,7 +29,12 @@ add_library( ${PROJECT_NAME} src/topic_based_system.cpp ) -ament_target_dependencies(${PROJECT_NAME} ${THIS_PACKAGE_INCLUDE_DEPENDS}) +target_link_libraries(${PROJECT_NAME} PUBLIC + angles::angles + hardware_interface::hardware_interface + rclcpp::rclcpp + ${sensor_msgs_TARGETS} +) target_include_directories(${PROJECT_NAME} PUBLIC $ $) @@ -69,8 +74,9 @@ if(BUILD_TESTING) # GTests ament_add_gtest(topic_based_system_test test/topic_based_system_test.cpp) target_link_libraries(topic_based_system_test - ${PROJECT_NAME}) - ament_target_dependencies(topic_based_system_test ${THIS_PACKAGE_INCLUDE_DEPENDS} ros2_control_test_assets) + ${PROJECT_NAME} + ros2_control_test_assets::ros2_control_test_assets + ) # Integration tests add_ros_test( diff --git a/include/topic_based_ros2_control/topic_based_system.hpp b/include/topic_based_ros2_control/topic_based_system.hpp index cf67d61..5ecff17 100644 --- a/include/topic_based_ros2_control/topic_based_system.hpp +++ b/include/topic_based_ros2_control/topic_based_system.hpp @@ -40,6 +40,11 @@ #include #include #include +#if __has_include() +#include +#else +#include +#endif #include #include #include @@ -55,7 +60,11 @@ using CallbackReturn = rclcpp_lifecycle::node_interfaces::LifecycleNodeInterface class TopicBasedSystem : public hardware_interface::SystemInterface { public: +#if HARDWARE_INTERFACE_VERSION_GTE(6, 0, 0) + CallbackReturn on_init(const hardware_interface::HardwareComponentInterfaceParams& params) override; +#else CallbackReturn on_init(const hardware_interface::HardwareInfo& info) override; +#endif std::vector export_state_interfaces() override; diff --git a/src/topic_based_system.cpp b/src/topic_based_system.cpp index 67a9ec9..bc8fffc 100644 --- a/src/topic_based_system.cpp +++ b/src/topic_based_system.cpp @@ -61,9 +61,15 @@ static constexpr std::size_t VELOCITY_INTERFACE_INDEX = 1; // JointState doesn't contain an acceleration field, so right now it's not used static constexpr std::size_t EFFORT_INTERFACE_INDEX = 3; +#if HARDWARE_INTERFACE_VERSION_GTE(6, 0, 0) +CallbackReturn TopicBasedSystem::on_init(const hardware_interface::HardwareComponentInterfaceParams& params) +{ + if (hardware_interface::SystemInterface::on_init(params) != CallbackReturn::SUCCESS) +#else CallbackReturn TopicBasedSystem::on_init(const hardware_interface::HardwareInfo& info) { if (hardware_interface::SystemInterface::on_init(info) != CallbackReturn::SUCCESS) +#endif { return CallbackReturn::ERROR; }