From b478fe5489e60110da183119c03e823c65dbd683 Mon Sep 17 00:00:00 2001 From: "Dr. Denis" Date: Fri, 19 May 2023 11:01:24 +0200 Subject: [PATCH 1/7] Use consequently 'mock' instead of 'fake'. (#1026) (cherry picked from commit 7174a1d1038bf2fbf3529409e2ea44b6ce64f759) # Conflicts: # hardware_interface/include/mock_components/generic_system.hpp # hardware_interface/src/mock_components/generic_system.cpp # hardware_interface/test/mock_components/test_generic_system.cpp --- .../mock_components/generic_system.hpp | 9 +- .../src/mock_components/generic_system.cpp | 69 +++++++--- .../mock_components/test_generic_system.cpp | 126 ++++++++++++++++-- 3 files changed, 173 insertions(+), 31 deletions(-) diff --git a/hardware_interface/include/mock_components/generic_system.hpp b/hardware_interface/include/mock_components/generic_system.hpp index 2ff3f2b4e8..f211839acd 100644 --- a/hardware_interface/include/mock_components/generic_system.hpp +++ b/hardware_interface/include/mock_components/generic_system.hpp @@ -81,12 +81,12 @@ class HARDWARE_INTERFACE_PUBLIC GenericSystem : public hardware_interface::Syste std::vector sensor_interfaces_; /// The size of this vector is (sensor_interfaces_.size() x nr_joints) - std::vector> sensor_fake_commands_; + std::vector> sensor_mock_commands_; std::vector> sensor_states_; std::vector gpio_interfaces_; /// The size of this vector is (gpio_interfaces_.size() x nr_joints) - std::vector> gpio_fake_commands_; + std::vector> gpio_mock_commands_; std::vector> gpio_commands_; std::vector> gpio_states_; @@ -108,8 +108,13 @@ class HARDWARE_INTERFACE_PUBLIC GenericSystem : public hardware_interface::Syste std::vector & interfaces, std::vector> & storage, std::vector & target_interfaces, bool using_state_interfaces); +<<<<<<< HEAD bool use_fake_gpio_command_interfaces_; bool use_fake_sensor_command_interfaces_; +======= + bool use_mock_gpio_command_interfaces_; + bool use_mock_sensor_command_interfaces_; +>>>>>>> 7174a1d (Use consequently 'mock' instead of 'fake'. (#1026)) double position_state_following_offset_; std::string custom_interface_with_following_offset_; diff --git a/hardware_interface/src/mock_components/generic_system.cpp b/hardware_interface/src/mock_components/generic_system.cpp index c7ea2044ed..28323df7d3 100644 --- a/hardware_interface/src/mock_components/generic_system.cpp +++ b/hardware_interface/src/mock_components/generic_system.cpp @@ -66,18 +66,48 @@ CallbackReturn GenericSystem::on_init(const hardware_interface::HardwareInfo & i } else { +<<<<<<< HEAD use_fake_sensor_command_interfaces_ = false; +======= + // check if fake_sensor_commands was set instead and issue warning. + it = info_.hardware_parameters.find("fake_sensor_commands"); + if (it != info_.hardware_parameters.end()) + { + use_mock_sensor_command_interfaces_ = hardware_interface::parse_bool(it->second); + RCUTILS_LOG_WARN_NAMED( + "mock_generic_system", + "Parameter 'fake_sensor_commands' has been deprecated from usage. Use" + "'mock_sensor_commands' instead."); + } + else + { + use_mock_sensor_command_interfaces_ = false; + } +>>>>>>> 7174a1d (Use consequently 'mock' instead of 'fake'. (#1026)) } - // check if to create fake command interface for gpio - it = info_.hardware_parameters.find("fake_gpio_commands"); + // check if to create mock command interface for gpio + it = info_.hardware_parameters.find("mock_gpio_commands"); if (it != info_.hardware_parameters.end()) { - use_fake_gpio_command_interfaces_ = hardware_interface::parse_bool(it->second); + use_mock_gpio_command_interfaces_ = hardware_interface::parse_bool(it->second); } else { - use_fake_gpio_command_interfaces_ = false; + // check if fake_gpio_commands was set instead and issue warning + it = info_.hardware_parameters.find("fake_gpio_commands"); + if (it != info_.hardware_parameters.end()) + { + use_mock_gpio_command_interfaces_ = hardware_interface::parse_bool(it->second); + RCUTILS_LOG_WARN_NAMED( + "mock_generic_system", + "Parameter 'fake_gpio_commands' has been deprecated from usage. Use" + "'mock_gpio_commands' instead."); + } + else + { + use_mock_gpio_command_interfaces_ = false; + } } // process parameters about state following @@ -162,14 +192,14 @@ CallbackReturn GenericSystem::on_init(const hardware_interface::HardwareInfo & i index_custom_interface_with_following_offset_ = std::distance(other_interfaces_.begin(), if_it); RCUTILS_LOG_INFO_NAMED( - "fake_generic_system", "Custom interface with following offset '%s' found at index: %zu.", + "mock_generic_system", "Custom interface with following offset '%s' found at index: %zu.", custom_interface_with_following_offset_.c_str(), index_custom_interface_with_following_offset_); } else { RCUTILS_LOG_WARN_NAMED( - "fake_generic_system", + "mock_generic_system", "Custom interface with following offset '%s' does not exist. Offset will not be applied", custom_interface_with_following_offset_.c_str()); } @@ -188,7 +218,7 @@ CallbackReturn GenericSystem::on_init(const hardware_interface::HardwareInfo & i } } initialize_storage_vectors( - sensor_fake_commands_, sensor_states_, sensor_interfaces_, info_.sensors); + sensor_mock_commands_, sensor_states_, sensor_interfaces_, info_.sensors); // search for gpio interfaces for (const auto & gpio : info_.gpios) @@ -200,10 +230,10 @@ CallbackReturn GenericSystem::on_init(const hardware_interface::HardwareInfo & i populate_non_standard_interfaces(gpio.state_interfaces, gpio_interfaces_); } - // Fake gpio command interfaces - if (use_fake_gpio_command_interfaces_) + // Mock gpio command interfaces + if (use_mock_gpio_command_interfaces_) { - initialize_storage_vectors(gpio_fake_commands_, gpio_states_, gpio_interfaces_, info_.gpios); + initialize_storage_vectors(gpio_mock_commands_, gpio_states_, gpio_interfaces_, info_.gpios); } // Real gpio command interfaces else @@ -283,22 +313,27 @@ std::vector GenericSystem::export_command_ } } +<<<<<<< HEAD // Fake sensor command interfaces if (use_fake_sensor_command_interfaces_) +======= + // Mock sensor command interfaces + if (use_mock_sensor_command_interfaces_) +>>>>>>> 7174a1d (Use consequently 'mock' instead of 'fake'. (#1026)) { if (!populate_interfaces( - info_.sensors, sensor_interfaces_, sensor_fake_commands_, command_interfaces, true)) + info_.sensors, sensor_interfaces_, sensor_mock_commands_, command_interfaces, true)) { throw std::runtime_error( "Interface is not found in the standard nor other list. This should never happen!"); } } - // Fake gpio command interfaces (consider all state interfaces for command interfaces) - if (use_fake_gpio_command_interfaces_) + // Mock gpio command interfaces (consider all state interfaces for command interfaces) + if (use_mock_gpio_command_interfaces_) { if (!populate_interfaces( - info_.gpios, gpio_interfaces_, gpio_fake_commands_, command_interfaces, true)) + info_.gpios, gpio_interfaces_, gpio_mock_commands_, command_interfaces, true)) { throw std::runtime_error( "Interface is not found in the gpio list. This should never happen!"); @@ -377,13 +412,13 @@ return_type GenericSystem::read(const rclcpp::Time & /*time*/, const rclcpp::Dur if (use_fake_sensor_command_interfaces_) { - mirror_command_to_state(sensor_states_, sensor_fake_commands_); + mirror_command_to_state(sensor_states_, sensor_mock_commands_); } // do loopback on all gpio interfaces - if (use_fake_gpio_command_interfaces_) + if (use_mock_gpio_command_interfaces_) { - mirror_command_to_state(gpio_states_, gpio_fake_commands_); + mirror_command_to_state(gpio_states_, gpio_mock_commands_); } else { diff --git a/hardware_interface/test/mock_components/test_generic_system.cpp b/hardware_interface/test/mock_components/test_generic_system.cpp index 93d0d7462b..ca1aa4216d 100644 --- a/hardware_interface/test/mock_components/test_generic_system.cpp +++ b/hardware_interface/test/mock_components/test_generic_system.cpp @@ -38,6 +38,14 @@ const auto PERIOD = rclcpp::Duration::from_seconds(0.01); class TestGenericSystem : public ::testing::Test { +<<<<<<< HEAD +======= +public: + void test_generic_system_with_mimic_joint(std::string & urdf); + void test_generic_system_with_mock_sensor_commands(std::string & urdf); + void test_generic_system_with_mock_gpio_commands(std::string & urdf); + +>>>>>>> 7174a1d (Use consequently 'mock' instead of 'fake'. (#1026)) protected: void SetUp() override { @@ -181,7 +189,7 @@ class TestGenericSystem : public ::testing::Test )"; - hardware_system_2dof_with_sensor_fake_command_ = + hardware_system_2dof_with_sensor_mock_command_ = R"( @@ -210,7 +218,7 @@ class TestGenericSystem : public ::testing::Test )"; - hardware_system_2dof_with_sensor_fake_command_True_ = + hardware_system_2dof_with_sensor_mock_command_True_ = R"( @@ -377,7 +385,41 @@ class TestGenericSystem : public ::testing::Test )"; - valid_urdf_ros2_control_system_robot_with_gpio_fake_command_ = + valid_urdf_ros2_control_system_robot_with_gpio_mock_command_ = + R"( + + + mock_components/GenericSystem + true + + + + + + + 3.45 + + + + + + + 2.78 + + + + + + + + + + + + +)"; + + valid_urdf_ros2_control_system_robot_with_gpio_mock_command_True_ = R"( @@ -453,18 +495,54 @@ class TestGenericSystem : public ::testing::Test std::string hardware_system_2dof_standard_interfaces_; std::string hardware_system_2dof_with_other_interface_; std::string hardware_system_2dof_with_sensor_; - std::string hardware_system_2dof_with_sensor_fake_command_; - std::string hardware_system_2dof_with_sensor_fake_command_True_; + std::string hardware_system_2dof_with_sensor_mock_command_; + std::string hardware_system_2dof_with_sensor_mock_command_True_; std::string hardware_system_2dof_with_mimic_joint_; std::string hardware_system_2dof_standard_interfaces_with_offset_; std::string hardware_system_2dof_standard_interfaces_with_custom_interface_for_offset_; std::string hardware_system_2dof_standard_interfaces_with_custom_interface_for_offset_missing_; std::string valid_urdf_ros2_control_system_robot_with_gpio_; - std::string valid_urdf_ros2_control_system_robot_with_gpio_fake_command_; + std::string valid_urdf_ros2_control_system_robot_with_gpio_mock_command_; + std::string valid_urdf_ros2_control_system_robot_with_gpio_mock_command_True_; std::string sensor_with_initial_value_; std::string gpio_with_initial_value_; }; +<<<<<<< HEAD +======= +// Forward declaration +namespace hardware_interface +{ +class ResourceStorage; +} + +class TestableResourceManager : public hardware_interface::ResourceManager +{ +public: + friend TestGenericSystem; + + FRIEND_TEST(TestGenericSystem, generic_fake_system_2dof_symetric_interfaces); + FRIEND_TEST(TestGenericSystem, generic_system_2dof_symetric_interfaces); + FRIEND_TEST(TestGenericSystem, generic_system_2dof_asymetric_interfaces); + FRIEND_TEST(TestGenericSystem, generic_system_2dof_other_interfaces); + FRIEND_TEST(TestGenericSystem, generic_system_2dof_sensor); + FRIEND_TEST(TestGenericSystem, generic_system_2dof_sensor_mock_command); + FRIEND_TEST(TestGenericSystem, generic_system_2dof_sensor_mock_command_True); + FRIEND_TEST(TestGenericSystem, hardware_system_2dof_with_mimic_joint); + FRIEND_TEST(TestGenericSystem, valid_urdf_ros2_control_system_robot_with_gpio); + FRIEND_TEST(TestGenericSystem, valid_urdf_ros2_control_system_robot_with_gpio_mock_command); + FRIEND_TEST(TestGenericSystem, valid_urdf_ros2_control_system_robot_with_gpio_mock_command_True); + + TestableResourceManager() : hardware_interface::ResourceManager() {} + + TestableResourceManager( + const std::string & urdf, bool validate_interfaces = true, bool activate_all = false) + : hardware_interface::ResourceManager(urdf, validate_interfaces, activate_all) + { + } +}; + +>>>>>>> 7174a1d (Use consequently 'mock' instead of 'fake'. (#1026)) void set_components_state( hardware_interface::ResourceManager & rm, const std::vector & components, const uint8_t state_id, const std::string & state_name) @@ -1034,18 +1112,18 @@ void test_generic_system_with_fake_sensor_commands(std::string urdf) ASSERT_EQ(4.44, sty_c.get_value()); } -TEST_F(TestGenericSystem, generic_system_2dof_sensor_fake_command) +TEST_F(TestGenericSystem, generic_system_2dof_sensor_mock_command) { - auto urdf = ros2_control_test_assets::urdf_head + hardware_system_2dof_with_sensor_fake_command_ + + auto urdf = ros2_control_test_assets::urdf_head + hardware_system_2dof_with_sensor_mock_command_ + ros2_control_test_assets::urdf_tail; test_generic_system_with_fake_sensor_commands(urdf); } -TEST_F(TestGenericSystem, generic_system_2dof_sensor_fake_command_True) +TEST_F(TestGenericSystem, generic_system_2dof_sensor_mock_command_True) { auto urdf = ros2_control_test_assets::urdf_head + - hardware_system_2dof_with_sensor_fake_command_True_ + + hardware_system_2dof_with_sensor_mock_command_True_ + ros2_control_test_assets::urdf_tail; test_generic_system_with_fake_sensor_commands(urdf); @@ -1360,12 +1438,18 @@ TEST_F(TestGenericSystem, valid_urdf_ros2_control_system_robot_with_gpio_) generic_system_functional_test(urdf); } +<<<<<<< HEAD TEST_F(TestGenericSystem, valid_urdf_ros2_control_system_robot_with_gpio_fake_command_) { auto urdf = ros2_control_test_assets::urdf_head + valid_urdf_ros2_control_system_robot_with_gpio_fake_command_ + ros2_control_test_assets::urdf_tail; hardware_interface::ResourceManager rm(urdf); +======= +void TestGenericSystem::test_generic_system_with_mock_gpio_commands(std::string & urdf) +{ + TestableResourceManager rm(urdf); +>>>>>>> 7174a1d (Use consequently 'mock' instead of 'fake'. (#1026)) // check is hardware is started auto status_map = rm.get_components_status(); @@ -1471,7 +1555,25 @@ TEST_F(TestGenericSystem, valid_urdf_ros2_control_system_robot_with_gpio_fake_co ASSERT_EQ(2.22, gpio2_vac_c.get_value()); } -TEST_F(TestGenericSystem, sensor_with_initial_value_) +TEST_F(TestGenericSystem, valid_urdf_ros2_control_system_robot_with_gpio_mock_command) +{ + auto urdf = ros2_control_test_assets::urdf_head + + valid_urdf_ros2_control_system_robot_with_gpio_mock_command_ + + ros2_control_test_assets::urdf_tail; + + test_generic_system_with_mock_gpio_commands(urdf); +} + +TEST_F(TestGenericSystem, valid_urdf_ros2_control_system_robot_with_gpio_mock_command_True) +{ + auto urdf = ros2_control_test_assets::urdf_head + + valid_urdf_ros2_control_system_robot_with_gpio_mock_command_True_ + + ros2_control_test_assets::urdf_tail; + + test_generic_system_with_mock_gpio_commands(urdf); +} + +TEST_F(TestGenericSystem, sensor_with_initial_value) { auto urdf = ros2_control_test_assets::urdf_head + sensor_with_initial_value_ + ros2_control_test_assets::urdf_tail; @@ -1499,7 +1601,7 @@ TEST_F(TestGenericSystem, sensor_with_initial_value_) ASSERT_EQ(0.0, force_z_s.get_value()); } -TEST_F(TestGenericSystem, gpio_with_initial_value_) +TEST_F(TestGenericSystem, gpio_with_initial_value) { auto urdf = ros2_control_test_assets::urdf_head + gpio_with_initial_value_ + ros2_control_test_assets::urdf_tail; From 50a9a58f6e5216db97dc03952a38c9dc9c4fba1a Mon Sep 17 00:00:00 2001 From: "Dr. Denis" Date: Mon, 5 Jun 2023 15:35:04 +0200 Subject: [PATCH 2/7] resolve conflict --- .../include/mock_components/generic_system.hpp | 5 ----- 1 file changed, 5 deletions(-) diff --git a/hardware_interface/include/mock_components/generic_system.hpp b/hardware_interface/include/mock_components/generic_system.hpp index f211839acd..9506139c4a 100644 --- a/hardware_interface/include/mock_components/generic_system.hpp +++ b/hardware_interface/include/mock_components/generic_system.hpp @@ -108,13 +108,8 @@ class HARDWARE_INTERFACE_PUBLIC GenericSystem : public hardware_interface::Syste std::vector & interfaces, std::vector> & storage, std::vector & target_interfaces, bool using_state_interfaces); -<<<<<<< HEAD - bool use_fake_gpio_command_interfaces_; - bool use_fake_sensor_command_interfaces_; -======= bool use_mock_gpio_command_interfaces_; bool use_mock_sensor_command_interfaces_; ->>>>>>> 7174a1d (Use consequently 'mock' instead of 'fake'. (#1026)) double position_state_following_offset_; std::string custom_interface_with_following_offset_; From d4004e330e75ee7d120d75e3eaf28321714a6619 Mon Sep 17 00:00:00 2001 From: "Dr. Denis" Date: Mon, 5 Jun 2023 15:40:03 +0200 Subject: [PATCH 3/7] Resolve conflicts --- .../src/mock_components/generic_system.cpp | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-) diff --git a/hardware_interface/src/mock_components/generic_system.cpp b/hardware_interface/src/mock_components/generic_system.cpp index 28323df7d3..b607c9510b 100644 --- a/hardware_interface/src/mock_components/generic_system.cpp +++ b/hardware_interface/src/mock_components/generic_system.cpp @@ -59,16 +59,13 @@ CallbackReturn GenericSystem::on_init(const hardware_interface::HardwareInfo & i }; // check if to create fake command interface for sensor - auto it = info_.hardware_parameters.find("fake_sensor_commands"); + auto it = info_.hardware_parameters.find("mock_sensor_commands"); if (it != info_.hardware_parameters.end()) { - use_fake_sensor_command_interfaces_ = hardware_interface::parse_bool(it->second); + use_mock_sensor_command_interfaces_ = hardware_interface::parse_bool(it->second); } else { -<<<<<<< HEAD - use_fake_sensor_command_interfaces_ = false; -======= // check if fake_sensor_commands was set instead and issue warning. it = info_.hardware_parameters.find("fake_sensor_commands"); if (it != info_.hardware_parameters.end()) @@ -83,7 +80,6 @@ CallbackReturn GenericSystem::on_init(const hardware_interface::HardwareInfo & i { use_mock_sensor_command_interfaces_ = false; } ->>>>>>> 7174a1d (Use consequently 'mock' instead of 'fake'. (#1026)) } // check if to create mock command interface for gpio @@ -313,13 +309,8 @@ std::vector GenericSystem::export_command_ } } -<<<<<<< HEAD - // Fake sensor command interfaces - if (use_fake_sensor_command_interfaces_) -======= // Mock sensor command interfaces if (use_mock_sensor_command_interfaces_) ->>>>>>> 7174a1d (Use consequently 'mock' instead of 'fake'. (#1026)) { if (!populate_interfaces( info_.sensors, sensor_interfaces_, sensor_mock_commands_, command_interfaces, true)) From ab22cf217428c879c5b265f9ffa0f194ff5fff1c Mon Sep 17 00:00:00 2001 From: "Dr. Denis" Date: Mon, 5 Jun 2023 16:39:38 +0200 Subject: [PATCH 4/7] Update test_generic_system.cpp --- .../test/mock_components/test_generic_system.cpp | 15 --------------- 1 file changed, 15 deletions(-) diff --git a/hardware_interface/test/mock_components/test_generic_system.cpp b/hardware_interface/test/mock_components/test_generic_system.cpp index ca1aa4216d..eff3b4bcad 100644 --- a/hardware_interface/test/mock_components/test_generic_system.cpp +++ b/hardware_interface/test/mock_components/test_generic_system.cpp @@ -38,14 +38,11 @@ const auto PERIOD = rclcpp::Duration::from_seconds(0.01); class TestGenericSystem : public ::testing::Test { -<<<<<<< HEAD -======= public: void test_generic_system_with_mimic_joint(std::string & urdf); void test_generic_system_with_mock_sensor_commands(std::string & urdf); void test_generic_system_with_mock_gpio_commands(std::string & urdf); ->>>>>>> 7174a1d (Use consequently 'mock' instead of 'fake'. (#1026)) protected: void SetUp() override { @@ -508,8 +505,6 @@ class TestGenericSystem : public ::testing::Test std::string gpio_with_initial_value_; }; -<<<<<<< HEAD -======= // Forward declaration namespace hardware_interface { @@ -542,7 +537,6 @@ class TestableResourceManager : public hardware_interface::ResourceManager } }; ->>>>>>> 7174a1d (Use consequently 'mock' instead of 'fake'. (#1026)) void set_components_state( hardware_interface::ResourceManager & rm, const std::vector & components, const uint8_t state_id, const std::string & state_name) @@ -1438,18 +1432,9 @@ TEST_F(TestGenericSystem, valid_urdf_ros2_control_system_robot_with_gpio_) generic_system_functional_test(urdf); } -<<<<<<< HEAD -TEST_F(TestGenericSystem, valid_urdf_ros2_control_system_robot_with_gpio_fake_command_) -{ - auto urdf = ros2_control_test_assets::urdf_head + - valid_urdf_ros2_control_system_robot_with_gpio_fake_command_ + - ros2_control_test_assets::urdf_tail; - hardware_interface::ResourceManager rm(urdf); -======= void TestGenericSystem::test_generic_system_with_mock_gpio_commands(std::string & urdf) { TestableResourceManager rm(urdf); ->>>>>>> 7174a1d (Use consequently 'mock' instead of 'fake'. (#1026)) // check is hardware is started auto status_map = rm.get_components_status(); From 47d43bc6617281d94c1a9080c8158ee19b50e01d Mon Sep 17 00:00:00 2001 From: "Dr. Denis" Date: Tue, 6 Jun 2023 21:56:47 +0200 Subject: [PATCH 5/7] Update generic_system.cpp --- hardware_interface/src/mock_components/generic_system.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/hardware_interface/src/mock_components/generic_system.cpp b/hardware_interface/src/mock_components/generic_system.cpp index b607c9510b..d5b317c517 100644 --- a/hardware_interface/src/mock_components/generic_system.cpp +++ b/hardware_interface/src/mock_components/generic_system.cpp @@ -58,7 +58,7 @@ CallbackReturn GenericSystem::on_init(const hardware_interface::HardwareInfo & i } }; - // check if to create fake command interface for sensor + // check if to create mock command interface for sensor auto it = info_.hardware_parameters.find("mock_sensor_commands"); if (it != info_.hardware_parameters.end()) { @@ -401,7 +401,7 @@ return_type GenericSystem::read(const rclcpp::Time & /*time*/, const rclcpp::Dur } } - if (use_fake_sensor_command_interfaces_) + if (use_mock_sensor_command_interfaces_) { mirror_command_to_state(sensor_states_, sensor_mock_commands_); } From 0dd3b1f11b5c6e93d0ab3b87c6ebc67f5538c267 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Denis=20=C5=A0togl?= Date: Wed, 7 Jun 2023 22:32:20 +0200 Subject: [PATCH 6/7] Test fixes in referencing. --- .../mock_components/test_generic_system.cpp | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/hardware_interface/test/mock_components/test_generic_system.cpp b/hardware_interface/test/mock_components/test_generic_system.cpp index eff3b4bcad..8ebd60e3d7 100644 --- a/hardware_interface/test/mock_components/test_generic_system.cpp +++ b/hardware_interface/test/mock_components/test_generic_system.cpp @@ -39,9 +39,9 @@ const auto PERIOD = rclcpp::Duration::from_seconds(0.01); class TestGenericSystem : public ::testing::Test { public: - void test_generic_system_with_mimic_joint(std::string & urdf); - void test_generic_system_with_mock_sensor_commands(std::string & urdf); - void test_generic_system_with_mock_gpio_commands(std::string & urdf); + void test_generic_system_with_mimic_joint(const std::string & urdf); + void test_generic_system_with_mock_sensor_commands(const std::string & urdf); + void test_generic_system_with_mock_gpio_commands(const std::string & urdf); protected: void SetUp() override @@ -191,7 +191,7 @@ class TestGenericSystem : public ::testing::Test mock_components/GenericSystem - true + true @@ -984,7 +984,7 @@ TEST_F(TestGenericSystem, generic_system_2dof_sensor) ASSERT_EQ(0.33, j2p_c.get_value()); } -void test_generic_system_with_fake_sensor_commands(std::string urdf) +void TestGenericSystem::test_generic_system_with_mock_sensor_commands(const std::string & urdf) { hardware_interface::ResourceManager rm(urdf); // Activate components to get all interfaces available @@ -1111,7 +1111,7 @@ TEST_F(TestGenericSystem, generic_system_2dof_sensor_mock_command) auto urdf = ros2_control_test_assets::urdf_head + hardware_system_2dof_with_sensor_mock_command_ + ros2_control_test_assets::urdf_tail; - test_generic_system_with_fake_sensor_commands(urdf); + test_generic_system_with_mock_sensor_commands(urdf); } TEST_F(TestGenericSystem, generic_system_2dof_sensor_mock_command_True) @@ -1120,10 +1120,10 @@ TEST_F(TestGenericSystem, generic_system_2dof_sensor_mock_command_True) hardware_system_2dof_with_sensor_mock_command_True_ + ros2_control_test_assets::urdf_tail; - test_generic_system_with_fake_sensor_commands(urdf); + test_generic_system_with_mock_sensor_commands(urdf); } -void test_generic_system_with_mimic_joint(std::string urdf) +void TestGenericSystem::test_generic_system_with_mimic_joint(const std::string& urdf) { hardware_interface::ResourceManager rm(urdf); // Activate components to get all interfaces available @@ -1432,7 +1432,7 @@ TEST_F(TestGenericSystem, valid_urdf_ros2_control_system_robot_with_gpio_) generic_system_functional_test(urdf); } -void TestGenericSystem::test_generic_system_with_mock_gpio_commands(std::string & urdf) +void TestGenericSystem::test_generic_system_with_mock_gpio_commands(const std::string & urdf) { TestableResourceManager rm(urdf); From 69f1902c98cb2232a66371ea8cfb961ec79483e4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Denis=20=C5=A0togl?= Date: Wed, 7 Jun 2023 22:54:20 +0200 Subject: [PATCH 7/7] Fix formatting. --- hardware_interface/test/mock_components/test_generic_system.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hardware_interface/test/mock_components/test_generic_system.cpp b/hardware_interface/test/mock_components/test_generic_system.cpp index 8ebd60e3d7..b88646e63e 100644 --- a/hardware_interface/test/mock_components/test_generic_system.cpp +++ b/hardware_interface/test/mock_components/test_generic_system.cpp @@ -1123,7 +1123,7 @@ TEST_F(TestGenericSystem, generic_system_2dof_sensor_mock_command_True) test_generic_system_with_mock_sensor_commands(urdf); } -void TestGenericSystem::test_generic_system_with_mimic_joint(const std::string& urdf) +void TestGenericSystem::test_generic_system_with_mimic_joint(const std::string & urdf) { hardware_interface::ResourceManager rm(urdf); // Activate components to get all interfaces available