From 730e91b749c84fc318418b2bf2ec562d1453f2d1 Mon Sep 17 00:00:00 2001 From: Bence Magyar Date: Wed, 2 Oct 2024 19:22:35 +0100 Subject: [PATCH] shared_ptr -> X::SharedPtr --- .../chainable_controller_interface.hpp | 14 ++++++-------- .../controller_interface/controller_interface.hpp | 5 ++--- .../controller_interface_base.hpp | 5 ++--- .../src/chainable_controller_interface.cpp | 10 +++++----- controller_interface/src/controller_interface.cpp | 4 ++-- .../test/test_chainable_controller_interface.cpp | 4 ++-- controller_manager/src/controller_manager.cpp | 4 ++-- .../test/test_resource_manager.cpp | 2 +- 8 files changed, 22 insertions(+), 26 deletions(-) diff --git a/controller_interface/include/controller_interface/chainable_controller_interface.hpp b/controller_interface/include/controller_interface/chainable_controller_interface.hpp index 3aa2f2ad3d..912e224c74 100644 --- a/controller_interface/include/controller_interface/chainable_controller_interface.hpp +++ b/controller_interface/include/controller_interface/chainable_controller_interface.hpp @@ -59,11 +59,10 @@ class ChainableControllerInterface : public ControllerInterfaceBase bool is_chainable() const final; CONTROLLER_INTERFACE_PUBLIC - std::vector> export_state_interfaces() final; + std::vector export_state_interfaces() final; CONTROLLER_INTERFACE_PUBLIC - std::vector> export_reference_interfaces() - final; + std::vector export_reference_interfaces() final; CONTROLLER_INTERFACE_PUBLIC bool set_chained_mode(bool chained_mode) final; @@ -134,9 +133,8 @@ class ChainableControllerInterface : public ControllerInterfaceBase /// Storage of values for state interfaces std::vector exported_state_interface_names_; - std::vector> - ordered_exported_state_interfaces_; - std::unordered_map> + std::vector ordered_exported_state_interfaces_; + std::unordered_map exported_state_interfaces_; // BEGIN (Handle export change): for backward compatibility std::vector state_interfaces_values_; @@ -147,8 +145,8 @@ class ChainableControllerInterface : public ControllerInterfaceBase // BEGIN (Handle export change): for backward compatibility std::vector reference_interfaces_; // END - std::vector> ordered_reference_interfaces_; - std::unordered_map> + std::vector ordered_reference_interfaces_; + std::unordered_map reference_interfaces_ptrs_; private: diff --git a/controller_interface/include/controller_interface/controller_interface.hpp b/controller_interface/include/controller_interface/controller_interface.hpp index b1e7afbfc0..5c321b0e42 100644 --- a/controller_interface/include/controller_interface/controller_interface.hpp +++ b/controller_interface/include/controller_interface/controller_interface.hpp @@ -47,7 +47,7 @@ class ControllerInterface : public controller_interface::ControllerInterfaceBase * \returns empty list. */ CONTROLLER_INTERFACE_PUBLIC - std::vector> export_state_interfaces() final; + std::vector export_state_interfaces() final; /** * Controller has no reference interfaces. @@ -55,8 +55,7 @@ class ControllerInterface : public controller_interface::ControllerInterfaceBase * \returns empty list. */ CONTROLLER_INTERFACE_PUBLIC - std::vector> export_reference_interfaces() - final; + std::vector export_reference_interfaces() final; /** * Controller is not chainable, therefore no chained mode can be set. diff --git a/controller_interface/include/controller_interface/controller_interface_base.hpp b/controller_interface/include/controller_interface/controller_interface_base.hpp index ec82334b3a..1f350abeef 100644 --- a/controller_interface/include/controller_interface/controller_interface_base.hpp +++ b/controller_interface/include/controller_interface/controller_interface_base.hpp @@ -235,7 +235,7 @@ class ControllerInterfaceBase : public rclcpp_lifecycle::node_interfaces::Lifecy * \returns list of command interfaces for preceding controllers. */ CONTROLLER_INTERFACE_PUBLIC - virtual std::vector> + virtual std::vector export_reference_interfaces() = 0; /** @@ -245,8 +245,7 @@ class ControllerInterfaceBase : public rclcpp_lifecycle::node_interfaces::Lifecy * \returns list of state interfaces for preceding controllers. */ CONTROLLER_INTERFACE_PUBLIC - virtual std::vector> - export_state_interfaces() = 0; + virtual std::vector export_state_interfaces() = 0; /** * Set chained mode of a chainable controller. This method triggers internal processes to switch diff --git a/controller_interface/src/chainable_controller_interface.cpp b/controller_interface/src/chainable_controller_interface.cpp index e5c5172065..06ba17a30d 100644 --- a/controller_interface/src/chainable_controller_interface.cpp +++ b/controller_interface/src/chainable_controller_interface.cpp @@ -44,11 +44,11 @@ return_type ChainableControllerInterface::update( return ret; } -std::vector> +std::vector ChainableControllerInterface::export_state_interfaces() { auto state_interfaces = on_export_state_interfaces(); - std::vector> state_interfaces_ptrs_vec; + std::vector state_interfaces_ptrs_vec; state_interfaces_ptrs_vec.reserve(state_interfaces.size()); ordered_exported_state_interfaces_.reserve(state_interfaces.size()); exported_state_interface_names_.reserve(state_interfaces.size()); @@ -94,11 +94,11 @@ ChainableControllerInterface::export_state_interfaces() return state_interfaces_ptrs_vec; } -std::vector> +std::vector ChainableControllerInterface::export_reference_interfaces() { auto reference_interfaces = on_export_reference_interfaces(); - std::vector> reference_interfaces_ptrs_vec; + std::vector reference_interfaces_ptrs_vec; reference_interfaces_ptrs_vec.reserve(reference_interfaces.size()); exported_reference_interface_names_.reserve(reference_interfaces.size()); ordered_reference_interfaces_.reserve(reference_interfaces.size()); @@ -134,7 +134,7 @@ ChainableControllerInterface::export_reference_interfaces() throw std::runtime_error(error_msg); } - std::shared_ptr reference_interface = + hardware_interface::CommandInterface::SharedPtr reference_interface = std::make_shared(std::move(interface)); const auto inteface_name = reference_interface->get_name(); // check the exported interface name is unique diff --git a/controller_interface/src/controller_interface.cpp b/controller_interface/src/controller_interface.cpp index 58c1c53496..4a22d78666 100644 --- a/controller_interface/src/controller_interface.cpp +++ b/controller_interface/src/controller_interface.cpp @@ -22,13 +22,13 @@ ControllerInterface::ControllerInterface() : ControllerInterfaceBase() {} bool ControllerInterface::is_chainable() const { return false; } -std::vector> +std::vector ControllerInterface::export_state_interfaces() { return {}; } -std::vector> +std::vector ControllerInterface::export_reference_interfaces() { return {}; diff --git a/controller_interface/test/test_chainable_controller_interface.cpp b/controller_interface/test/test_chainable_controller_interface.cpp index 8918b7178e..5233fe0278 100644 --- a/controller_interface/test/test_chainable_controller_interface.cpp +++ b/controller_interface/test/test_chainable_controller_interface.cpp @@ -89,13 +89,13 @@ TEST_F(ChainableControllerInterfaceTest, interfaces_prefix_is_not_node_name) controller.set_name_prefix_of_reference_interfaces("some_not_correct_interface_prefix"); // expect empty return because interface prefix is not equal to the node name - std::vector> exported_reference_interfaces; + std::vector exported_reference_interfaces; EXPECT_THROW( { exported_reference_interfaces = controller.export_reference_interfaces(); }, std::runtime_error); ASSERT_THAT(exported_reference_interfaces, IsEmpty()); // expect empty return because interface prefix is not equal to the node name - std::vector> exported_state_interfaces; + std::vector exported_state_interfaces; EXPECT_THROW( { exported_state_interfaces = controller.export_state_interfaces(); }, std::runtime_error); ASSERT_THAT(exported_state_interfaces, IsEmpty()); diff --git a/controller_manager/src/controller_manager.cpp b/controller_manager/src/controller_manager.cpp index 000d863dcc..bad55e2e1c 100644 --- a/controller_manager/src/controller_manager.cpp +++ b/controller_manager/src/controller_manager.cpp @@ -771,8 +771,8 @@ controller_interface::return_type ControllerManager::configure_controller( get_logger(), "Controller '%s' is chainable. Interfaces are being exported to resource manager.", controller_name.c_str()); - std::vector> state_interfaces; - std::vector> ref_interfaces; + std::vector state_interfaces; + std::vector ref_interfaces; try { state_interfaces = controller->export_state_interfaces(); diff --git a/hardware_interface_testing/test/test_resource_manager.cpp b/hardware_interface_testing/test/test_resource_manager.cpp index f932c610fe..e72a4a8214 100644 --- a/hardware_interface_testing/test/test_resource_manager.cpp +++ b/hardware_interface_testing/test/test_resource_manager.cpp @@ -1230,7 +1230,7 @@ TEST_F(ResourceManagerTest, managing_controllers_reference_interfaces) CONTROLLER_NAME + "/" + REFERENCE_INTERFACE_NAMES[1], CONTROLLER_NAME + "/" + REFERENCE_INTERFACE_NAMES[2]}; - std::vector> reference_interfaces; + std::vector reference_interfaces; std::vector reference_interface_values = {1.0, 2.0, 3.0}; for (size_t i = 0; i < REFERENCE_INTERFACE_NAMES.size(); ++i)