diff --git a/wpilibNewCommands/src/main/java/edu/wpi/first/wpilibj2/command/Command.java b/wpilibNewCommands/src/main/java/edu/wpi/first/wpilibj2/command/Command.java
index 73d562fc5f..bff828ac28 100644
--- a/wpilibNewCommands/src/main/java/edu/wpi/first/wpilibj2/command/Command.java
+++ b/wpilibNewCommands/src/main/java/edu/wpi/first/wpilibj2/command/Command.java
@@ -430,14 +430,32 @@ public interface Command {
}
/**
- * Gets the name of this Command.
+ * Gets the name of this Command. Defaults to the simple class name if not overridden.
*
- * @return Name
+ * @return The display name of the Command
*/
default String getName() {
return this.getClass().getSimpleName();
}
+ /**
+ * Sets the name of this Command. Nullop if not overridden.
+ *
+ * @param name The display name of the Command.
+ */
+ default void setName(String name) {}
+
+ /**
+ * Decorates this Command with a name. Is an inline function for #setName(String);
+ *
+ * @param name name
+ * @return the decorated Command
+ */
+ default Command withName(String name) {
+ this.setName(name);
+ return this;
+ }
+
/**
* An enum describing the command's behavior when another command with a shared requirement is
* scheduled.
diff --git a/wpilibNewCommands/src/main/java/edu/wpi/first/wpilibj2/command/CommandBase.java b/wpilibNewCommands/src/main/java/edu/wpi/first/wpilibj2/command/CommandBase.java
index 5b577bd3cc..a8e591c5c7 100644
--- a/wpilibNewCommands/src/main/java/edu/wpi/first/wpilibj2/command/CommandBase.java
+++ b/wpilibNewCommands/src/main/java/edu/wpi/first/wpilibj2/command/CommandBase.java
@@ -51,21 +51,11 @@ public abstract class CommandBase implements Sendable, Command {
*
* @param name name
*/
+ @Override
public void setName(String name) {
SendableRegistry.setName(this, name);
}
- /**
- * Decorates this Command with a name. Is an inline function for #setName(String);
- *
- * @param name name
- * @return the decorated Command
- */
- public CommandBase withName(String name) {
- this.setName(name);
- return this;
- }
-
/**
* Gets the subsystem name of this Command.
*
diff --git a/wpilibNewCommands/src/main/java/edu/wpi/first/wpilibj2/command/Commands.java b/wpilibNewCommands/src/main/java/edu/wpi/first/wpilibj2/command/Commands.java
new file mode 100644
index 0000000000..862e3c11ae
--- /dev/null
+++ b/wpilibNewCommands/src/main/java/edu/wpi/first/wpilibj2/command/Commands.java
@@ -0,0 +1,210 @@
+// Copyright (c) FIRST and other WPILib contributors.
+// Open Source Software; you can modify and/or share it under the terms of
+// the WPILib BSD license file in the root directory of this project.
+
+package edu.wpi.first.wpilibj2.command;
+
+import static edu.wpi.first.wpilibj.util.ErrorMessages.requireNonNullParam;
+
+import java.util.Map;
+import java.util.function.BooleanSupplier;
+import java.util.function.Supplier;
+
+/**
+ * Namespace for command factory methods.
+ *
+ *
For convenience, you might want to static import the members of this class.
+ */
+public final class Commands {
+ /**
+ * Constructs a command that does nothing, finishing immediately.
+ *
+ * @return the command
+ */
+ public static Command none() {
+ return new InstantCommand();
+ }
+
+ // Action Commands
+
+ /**
+ * Constructs a command that runs an action once and finishes.
+ *
+ * @param action the action to run
+ * @param requirements subsystems the action requires
+ * @return the command
+ * @see InstantCommand
+ */
+ public static Command runOnce(Runnable action, Subsystem... requirements) {
+ return new InstantCommand(action, requirements);
+ }
+
+ /**
+ * Constructs a command that runs an action every iteration until interrupted.
+ *
+ * @param action the action to run
+ * @param requirements subsystems the action requires
+ * @return the command
+ * @see RunCommand
+ */
+ public static Command run(Runnable action, Subsystem... requirements) {
+ return new RunCommand(action, requirements);
+ }
+
+ /**
+ * Constructs a command that runs an action once and another action when the command is
+ * interrupted.
+ *
+ * @param start the action to run on start
+ * @param end the action to run on interrupt
+ * @param requirements subsystems the action requires
+ * @return the command
+ * @see StartEndCommand
+ */
+ public static Command startEnd(Runnable start, Runnable end, Subsystem... requirements) {
+ return new StartEndCommand(start, end, requirements);
+ }
+
+ /**
+ * Constructs a command that runs an action every iteration until interrupted, and then runs a
+ * second action.
+ *
+ * @param run the action to run every iteration
+ * @param end the action to run on interrupt
+ * @param requirements subsystems the action requires
+ * @return the command
+ */
+ public static Command runEnd(Runnable run, Runnable end, Subsystem... requirements) {
+ requireNonNullParam(end, "end", "Command.runEnd");
+ return new FunctionalCommand(
+ () -> {}, run, interrupted -> end.run(), () -> false, requirements);
+ }
+
+ /**
+ * Constructs a command that prints a message and finishes.
+ *
+ * @param message the message to print
+ * @return the command
+ * @see PrintCommand
+ */
+ public static Command print(String message) {
+ return new PrintCommand(message);
+ }
+
+ // Idling Commands
+
+ /**
+ * Constructs a command that does nothing, finishing after a specified duration.
+ *
+ * @param seconds after how long the command finishes
+ * @return the command
+ * @see WaitCommand
+ */
+ public static Command wait(double seconds) {
+ return new WaitCommand(seconds);
+ }
+
+ /**
+ * Constructs a command that does nothing, finishing once a command becomes true.
+ *
+ * @param condition the condition
+ * @return the command
+ * @see WaitUntilCommand
+ */
+ public static Command waitUntil(BooleanSupplier condition) {
+ return new WaitUntilCommand(condition);
+ }
+
+ // Selector Commands
+
+ /**
+ * Runs one of two commands, based on the boolean selector function.
+ *
+ * @param onTrue the command to run if the selector function returns true
+ * @param onFalse the command to run if the selector function returns false
+ * @param selector the selector function
+ * @return the command
+ * @see ConditionalCommand
+ */
+ public static Command either(Command onTrue, Command onFalse, BooleanSupplier selector) {
+ return new ConditionalCommand(onTrue, onFalse, selector);
+ }
+
+ /**
+ * Runs one of several commands, based on the selector function.
+ *
+ * @param selector the selector function
+ * @param commands map of commands to select from
+ * @return the command
+ * @see SelectCommand
+ */
+ public static Command select(Map