add testing commands and buttons
authorCindy Zhang <cindyzyx9@gmail.com>
Wed, 17 Feb 2016 21:25:39 +0000 (13:25 -0800)
committerCindy Zhang <cindyzyx9@gmail.com>
Tue, 23 Feb 2016 00:22:21 +0000 (16:22 -0800)
src/org/usfirst/frc/team3501/robot/Constants.java
src/org/usfirst/frc/team3501/robot/OI.java
src/org/usfirst/frc/team3501/robot/commands/shooter/RecordData.java [new file with mode: 0644]
src/org/usfirst/frc/team3501/robot/commands/shooter/Test1.java
src/org/usfirst/frc/team3501/robot/commands/shooter/Test2.java
src/org/usfirst/frc/team3501/robot/commands/shooter/Test3.java
src/org/usfirst/frc/team3501/robot/commands/shooter/Test4.java [deleted file]
src/org/usfirst/frc/team3501/robot/subsystems/Shooter.java

index 4810e4b92c8abe1e748705f1d487854f821ff610..4374e3720bfe775845dca32e0f1598256adf3b39 100644 (file)
@@ -1,5 +1,7 @@
 package org.usfirst.frc.team3501.robot;
 
+import java.util.ArrayList;
+
 import edu.wpi.first.wpilibj.DoubleSolenoid;
 import edu.wpi.first.wpilibj.DoubleSolenoid.Value;
 import edu.wpi.first.wpilibj.I2C;
@@ -118,6 +120,9 @@ public class Constants {
 
     public static final Port LIDAR_I2C_PORT = I2C.Port.kMXP;
 
+    public static ArrayList<Double> speeds = new ArrayList<Double>();
+    public static ArrayList<Double> distances = new ArrayList<Double>();
+
     public static enum State {
       RUNNING, STOPPED;
     }
index fa7c3ec56ae5a6cb5fd334e3687d9b629e08fced..b59b6e08b14bcf3d53a76e1a25d4b2ab5aaad3f4 100644 (file)
@@ -1,9 +1,9 @@
 package org.usfirst.frc.team3501.robot;
 
+import org.usfirst.frc.team3501.robot.commands.shooter.RecordData;
 import org.usfirst.frc.team3501.robot.commands.shooter.Test1;
 import org.usfirst.frc.team3501.robot.commands.shooter.Test2;
 import org.usfirst.frc.team3501.robot.commands.shooter.Test3;
-import org.usfirst.frc.team3501.robot.commands.shooter.Test4;
 
 import edu.wpi.first.wpilibj.Joystick;
 import edu.wpi.first.wpilibj.buttons.Button;
@@ -12,10 +12,10 @@ import edu.wpi.first.wpilibj.buttons.JoystickButton;
 public class OI {
   public static Joystick leftJoystick;
   public static Joystick rightJoystick;
-  public static Button test1;
-  public static Button test2;
-  public static Button test3;
-  public static Button test4;
+  public static Button recordData;
+  public static Button shoot;
+  public static Button incrementSpeed;
+  public static Button decrementSpeed;
 
   // // first column of arcade buttons - getting past defenses
   // public static DigitalButton passPortcullis;
@@ -31,7 +31,8 @@ public class OI {
   // public static DigitalButton moveIntakeArmInsideRobot;
   //
   // // left joystick buttons
-  // public static Button toggleShooter;
+  public static Button toggleShooter;
+
   // public static Button SpinRobot180_1; // both do the same thing, just two
   // public static Button SpinRobot180_2; // different buttons
   // public static Button compactRobot_1;
@@ -48,22 +49,6 @@ public class OI {
     leftJoystick = new Joystick(Constants.OI.LEFT_STICK_PORT);
     rightJoystick = new Joystick(Constants.OI.RIGHT_STICK_PORT);
 
-    test1 = new JoystickButton(leftJoystick,
-        Constants.OI.SPIN1_PORT);
-    test1.whenPressed(new Test1());
-
-    test2 = new JoystickButton(leftJoystick,
-        Constants.OI.LEFT_JOYSTICK_TOP_CENTER_PORT);
-    test2.whenPressed(new Test2());
-
-    test3 = new JoystickButton(leftJoystick,
-        Constants.OI.SPIN2_PORT);
-    test3.whenPressed(new Test3());
-
-    test4 = new JoystickButton(leftJoystick,
-        Constants.OI.LEFT_JOYSTICK_TOP_LOW_PORT);
-    test4.whenPressed(new Test4());
-
     // passPortcullis = new DigitalButton(
     // new DigitalInput(Constants.OI.PASS_PORTCULLIS_PORT));
     // passPortcullis.whenPressed(new PassPortcullis());
@@ -102,6 +87,23 @@ public class OI {
     //
     // toggleShooter = new JoystickButton(leftJoystick,
     // Constants.OI.LEFT_JOYSTICK_TRIGGER_PORT);
+
+    recordData = new JoystickButton(leftJoystick,
+        Constants.OI.SPIN1_PORT);
+    recordData.whenPressed(new RecordData());
+
+    shoot = new JoystickButton(leftJoystick,
+        Constants.OI.LEFT_JOYSTICK_TRIGGER_PORT);
+    shoot.whenPressed(new Test1());
+
+    incrementSpeed = new JoystickButton(leftJoystick,
+        Constants.OI.SPIN2_PORT);
+    incrementSpeed.whenPressed(new Test2());
+
+    decrementSpeed = new JoystickButton(leftJoystick,
+        Constants.OI.LEFT_JOYSTICK_TOP_LOW_PORT);
+    decrementSpeed.whenPressed(new Test3());
+
     // SpinRobot180_1 = new JoystickButton(leftJoystick,
     // Constants.OI.SPIN1_PORT);
     // SpinRobot180_1.whenPressed(new Turn180());
diff --git a/src/org/usfirst/frc/team3501/robot/commands/shooter/RecordData.java b/src/org/usfirst/frc/team3501/robot/commands/shooter/RecordData.java
new file mode 100644 (file)
index 0000000..365a135
--- /dev/null
@@ -0,0 +1,40 @@
+package org.usfirst.frc.team3501.robot.commands.shooter;
+
+import org.usfirst.frc.team3501.robot.Constants;
+import org.usfirst.frc.team3501.robot.Robot;
+
+import edu.wpi.first.wpilibj.command.Command;
+
+/**
+ *
+ */
+public class RecordData extends Command {
+
+  public RecordData() {
+    requires(Robot.shooter);
+  }
+
+  @Override
+  protected void initialize() {
+    Constants.Shooter.speeds.add(Robot.shooter.getSpeed());
+    Constants.Shooter.distances.add(Robot.shooter.getDistanceToGoal());
+  }
+
+  @Override
+  protected void execute() {
+  }
+
+  @Override
+  protected boolean isFinished() {
+    return true;
+  }
+
+  @Override
+  protected void end() {
+  }
+
+  @Override
+  protected void interrupted() {
+    this.end();
+  }
+}
index f598dec9b6b100a62ea0307176ed2d5792018e20..edb1e0ac837be6b64424f2c248fb9f8751431863 100644 (file)
@@ -1,36 +1,13 @@
 package org.usfirst.frc.team3501.robot.commands.shooter;
 
-import edu.wpi.first.wpilibj.command.Command;
+import edu.wpi.first.wpilibj.command.CommandGroup;
 
 /**
  *
  */
-public class Test1 extends Command {
+public class Test1 extends CommandGroup {
 
-    public Test1() {
-        // Use requires() here to declare subsystem dependencies
-        // eg. requires(chassis);
-    }
-
-    // Called just before this Command runs the first time
-    protected void initialize() {
-    }
-
-    // Called repeatedly when this Command is scheduled to run
-    protected void execute() {
-    }
-
-    // Make this return true when this Command no longer needs to run execute()
-    protected boolean isFinished() {
-        return false;
-    }
-
-    // Called once after isFinished returns true
-    protected void end() {
-    }
-
-    // Called when another command which requires one or more of the same
-    // subsystems is scheduled to run
-    protected void interrupted() {
-    }
+  public Test1() {
+    addSequential(new Shoot());
+  }
 }
index 51ca6a9ff2f1dc6a19ad559b0596a9f824c9ebc8..8284f0bbc578aa424db2ffd0267427b85e6aec43 100644 (file)
@@ -1,36 +1,13 @@
 package org.usfirst.frc.team3501.robot.commands.shooter;
 
-import edu.wpi.first.wpilibj.command.Command;
+import edu.wpi.first.wpilibj.command.CommandGroup;
 
 /**
  *
  */
-public class Test2 extends Command {
+public class Test2 extends CommandGroup {
 
-    public Test2() {
-        // Use requires() here to declare subsystem dependencies
-        // eg. requires(chassis);
-    }
-
-    // Called just before this Command runs the first time
-    protected void initialize() {
-    }
-
-    // Called repeatedly when this Command is scheduled to run
-    protected void execute() {
-    }
-
-    // Make this return true when this Command no longer needs to run execute()
-    protected boolean isFinished() {
-        return false;
-    }
-
-    // Called once after isFinished returns true
-    protected void end() {
-    }
-
-    // Called when another command which requires one or more of the same
-    // subsystems is scheduled to run
-    protected void interrupted() {
-    }
+  public Test2() {
+    addSequential(new ChangeShooterSpeed(1));
+  }
 }
index 28afa218256d0ea0667bfa29506cdf4a78b804be..6625fe4290db42137e4e7e0e8c1b1b8ec1d137b0 100644 (file)
@@ -1,36 +1,13 @@
 package org.usfirst.frc.team3501.robot.commands.shooter;
 
-import edu.wpi.first.wpilibj.command.Command;
+import edu.wpi.first.wpilibj.command.CommandGroup;
 
 /**
  *
  */
-public class Test3 extends Command {
+public class Test3 extends CommandGroup {
 
-    public Test3() {
-        // Use requires() here to declare subsystem dependencies
-        // eg. requires(chassis);
-    }
-
-    // Called just before this Command runs the first time
-    protected void initialize() {
-    }
-
-    // Called repeatedly when this Command is scheduled to run
-    protected void execute() {
-    }
-
-    // Make this return true when this Command no longer needs to run execute()
-    protected boolean isFinished() {
-        return false;
-    }
-
-    // Called once after isFinished returns true
-    protected void end() {
-    }
-
-    // Called when another command which requires one or more of the same
-    // subsystems is scheduled to run
-    protected void interrupted() {
-    }
+  public Test3() {
+    addSequential(new ChangeShooterSpeed(-1));
+  }
 }
diff --git a/src/org/usfirst/frc/team3501/robot/commands/shooter/Test4.java b/src/org/usfirst/frc/team3501/robot/commands/shooter/Test4.java
deleted file mode 100644 (file)
index bc2e5cd..0000000
+++ /dev/null
@@ -1,36 +0,0 @@
-package org.usfirst.frc.team3501.robot.commands.shooter;
-
-import edu.wpi.first.wpilibj.command.Command;
-
-/**
- *
- */
-public class Test4 extends Command {
-
-    public Test4() {
-        // Use requires() here to declare subsystem dependencies
-        // eg. requires(chassis);
-    }
-
-    // Called just before this Command runs the first time
-    protected void initialize() {
-    }
-
-    // Called repeatedly when this Command is scheduled to run
-    protected void execute() {
-    }
-
-    // Make this return true when this Command no longer needs to run execute()
-    protected boolean isFinished() {
-        return false;
-    }
-
-    // Called once after isFinished returns true
-    protected void end() {
-    }
-
-    // Called when another command which requires one or more of the same
-    // subsystems is scheduled to run
-    protected void interrupted() {
-    }
-}
index 7b6ef174bd3cc046ade23a65c00695c7a99862cd..bf29b21e4907b71b8eea273f0b0dcc5b7e4ee8d8 100755 (executable)
@@ -87,6 +87,10 @@ public class Shooter extends Subsystem {
     return shooterSpeed;
   }
 
+  public double getDistanceToGoal() {
+    return lidar.getDistance();
+  }
+
   // Use negative # for decrement. Positive for increment.
 
   public void changeSpeed(double change) {