From faf9c7596c3b5683bdb9a3c4cc762395f5395751 Mon Sep 17 00:00:00 2001 From: Sai Kishor Kothakota Date: Sun, 17 Nov 2024 20:42:06 +0100 Subject: [PATCH] Fix hardware management service tests --- controller_manager/doc/parameters_context.yaml | 14 +++++++------- controller_manager/src/controller_manager.cpp | 5 +++++ .../src/controller_manager_parameters.yaml | 2 -- .../test/test_hardware_management_srvs.cpp | 4 ++-- 4 files changed, 14 insertions(+), 11 deletions(-) diff --git a/controller_manager/doc/parameters_context.yaml b/controller_manager/doc/parameters_context.yaml index f5df997661..a015765c79 100644 --- a/controller_manager/doc/parameters_context.yaml +++ b/controller_manager/doc/parameters_context.yaml @@ -5,14 +5,14 @@ hardware_components_initial_state: | Detailed explanation of each parameter is given below. The full structure of the map is given in the following example: - .. code-block:: yaml + .. code-block:: yaml - hardware_components_initial_state: - unconfigured: - - "arm1" - - "arm2" - inactive: - - "base3" + hardware_components_initial_state: + unconfigured: + - "arm1" + - "arm2" + inactive: + - "base3" diagnostics.threshold.controllers.periodicity: | The ``periodicity`` diagnostics will be published only for the asynchronous controllers, because any affect to the synchronous controllers will be reflected directly in the controller manager's periodicity. diff --git a/controller_manager/src/controller_manager.cpp b/controller_manager/src/controller_manager.cpp index 6ffb154cb4..d9de54ea38 100644 --- a/controller_manager/src/controller_manager.cpp +++ b/controller_manager/src/controller_manager.cpp @@ -415,6 +415,11 @@ void ControllerManager::init_resource_manager(const std::string & robot_descript } }; + if (cm_param_listener_->is_old(*params_)) + { + *params_ = cm_param_listener_->get_params(); + } + // unconfigured (loaded only) set_components_to_state( params_->hardware_components_initial_state.unconfigured, diff --git a/controller_manager/src/controller_manager_parameters.yaml b/controller_manager/src/controller_manager_parameters.yaml index b5f9dfdc0a..dd4bf1bc1b 100644 --- a/controller_manager/src/controller_manager_parameters.yaml +++ b/controller_manager/src/controller_manager_parameters.yaml @@ -11,7 +11,6 @@ controller_manager: type: string_array, default_value: [], description: "Defines which hardware components will be only loaded immediately when controller manager is started.", - read_only: true, validation: { unique<>: null, } @@ -21,7 +20,6 @@ controller_manager: type: string_array, default_value: [], description: "Defines which hardware components will be configured immediately when controller manager is started.", - read_only: true, validation: { unique<>: null, } diff --git a/controller_manager/test/test_hardware_management_srvs.cpp b/controller_manager/test/test_hardware_management_srvs.cpp index c7b67e0cfe..bdd48f15ae 100644 --- a/controller_manager/test/test_hardware_management_srvs.cpp +++ b/controller_manager/test/test_hardware_management_srvs.cpp @@ -65,6 +65,7 @@ class TestControllerManagerHWManagementSrvs : public TestControllerManagerSrvs cm_ = std::make_shared(executor_, TEST_CM_NAME); run_updater_ = false; + SetUpSrvsCMExecutor(); cm_->set_parameter(rclcpp::Parameter( "hardware_components_initial_state.unconfigured", std::vector({TEST_SYSTEM_HARDWARE_NAME}))); @@ -72,11 +73,10 @@ class TestControllerManagerHWManagementSrvs : public TestControllerManagerSrvs "hardware_components_initial_state.inactive", std::vector({TEST_SENSOR_HARDWARE_NAME}))); + std::this_thread::sleep_for(std::chrono::milliseconds(100)); auto msg = std_msgs::msg::String(); msg.data = ros2_control_test_assets::minimal_robot_urdf; cm_->robot_description_callback(msg); - - SetUpSrvsCMExecutor(); } void check_component_fileds(