Skip to content

Commit b9b99ec

Browse files
author
James Hagborg
committed
Add release command to release subsystems
1 parent b3f0e63 commit b9b99ec

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

src/main/java/org/usfirst/frc/team69/util/QuickCommand.java

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -351,4 +351,31 @@ protected void end() {
351351
}
352352
};
353353
}
354+
355+
/**
356+
* Create a command which releases control of a subsystem.
357+
*
358+
* The {@link Command} returned by this method will require the given
359+
* subsystem, and end instantly. This has the effect of stopping any
360+
* command using the given subsystem, and of starting the default
361+
* command, if one exists.
362+
*
363+
* @param subsystem The subsystem to release
364+
* @return A command which releases the subsystem
365+
*/
366+
public static Command release(Subsystem subsystem) {
367+
if (subsystem == null) {
368+
throw new NullPointerException("subsystem == null");
369+
}
370+
371+
return new Command() {
372+
{
373+
requires(subsystem);
374+
}
375+
@Override
376+
protected boolean isFinished() {
377+
return true;
378+
}
379+
};
380+
}
354381
}

0 commit comments

Comments
 (0)