Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
91a189e
Add parameter to allow controllers with inactive hardware components
saikishor Aug 27, 2025
012f519
Add tests for the new parameter
saikishor Aug 28, 2025
92e335f
Update controller_manager/src/controller_manager_parameters.yaml
saikishor Aug 29, 2025
892805f
unify controller manager constructors
saikishor Aug 30, 2025
6756eef
Update controller_manager/src/controller_manager_parameters.yaml
saikishor Sep 1, 2025
f1ef50c
Fix the documentation formaty
saikishor Sep 2, 2025
1251349
Merge branch 'master' into parameterize/controller_switching/inactive…
saikishor Sep 2, 2025
8c23165
Merge branch 'master' into parameterize/controller_switching/inactive…
saikishor Sep 8, 2025
dc6656d
Merge branch 'master' into parameterize/controller_switching/inactive…
christophfroehlich Sep 10, 2025
6bb2a4f
Merge branch 'master' into parameterize/controller_switching/inactive…
saikishor Sep 15, 2025
437fd61
Merge branch 'master' into parameterize/controller_switching/inactive…
saikishor Sep 24, 2025
96bc87d
rename the parameter to allow_controller_activation_with_inactive_har…
saikishor Sep 24, 2025
b04ed0b
Add deactivate_controllers_on_hardware_return_deactivate parameter
saikishor Sep 24, 2025
b577fc1
Merge branch 'master' into parameterize/controller_switching/inactive…
saikishor Sep 24, 2025
eb52840
Update controller_manager/src/controller_manager_parameters.yaml
saikishor Sep 24, 2025
9ddd60d
Add warn expression for the new parameter
saikishor Sep 24, 2025
8dddf74
rename the parameter to deactivate_controllers_on_hardware_self_deact…
saikishor Sep 24, 2025
2f0dbb1
Add release notes
saikishor Sep 24, 2025
43f66b5
Fix the condition
saikishor Sep 24, 2025
9d61643
Apply suggestions from code review
saikishor Sep 25, 2025
1921d20
Update hardware_interface/src/resource_manager.cpp
saikishor Sep 25, 2025
2e83f67
remove the node to fix the shadowing error in clang build
saikishor Sep 25, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions controller_manager/src/controller_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -417,6 +417,8 @@ ControllerManager::ControllerManager(
params.activate_all = activate_all_hw_components;
params.update_rate = static_cast<unsigned int>(params_->update_rate);
params.executor = executor_;
params.allow_control_with_inactive_hardware =
params_->defaults.allow_control_with_inactive_hardware;
resource_manager_ = std::make_unique<hardware_interface::ResourceManager>(params, true);
init_controller_manager();
}
Expand Down
6 changes: 6 additions & 0 deletions controller_manager/src/controller_manager_parameters.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,12 @@ controller_manager:
]],
}
}
allow_control_with_inactive_hardware: {
type: bool,
default_value: false,
read_only: true,
description: "If true, controllers are allowed to claim resources from inactive hardware components. If false, controllers can only claim resources from active hardware components. Moreover, when the hardware component returns DEACTIVATE on read/write cycle, the controllers using those interfaces will continue to run, when the parameter is set to false. If set to true, the controllers using those interfaces will be deactivated.",
Comment thread
saikishor marked this conversation as resolved.
Outdated
Comment thread
saikishor marked this conversation as resolved.
Outdated
}

diagnostics:
threshold:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -631,6 +631,7 @@ class ResourceManager
rclcpp::Clock::SharedPtr get_clock() const;

bool components_are_loaded_and_initialized_ = false;
bool allow_control_with_inactive_hardware_ = false;

mutable std::recursive_mutex resource_interfaces_lock_;
mutable std::recursive_mutex claimed_command_interfaces_lock_;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,19 @@ struct ResourceManagerParams
*/
bool activate_all = false;

/**
* @brief If true, controllers are allowed to claim resources from inactive hardware components.
* If false, controllers can only claim resources from active hardware components.
* Moreover, when the hardware component returns DEACTIVATE on read/write cycle,
* the controllers using those interfaces will continue to run, when the parameter is set to
* false. If set to true, the controllers using those interfaces will be deactivated.
Comment thread
saikishor marked this conversation as resolved.
Outdated
* @warning Allowing control with inactive hardware is not recommended for safety reasons.
* Use with caution only if you really know what you are doing.
* @note This parameter might be deprecated or removed in the future releases. Please use with
* caution.
*/
bool allow_control_with_inactive_hardware = false;

/**
* @brief The update rate (in Hz) of the ControllerManager.
* This can be used by ResourceManager to configure asynchronous hardware components
Expand Down
25 changes: 20 additions & 5 deletions hardware_interface/src/resource_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1397,6 +1397,12 @@ ResourceManager::ResourceManager(
const hardware_interface::ResourceManagerParams & params, bool load)
: resource_storage_(std::make_unique<ResourceStorage>(params.clock, params.logger))
{
RCLCPP_WARN_EXPRESSION(
Comment thread
saikishor marked this conversation as resolved.
params.logger, params.allow_control_with_inactive_hardware,
"The parameter 'allow_control_with_inactive_hardware' is set to true. It is recommended to use "
"the settings to false in order to avoid controllers to use inactive hardware components and "
"to avoid any unexpected behavior. This feature might be removed in future releases.");
allow_control_with_inactive_hardware_ = params.allow_control_with_inactive_hardware;
if (load)
{
load_and_initialize_components(params);
Expand Down Expand Up @@ -1994,7 +2000,8 @@ bool ResourceManager::prepare_command_mode_switch(

const auto & hardware_info_map = resource_storage_->hardware_info_map_;
auto call_prepare_mode_switch =
[&start_interfaces, &stop_interfaces, &hardware_info_map, logger = get_logger()](
[&start_interfaces, &stop_interfaces, &hardware_info_map, logger = get_logger(),
allow_control_with_inactive_hardware = allow_control_with_inactive_hardware_](
auto & components, auto & start_interfaces_buffer, auto & stop_interfaces_buffer)
{
bool ret = true;
Expand All @@ -2012,7 +2019,9 @@ bool ResourceManager::prepare_command_mode_switch(
}
if (
!start_interfaces_buffer.empty() &&
component.get_lifecycle_state().id() == lifecycle_msgs::msg::State::PRIMARY_STATE_INACTIVE)
component.get_lifecycle_state().id() ==
lifecycle_msgs::msg::State::PRIMARY_STATE_INACTIVE &&
!allow_control_with_inactive_hardware)
{
RCLCPP_WARN(
logger, "Component '%s' is in INACTIVE state, but has start interfaces to switch: \n%s",
Expand Down Expand Up @@ -2094,7 +2103,8 @@ bool ResourceManager::perform_command_mode_switch(

const auto & hardware_info_map = resource_storage_->hardware_info_map_;
auto call_perform_mode_switch =
[&start_interfaces, &stop_interfaces, &hardware_info_map, logger = get_logger()](
[&start_interfaces, &stop_interfaces, &hardware_info_map, logger = get_logger(),
allow_control_with_inactive_hardware = allow_control_with_inactive_hardware_](
auto & components, auto & start_interfaces_buffer, auto & stop_interfaces_buffer)
{
bool ret = true;
Expand All @@ -2112,7 +2122,9 @@ bool ResourceManager::perform_command_mode_switch(
}
if (
!start_interfaces_buffer.empty() &&
component.get_lifecycle_state().id() == lifecycle_msgs::msg::State::PRIMARY_STATE_INACTIVE)
component.get_lifecycle_state().id() ==
lifecycle_msgs::msg::State::PRIMARY_STATE_INACTIVE &&
!allow_control_with_inactive_hardware)
{
RCLCPP_WARN(
logger, "Component '%s' is in INACTIVE state, but has start interfaces to switch: \n%s",
Expand Down Expand Up @@ -2495,7 +2507,10 @@ HardwareReadWriteStatus ResourceManager::write(
lifecycle_msgs::msg::State::PRIMARY_STATE_INACTIVE, lifecycle_state_names::INACTIVE);
set_component_state(component_name, inactive_state);
read_write_status.result = ret_val;
read_write_status.failed_hardware_names.push_back(component_name);
if (!allow_control_with_inactive_hardware_)
{
read_write_status.failed_hardware_names.push_back(component_name);
}
}
}
};
Expand Down
Loading