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;
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;
}
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;
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;
// 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;
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());
//
// 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());
--- /dev/null
+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();
+ }
+}
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());
+ }
}
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));
+ }
}
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));
+ }
}
+++ /dev/null
-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() {
- }
-}
return shooterSpeed;
}
+ public double getDistanceToGoal() {
+ return lidar.getDistance();
+ }
+
// Use negative # for decrement. Positive for increment.
public void changeSpeed(double change) {