Skip to content

Commit cdd7c74

Browse files
MarqRazzsaikishorchristophfroehlich
authored
[CM] Add option to avoid shutting down on hardware initial state failure (#2230)
--------- Co-authored-by: Sai Kishor Kothakota <[email protected]> Co-authored-by: Christoph Froehlich <[email protected]>
1 parent 73d5dca commit cdd7c74

File tree

3 files changed

+33
-8
lines changed

3 files changed

+33
-8
lines changed

controller_manager/src/controller_manager.cpp

Lines changed: 26 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -657,10 +657,19 @@ void ControllerManager::init_resource_manager(const std::string & robot_descript
657657
resource_manager_->set_component_state(component, state) ==
658658
hardware_interface::return_type::ERROR)
659659
{
660-
throw std::runtime_error(
661-
fmt::format(
662-
FMT_COMPILE("Failed to set the initial state of the component : {} to {}"),
663-
component.c_str(), state.label()));
660+
if (params_->hardware_components_initial_state.shutdown_on_initial_state_failure)
661+
{
662+
throw std::runtime_error(
663+
fmt::format(
664+
FMT_COMPILE("Failed to set the initial state of the component : {} to {}"),
665+
component.c_str(), state.label()));
666+
}
667+
else
668+
{
669+
RCLCPP_ERROR(
670+
get_logger(), "Failed to set the initial state of the component : '%s' to '%s'",
671+
component.c_str(), state.label().c_str());
672+
}
664673
}
665674
components_to_activate.erase(component);
666675
}
@@ -693,10 +702,19 @@ void ControllerManager::init_resource_manager(const std::string & robot_descript
693702
resource_manager_->set_component_state(component, active_state) ==
694703
hardware_interface::return_type::ERROR)
695704
{
696-
throw std::runtime_error(
697-
fmt::format(
698-
FMT_COMPILE("Failed to set the initial state of the component : {} to {}"),
699-
component.c_str(), active_state.label()));
705+
if (params_->hardware_components_initial_state.shutdown_on_initial_state_failure)
706+
{
707+
throw std::runtime_error(
708+
fmt::format(
709+
FMT_COMPILE("Failed to set the initial state of the component : {} to {}"),
710+
component.c_str(), active_state.label()));
711+
}
712+
else
713+
{
714+
RCLCPP_ERROR(
715+
get_logger(), "Failed to set the initial state of the component : '%s' to '%s'",
716+
component.c_str(), active_state.label().c_str());
717+
}
700718
}
701719
}
702720
robot_description_notification_timer_->cancel();

controller_manager/src/controller_manager_parameters.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,12 @@ controller_manager:
2525
}
2626
}
2727

28+
shutdown_on_initial_state_failure: {
29+
type: bool,
30+
default_value: false,
31+
description: "Specifies whether the controller manager should shut down if setting the desired initial state fails during startup.",
32+
}
33+
2834
defaults:
2935
switch_controller:
3036
strictness: {

doc/release_notes.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ This list summarizes the changes between Jazzy (previous) and Kilted (current) r
88
controller_manager
99
******************
1010
* The default strictness of the ``swtich_controllers`` can now we be chosen using ROS 2 parameters. The default behaviour is still left to ``BEST_EFFORT`` (`#2168 <https://github.com/ros-controls/ros2_control/pull/2168>`_).
11+
* Parameter ``shutdown_on_initial_state_failure`` was added to avoid shutting down on hardware initial state failure (`#2330 <https://github.com/ros-controls/ros2_control/pull/2330>`_).
1112

1213
ros2controlcli
1314
**************

0 commit comments

Comments
 (0)