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

Add additional checks for non existing and not available interfaces. #1218

Conversation

destogl
Copy link
Member

@destogl destogl commented Dec 12, 2023

Fixing issues where controllers "prepare" and "perform" switch might be called even if HW is not configured which could lead to crashes.
Now only calls with all existing and available interface are allowed and on HW that is in inactive of active state.

@destogl destogl self-assigned this Dec 12, 2023
@destogl destogl added backport-humble This label should be used by maintainers only! Label triggers PR backport to ROS2 humble. backport-iron high-priority labels Dec 12, 2023
@saikishor
Copy link
Member

@destogl can we also get this PR : #1098 into account, as it handles similar cases

@destogl destogl force-pushed the allow-prepare-comand-mode-switch-only-for-existing-and-available-interfaces branch from 19199ac to 37e64a8 Compare December 13, 2023 15:48
@destogl
Copy link
Member Author

destogl commented Dec 13, 2023

Rethinking this in the context of #1098 - I would change #1098, but then we don't have nicely shown all three states... (if this is needed at all) If we go with #1098 then the check in the Resource Manage will become much more complex. I am not sure if I want to go that route because I think that we gain nothing having this complexity. The available interface in the context of controller doesn't make much sense. So I propose that we have the following case:

New behavior:

  • Configured chainable controller: Listed exported interfaces are available and unclaimed
  • Active chainable controller(not in chained mode): Listed exported interfaces are available but unclaimed
  • Active chainable controller(in chained mode): Listed exported interfaces are available and claimed

Copy link

codecov bot commented Dec 13, 2023

Codecov Report

Attention: 29 lines in your changes are missing coverage. Please review.

Comparison is base (477c85d) 47.85% compared to head (1e9f8a6) 48.02%.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1218      +/-   ##
==========================================
+ Coverage   47.85%   48.02%   +0.17%     
==========================================
  Files          41       41              
  Lines        3477     3525      +48     
  Branches     1889     1912      +23     
==========================================
+ Hits         1664     1693      +29     
+ Misses        446      442       -4     
- Partials     1367     1390      +23     
Flag Coverage Δ
unittests 48.02% <55.38%> (+0.17%) ⬆️

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

Files Coverage Δ
hardware_interface/src/resource_manager.cpp 48.90% <55.38%> (+1.18%) ⬆️

... and 1 file with indirect coverage changes

@saikishor
Copy link
Member

Rethinking this in the context of #1098 - I would change #1098, but then we don't have nicely shown all three states... (if this is needed at all) If we go with #1098 then the check in the Resource Manage will become much more complex. I am not sure if I want to go that route because I think that we gain nothing having this complexity. The available interface in the context of controller doesn't make much sense. So I propose that we have the following case:

New behavior:

  • Configured chainable controller: Listed exported interfaces are available and unclaimed
  • Active chainable controller(not in chained mode): Listed exported interfaces are available but unclaimed
  • Active chainable controller(in chained mode): Listed exported interfaces are available and claimed

@destogl I'm not sure about this convention. IMO the available interface does make sense in the context of the controllers as well. For instance, until the controller is active they are not exported to the Resource manager and also it doesn't make sense to export them on configure as the controller is not ready yet and you cannot start chaining them.

I believe they should be available only upon activation and unavailable upon deactivation.

Copy link
Contributor

mergify bot commented Dec 17, 2023

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

@destogl destogl force-pushed the allow-prepare-comand-mode-switch-only-for-existing-and-available-interfaces branch from 37e64a8 to 485b25f Compare December 17, 2023 18:48
@destogl
Copy link
Member Author

destogl commented Dec 18, 2023

@saikishor you are right. I will adjust this PR if needed. I would expect that I need adjustments, but the tests are passing. Let me today test in a real-world scenario if everything works, we can also start merging this :)

Thanks for your support and patience! (the feature is quite tricky and I am careful to not break anything - so writing many tests...)

Copy link
Member

@saikishor saikishor left a comment

Choose a reason for hiding this comment

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

Looks fine to me. Test it and let us know

@destogl
Copy link
Member Author

destogl commented Dec 18, 2023

This works on the HW, so we can move one with it, if all are happy.

@saikishor
Copy link
Member

@destogl can you rebase the PR?

destogl and others added 2 commits January 3, 2024 19:14
Copy link
Contributor

mergify bot commented Jan 4, 2024

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

hardware_interface/src/resource_manager.cpp Show resolved Hide resolved
hardware_interface/src/resource_manager.cpp Outdated Show resolved Hide resolved
hardware_interface/src/resource_manager.cpp Outdated Show resolved Hide resolved
Copy link
Member

@saikishor saikishor left a comment

Choose a reason for hiding this comment

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

The changes itself look good to me @destogl
Great job 👏

@destogl destogl requested a review from bmagyar January 12, 2024 17:19
@bmagyar bmagyar merged commit 8c34ab6 into master Jan 12, 2024
13 checks passed
mergify bot pushed a commit that referenced this pull request Jan 12, 2024
…1218)

(cherry picked from commit 8c34ab6)

# Conflicts:
#	hardware_interface/src/resource_manager.cpp
#	hardware_interface/test/mock_components/test_generic_system.cpp
#	hardware_interface/test/test_resource_manager.cpp
mergify bot pushed a commit that referenced this pull request Jan 12, 2024
…1218)

(cherry picked from commit 8c34ab6)

# Conflicts:
#	hardware_interface/test/mock_components/test_generic_system.cpp
@destogl destogl deleted the allow-prepare-comand-mode-switch-only-for-existing-and-available-interfaces branch January 12, 2024 18:20
destogl added a commit that referenced this pull request Jan 17, 2024
…1218)

(cherry picked from commit 8c34ab6)

# Conflicts:
#	hardware_interface/src/resource_manager.cpp
#	hardware_interface/test/mock_components/test_generic_system.cpp
#	hardware_interface/test/test_resource_manager.cpp
destogl added a commit that referenced this pull request Jan 17, 2024
…(backport #1218) (#1291)

* Add additional checks for non-existing and not available interfaces. (#1218)

(cherry picked from commit 8c34ab6)

* Resolve conflicts for backport.
* Make tests to use hardware description in tests to be able to activate controllers.
* Fix variable name for clarity.

---------

Co-authored-by: Dr. Denis <[email protected]>
destogl added a commit that referenced this pull request Jan 17, 2024
…(backport #1218) (#1292)

* Add additional checks for non-existing and not available interfaces. (#1218)

(cherry picked from commit 8c34ab6)

* Resolve conflicts for backport.
* Make tests to use hardware description in tests to be able to activate controllers.

---------

Co-authored-by: Dr. Denis <[email protected]>
Co-authored-by: Bence Magyar <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport-humble This label should be used by maintainers only! Label triggers PR backport to ROS2 humble. bug enhancement high-priority
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants