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

Predicates are still published periodically in python components #158

Closed
domire8 opened this issue Oct 15, 2024 · 1 comment · Fixed by #159
Closed

Predicates are still published periodically in python components #158

domire8 opened this issue Oct 15, 2024 · 1 comment · Fixed by #159
Assignees

Comments

@domire8
Copy link
Member

domire8 commented Oct 15, 2024

There is an incorrect behavior in version 5.0.0 that makes python components publish their predicates periodically, even though they don't change the value.

@domire8
Copy link
Member Author

domire8 commented Oct 16, 2024

Additionally, there is another detail that might cause confusion: the Predicate class in both cpp and py initializes the previous_value attribute to the opposite value of the initial value of the predicate. It was the intention that the first time around in the step function, the query() call would return a value and the initial value would be published as a predicate. However, we missed the fact that if one does

p = Predicate(lambda: False)
p.set_predicate(lambda: True)
value = p.query() # --> this will be none instead of true!

i.e. change the predicate value before the step (or anyone else, but it will be the step function) queries the predicate value for the first time, it will return None because internally in fact the predicate value hasn't changed. This can indeed happen in test scenarios where we spin manually or in the execute behavior of components. Two potential fixes:

  1. Fix it in the component interface and publish the predicate directly on ComponentInterface::add_predicate to make sure it's queried immediately. This is a simple non breaking change
  2. Fix it in the Predicate class to have an uninitialized previous_value on construction. This is cleaner but technically a breaking change.

@domire8 domire8 linked a pull request Oct 20, 2024 that will close this issue
1 task
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 a pull request may close this issue.

1 participant