-
Notifications
You must be signed in to change notification settings - Fork 421
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 support for spin_until_timeout (#1821) #1874
Conversation
f69da46
to
5a6122a
Compare
I can see value in this new utility. What if we make this new function more generic, by taking as an extra argument a function that signals that we need to exit early.
|
Thanks for the feedback. You are right, it is basically the simplified version of I did it as it is, only because it's my first change and I did not want to break anything - but my initial idea was to make one generic method. I'll make it more generic. |
@alsora I was also thinking about API stability, because this could be easily changed to |
I think we wouldn't break any API as we would keep |
In general, it is allowed to change API between versions in a "tick-tock" cycle. That is, for public APIs, we deprecate the old API in one release, add in the new one. In the next release, we remove the old one. This gives time for downstream users to switch to the new API. Note, however, that if you deprecate an API, all of the core of ROS 2 has to change at the same time, since we count deprecation warnings as regressions in the core. In this particular case, this is a very commonly used function. So I wouldn't break the API here without really good justification. |
Interestingly, I suggested a similar API change awhile back #1712. The reason this hasn't started yet is due to the lack of desire for churn in the API without a cause. Once we change something more significant or support non-futures, I would jump on that opportunity to make the change in name to coincide with a necessary change. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure if it's a good idea to continue adding more flavors of spin_*()
, but the implementation lgtm!
Hi @hliberacki In particular:
|
Hi @alsora, Yeah sorry for that it's pending for that long - I had some fire in my day-to-day project. At the moment I would need to know which way would be the best fit, your first comment #1874 (comment) - which is significantly easier or @SteveMacenski comment #1874 (comment) to extend Even though I find @SteveMacenski solution more robust - it will be a lot of changes because I need to change most of Some part of the work is already done, but still, I would need to fix tests - parts of python codebase and probably nodes which I did not take look into. I could also take your suggestion and we can create a second ticket - to handle altering How do you feel about it? And again sorry for being idle that long - not gonna happen again :) |
No worries! About whether to integrate this into The Then, next to this, I can see a variety of other "spin functionalities" that can be provided by one or more functions.
In theory all these "spin until X" could be done using a single, configurable function. |
Ok, it seems a better fit for the moment. I will take care of that this week |
Think about it this way, every time anyone uses the usual I know its unfair that different maintainers are telling you different things -- just to see if my summarization of this conversation is correct to see if we can derive some sense of consensus
It sounds to me like the 2 options to make the most people happy
I actually prefer the second idea, which would make me, Alberto, and Ivan happy |
Keep in mind that #1712 (comment) still applies here; if we are going to rename it, we'll have to do all of the steps listed in that comment. |
Definitely! I'm just trying to build consensus for a direction at this point -- I'm fine with either option |
Would this be a new overload of the current
I would rather not see the word "until" in the name for this overload. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM with the minor naming issue resolved
I don't have a strong preference for |
For starters thanks for the feedback @SteveMacenski . I guess following your previous idea - #1712 would be a good tradeoff between overloading
That's not a problem at all, I am just still a newbie Ros wise so it's hard for me to pick the best approach. I will then implement as it's described in #1712. As per naming, to me for and until sounds equaly good. |
5a6122a
to
fd895b5
Compare
Since the most concern was about the end API - I thought that it might be beneficial that I just push how I've updated the public API executors - from one of my first commits. I've done far more than this single change- but this is still a draft that I will push as a complete result. I'd like to only know whether you feel ok with API approach ( |
rclcpp/include/rclcpp/executor.hpp
Outdated
@@ -319,6 +320,53 @@ class Executor | |||
virtual void | |||
spin_once(std::chrono::nanoseconds timeout = std::chrono::nanoseconds(-1)); | |||
|
|||
// TODO(hliberacki): Add documentation | |||
template<typename FutureT, typename DurationT = std::chrono::milliseconds, | |||
// typename std::enable_if_t< |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was wondering about that? This is commented out since this type_trait is far from being readable or pretty - yet it's more accurate than a single negation - typename std::enable_if_t<!std::is_invocable_v<FutureT>, bool> = true
. Not sure what suites the codebase better.
Also I was wondering about C++17 support - I know that several companies are based on ros2 (like Apex) and they uses C++14 - can we freely use all c++17 features? If so I will just drop if constexpr
instead of SFINAE
@alsora @SteveMacenski - ideas would be appreciated - I am still a newbie here hence the question ;)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe Humble targets C++17, so I see no reason why not to use any C++17 features you like, but I am definitely not the right person to ask. Someone at OR would have to jump in to let us know if we should be trying to minimize its use to help in C++14 compatibility for other important users
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
typename std::enable_if_t<!std::is_invocable_v, bool> = true
It'll be hard to understand in the future why std::is_invocable_v
was used.
I would rather have the more accurate condition (even if it doesn't look pretty) or two overloads.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ivanpauno At the moment i've decided to use if constexpr
and reduce second check whether the Condition
is a of type Future
or SharedFuture
. I did it because realize that there are more use cases, like using src/ros2/rclcpp/rclcpp/include/rclcpp/client.hpp
fromsrc/ros2/rclcpp/rclcpp/include/rclcpp/client.hpp
.
If you still would like to have more grain granularity - then I would suggest to create Concept like requirement of the API for the given condition. So it would have to have wait_for(timeout)
method which returns enum class future_status
. I did not introduce it for now, on purpose because I am not sure whether it will be valuable to have that type_trait which is a bit hard to read. But If needed I can introduce it - no problem with that.
@hliberacki is this PR still draft? you are still working on this as PoC? |
I'm still working on that. i have changed status from open to draft to mark that the patch that i currently committed is just a question about the the API ans not an actual final solution - to avoid confusion. i have done far more and intensified my work since yesterday - so this is definitely on going (at the moment I'm extending unit tests for executors). but since I'm doing it which take a bit of time I'd like to confirm how the revievers feel about the API itself so i would not polish thing (document, unit test) that has to be changed. thats why I've pushed it in that state, hopefully it makes sense :) also I know that there is a release in the begging of April therefore i wanted to have some very basic feedback before the weekend, because i would like to finalize it during the weekend or be close to do it. |
Yes, the PR is good to go for me. |
👨🌾 This seems to have introduced several build regressions on the linux buildfarm, it's failing on See: I'm opening a revert PR to be sure this is causing the problem and merge before EOD if we don't find another way to address it. @clalancette |
We definitely missed merging at least ros2/system_tests#499 , there may be others. I'll go see if I can track them down. |
@clalancette most of that (all?) has already been reviewed, so it shall be rather straight forward. |
unfortunately replying on my phone, so tis hard to check the list myself but |
Ah this is my fault, I should have merged the corresponding prs, I was on my phone and didn't see the cross-references. In retrospect it's obvious that this was required. |
Should I proceed with merging this, or wait? |
Let's wait for the moment. We're still not sure whether we are going forward or back here. We'll ping you once we want you to merge. |
So, @clalancette and I discussed it and I'm going to revert this. The I could have split the |
@wjwwood thanks for taking care of that. i will try to fix your findings in rclpy as soon as possible. |
Can do |
Something that also should probably be updated is documentation on docs.ros.org. Migration guide mention for Iron + update the tutorials. I took a look and its a pretty trivial number of changes. I'll do that now |
ros2/ros2_documentation#2798 Docs PR |
Hey there, it seems like this didn't get in to |
@clalancette @wjwwood @alsora any objection for taking these PRs? i think this is useful. you can see the entire PR list here, #1874 (comment) |
Yes, I agree that this is a very useful feature to have. |
Introduce executors new spin_for method, replace spin_until_future_complete with spin_until_complete. (#1821)