Skip to content

Command factories and triggers examples#53

Closed
aridavidson001 wants to merge 3 commits into
mainfrom
command-factories-and-triggers-examples
Closed

Command factories and triggers examples#53
aridavidson001 wants to merge 3 commits into
mainfrom
command-factories-and-triggers-examples

Conversation

@aridavidson001

Copy link
Copy Markdown
Contributor

command factories are subsystem-specific commands at are written in the subsystems in order to reduce the amount of information shared between the subsystem and other parts of code. Triggers are basically the same thing but as booleans, meaning we can get information from the subsystem using them; we can also bind commands to them so when they happen a command is scheduled. Pretty cool stuff that should make the code much more readable and reduce the amount of complex commands we have, when used in combination with the .alongWith() and .and().

@aridavidson001 aridavidson001 linked an issue Jan 24, 2025 that may be closed by this pull request
import java.util.function.DoubleSupplier;

public class ExampleSubsystem extends SubsystemBase {
private DoubleSupplier DOUBLELOL;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

?

@Ishan1522

Copy link
Copy Markdown
Contributor

lgtm

@Ishan1522

Copy link
Copy Markdown
Contributor

is pretty chill

@Ishan1522

Ishan1522 commented Jan 25, 2025

Copy link
Copy Markdown
Contributor

@JacksonElia thoughts on a superstructure class that contains all the subsystems, allowing u to do these types of commands within a single class. ill put some examples here.

I feel like it'd be cleaner than having multiple command files. For big commands we could create a file for it probably

// Public Command Factory
// create these for everything you would need to access from a command
// so you don't input values or acces the internals of a subsystem in the commands themselves
public Command exampleFunctionalCommand() {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

dude yk what this is pretty clean

// NOTE: Consider using this command inline, rather than writing a subclass. For more
// information, see:
// https://docs.wpilib.org/en/stable/docs/software/commandbased/convenience-features.html
public class ExampleAuto extends SequentialCommandGroup {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

this is what we've been using for autos 😄

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

we're rewriting this!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!11

@aridavidson001 aridavidson001 Jan 26, 2025

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Idk tbh. I created another branch that uses auto factories and it's a lot cleaner. I'm not 100% sure it's done yet but if you want to check it out go for it

@JacksonElia

Copy link
Copy Markdown
Member

@JacksonElia thoughts on a superstructure class that contains all the subsystems, allowing u to do these types of commands within a single class. ill put some examples here.

I feel like it'd be cleaner than having multiple command files. For big commands we could create a file for it probably

uhhhh idk that seems scary to me. I just feel like the file size would get insane, and knowing how our team programs when under stress it would not be clean at all. I really like this though for replacing simple commands (e.g. an intake command) and Instant commands.

@JacksonElia

Copy link
Copy Markdown
Member

Awesome find @aridavidson001, we should def do some of this! Why have a whole file when we can just do it like this?!

So for simple stuff we do it this way, for more complex commands we can stick with the ways we have been doing commands so far.

@JacksonElia
JacksonElia marked this pull request as draft January 26, 2025 16:47
@JacksonElia JacksonElia added the enhancement New feature or request label Jan 26, 2025
@Ishan1522

Copy link
Copy Markdown
Contributor

Awesome find @aridavidson001

bruh ☠️

@aridavidson001

aridavidson001 commented Jan 26, 2025

Copy link
Copy Markdown
Contributor Author

Awesome find @aridavidson001, we should def do some of this! Why have a whole file when we can just do it like this?!

So for simple stuff we do it this way, for more complex commands we can stick with the ways we have been doing commands so far.

Ishan found it lmao - but I think we can just create commands like this for everything in the subsystem we would want to access in a command(if that makes sense).

@aridavidson001

Copy link
Copy Markdown
Contributor Author

Why have a whole file when we can just do it like this?!

Wait till you see the auto stuff 🤩

@Ishan1522

Copy link
Copy Markdown
Contributor

I just feel like the file size would get insane, and knowing how our team programs when under stress it would not be clean at all

The point is that it removes the insane amount of boilerplate that comes with Command classes. They aren't clean anyway during competition so like idk. man tbh i dont rlly care.

@Ishan1522

Copy link
Copy Markdown
Contributor

i feel like we generally don't write that complex of commands as well tho

@aridavidson001

Copy link
Copy Markdown
Contributor Author

I just feel like the file size would get insane, and knowing how our team programs when under stress it would not be clean at all

The point is that it removes the insane amount of boilerplate that comes with Command classes. They aren't clean anyway during competition so like idk. man tbh i dont rlly care.

The amount of merge conflicts would also go crazy tbh

@Ishan1522

Copy link
Copy Markdown
Contributor

I just feel like the file size would get insane, and knowing how our team programs when under stress it would not be clean at all

The point is that it removes the insane amount of boilerplate that comes with Command classes. They aren't clean anyway during competition so like idk. man tbh i dont rlly care.

The amount of merge conflicts would also go crazy tbh

That changes nothing 😄 because u guys don't pull changes anyway

@aridavidson001

Copy link
Copy Markdown
Contributor Author

i feel like we generally don't write that complex of commands as well tho

This. We can just use things like .alongwith() and .and() to combine some simple commands together if we really need to. Triggers reduce the need for complex commands since we can just bind lots of simple commands to specific triggers to emulate some of the functionality of more complex commands. I'll create a PR for the auto factories branch so you can take a look at that @JacksonElia

@JacksonElia JacksonElia closed this Oct 6, 2025
@Ishan1522
Ishan1522 deleted the command-factories-and-triggers-examples branch October 10, 2025 16:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

No open projects
Status: Todo

Development

Successfully merging this pull request may close these issues.

Use command factories and triggers

3 participants