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

[cmd] Add Commands.choose (aka SendableChooserCommand) #6355

Open
wants to merge 11 commits into
base: main
Choose a base branch
from

Conversation

Starlight220
Copy link
Member

No description provided.

@Alextopher
Copy link
Contributor

Alextopher commented Feb 27, 2024

I implemented something similar recently.

The Consumer<Sendable> rubs me the wrong way (so does hard coding SmartDashboard like I did). It's a good way to add this change within the existing APIs. I'm just not a fan of how this singular idea SendableChooserCommand requires putting 2 things onto a Dashboard for complete functionality.

Command chooser = Commands.choose(
   chooser -> SmartDashboard.putData("Drive Command Chooser", chooser),
   tankDrive, arcadeDrive, curvatureDrive
);
SmartDashboard.putData("Drive Command", chooser);

I wonder if this change could increase in scope and if SendableChooserCommand could be a new, unique, widget (setSmartDashboardType()), on the same footing as "Command" or "String Chooser".

var chooser = new SendableChooserCommand(tankDrive, arcadeDrive, curvatureDrive);
// Does nothing unless sent to a Dashboard
SmartDashboard.putData("Drive Command", chooser);

@Starlight220
Copy link
Member Author

Why do you need to publish the command to the dashboard?

@Starlight220
Copy link
Member Author

Starlight220 commented Feb 28, 2024

Sure. That's separate functionality, and isn't needed for SendableChooserCommand.

The primary use case for SendableChooser is selecting a command for auto, and the SendableChooser needs to be published for selections to be possible; there's no need (and practically no benefit) to put the command on the dashboard as well.

@KangarooKoala
Copy link
Contributor

#7340 might be resolved by this, though the discussion of the impl in that issue is different from the impl in this PR. (Hence why I'm avoiding the auto-linking words for now)

@Starlight220
Copy link
Member Author

Starlight220 commented Nov 4, 2024

Wow I forgot I wrote this. This PR does what I was thinking of in that issue.

Is this missing something?

@Starlight220 Starlight220 marked this pull request as ready for review November 4, 2024 15:57
@Starlight220 Starlight220 requested a review from a team as a code owner November 4, 2024 15:57
@Daniel1464
Copy link

I think there should be an overload that accepts a string and a command vararg in addition to the sendable chooser lambda overload.

@Starlight220
Copy link
Member Author

What would that string be used for, and what's the motivation for that overload?

@Daniel1464
Copy link

Daniel1464 commented Nov 5, 2024

What would that string be used for, and what's the motivation for that overload?

Commands.choose(
      "AutoCommandChoice",
       commands
)

Commands.choose(
      (chooser) -> SmartDashboard.putData("AutoCommandChoice", chooser),
      commands
)

@Starlight220
Copy link
Member Author

It shouldn't be coupled to SmartDashboard.

Accepting an absolute NT key would be good, though.

@KangarooKoala
Copy link
Contributor

There doesn't appear to be a standard way to add a sendable to an arbitrary NT key, unfortunately. Maybe fix the merge conflicts for this PR and make an issue to add that capacity later?

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.

4 participants