Fix some PIDCommand constructors not forwarding subsystems (#1299)

Also added missing constructor to wpilibc's InstantCommand and renamed
argument from requirement to subsystem as per
https://github.com/wpilibsuite/allwpilib/pull/1275#issuecomment-416071940.
This commit is contained in:
Tyler Veness
2018-09-02 14:18:12 -07:00
committed by Peter Johnson
parent c8482cd6d2
commit 0b113ad9ce
12 changed files with 119 additions and 113 deletions

View File

@@ -139,39 +139,39 @@ public abstract class Command extends SendableBase {
* Creates a new command with the given timeout and a default name. The default name is the name
* of the class.
*
* @param requirement the subsystem that this command requires
* @param subsystem the subsystem that this command requires
* @throws IllegalArgumentException if given a negative timeout
* @see Command#isTimedOut() isTimedOut()
*/
public Command(Subsystem requirement) {
public Command(Subsystem subsystem) {
this();
requires(requirement);
requires(subsystem);
}
/**
* Creates a new command with the given name.
*
* @param name the name for this command
* @param requirement the subsystem that this command requires
* @param name the name for this command
* @param subsystem the subsystem that this command requires
* @throws IllegalArgumentException if name is null
*/
public Command(String name, Subsystem requirement) {
public Command(String name, Subsystem subsystem) {
this(name);
requires(requirement);
requires(subsystem);
}
/**
* Creates a new command with the given timeout and a default name. The default name is the name
* of the class.
*
* @param timeout the time (in seconds) before this command "times out"
* @param requirement the subsystem that this command requires
* @param timeout the time (in seconds) before this command "times out"
* @param subsystem the subsystem that this command requires
* @throws IllegalArgumentException if given a negative timeout
* @see Command#isTimedOut() isTimedOut()
*/
public Command(double timeout, Subsystem requirement) {
public Command(double timeout, Subsystem subsystem) {
this(timeout);
requires(requirement);
requires(subsystem);
}
/**
@@ -193,16 +193,16 @@ public abstract class Command extends SendableBase {
/**
* Creates a new command with the given name and timeout.
*
* @param name the name of the command
* @param timeout the time (in seconds) before this command "times out"
* @param requirement the subsystem that this command requires
* @param name the name of the command
* @param timeout the time (in seconds) before this command "times out"
* @param subsystem the subsystem that this command requires
* @throws IllegalArgumentException if given a negative timeout
* @throws IllegalArgumentException if given a negative timeout or name was null.
* @see Command#isTimedOut() isTimedOut()
*/
public Command(String name, double timeout, Subsystem requirement) {
public Command(String name, double timeout, Subsystem subsystem) {
this(name, timeout);
requires(requirement);
requires(subsystem);
}
/**

View File

@@ -27,19 +27,19 @@ public class InstantCommand extends Command {
/**
* Creates a new {@link InstantCommand InstantCommand} with the given requirement.
* @param requirement the subsystem this command requires
* @param subsystem the subsystem this command requires
*/
public InstantCommand(Subsystem requirement) {
super(requirement);
public InstantCommand(Subsystem subsystem) {
super(subsystem);
}
/**
* Creates a new {@link InstantCommand InstantCommand} with the given name and requirement.
* @param name the name for this command
* @param requirement the subsystem this command requires
* @param name the name for this command
* @param subsystem the subsystem this command requires
*/
public InstantCommand(String name, Subsystem requirement) {
super(name, requirement);
public InstantCommand(String name, Subsystem subsystem) {
super(name, subsystem);
}
@Override

View File

@@ -109,15 +109,15 @@ public abstract class PIDCommand extends Command {
/**
* Instantiates a {@link PIDCommand} that will use the given p, i and d values.
*
* @param name the name of the command
* @param p the proportional value
* @param i the integral value
* @param d the derivative value
* @param requirement the subsystem that this command requires
* @param name the name of the command
* @param p the proportional value
* @param i the integral value
* @param d the derivative value
* @param subsystem the subsystem that this command requires
*/
@SuppressWarnings("ParameterName")
public PIDCommand(String name, double p, double i, double d, Subsystem requirement) {
super(name, requirement);
public PIDCommand(String name, double p, double i, double d, Subsystem subsystem) {
super(name, subsystem);
m_controller = new PIDController(p, i, d, m_source, m_output);
}
@@ -125,17 +125,17 @@ public abstract class PIDCommand extends Command {
* Instantiates a {@link PIDCommand} that will use the given p, i and d values. It will also space
* the time between PID loop calculations to be equal to the given period.
*
* @param name the name
* @param p the proportional value
* @param i the integral value
* @param d the derivative value
* @param period the time (in seconds) between calculations
* @param requirement the subsystem that this command requires
* @param name the name
* @param p the proportional value
* @param i the integral value
* @param d the derivative value
* @param period the time (in seconds) between calculations
* @param subsystem the subsystem that this command requires
*/
@SuppressWarnings("ParameterName")
public PIDCommand(String name, double p, double i, double d, double period,
Subsystem requirement) {
super(name, requirement);
Subsystem subsystem) {
super(name, subsystem);
m_controller = new PIDController(p, i, d, m_source, m_output, period);
}
@@ -143,14 +143,14 @@ public abstract class PIDCommand extends Command {
* Instantiates a {@link PIDCommand} that will use the given p, i and d values. It will use the
* class name as its name.
*
* @param p the proportional value
* @param i the integral value
* @param d the derivative value
* @param requirement the subsystem that this command requires
* @param p the proportional value
* @param i the integral value
* @param d the derivative value
* @param subsystem the subsystem that this command requires
*/
@SuppressWarnings("ParameterName")
public PIDCommand(double p, double i, double d, Subsystem requirement) {
super(requirement);
public PIDCommand(double p, double i, double d, Subsystem subsystem) {
super(subsystem);
m_controller = new PIDController(p, i, d, m_source, m_output);
}
@@ -159,15 +159,15 @@ public abstract class PIDCommand extends Command {
* class name as its name. It will also space the time between PID loop calculations to be equal
* to the given period.
*
* @param p the proportional value
* @param i the integral value
* @param d the derivative value
* @param period the time (in seconds) between calculations
* @param requirement the subsystem that this command requires
* @param p the proportional value
* @param i the integral value
* @param d the derivative value
* @param period the time (in seconds) between calculations
* @param subsystem the subsystem that this command requires
*/
@SuppressWarnings("ParameterName")
public PIDCommand(double p, double i, double d, double period, Subsystem requirement) {
super(requirement);
public PIDCommand(double p, double i, double d, double period, Subsystem subsystem) {
super(subsystem);
m_controller = new PIDController(p, i, d, m_source, m_output, period);
}

View File

@@ -34,22 +34,22 @@ public class TimedCommand extends Command {
/**
* Instantiates a TimedCommand with the given name and timeout.
*
* @param name the name of the command
* @param timeout the time the command takes to run (seconds)
* @param requirement the subsystem that this command requires
* @param name the name of the command
* @param timeout the time the command takes to run (seconds)
* @param subsystem the subsystem that this command requires
*/
public TimedCommand(String name, double timeout, Subsystem requirement) {
super(name, timeout, requirement);
public TimedCommand(String name, double timeout, Subsystem subsystem) {
super(name, timeout, subsystem);
}
/**
* Instantiates a TimedCommand with the given timeout.
*
* @param timeout the time the command takes to run (seconds)
* @param requirement the subsystem that this command requires
* @param timeout the time the command takes to run (seconds)
* @param subsystem the subsystem that this command requires
*/
public TimedCommand(double timeout, Subsystem requirement) {
super(timeout, requirement);
public TimedCommand(double timeout, Subsystem subsystem) {
super(timeout, subsystem);
}
/**