Skip to content
This repository has been archived by the owner on Jan 13, 2025. It is now read-only.

(Proposal) Convert PathSequenceAuto from Builder pattern to procedural code #83

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

rcahoon
Copy link
Member

@rcahoon rcahoon commented Mar 11, 2024

Description

About the same amount of code as before, but this allows you to more flexibly insert logic between the steps of the path. For example, this style makes it more natural to write things like

runPath(context, "move to the next note");
if (cameraSeesThatNoteIsPresent()) {
    context.runSync(new PickupNoteAndShoot());
}
runPath(context, "move to the next note");
while (!cameraSeesThatNoteIsPresent()) {
    runPath(context, "move forward a bit in case the note is further than we thought");
}
context.runSync(new PickupNoteAndShoot());

How Has This Been Tested?

Please describe the tests that you ran to verify your changes. Be detailed so that your code reviewer can understand exactly how much and what kinds of testing were done, and which might still be worthwhile to do.

  • Unit tests: [Add your description here]
  • Simulator testing: [Add your description here]
  • On-robot bench testing: [Add your description here]
  • On-robot field testing: [Add your description here]

@rcahoon rcahoon requested a review from qntmcube March 11, 2024 06:20
Copy link
Contributor

@qntmcube qntmcube left a comment

Choose a reason for hiding this comment

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

Makes sense and looks good (in hindsight this is way simpler and less limited than what I had before). We can probably test this along with the runSync changes (although both look like they should work perfectly fine).

@rcahoon
Copy link
Member Author

rcahoon commented Mar 15, 2024

[Tangent] What you had is actually quite similar to the way that WPILib composes their Commands together, so it's a valid approach -- but as it gets built out to handle more use cases, you sorta have to recreate your own mini programming language interpreter inside Java. (Which is fun project to work through, if you want a hobby project over the summer: you already have the "named block of statements" aka simple functions; the next steps would be if-then-else statements, loops, and then variable assignment.) The idea behind the Procedures approach is that Java already exists as a programming language that we can use, so let's just use that.

@rcahoon rcahoon force-pushed the rcahoon/procedural-PathSequenceAuto branch from d993a57 to 1b0c2df Compare April 13, 2024 21:07
Base automatically changed from rcahoon/runSync to main April 19, 2024 07:21
@rcahoon rcahoon force-pushed the rcahoon/procedural-PathSequenceAuto branch from 1b0c2df to 1457d1c Compare April 19, 2024 08:29
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants