Skip to content

Controller Manager recovery from invalid URDF errors#2775

Open
VitezGabriela wants to merge 30 commits intoros-controls:masterfrom
b-robotized-forks:feature/invalid-urdf-cm-recovery
Open

Controller Manager recovery from invalid URDF errors#2775
VitezGabriela wants to merge 30 commits intoros-controls:masterfrom
b-robotized-forks:feature/invalid-urdf-cm-recovery

Conversation

@VitezGabriela
Copy link
Copy Markdown

Goal:

Update the Controller Manager to handle errors when the ResourceManager fails to initialize due to an invalid URDF or faulty hardware plugin.

Behavior:

  • Catch exceptions caused by parsing invalid URDFs during initialization
  • Log error messages
  • Reset the resource_manager_ pointer to a minimal, safe state.
  • Continue waiting for a valid robot_description to be published

Observations:

The Controller Manager now no longer crashes on invalid URDFs. Instead, it safely recovers by initializing the resource_manager_ pointer to a minimal state, allowing the controller manager to continue operating and respond to future valid robot descriptions.

Testing:
Unit tests were created with multiple invalid URDF scenarios. All tests passed successfully. Testing can be done by executing:
./build/controller_manager/test_controller_manager_with_resource_manager

@mergify
Copy link
Copy Markdown
Contributor

mergify bot commented Nov 3, 2025

@VitezGabriela, all pull requests must be targeted towards the master development branch.
Once merged into master, it is possible to backport to jazzy, but it must be in master
to have these changes reflected into new distributions.

@destogl destogl changed the base branch from jazzy to master November 3, 2025 17:26
@mergify
Copy link
Copy Markdown
Contributor

mergify bot commented Nov 3, 2025

This pull request is in conflict. Could you fix it @VitezGabriela?

@VitezGabriela VitezGabriela force-pushed the feature/invalid-urdf-cm-recovery branch from 194ed06 to f5d9c81 Compare November 3, 2025 18:04
Comment thread controller_manager/CMakeLists.txt Outdated
Comment thread controller_manager/CMakeLists.txt Outdated
Comment thread controller_manager/include/controller_manager/controller_manager.hpp Outdated
Comment thread controller_manager/package.xml Outdated
Comment thread controller_manager/src/controller_manager.cpp Outdated
Comment thread controller_manager/src/controller_manager.cpp Outdated
Comment thread controller_manager/src/controller_manager.cpp Outdated
Comment thread controller_manager/src/controller_manager.cpp Outdated
Comment thread hardware_interface/src/resource_manager.cpp Outdated
Comment thread controller_manager/include/controller_manager/controller_manager.hpp Outdated
Comment thread controller_manager/src/controller_manager.cpp
Comment thread controller_manager/src/controller_manager.cpp Outdated
Comment thread controller_interface/src/controller_interface_base.cpp
#include <vector>

#include "controller_interface/controller_interface_base.hpp"
#include "controller_manager/controller_manager_parameters.hpp"
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should not move this, as it is not related.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a change merged from master branch.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

still an unrelated change

Comment thread controller_manager/test/test_controller_manager_with_resource_manager.cpp Outdated
Comment thread controller_manager/test/test_controller_manager_with_resource_manager.hpp Outdated
Comment thread hardware_interface/include/hardware_interface/resource_manager.hpp Outdated
Comment thread hardware_interface/src/resource_manager.cpp Outdated
Comment thread ros2_control_test_assets/include/ros2_control_test_assets/descriptions.hpp Outdated
@VitezGabriela VitezGabriela force-pushed the feature/invalid-urdf-cm-recovery branch from 3254bd3 to 0244064 Compare December 8, 2025 14:00
Comment thread controller_manager/src/controller_manager.cpp Outdated
Comment thread controller_manager/src/controller_manager.cpp
Comment thread controller_manager/src/controller_manager.cpp
Comment thread controller_manager/src/controller_manager.cpp Outdated
@codecov
Copy link
Copy Markdown

codecov bot commented Dec 9, 2025

Codecov Report

❌ Patch coverage is 87.32394% with 18 lines in your changes missing coverage. Please review.
✅ Project coverage is 89.03%. Comparing base (60a7244) to head (ce6ade4).

Files with missing lines Patch % Lines
controller_manager/src/controller_manager.cpp 85.50% 5 Missing and 5 partials ⚠️
controller_manager/test/test_hardware_spawner.cpp 0.00% 2 Missing and 1 partial ⚠️
controller_manager/test/test_spawner_unspawner.cpp 0.00% 2 Missing and 1 partial ⚠️
.../test_controller_manager_with_resource_manager.cpp 96.00% 0 Missing and 2 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #2775      +/-   ##
==========================================
- Coverage   89.04%   89.03%   -0.02%     
==========================================
  Files         158      159       +1     
  Lines       19587    19647      +60     
  Branches     1589     1595       +6     
==========================================
+ Hits        17442    17493      +51     
- Misses       1486     1491       +5     
- Partials      659      663       +4     
Flag Coverage Δ
unittests 89.03% <87.32%> (-0.02%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
.../include/controller_manager/controller_manager.hpp 97.29% <ø> (ø)
...er_manager/test/controller_manager_test_common.hpp 89.04% <100.00%> (+0.88%) ⬆️
...est_controller_manager_hardware_error_handling.cpp 100.00% <100.00%> (ø)
...ller_manager/test/test_controller_manager_srvs.cpp 99.44% <100.00%> (-0.01%) ⬇️
...ager/test/test_controller_manager_urdf_passing.cpp 100.00% <100.00%> (ø)
...er/test/test_controller_manager_with_namespace.cpp 100.00% <100.00%> (ø)
...t_controllers_chaining_with_controller_manager.cpp 99.01% <100.00%> (-0.01%) ⬇️
hardware_interface/src/resource_manager.cpp 78.28% <100.00%> (-0.19%) ⬇️
.../test_controller_manager_with_resource_manager.cpp 96.00% <96.00%> (ø)
controller_manager/test/test_hardware_spawner.cpp 96.25% <0.00%> (-3.75%) ⬇️
... and 2 more

... and 1 file with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copy link
Copy Markdown
Member

@destogl destogl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A few smaller comments.

Comment thread controller_manager/include/controller_manager/controller_manager.hpp Outdated
Comment thread controller_manager/include/controller_manager/controller_manager.hpp Outdated
Comment thread controller_manager/src/controller_manager.cpp
Comment thread controller_manager/src/controller_manager.cpp Outdated
Comment thread controller_manager/src/controller_manager.cpp Outdated
Comment thread controller_manager/src/controller_manager.cpp
Comment thread controller_manager/src/controller_manager.cpp
Comment thread controller_manager/src/controller_manager.cpp
Comment thread controller_manager/include/controller_manager/controller_manager.hpp Outdated
Comment thread controller_manager/include/controller_manager/controller_manager.hpp Outdated
Comment thread controller_manager/src/controller_manager.cpp
Comment thread controller_manager/src/controller_manager.cpp
Comment thread controller_manager/src/controller_manager.cpp
Comment thread controller_manager/include/controller_manager/controller_manager.hpp Outdated
Comment thread controller_manager/src/controller_manager.cpp
Comment thread controller_manager/src/controller_manager.cpp Outdated
Comment thread controller_manager/src/controller_manager.cpp
Comment thread controller_manager/src/controller_manager.cpp Outdated
Comment thread controller_manager/src/controller_manager.cpp Outdated
Comment thread controller_manager/src/controller_manager.cpp Outdated
Comment thread controller_manager/src/controller_manager.cpp
Comment thread controller_manager/src/controller_manager.cpp Outdated
@VitezGabriela VitezGabriela requested a review from destogl January 9, 2026 16:46
@destogl destogl force-pushed the feature/invalid-urdf-cm-recovery branch from 8a33671 to ebf2fba Compare March 28, 2026 17:08
@mergify
Copy link
Copy Markdown
Contributor

mergify bot commented Mar 28, 2026

This pull request is in conflict. Could you fix it @VitezGabriela?

Copy link
Copy Markdown
Contributor

@fmauch fmauch left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think, the clang and win builds raise a valid error. Also, fixing the Wreorder warnings might be good.

// TEST_F(ResourceManagerTest, initialization_empty)
// {
// ASSERT_ANY_THROW(TestableResourceManager rm(node_, "");
// }
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What should happen with this test, then?

Copy link
Copy Markdown
Author

@VitezGabriela VitezGabriela Apr 9, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is uncommented now and the test passes.

@christophfroehlich christophfroehlich moved this from WIP to Needs review in Review triage Apr 9, 2026
Copy link
Copy Markdown
Member

@christophfroehlich christophfroehlich left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please fix the clang errors. Earlier windows build failure is not directly related and will hopefully be fixed with #3204

New windows build failure IS related, please fix

[292](https://github.com/ros-controls/ros2_control/actions/runs/24187185504/job/70594996240?pr=2775#step:19:3293)
D:\a\ros2_control\ros2_control\src\ros-controls\ros2_control\controller_manager\test\test_controllers_chaining_with_controller_manager.cpp(125,40): error C2512: 'rclcpp::NodeOptions': no appropriate default constructor available [D:\a\ros2_control\ros2_control\build\controller_manager\test_controllers_chaining_with_controller_manager.vcxproj]

      D:\a\ros2_control\ros2_control\src\ros-controls\ros2_control\controller_manager\test\test_controllers_chaining_with_controller_manager.cpp(125,40):

      Constructor for class 'rclcpp::NodeOptions' is declared 'explicit'

@github-project-automation github-project-automation bot moved this from Needs review to WIP in Review triage Apr 9, 2026
@christophfroehlich christophfroehlich moved this from WIP to Needs review in Review triage Apr 11, 2026
Copy link
Copy Markdown
Member

@christophfroehlich christophfroehlich left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Builds are fine now, thanks. Some high-level comments from my side below.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we add a docstring to the new methods please?

#include <vector>

#include "controller_interface/controller_interface_base.hpp"
#include "controller_manager/controller_manager_parameters.hpp"
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

still an unrelated change

else
use_sim_time_ = this->get_parameter("use_sim_time").as_bool();

if (!this->has_parameter("overruns.print_warnings"))
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't parameter handling be done via generate_parameter_library? for example

overruns:
print_warnings: {
type: bool,
description: "If true, the controller manager will print a warning message to the console if an overrun is detected in its real-time loop (``read``, ``update`` and ``write``). By default, it is set to true, except when used with ``use_sim_time`` parameter set to true.",
}

and see params_ below.

I see this existed in initialize_parameters, but why?

@github-project-automation github-project-automation bot moved this from Needs review to WIP in Review triage Apr 11, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: WIP

Development

Successfully merging this pull request may close these issues.

7 participants