Skip to content

Add AdvantageKit auto chooser#1349

Open
Daniel1464 wants to merge 9 commits intoSleipnirGroup:mainfrom
Daniel1464:akit-auto-chooser
Open

Add AdvantageKit auto chooser#1349
Daniel1464 wants to merge 9 commits intoSleipnirGroup:mainfrom
Daniel1464:akit-auto-chooser

Conversation

@Daniel1464
Copy link
Copy Markdown
Contributor

This was always a thing that we should have added to the docs, so here it is.
Also, I fixed a couple of small things related to the AutoChooser too.

@github-actions github-actions Bot added component: documentation Improvements or additions to documentation component: choreolib-java labels Nov 15, 2025
Comment thread choreolib/src/main/java/choreo/auto/AutoChooser.java Outdated
Comment thread choreolib/src/main/java/choreo/auto/AutoChooser.java Outdated
Comment thread docs/choreolib/auto-factory.md Outdated
Comment thread docs/choreolib/auto-factory.md Outdated
@DJ-Laser
Copy link
Copy Markdown

My take on a LoggedAutoChooser: https://gist.github.com/DJ-Laser/e0c11d7b835489ff63e6e4d2f72e089f
Since the default autoChooser has a special behavior on sim, it's important to keep the command name that will actually be ran logged instead of the user selected name, otherwise replay and real behavior could differ if an auto is selected and ran without alliance info.

@Daniel1464
Copy link
Copy Markdown
Contributor Author

My take on a LoggedAutoChooser: https://gist.github.com/DJ-Laser/e0c11d7b835489ff63e6e4d2f72e089f Since the default autoChooser has a special behavior on sim, it's important to keep the command name that will actually be ran logged instead of the user selected name, otherwise replay and real behavior could differ if an auto is selected and ran without alliance info.

Your implementation does seem correct, but isn't alliance info automatically replayed as well? If no alliance info is given, the auto should default to a null-op.
My main concern with your implementation, though, is that its a little bit of a leaky abstraction. Manual select() calls on the AutoChooser will cause replay to be inaccurate, because they override the AutoChooser's internal selected String property.

@DJ-Laser
Copy link
Copy Markdown

In a real robot, starting an auto without alliance info would be a no-op, but in simulation, it forces the command to generate, which would cause a difference in behavior in replay.

// AutoChooser.class line 213
public Command selectedCommand() {
    if (RobotBase.isSimulation() && nameAtGeneration == DO_NOTHING_NAME) {
      select(selected, true);
    }
    return generatedCommand;
}

I don't think calling select() an issue since that's what happens when it is set via networktables anyway?
In a real robot the internal selected variable may be "someAuto" but have a "Nothing" nameAtGeneration until it is selected again with Alliance data.
In a replay, the Chooser's selected variable will be "Nothing" until the time when a a different nameAtGeneration was logged, so the behavior should be the same, though correct me if I'm wrong?

Copy link
Copy Markdown
Collaborator

@spacey-sooty spacey-sooty left a 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 I agree with the premise we should have something like this in the docs. First of all it seems prone to breakage over time since its just a huge code block. Secondly it also seems out of scope for us as a project. At most a callout that our normal impl won't work with replay seems appropriate, its relatively easy for a user to port our logic to something replay compatible

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

component: documentation Improvements or additions to documentation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants