Skip to content

Commit dc348e0

Browse files
authored
Merge branch 'master' into fix/exclusive_hw_interface_switching
2 parents 6584d6c + 46f8d4d commit dc348e0

File tree

65 files changed

+1713
-392
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

65 files changed

+1713
-392
lines changed

.github/workflows/humble-pre-commit.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@ on:
55
pull_request:
66
branches:
77
- humble
8+
push:
9+
branches:
10+
- humble
811

912
concurrency:
1013
group: ${{ github.workflow }}-${{ github.ref }}

.github/workflows/jazzy-pre-commit.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@ on:
55
pull_request:
66
branches:
77
- jazzy
8+
push:
9+
branches:
10+
- jazzy
811

912
concurrency:
1013
group: ${{ github.workflow }}-${{ github.ref }}

.github/workflows/rolling-pre-commit.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@ on:
55
pull_request:
66
branches:
77
- master
8+
push:
9+
branches:
10+
- master
811

912
concurrency:
1013
group: ${{ github.workflow }}-${{ github.ref }}

.pre-commit-config.yaml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -56,14 +56,14 @@ repos:
5656
args: ["--line-length=99"]
5757

5858
- repo: https://github.com/pycqa/flake8
59-
rev: 7.2.0
59+
rev: 7.3.0
6060
hooks:
6161
- id: flake8
6262
args: ["--extend-ignore=E501"]
6363

6464
# CPP hooks
6565
- repo: https://github.com/pre-commit/mirrors-clang-format
66-
rev: v20.1.5
66+
rev: v20.1.7
6767
hooks:
6868
- id: clang-format
6969
args: ['-fallback-style=none', '-i']
@@ -109,7 +109,7 @@ repos:
109109

110110
# Docs - RestructuredText hooks
111111
- repo: https://github.com/PyCQA/doc8
112-
rev: v1.1.2
112+
rev: v2.0.0
113113
hooks:
114114
- id: doc8
115115
args: ['--max-line-length=100', '--ignore=D001']
@@ -133,7 +133,7 @@ repos:
133133
exclude: CHANGELOG\.rst|\.(svg|pyc|drawio)$
134134

135135
- repo: https://github.com/python-jsonschema/check-jsonschema
136-
rev: 0.33.0
136+
rev: 0.33.1
137137
hooks:
138138
- id: check-github-workflows
139139
args: ["--verbose"]

controller_interface/CHANGELOG.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22
Changelog for package controller_interface
33
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
44

5+
5.3.0 (2025-07-02)
6+
------------------
7+
58
5.2.0 (2025-06-07)
69
------------------
710

controller_interface/package.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<?xml-model href="http://download.ros.org/schema/package_format2.xsd" schematypens="http://www.w3.org/2001/XMLSchema"?>
33
<package format="2">
44
<name>controller_interface</name>
5-
<version>5.2.0</version>
5+
<version>5.3.0</version>
66
<description>Base classes for controllers and syntax cookies for supporting common sensor types in controllers and broadcasters</description>
77
<maintainer email="[email protected]">Bence Magyar</maintainer>
88
<maintainer email="[email protected]">Denis Štogl</maintainer>

controller_manager/CHANGELOG.rst

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,14 @@
22
Changelog for package controller_manager
33
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
44

5+
5.3.0 (2025-07-02)
6+
------------------
7+
* Cleanup old internal API (`#2346 <https://github.com/ros-controls/ros2_control/issues/2346>`_)
8+
* added params approach to allow propagation in gz_ros2_control (`#2340 <https://github.com/ros-controls/ros2_control/issues/2340>`_)
9+
* Deactivate controllers with command interfaces to hardware on DEACTIVATE (`#2334 <https://github.com/ros-controls/ros2_control/issues/2334>`_)
10+
* Shift to Struct based Method and Constructors, with Executor passed from CM to `on_init()` (`#2323 <https://github.com/ros-controls/ros2_control/issues/2323>`_)
11+
* Contributors: Marq Rasmussen, Sai Kishor Kothakota, Soham Patil
12+
513
5.2.0 (2025-06-07)
614
------------------
715
* Move `enforce_command_limits` parameter to GPL parameters (`#2305 <https://github.com/ros-controls/ros2_control/issues/2305>`_)

controller_manager/package.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<?xml-model href="http://download.ros.org/schema/package_format2.xsd" schematypens="http://www.w3.org/2001/XMLSchema"?>
33
<package format="2">
44
<name>controller_manager</name>
5-
<version>5.2.0</version>
5+
<version>5.3.0</version>
66
<description>The main runnable entrypoint of ros2_control and home of controller management and resource management.</description>
77
<maintainer email="[email protected]">Bence Magyar</maintainer>
88
<maintainer email="[email protected]">Denis Štogl</maintainer>

controller_manager/src/controller_manager.cpp

Lines changed: 64 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -410,8 +410,14 @@ ControllerManager::ControllerManager(
410410
robot_description_(urdf)
411411
{
412412
initialize_parameters();
413-
resource_manager_ = std::make_unique<hardware_interface::ResourceManager>(
414-
urdf, trigger_clock_, this->get_logger(), activate_all_hw_components, params_->update_rate);
413+
hardware_interface::ResourceManagerParams params;
414+
params.robot_description = urdf;
415+
params.clock = trigger_clock_;
416+
params.logger = this->get_logger();
417+
params.activate_all = activate_all_hw_components;
418+
params.update_rate = static_cast<unsigned int>(params_->update_rate);
419+
params.executor = executor_;
420+
resource_manager_ = std::make_unique<hardware_interface::ResourceManager>(params, true);
415421
init_controller_manager();
416422
}
417423

@@ -615,7 +621,13 @@ void ControllerManager::init_resource_manager(const std::string & robot_descript
615621
{
616622
resource_manager_->import_joint_limiters(robot_description_);
617623
}
618-
if (!resource_manager_->load_and_initialize_components(robot_description, update_rate_))
624+
hardware_interface::ResourceManagerParams params;
625+
params.robot_description = robot_description;
626+
params.clock = trigger_clock_;
627+
params.logger = this->get_logger();
628+
params.executor = executor_;
629+
params.update_rate = static_cast<unsigned int>(params_->update_rate);
630+
if (!resource_manager_->load_and_initialize_components(params))
619631
{
620632
RCLCPP_WARN(
621633
get_logger(),
@@ -2679,9 +2691,9 @@ std::vector<std::string> ControllerManager::get_controller_names()
26792691
void ControllerManager::read(const rclcpp::Time & time, const rclcpp::Duration & period)
26802692
{
26812693
periodicity_stats_.AddMeasurement(1.0 / period.seconds());
2682-
auto [ok, failed_hardware_names] = resource_manager_->read(time, period);
2694+
auto [result, failed_hardware_names] = resource_manager_->read(time, period);
26832695

2684-
if (!ok)
2696+
if (result != hardware_interface::return_type::OK)
26852697
{
26862698
rt_buffer_.deactivate_controllers_list.clear();
26872699
// Determine controllers to stop
@@ -2948,9 +2960,9 @@ controller_interface::return_type ControllerManager::update(
29482960

29492961
void ControllerManager::write(const rclcpp::Time & time, const rclcpp::Duration & period)
29502962
{
2951-
auto [ok, failed_hardware_names] = resource_manager_->write(time, period);
2963+
auto [result, failed_hardware_names] = resource_manager_->write(time, period);
29522964

2953-
if (!ok)
2965+
if (result == hardware_interface::return_type::ERROR)
29542966
{
29552967
rt_buffer_.deactivate_controllers_list.clear();
29562968
// Determine controllers to stop
@@ -2978,6 +2990,51 @@ void ControllerManager::write(const rclcpp::Time & time, const rclcpp::Duration
29782990
deactivate_controllers(rt_controller_list, rt_buffer_.deactivate_controllers_list);
29792991
// TODO(destogl): do auto-start of broadcasters
29802992
}
2993+
else if (result == hardware_interface::return_type::DEACTIVATE)
2994+
{
2995+
rt_buffer_.deactivate_controllers_list.clear();
2996+
auto loaded_controllers = get_loaded_controllers();
2997+
// Only stop controllers with active command interfaces to the failed_hardware_names
2998+
for (const auto & hardware_name : failed_hardware_names)
2999+
{
3000+
auto controllers = resource_manager_->get_cached_controllers_to_hardware(hardware_name);
3001+
for (const auto & controller : controllers)
3002+
{
3003+
auto controller_spec = std::find_if(
3004+
loaded_controllers.begin(), loaded_controllers.end(),
3005+
[&](const controller_manager::ControllerSpec & spec)
3006+
{ return spec.c->get_name() == controller; });
3007+
if (controller_spec == loaded_controllers.end())
3008+
{
3009+
RCLCPP_WARN(
3010+
get_logger(),
3011+
"Deactivate failed to find controller [%s] in loaded controllers. "
3012+
"This can happen due to multiple returns of 'DEACTIVATE' from [%s] write()",
3013+
controller.c_str(), hardware_name.c_str());
3014+
continue;
3015+
}
3016+
std::vector<std::string> command_interface_names;
3017+
extract_command_interfaces_for_controller(
3018+
*controller_spec, resource_manager_, command_interface_names);
3019+
// if this controller has command interfaces add it to the deactivate_controllers_list
3020+
if (!command_interface_names.empty())
3021+
{
3022+
rt_buffer_.deactivate_controllers_list.push_back(controller);
3023+
}
3024+
}
3025+
}
3026+
RCLCPP_ERROR_EXPRESSION(
3027+
get_logger(), !rt_buffer_.deactivate_controllers_list.empty(),
3028+
"Deactivating controllers [%s] as their command interfaces are tied to DEACTIVATEing "
3029+
"hardware components",
3030+
rt_buffer_.get_concatenated_string(rt_buffer_.deactivate_controllers_list).c_str());
3031+
std::vector<ControllerSpec> & rt_controller_list =
3032+
rt_controllers_wrapper_.update_and_get_used_by_rt_list();
3033+
3034+
perform_hardware_command_mode_change(
3035+
rt_controller_list, {}, rt_buffer_.deactivate_controllers_list, "write");
3036+
deactivate_controllers(rt_controller_list, rt_buffer_.deactivate_controllers_list);
3037+
}
29813038
}
29823039

29833040
std::vector<ControllerSpec> &

0 commit comments

Comments
 (0)