Skip to content

Adds Guard Conditions #249

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

Merged
merged 3 commits into from
Oct 3, 2022

Conversation

christopherjreid
Copy link
Contributor

  • Adds the Guard Condition struct encapsulating rcl_guard_condition_t.
  • Adds optional callbacks and a trigger method to approximate the rclcpp
    implementation.
  • Adds an add_guard_condition method to WaitSet to add the
    GuardCondition to the WaitSet

@christopherjreid christopherjreid force-pushed the feature/guard_condition branch from 0d504a0 to 120817b Compare August 20, 2022 01:29
@nnmm nnmm requested a review from a team August 20, 2022 11:21
@nnmm
Copy link
Contributor

nnmm commented Aug 20, 2022

I'll check it out this evening!

@christopherjreid christopherjreid force-pushed the feature/guard_condition branch from 120817b to c6e3145 Compare August 20, 2022 18:03
Copy link
Contributor

@nnmm nnmm left a comment

Choose a reason for hiding this comment

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

Great job as usual. I left a round of comments.

@nnmm nnmm mentioned this pull request Aug 21, 2022
@christopherjreid
Copy link
Contributor Author

Updated to address all comments!

@esteve esteve self-requested a review September 17, 2022 13:19
@christopherjreid christopherjreid force-pushed the feature/guard_condition branch 2 times, most recently from b9c242b to 8db9568 Compare September 17, 2022 13:27
@nnmm
Copy link
Contributor

nnmm commented Sep 24, 2022

BTW, you could add guard conditions (and graph support, which I forgot) to the new rclrs/CHANGELOG.rst file in here too.

@christopherjreid christopherjreid force-pushed the feature/guard_condition branch 3 times, most recently from 6543fd4 to 4ca95c5 Compare September 24, 2022 14:58
@christopherjreid
Copy link
Contributor Author

All comments addressed, except for the open discussion on the return type of GuardCondition::new.
We may need a new discussion on the impl of PartialEq for GuardCondition. I believe that -only- checking eq on the underlying rcl_guard_condition is sufficient, but I'm open to thoughts on that. @nnmm suggested a static counter that would serve as an ID for each GuardCondition

Copy link
Contributor

@nnmm nnmm left a comment

Choose a reason for hiding this comment

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

(Probably) final comments from my side

@christopherjreid christopherjreid force-pushed the feature/guard_condition branch 2 times, most recently from 7e0744b to 108ea39 Compare September 30, 2022 11:43
@esteve
Copy link
Collaborator

esteve commented Sep 30, 2022

@christopherjreid in the future, could you push commit by commit, instead of force-push? It's easier to see the changes that happen while reviewing a PR. We'll squash all the commits in the end when we merge the PR, so there's no need to squash them while the PR is being worked on. Thanks.

- Adds the Guard Condition struct encapsulating rcl_guard_condition_t.
- Adds optional callbacks and a trigger method to approximate the rclcpp
  implementation.
- Adds an `add_guard_condition` method to `WaitSet` to add the
  GuardCondition to the WaitSet
- Adds a `create_guard_condition` method to `Node` and adds a weak
  pointer to the created guard condition to the `Node`'s internal data.
  When `spin_once` is called on the node, the guard condition can be
  used to interrupt the wait
- Increments version for all packages to 0.3.0
@nnmm
Copy link
Contributor

nnmm commented Sep 30, 2022

I also took a look at the clippy error – I hadn't thought about that. Maybe it would be nicest to have two methods:

  • GuardCondition::new() (does not take a callback)
  • GuardCondition::new_with_callback() (takes a callback, i.e. not enclosed in an Option)

That way the callback type could always be deduced. I think it also makes the call sites prettier.

Alternatively, we could just revert to taking boxed callbacks.

@esteve
Copy link
Collaborator

esteve commented Sep 30, 2022

@christopherjreid I agree with @nnmm about adding an explicit GuardCondition::new_with_callback(), instead of an Option

@christopherjreid
Copy link
Contributor Author

christopherjreid commented Sep 30, 2022

Hrm, so we're looking at:

pub fn new(...);

pub fn new_with_callback(...);

pub(crate) fn new_with_rcl_context(...);

pub(crate) fn new_with_rcl_context_with_callback(...);

?

@nnmm
Copy link
Contributor

nnmm commented Sep 30, 2022

Hrm, so we're looking at:

pub fn new(...);

pub fn new_with_callback(...);

pub(crate) fn new_with_rcl_context(...);

pub(crate) fn new_with_rcl_context_with_callback(...);

?

No, the rcl_context version can receive a boxed Option callback

@christopherjreid christopherjreid force-pushed the feature/guard_condition branch 3 times, most recently from 57fcc86 to a256204 Compare October 1, 2022 01:24
@christopherjreid christopherjreid force-pushed the feature/guard_condition branch from a256204 to 7722761 Compare October 1, 2022 01:54
nnmm
nnmm previously approved these changes Oct 1, 2022
Copy link
Contributor

@nnmm nnmm left a comment

Choose a reason for hiding this comment

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

LGTM!

Copy link
Collaborator

@esteve esteve left a comment

Choose a reason for hiding this comment

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

@christopherjreid LGTM! Thank you so much for iterating with us and for your patience 🙂

@esteve esteve merged commit cad6964 into ros2-rust:main Oct 3, 2022
@Carter12s Carter12s mentioned this pull request Oct 25, 2023
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.

3 participants