Skip to content

Commit

Permalink
Fix RessourceManager constructor (#30)
Browse files Browse the repository at this point in the history
* Fix rm() constructor
* Enable CI on jazzy/rolling
* Add macro to check hardware_interface version
---------

Co-authored-by: JafarAbdi <[email protected]>
  • Loading branch information
christophfroehlich and JafarAbdi authored Dec 12, 2024
1 parent eecda6e commit de05896
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 6 deletions.
10 changes: 4 additions & 6 deletions .github/workflows/build_and_test.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# This config uses industrial_ci (https://github.com/ros-industrial/industrial_ci.git).
# For troubleshooting, see readme (https://github.com/ros-industrial/industrial_ci/blob/master/README.rst)

name: Build and Test (humble)
name: Build and Test

# This determines when this workflow is run
on:
Expand All @@ -20,15 +20,13 @@ jobs:
fail-fast: false
matrix:
env:
- CI_NAME: build-and-test
# TODO: Enable clang-tidy it's failing to errors unrelated to this repo
# - CI_NAME: clang-tidy
# CLANG_TIDY: true
- ROS_DISTRO: jazzy
- ROS_DISTRO: humble
- ROS_DISTRO: rolling

env:
CCACHE_DIR: /github/home/.ccache
CXXFLAGS: "-Wall -Wextra -Wwrite-strings -Wunreachable-code -Wpointer-arith -Wredundant-decls"
ROS_DISTRO: humble
ROS_REPO: main

runs-on: ubuntu-latest
Expand Down
6 changes: 6 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,12 @@ if(BUILD_TESTING)
target_link_libraries(topic_based_system_test
${PROJECT_NAME})
ament_target_dependencies(topic_based_system_test ${THIS_PACKAGE_INCLUDE_DEPENDS} ros2_control_test_assets)
target_compile_definitions(
topic_based_system_test
PRIVATE
HARDWARE_INTERFACE_VERSION_MAJOR=${hardware_interface_VERSION_MAJOR}
HARDWARE_INTERFACE_VERSION_MINOR=${hardware_interface_VERSION_MINOR}
HARDWARE_INTERFACE_VERSION_PATCH=${hardware_interface_VERSION_PATCH})
endif()

pluginlib_export_plugin_description_file(hardware_interface topic_based_ros2_control_plugin_description.xml)
Expand Down
14 changes: 14 additions & 0 deletions test/topic_based_system_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,15 @@

#include <gtest/gtest.h>
#include <hardware_interface/resource_manager.hpp>
#include <rclcpp/node.hpp>
#include <rclcpp/utilities.hpp>
#include <rclcpp_lifecycle/state.hpp>
#include <ros2_control_test_assets/descriptions.hpp>

#define VERSION_GREATER_EQUAL(major1, minor1, patch1, major2, minor2, patch2) \
((major1) > (major2) || \
((major1) == (major2) && ((minor1) > (minor2) || ((minor1) == (minor2) && (patch1) >= (patch2)))))

TEST(TestTopicBasedSystem, load_topic_based_system_2dof)
{
const std::string hardware_system_2dof_standard_interfaces_with_topic_based =
Expand All @@ -63,7 +68,16 @@ TEST(TestTopicBasedSystem, load_topic_based_system_2dof)
)";
auto urdf = ros2_control_test_assets::urdf_head + hardware_system_2dof_standard_interfaces_with_topic_based +
ros2_control_test_assets::urdf_tail;
auto node = std::make_shared<rclcpp::Node>("test_topic_based_system");

// The API of the RessourceManager has changed in hardware_interface 4.13.0
#if VERSION_GREATER_EQUAL(HARDWARE_INTERFACE_VERSION_MAJOR, HARDWARE_INTERFACE_VERSION_MINOR, \
HARDWARE_INTERFACE_VERSION_PATCH, 4, 13, 0)
ASSERT_NO_THROW(hardware_interface::ResourceManager rm(urdf, node->get_node_clock_interface(),
node->get_node_logging_interface(), false));
#else
ASSERT_NO_THROW(hardware_interface::ResourceManager rm(urdf, true, false));
#endif
}

int main(int argc, char** argv)
Expand Down

0 comments on commit de05896

Please sign in to comment.