Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feature] Fallback controllers #1789

Merged

Conversation

saikishor
Copy link
Member

@saikishor saikishor commented Oct 12, 2024

We already introduced the necessary information for setting up the fallback controllers via (#1499 and #1503). This PR aims to complete the Fallback controllers feature (When a controller is returning ERROR in the update cycle, it will be deactivated and any fallback controllers linked to this controller will be activated)

This PR has the main logic to have the fallback controllers working, pending some tests

Closes #1468

add fallback controllers list to the ControllerInterfaceBase

do not activate the controller if it's fallback controllers are not found or not in inactive state

add formatting changes

added the first logic of switching to the fallback controller upon error

Added a method to get the active controllers that use the command interfaces of the given controller

Compute the complete list of active controllers that already use the command interfaces needed by the fallback controllers

added fixes for the compilation

retouch for the new structure
Copy link

codecov bot commented Oct 13, 2024

Codecov Report

Attention: Patch coverage is 94.93671% with 28 lines in your changes missing coverage. Please review.

Project coverage is 87.29%. Comparing base (0ba1428) to head (5c2d2d5).
Report is 3 commits behind head on master.

Files with missing lines Patch % Lines
controller_manager/src/controller_manager.cpp 82.29% 5 Missing and 12 partials ⚠️
...ontroller_manager/test/test_controller_manager.cpp 97.57% 10 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1789      +/-   ##
==========================================
+ Coverage   86.83%   87.29%   +0.45%     
==========================================
  Files         121      121              
  Lines       11542    12093     +551     
  Branches     1054     1079      +25     
==========================================
+ Hits        10023    10557     +534     
- Misses       1144     1148       +4     
- Partials      375      388      +13     
Flag Coverage Δ
unittests 87.29% <94.93%> (+0.45%) ⬆️

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 100.00% <100.00%> (ø)
...r_manager/test/test_controller/test_controller.cpp 95.55% <100.00%> (+0.20%) ⬆️
...r_manager/test/test_controller/test_controller.hpp 100.00% <ø> (ø)
...ontroller_manager/test/test_controller_manager.cpp 96.59% <97.57%> (+2.72%) ⬆️
controller_manager/src/controller_manager.cpp 77.70% <82.29%> (+1.02%) ⬆️

... and 1 file with indirect coverage changes

@saikishor saikishor marked this pull request as ready for review October 14, 2024 21:47
Comment on lines +2432 to +2433
std::string controllers_string;
controllers_string.reserve(500);
Copy link
Member

Choose a reason for hiding this comment

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

quite interesting that there isn't a pre-reserve constructor for strings...

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes it sucks. I want to optimize all of these sooner in the following PRs

Copy link
Member

Choose a reason for hiding this comment

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

Can't we pre-reserve all of this?

bmagyar
bmagyar previously approved these changes Oct 16, 2024
Co-authored-by: Bence Magyar <bence.magyar.robotics@gmail.com>
Copy link
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.

Looks good. We should proceed and then optimize the vector and string initialization part.

std::string failed_controllers;
const auto FALLBACK_STACK_MAX_SIZE = 500;
std::vector<std::string> active_controllers_using_interfaces(failed_controllers_list);
active_controllers_using_interfaces.reserve(FALLBACK_STACK_MAX_SIZE);
Copy link
Member

Choose a reason for hiding this comment

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

We are here in update, can we pre-reserve this?

This can be also done in a follow-up PR, but we should make sure that it is resolved.

Comment on lines +2432 to +2433
std::string controllers_string;
controllers_string.reserve(500);
Copy link
Member

Choose a reason for hiding this comment

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

Can't we pre-reserve all of this?

@destogl destogl merged commit 4eabd25 into ros-controls:master Oct 16, 2024
21 checks passed
@destogl
Copy link
Member

destogl commented Oct 16, 2024

Merging this as discussed with @bmagyar. We should then optimize the memory allocation

@saikishor saikishor deleted the feature/fallback_controllers branch October 16, 2024 21:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Fallback controllers
3 participants