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

Replace existing RealtimeBox implementation with RealtimeBoxBestEffort implementation #146

Merged
merged 47 commits into from
Nov 23, 2024

Conversation

firesurfer
Copy link
Contributor

@firesurfer firesurfer commented Jan 25, 2024

Hi as said in #139 this PR replaces the existing RealtimeBox implementation with the new implementation provided in #139 . I merged the tests into a single file and they work fine (even though the existing implementation had only a very small amount of tests)

The implementation of the get/set methods matches exactly the one from the existing implementation apart from some template magic which disables the standard get/set methods for pointer types. (For which they wouldnt provide any thread safety btw from my point of view - see #138)

TLDR: Merging this has the potential to break existing code if someone used pointer types with the RealtimeBox. For everything else it should work just fine.

I would also be happy to provide some documentation on how to use this implementation but I am not sure where in the repository it should go.

This PR should be merged after #139

EDIT: One question regarding the copyright notice for the existing tests. How should this be handled? At the moment I didn't copy any of it to the merged file.

@codecov-commenter
Copy link

codecov-commenter commented Jan 31, 2024

Codecov Report

Attention: Patch coverage is 85.71429% with 8 lines in your changes missing coverage. Please review.

Project coverage is 73.47%. Comparing base (97f9f41) to head (3f57b78).

Files with missing lines Patch % Lines
include/realtime_tools/realtime_box.h 85.71% 3 Missing and 5 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master     #146      +/-   ##
==========================================
+ Coverage   73.11%   73.47%   +0.36%     
==========================================
  Files           8        7       -1     
  Lines         398      411      +13     
  Branches       65       67       +2     
==========================================
+ Hits          291      302      +11     
  Misses         68       68              
- Partials       39       41       +2     
Flag Coverage Δ
unittests 73.47% <85.71%> (+0.36%) ⬆️

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

Files with missing lines Coverage Δ
include/realtime_tools/realtime_box.h 86.20% <85.71%> (-13.80%) ⬇️
---- 🚨 Try these New Features:

@firesurfer
Copy link
Contributor Author

@christophfroehlich I will update this PR as soon as #139 is finished

@firesurfer
Copy link
Contributor Author

Fixes #138

@firesurfer
Copy link
Contributor Author

@christophfroehlich Given that #139 is now merged I updated this PR.
Please see my notes in the initial description about open points for discussion.

Also pinging @saikishor

@firesurfer
Copy link
Contributor Author

@christophfroehlich Just a note about the CI. Interestingly I just had the case that pre-commit in the CI failed but did run sucessfully on my system. (Note about using the right include guard - REALTIME_TOOLS__REALTIME_BOX_H_)

@christophfroehlich
Copy link
Contributor

The only package of the listed dependencies above which use any of the RealtimeBox/RealTimeBoxBestEffort classes is this ur_controller: It uses a shared pointer, but will fail if we delete the RealTimeBoxBestEffort classname. Would a using RealTimeBoxBestEffort=RealTimeBox; work here @firesurfer? 👀 @fmauch
https://github.com/UniversalRobots/Universal_Robots_ROS2_Driver/blob/main/ur_controllers/include/ur_controllers/ur_configuration_controller.hpp#L91-L93

@firesurfer
Copy link
Contributor Author

firesurfer commented Nov 21, 2024

Our @fmauch might want to fix this ? I think this controller is rather new - so the impact of fixing this would be managable.

And in order to answer your question @christophfroehlich - using RealTimeBoxBestEffort=RealTimeBox; should work

@saikishor

I could see these released packages are using it in rolling, we just have to make sure that all of these are using shared_ptrs instead of raw pointers. We will have to check the same for Jazzy and Humble

From my understanding using a shared_ptr isn't safer in anyway (apart from memory safety) than a normal pointer with the RealTimeBox -> That is the reason I enforced using the methods that are overloaded with a std::function for normal pointers and shared_ptrs.

The discussion is basically the same as in the beginning: Shall we enforce correct behavior and possibly break dependent code or do we add back the deprecation workaround - which is annoying to maintain.

@saikishor
Copy link
Member

And in order to answer your question @christophfroehlich - using RealTimeBoxBestEffort=RealTimeBox; should work

Yup let's do that. I don't know if we can add deprecation notice to the using keyword. If so, we can add it and ask everyone to switch to new RealTimeBox?

@saikishor

From my understanding using a shared_ptr isn't safer in anyway (apart from memory safety) than a normal pointer with the RealTimeBox -> That is the reason I enforced using the methods that are overloaded with a std::function for normal pointers and shared_ptrs.

You are absolutely right. The other day I was checking the same and it doesn't make sense to use Pointers here, as you can still change it outside the RealTimeBox class. As you said, it is meant for classes and structs to be used safely.

The discussion is basically the same as in the beginning: Shall we enforce correct behavior and possibly break dependent code or do we add back the deprecation workaround - which is annoying to maintain.

As the Original API is simple and it already mentions in the documentation note to use shared_ptrs I don't mind merging it and see what will be the case.

I apologize for delaying this so far.

@saikishor
Copy link
Member

@firesurfer I'll do one final review to see if I find something.

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.

@firesurfer Overall looks good to me, I've opened discussion at some points.

include/realtime_tools/realtime_box.h Show resolved Hide resolved
include/realtime_tools/realtime_box.h Outdated Show resolved Hide resolved
include/realtime_tools/realtime_box.h Outdated Show resolved Hide resolved
include/realtime_tools/realtime_box.h Show resolved Hide resolved
include/realtime_tools/realtime_box.h Outdated Show resolved Hide resolved
firesurfer and others added 5 commits November 21, 2024 10:13
conversion operator should use try_get not try_set

Co-authored-by: Sai Kishor Kothakota <saisastra3@gmail.com>
Fixed copyright and comments
…tion to std::mutex and std::recursive_mutex
include/realtime_tools/realtime_box.h Outdated Show resolved Hide resolved
include/realtime_tools/realtime_box.h Outdated Show resolved Hide resolved
include/realtime_tools/realtime_box.h Outdated Show resolved Hide resolved
firesurfer and others added 2 commits November 21, 2024 15:09
Co-authored-by: Sai Kishor Kothakota <saisastra3@gmail.com>
@fmauch
Copy link
Contributor

fmauch commented Nov 21, 2024

Our @fmauch might want to fix this ? I think this controller is rather new - so the impact of fixing this would be managable.

I'll add it to my tech debt list :-) Thanks for adding the deprecation layer, though!

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.

LGTM

Thank you so much @firesurfer for the follow-up

Copy link
Contributor

@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.

LGTM as far as I can assess this. Thanks again for the follow-up on this

Copy link
Contributor

@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.

see the clang fix above

Co-authored-by: Christoph Fröhlich <christophfroehlich@users.noreply.github.com>
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.

7 participants