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

Implement new behavior, RepeatSequence #24

Merged
merged 7 commits into from
Nov 26, 2023

Conversation

kaphula
Copy link
Collaborator

@kaphula kaphula commented Nov 14, 2023

Implements new behavior RepeatSequence which acts like a Sequence but repeats forever as long as a conditional behavior succeeds (or fails) that precedes the sequence. The condition is only checked before the sequence runs and not during the sequence, unlike in While behavior.

I am testing this on my own application soon to see if anything should be changed but here's the initial idea draft anyway.

Related issue: #23

@Sollimann
Copy link
Owner

Hey, sorry for late reply. Will have a look on your PR sometime in the next couple of days. Been quite busy lately

Copy link
Collaborator

@kembofly kembofly left a comment

Choose a reason for hiding this comment

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

Great work, and thank you for adding an additional useful behavior. Before I can approve the code I need you to:

  1. fix any comments I've added
  2. Include unit tests of new behavior. See /bonsai/tests/ folder to make sure the behavior works as intended. Test common cases and edge cases e.g input vector is empty
  3. Update the How to use a Behavior tree? section found in bonsai/README.md in the root to include the new behavior
  4. Update the bonsai/examples/README.md to cinlude your new example with a readme on what the examples show/does, how to run it, and if it requires any installations/dependecies (e.g from apt-get registry)

FYA, I'm writing from a different github user atm as I don't have access to my main user from this computer.

@@ -51,6 +51,8 @@ pub enum State<A> {
SequenceState(Vec<Behavior<A>>, usize, Box<State<A>>),
/// Keeps track of a `While` behavior.
WhileState(Box<State<A>>, Vec<Behavior<A>>, usize, Box<State<A>>),
/// Keeps track of a `While` behavior.
Copy link
Collaborator

Choose a reason for hiding this comment

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

typo, RepeatSequence

@kaphula
Copy link
Collaborator Author

kaphula commented Nov 21, 2023

I added the required changes but I could not verify that RepeatSequence works as intented when it comes to the timing values since I failed to understand how it they are supposed to work. I added one test for RepeatSequence, test_repeat_sequence_timed, that asserts the returned time values, but I am not sure it makes sense. Can you verify that?

It seems that the other behaviors (or at least While) also panic when empty sequence is given to them in addition to the initial condition, so added panic message to RepeatSequence. Perhaps other behaviors need this as well, or the panic cases should be fixed.

}

#[test]
fn test_repeat_sequence_timed() {
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think this makes sense.

wrt to dt, when one action terminates, it can consume some of dt and the remaining is passed onto the next action.

Copy link
Collaborator

Choose a reason for hiding this comment

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

@kembofly
Copy link
Collaborator

pre-commit is failing, so you need to make the fixes as suggested by the failing checks.

https://github.com/Sollimann/bonsai/actions/runs/6944779061

to install pre-commit for this project, see: https://pre-commit.com/

Its basically:

  1. sudo -H pip install pre-commit
  2. pre-commit install in root of this repo

Also, I have invited you to be collaborator on the project. That should give you some more privileges for the project.

@kembofly
Copy link
Collaborator

Other than that, I think it looks good now. Will approve when all the checks pass. Great work! :)

@kembofly
Copy link
Collaborator

Also, can you bump version to 0.5.0? I will release a new version to crates.io once merged.

@kaphula
Copy link
Collaborator Author

kaphula commented Nov 25, 2023

Thanks! I also had to do some cosmetic changes to the boids example to get through the pre-commit. Looks good now?

Copy link
Owner

@Sollimann Sollimann left a comment

Choose a reason for hiding this comment

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

lgtm!

@Sollimann
Copy link
Owner

I´ll make a new release once you have merged it to main :)

@kaphula kaphula merged commit 4d45dff into Sollimann:main Nov 26, 2023
2 checks passed
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