From 989df4341fb279b1ca69030fb3fa1fe1a87dcfc5 Mon Sep 17 00:00:00 2001 From: John Date: Sat, 8 Feb 2020 09:11:17 -0500 Subject: [PATCH 01/68] accounted for the other cansparks for drivetrain --- src/main/java/frc/robot/OI.java | 3 +- src/main/java/frc/robot/Robot.java | 4 +- .../frc/robot/commands/DriveWithJoystick.java | 112 +++++++++--------- .../robot/commands/DriveWithJoystickLeft.java | 4 +- .../frc/robot/commands/MoveDrivetrain.java | 2 +- .../frc/robot/commands/StopDrivetrain.java | 4 +- .../java/frc/robot/subsystems/Drivetrain.java | 35 ++++-- 7 files changed, 93 insertions(+), 71 deletions(-) diff --git a/src/main/java/frc/robot/OI.java b/src/main/java/frc/robot/OI.java index 5a185fb..0f1be14 100644 --- a/src/main/java/frc/robot/OI.java +++ b/src/main/java/frc/robot/OI.java @@ -68,12 +68,13 @@ public OI() { initButtons(); initUsed(); - // driveButton.whileHeld(new DriveWithJoystick(driverStick, 0.1)); //this should be the default command of the DT + driveButton.whileHeld(new DriveWithJoystick(driverStick, 0.1)); //this should be the default command of the DT //LEAVE OUT driverStart.whileHeld(new ExtendBothLifters(.8,false,driverStick)); //THESE TWO LINES ARE FOR TESTING //LEAVE OUT driverA.whenPressed(new AutoSetLifterPots()); //LEAVE OUT driverB.whenPressed(new ExtendBothLifters(.8,false,driverStick,false)); + driverA.whenPressed(new MoveShooter()); driverA.whenReleased(new StopShooter()); driverB.whenPressed(new MoveElevator()); diff --git a/src/main/java/frc/robot/Robot.java b/src/main/java/frc/robot/Robot.java index f260a0d..baf8b88 100644 --- a/src/main/java/frc/robot/Robot.java +++ b/src/main/java/frc/robot/Robot.java @@ -44,12 +44,12 @@ public void robotPeriodic() { @Override public void disabledInit() { - drivetrain.setMotors(0); + drivetrain.setMotors(0,0); } @Override public void disabledPeriodic() { - drivetrain.setMotors(0); + drivetrain.setMotors(0,0); // Robot.drivetrain.resetGyro(); // autoCommand.start(); } diff --git a/src/main/java/frc/robot/commands/DriveWithJoystick.java b/src/main/java/frc/robot/commands/DriveWithJoystick.java index b7a7deb..3a5cfdf 100644 --- a/src/main/java/frc/robot/commands/DriveWithJoystick.java +++ b/src/main/java/frc/robot/commands/DriveWithJoystick.java @@ -1,69 +1,69 @@ -// package frc.robot.commands; +package frc.robot.commands; -// import edu.wpi.first.wpilibj.Joystick; -// import edu.wpi.first.wpilibj.command.Command; -// import frc.robot.Constants; -// import frc.robot.Robot; +import edu.wpi.first.wpilibj.Joystick; +import edu.wpi.first.wpilibj.command.Command; +import frc.robot.Constants; +import frc.robot.Robot; -// public class DriveWithJoystick extends Command { -// private Joystick stick; -// private boolean isSquaredTurn; -// private double deadzone; +public class DriveWithJoystick extends Command { + private Joystick stick; + private boolean isSquaredTurn; + private double deadzone; -// public DriveWithJoystick(Joystick stick, double deadzone) { -// super("DriveWithJoystick"); -// requires(Robot.drivetrain); -// this.stick = stick; -// this.deadzone = deadzone; -// } + public DriveWithJoystick(Joystick stick, double deadzone) { + super("DriveWithJoystick"); + requires(Robot.drivetrain); + this.stick = stick; + this.deadzone = deadzone; + } -// public void execute() { -// double thrust = 0; -// if(stick.getRawButton(6)) { -// thrust = Constants.kCreep; -// } -// else if(stick.getRawButton(5)) { -// thrust = -Constants.kCreep; -// } else { -// thrust = stick.getRawAxis(3) - stick.getRawAxis(2); -// if(Math.abs(thrust) < deadzone) { -// thrust = 0; -// } -// } + public void execute() { + double thrust = 0; + if(stick.getRawButton(6)) { + thrust = Constants.kCreep; + } + else if(stick.getRawButton(5)) { + thrust = -Constants.kCreep; + } else { + thrust = stick.getRawAxis(3) - stick.getRawAxis(2); + if(Math.abs(thrust) < deadzone) { + thrust = 0; + } + } -// double turn = stick.getRawAxis(0); + double turn = stick.getRawAxis(0); -// if(turn < deadzone && turn > -deadzone) { -// turn = 0; -// } + if(turn < deadzone && turn > -deadzone) { + turn = 0; + } -// if(isSquaredTurn) { -// turn *= Math.abs(turn); -// } + if(isSquaredTurn) { + turn *= Math.abs(turn); + } -// if(stick.getRawButton(2)) { -// turn /= 3; -// } + if(stick.getRawButton(2)) { + turn /= 3; + } -// // This causes the robot to crash. It is the ideal solution to wheelies. -// // if(Math.abs(turn) > 0.05) { -// // Robot.drivetrain.setLimit(Constants.kNeoAmpLimitTurn); -// // } -// // else { -// // Robot.drivetrain.setLimit(Constants.kNeoAmpLimit); -// // } + // This causes the robot to crash. It is the ideal solution to wheelies. + // if(Math.abs(turn) > 0.05) { + // Robot.drivetrain.setLimit(Constants.kNeoAmpLimitTurn); + // } + // else { + // Robot.drivetrain.setLimit(Constants.kNeoAmpLimit); + // } -// double left = Math.max(Math.min(thrust + turn, 1), -1); -// double right = Math.max(Math.min(thrust - turn, 1), -1); + double left = Math.max(Math.min(thrust + turn, 1), -1); + double right = Math.max(Math.min(thrust - turn, 1), -1); -// Robot.drivetrain.setMotors(left, right); -// } + Robot.drivetrain.setMotors(left, right); + } -// public void end() { -// Robot.drivetrain.setMotors(0, 0); -// } + public void end() { + Robot.drivetrain.setMotors(0, 0); + } -// public boolean isFinished() { -// return false; -// } -// } \ No newline at end of file + public boolean isFinished() { + return false; + } +} \ No newline at end of file diff --git a/src/main/java/frc/robot/commands/DriveWithJoystickLeft.java b/src/main/java/frc/robot/commands/DriveWithJoystickLeft.java index d69c018..861df04 100644 --- a/src/main/java/frc/robot/commands/DriveWithJoystickLeft.java +++ b/src/main/java/frc/robot/commands/DriveWithJoystickLeft.java @@ -17,11 +17,11 @@ public DriveWithJoystickLeft() { public void execute() { System.out.println("This is left Neo"); - Robot.drivetrain.setMotors(-1); + Robot.drivetrain.setMotors(-1,-1); } public void end() { - Robot.drivetrain.setMotors(-1); + Robot.drivetrain.setMotors(-1,-1); } public boolean isFinished() { diff --git a/src/main/java/frc/robot/commands/MoveDrivetrain.java b/src/main/java/frc/robot/commands/MoveDrivetrain.java index 9f64dbd..b782c68 100644 --- a/src/main/java/frc/robot/commands/MoveDrivetrain.java +++ b/src/main/java/frc/robot/commands/MoveDrivetrain.java @@ -27,7 +27,7 @@ protected void initialize() { // Called repeatedly when this Command is scheduled to run @Override protected void execute() { - Robot.drivetrain.setMotors(Constants.DRIVETRAIN_OUTPUT); + Robot.drivetrain.setMotors(Constants.DRIVETRAIN_OUTPUT,Constants.DRIVETRAIN_OUTPUT); } // Make this return true when this Command no longer needs to run execute() diff --git a/src/main/java/frc/robot/commands/StopDrivetrain.java b/src/main/java/frc/robot/commands/StopDrivetrain.java index 5c430a6..4dfc545 100644 --- a/src/main/java/frc/robot/commands/StopDrivetrain.java +++ b/src/main/java/frc/robot/commands/StopDrivetrain.java @@ -27,7 +27,7 @@ protected void initialize() { // Called repeatedly when this Command is scheduled to run @Override protected void execute() { - Robot.drivetrain.setMotors(0); + Robot.drivetrain.setMotors(0,0); } // Make this return true when this Command no longer needs to run execute() @@ -39,7 +39,7 @@ protected boolean isFinished() { // Called once after isFinished returns true @Override protected void end() { - Robot.drivetrain.setMotors(0); + Robot.drivetrain.setMotors(0,0); } // Called when another command which requires one or more of the same diff --git a/src/main/java/frc/robot/subsystems/Drivetrain.java b/src/main/java/frc/robot/subsystems/Drivetrain.java index a49afaa..824b294 100644 --- a/src/main/java/frc/robot/subsystems/Drivetrain.java +++ b/src/main/java/frc/robot/subsystems/Drivetrain.java @@ -5,7 +5,7 @@ import com.ctre.phoenix.motorcontrol.ControlMode; import com.ctre.phoenix.motorcontrol.can.TalonSRX; - +import edu.wpi.first.wpilibj.CAN; import edu.wpi.first.wpilibj.command.Subsystem; import edu.wpi.first.wpilibj.smartdashboard.SmartDashboard; @@ -15,11 +15,31 @@ public class Drivetrain extends Subsystem { - public CANSparkMax drivetrain_neo; + private CANSparkMax leftLeader; + private CANSparkMax rightLeader; + private CANSparkMax [] leftFollowers; + private CANSparkMax [] rightFollowers; + + public Drivetrain() { - drivetrain_neo = new CANSparkMax(RobotMap.DRIVETRAIN_NEO, MotorType.kBrushless); - drivetrain_neo.setOpenLoopRampRate(Constants.kNeoRampTime); + leftLeader = new CANSparkMax(RobotMap.DRIVETRAIN_NEO, MotorType.kBrushless); + leftLeader.setOpenLoopRampRate(Constants.kNeoRampTime); + rightLeader = new CANSparkMax(RobotMap.DRIVETRAIN_NEO, MotorType.kBrushless); + rightLeader.setOpenLoopRampRate(Constants.kNeoRampTime); + + leftFollowers = new CANSparkMax[RobotMap.kLeftFollowers.length]; + for(int i = 0; i < leftFollowers.length; ++i) { + leftFollowers[i] = new CANSparkMax(RobotMap.kLeftFollowers[i], MotorType.kBrushless); + leftFollowers[i].setOpenLoopRampRate(Constants.kNeoRampTime); + leftFollowers[i].follow(leftLeader); + } + rightFollowers = new CANSparkMax[RobotMap.kLeftFollowers.length]; + for(int i = 0; i < leftFollowers.length; ++i) { + rightFollowers[i] = new CANSparkMax(RobotMap.kLeftFollowers[i], MotorType.kBrushless); + rightFollowers[i].setOpenLoopRampRate(Constants.kNeoRampTime); + rightFollowers[i].follow(rightLeader); + } } public void initDefaultCommand() { @@ -27,9 +47,10 @@ public void initDefaultCommand() { } - public void setMotors(final double left) { - drivetrain_neo.set(left); - } + public void setMotors(double left, double right) { + leftLeader.set(left); + rightLeader.set(right); + } public void debug() { } } \ No newline at end of file From 0dd433afc8100ca9a6cc7d0255ce0899699897df Mon Sep 17 00:00:00 2001 From: John Date: Sat, 8 Feb 2020 09:26:21 -0500 Subject: [PATCH 02/68] changed a drivetrian command and checked if ids for cansparkmaxs are correct --- src/main/java/frc/robot/OI.java | 16 +++++++++------- src/main/java/frc/robot/RobotMap.java | 4 ++-- ...oystickLeft.java => DrivetrainBackwards.java} | 7 +++---- 3 files changed, 14 insertions(+), 13 deletions(-) rename src/main/java/frc/robot/commands/{DriveWithJoystickLeft.java => DrivetrainBackwards.java} (74%) diff --git a/src/main/java/frc/robot/OI.java b/src/main/java/frc/robot/OI.java index 0f1be14..9a60041 100644 --- a/src/main/java/frc/robot/OI.java +++ b/src/main/java/frc/robot/OI.java @@ -68,19 +68,21 @@ public OI() { initButtons(); initUsed(); - driveButton.whileHeld(new DriveWithJoystick(driverStick, 0.1)); //this should be the default command of the DT + driveButton.whileHeld(new DriveWithJoystick(driverStick, 0.1)); // TODO CHANGE DEADZONE VALUE IT MIGHT NOT BE THE SAME //LEAVE OUT driverStart.whileHeld(new ExtendBothLifters(.8,false,driverStick)); //THESE TWO LINES ARE FOR TESTING //LEAVE OUT driverA.whenPressed(new AutoSetLifterPots()); //LEAVE OUT driverB.whenPressed(new ExtendBothLifters(.8,false,driverStick,false)); - driverA.whenPressed(new MoveShooter()); - driverA.whenReleased(new StopShooter()); - driverB.whenPressed(new MoveElevator()); - driverB.whenReleased(new StopElevator()); - driverX.whenPressed(new MoveHopper()); - driverX.whenReleased(new StopHopper()); + // driverA.whenPressed(new MoveShooter()); + // driverA.whenReleased(new StopShooter()); + // driverB.whenPressed(new MoveElevator()); + // driverB.whenReleased(new StopElevator()); + // driverX.whenPressed(new MoveHopper()); + // driverX.whenReleased(new StopHopper()); + driverB.whenPressed(new DrivetrainBackwards()); + driverB.whenReleased(new StopDrivetrain()); driverY.whenPressed(new MoveDrivetrain()); driverY.whenReleased(new StopDrivetrain()); driverLB.whenPressed(new runHopperElevator()); diff --git a/src/main/java/frc/robot/RobotMap.java b/src/main/java/frc/robot/RobotMap.java index 372ddb1..92a4cd9 100644 --- a/src/main/java/frc/robot/RobotMap.java +++ b/src/main/java/frc/robot/RobotMap.java @@ -24,8 +24,8 @@ public class RobotMap { //Drivetrain public static final int kLeftLeader = 1; public static final int kRightLeader = 3; - public static final int[] kLeftFollowers = {24}; - public static final int[] kRightFollowers = {23}; + public static final int[] kLeftFollowers = {24};// check if these are the right ids + public static final int[] kRightFollowers = {23}; // check if these are the right ids // public static final int[] kLineSensors = {7, 6, 5, 4}; public static final int[] kLineSensors = {4,5,6,7}; public static final int kLEDBlueSolenoid = 7; diff --git a/src/main/java/frc/robot/commands/DriveWithJoystickLeft.java b/src/main/java/frc/robot/commands/DrivetrainBackwards.java similarity index 74% rename from src/main/java/frc/robot/commands/DriveWithJoystickLeft.java rename to src/main/java/frc/robot/commands/DrivetrainBackwards.java index 861df04..af099eb 100644 --- a/src/main/java/frc/robot/commands/DriveWithJoystickLeft.java +++ b/src/main/java/frc/robot/commands/DrivetrainBackwards.java @@ -5,18 +5,17 @@ import frc.robot.Constants; import frc.robot.Robot; -public class DriveWithJoystickLeft extends Command { +public class DrivetrainBackwards extends Command { private Joystick stick; private boolean isSquaredTurn; private double deadzone; - public DriveWithJoystickLeft() { - super("DriveWithJoystickLeft"); + public DrivetrainBackwards() { + super("DrivetrainBackwards"); requires(Robot.drivetrain); } public void execute() { - System.out.println("This is left Neo"); Robot.drivetrain.setMotors(-1,-1); } From ad6ecfac81257d6c5bf5a6ed256f2c2eef665e46 Mon Sep 17 00:00:00 2001 From: John Date: Tue, 11 Feb 2020 16:02:59 -0500 Subject: [PATCH 03/68] made a lot of changes --- .../frc/robot/Autons/runElevatorShooter.java | 66 +++++++++---------- src/main/java/frc/robot/Constants.java | 3 + src/main/java/frc/robot/OI.java | 4 +- src/main/java/frc/robot/RobotMap.java | 8 ++- .../frc/robot/commands/DriveWithJoystick.java | 11 +++- .../frc/robot/commands/MoveDrivetrain.java | 2 +- .../java/frc/robot/subsystems/Drivetrain.java | 12 ++-- 7 files changed, 60 insertions(+), 46 deletions(-) diff --git a/src/main/java/frc/robot/Autons/runElevatorShooter.java b/src/main/java/frc/robot/Autons/runElevatorShooter.java index a04732b..357d400 100644 --- a/src/main/java/frc/robot/Autons/runElevatorShooter.java +++ b/src/main/java/frc/robot/Autons/runElevatorShooter.java @@ -1,38 +1,38 @@ -/*----------------------------------------------------------------------------*/ -/* Copyright (c) 2018 FIRST. All Rights Reserved. */ -/* Open Source Software - may be modified and shared by FRC teams. The code */ -/* must be accompanied by the FIRST BSD license file in the root directory of */ -/* the project. */ -/*----------------------------------------------------------------------------*/ +// /*----------------------------------------------------------------------------*/ +// /* Copyright (c) 2018 FIRST. All Rights Reserved. */ +// /* Open Source Software - may be modified and shared by FRC teams. The code */ +// /* must be accompanied by the FIRST BSD license file in the root directory of */ +// /* the project. */ +// /*----------------------------------------------------------------------------*/ -package frc.robot.Autons; +// package frc.robot.Autons; -import edu.wpi.first.wpilibj.command.CommandGroup; -import frc.robot.commands.MoveElevator; -import frc.robot.commands.MoveShooter; +// import edu.wpi.first.wpilibj.command.CommandGroup; +// import frc.robot.commands.MoveElevator; +// import frc.robot.commands.MoveShooter; -public class runElevatorShooter extends CommandGroup { - /** - * Add your docs here. - */ - public runElevatorShooter() { - addParallel(new MoveElevator()); - addParallel(new MoveShooter()); - // Add Commands here: - // e.g. addSequential(new Command1()); - // addSequential(new Command2()); - // these will run in order. +// public class runElevatorShooter extends CommandGroup { +// /** +// * Add your docs here. +// */ +// public runElevatorShooter() { +// addParallel(new MoveElevator()); +// addParallel(new MoveShooter()); +// // Add Commands here: +// // e.g. addSequential(new Command1()); +// // addSequential(new Command2()); +// // these will run in order. - // To run multiple commands at the same time, - // use addParallel() - // e.g. addParallel(new Command1()); - // addSequential(new Command2()); - // Command1 and Command2 will run in parallel. +// // To run multiple commands at the same time, +// // use addParallel() +// // e.g. addParallel(new Command1()); +// // addSequential(new Command2()); +// // Command1 and Command2 will run in parallel. - // A command group will require all of the subsystems that each member - // would require. - // e.g. if Command1 requires chassis, and Command2 requires arm, - // a CommandGroup containing them would require both the chassis and the - // arm. - } -} +// // A command group will require all of the subsystems that each member +// // would require. +// // e.g. if Command1 requires chassis, and Command2 requires arm, +// // a CommandGroup containing them would require both the chassis and the +// // arm. +// } +// } diff --git a/src/main/java/frc/robot/Constants.java b/src/main/java/frc/robot/Constants.java index 2bd28d7..1693426 100644 --- a/src/main/java/frc/robot/Constants.java +++ b/src/main/java/frc/robot/Constants.java @@ -44,4 +44,7 @@ public final class Constants { public static final double MANUAL_POWER = .2; + + public static final double TURN_FACTOR = 0.16; + } \ No newline at end of file diff --git a/src/main/java/frc/robot/OI.java b/src/main/java/frc/robot/OI.java index 9a60041..ee37b8b 100644 --- a/src/main/java/frc/robot/OI.java +++ b/src/main/java/frc/robot/OI.java @@ -6,7 +6,7 @@ import frc.robot.Autons.RunElevatorWithJoystick; import frc.robot.Autons.RunHopperWithJoystick; import frc.robot.Autons.runDrivetrainShooter; -import frc.robot.Autons.runElevatorShooter; +// import frc.robot.Autons.runElevatorShooter; import frc.robot.Autons.runHopperElevator; import frc.robot.Autons.stopDrivetrainShooter; import frc.robot.Autons.stopElevatorShooter; @@ -89,7 +89,7 @@ public OI() { driverLB.whenReleased(new stopHopperElevator()); driverRB.whenPressed(new runDrivetrainShooter()); driverRB.whenReleased(new stopDrivetrainShooter()); - driverLS.whenPressed(new runElevatorShooter()); + // driverLS.whenPressed(new runElevatorShooter()); driverLS.whenReleased(new stopElevatorShooter()); operatorLeftJoystickUsed.whenPressed(new RunHopperWithJoystick(operatorLeftJoystickUsed)); // //true does right hp far rocket path, false does right hp bay 1 ship path diff --git a/src/main/java/frc/robot/RobotMap.java b/src/main/java/frc/robot/RobotMap.java index 92a4cd9..2115963 100644 --- a/src/main/java/frc/robot/RobotMap.java +++ b/src/main/java/frc/robot/RobotMap.java @@ -22,9 +22,11 @@ public class RobotMap { public static final int kPDP = 0; //Drivetrain - public static final int kLeftLeader = 1; - public static final int kRightLeader = 3; - public static final int[] kLeftFollowers = {24};// check if these are the right ids + public static final int kLeftLeader = 20; + public static final int kRightLeader = 22; + public static final int leftFollower = 21; + public static final int rightFollower = 23; + public static final int[] kLeftFollowers = {21};// check if these are the right ids public static final int[] kRightFollowers = {23}; // check if these are the right ids // public static final int[] kLineSensors = {7, 6, 5, 4}; public static final int[] kLineSensors = {4,5,6,7}; diff --git a/src/main/java/frc/robot/commands/DriveWithJoystick.java b/src/main/java/frc/robot/commands/DriveWithJoystick.java index 3a5cfdf..3ff5a8e 100644 --- a/src/main/java/frc/robot/commands/DriveWithJoystick.java +++ b/src/main/java/frc/robot/commands/DriveWithJoystick.java @@ -18,6 +18,15 @@ public DriveWithJoystick(Joystick stick, double deadzone) { } public void execute() { + // if(stick.getRawButton(5) && stick.getRawButton(6)){ + // Robot.drivetrain.setMotors(Constants.kCreep, Constants.kCreep); + // } else if (stick.getRawButton(5)){ + // Robot.drivetrain.setMotors(-Constants.kCreep, Constants.kCreep); + // } else if (stick.getRawButton(6)){ + // Robot.drivetrain.setMotors( Constants.kCreep, -Constants.kCreep); + // } else { + // Robot.drivetrain.setMotors(0, 0); + // } double thrust = 0; if(stick.getRawButton(6)) { thrust = Constants.kCreep; @@ -31,7 +40,7 @@ else if(stick.getRawButton(5)) { } } - double turn = stick.getRawAxis(0); + double turn = stick.getRawAxis(0) * Constants.TURN_FACTOR; if(turn < deadzone && turn > -deadzone) { turn = 0; diff --git a/src/main/java/frc/robot/commands/MoveDrivetrain.java b/src/main/java/frc/robot/commands/MoveDrivetrain.java index b782c68..5c8ffc0 100644 --- a/src/main/java/frc/robot/commands/MoveDrivetrain.java +++ b/src/main/java/frc/robot/commands/MoveDrivetrain.java @@ -27,7 +27,7 @@ protected void initialize() { // Called repeatedly when this Command is scheduled to run @Override protected void execute() { - Robot.drivetrain.setMotors(Constants.DRIVETRAIN_OUTPUT,Constants.DRIVETRAIN_OUTPUT); + Robot.drivetrain.setMotors(Constants.DRIVETRAIN_OUTPUT,-Constants.DRIVETRAIN_OUTPUT); } // Make this return true when this Command no longer needs to run execute() diff --git a/src/main/java/frc/robot/subsystems/Drivetrain.java b/src/main/java/frc/robot/subsystems/Drivetrain.java index 824b294..e83bcfc 100644 --- a/src/main/java/frc/robot/subsystems/Drivetrain.java +++ b/src/main/java/frc/robot/subsystems/Drivetrain.java @@ -23,9 +23,9 @@ public class Drivetrain extends Subsystem { public Drivetrain() { - leftLeader = new CANSparkMax(RobotMap.DRIVETRAIN_NEO, MotorType.kBrushless); + leftLeader = new CANSparkMax(RobotMap.kLeftLeader, MotorType.kBrushless); leftLeader.setOpenLoopRampRate(Constants.kNeoRampTime); - rightLeader = new CANSparkMax(RobotMap.DRIVETRAIN_NEO, MotorType.kBrushless); + rightLeader = new CANSparkMax(RobotMap.kRightLeader, MotorType.kBrushless); rightLeader.setOpenLoopRampRate(Constants.kNeoRampTime); leftFollowers = new CANSparkMax[RobotMap.kLeftFollowers.length]; @@ -34,9 +34,9 @@ public Drivetrain() { leftFollowers[i].setOpenLoopRampRate(Constants.kNeoRampTime); leftFollowers[i].follow(leftLeader); } - rightFollowers = new CANSparkMax[RobotMap.kLeftFollowers.length]; - for(int i = 0; i < leftFollowers.length; ++i) { - rightFollowers[i] = new CANSparkMax(RobotMap.kLeftFollowers[i], MotorType.kBrushless); + rightFollowers = new CANSparkMax[RobotMap.kRightFollowers.length]; + for(int i = 0; i < rightFollowers.length; ++i) { + rightFollowers[i] = new CANSparkMax(RobotMap.kRightFollowers[i], MotorType.kBrushless); rightFollowers[i].setOpenLoopRampRate(Constants.kNeoRampTime); rightFollowers[i].follow(rightLeader); } @@ -48,7 +48,7 @@ public void initDefaultCommand() { public void setMotors(double left, double right) { - leftLeader.set(left); + leftLeader.set(-left); rightLeader.set(right); } public void debug() { From 5ef29a3f0721cae0aa25403567bc0361c924c03d Mon Sep 17 00:00:00 2001 From: John Date: Tue, 11 Feb 2020 16:34:14 -0500 Subject: [PATCH 04/68] added alternate encoder methods --- .../java/frc/robot/subsystems/Drivetrain.java | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/src/main/java/frc/robot/subsystems/Drivetrain.java b/src/main/java/frc/robot/subsystems/Drivetrain.java index e83bcfc..0c65b91 100644 --- a/src/main/java/frc/robot/subsystems/Drivetrain.java +++ b/src/main/java/frc/robot/subsystems/Drivetrain.java @@ -51,6 +51,26 @@ public void setMotors(double left, double right) { leftLeader.set(-left); rightLeader.set(right); } + + public double getLeftMotor(){ + return leftLeader.getEncoder().getVelocity(); + } + + public double getRightMotor(){ + return rightLeader.getEncoder().getVelocity(); + } + + public double getRightPosition(){ + return leftLeader.getAlternateEncoder().getPosition(); + } + + public double getLeftPosition(){ + return rightLeader.getAlternateEncoder().getPosition(); + } public void debug() { + SmartDashboard.putNumber("Get Left Velocity", getLeftMotor()); + SmartDashboard.putNumber("Get Right Velocity", getRightMotor()); + SmartDashboard.putNumber("Get Right Position", getRightPosition()); + SmartDashboard.putNumber("Get Left Position", getLeftPosition()); } } \ No newline at end of file From 51eb20e782b819cb72c5ef6afb3ce3df8220ca01 Mon Sep 17 00:00:00 2001 From: John Date: Tue, 11 Feb 2020 17:30:50 -0500 Subject: [PATCH 05/68] added in alternate encoder --- src/main/java/frc/robot/subsystems/Drivetrain.java | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/main/java/frc/robot/subsystems/Drivetrain.java b/src/main/java/frc/robot/subsystems/Drivetrain.java index 0c65b91..043d030 100644 --- a/src/main/java/frc/robot/subsystems/Drivetrain.java +++ b/src/main/java/frc/robot/subsystems/Drivetrain.java @@ -27,7 +27,6 @@ public Drivetrain() { leftLeader.setOpenLoopRampRate(Constants.kNeoRampTime); rightLeader = new CANSparkMax(RobotMap.kRightLeader, MotorType.kBrushless); rightLeader.setOpenLoopRampRate(Constants.kNeoRampTime); - leftFollowers = new CANSparkMax[RobotMap.kLeftFollowers.length]; for(int i = 0; i < leftFollowers.length; ++i) { leftFollowers[i] = new CANSparkMax(RobotMap.kLeftFollowers[i], MotorType.kBrushless); @@ -67,10 +66,19 @@ public double getRightPosition(){ public double getLeftPosition(){ return rightLeader.getAlternateEncoder().getPosition(); } + public double getLeftCPR(){ + return leftLeader.getAlternateEncoder().getCountsPerRevolution(); + } + + public double getRightCPR(){ + return rightLeader.getAlternateEncoder().getCountsPerRevolution(); + } public void debug() { SmartDashboard.putNumber("Get Left Velocity", getLeftMotor()); SmartDashboard.putNumber("Get Right Velocity", getRightMotor()); SmartDashboard.putNumber("Get Right Position", getRightPosition()); SmartDashboard.putNumber("Get Left Position", getLeftPosition()); + SmartDashboard.putNumber("Get Right CPR", getRightCPR()); + SmartDashboard.putNumber("Get Left CPR", getLeftCPR()); } } \ No newline at end of file From 4b879789b9862edb1f32a5cfc6f1ed35ae8f847f Mon Sep 17 00:00:00 2001 From: fidgetspinnerkid <35818373+fidgetspinnerkid@users.noreply.github.com> Date: Tue, 11 Feb 2020 15:58:55 -0800 Subject: [PATCH 06/68] Changing and testing things in Drivetrain Still not done unfortunately but will continue tomorrow --- src/main/java/frc/robot/Constants.java | 4 +-- src/main/java/frc/robot/OI.java | 3 +- .../frc/robot/commands/DriveWithJoystick.java | 1 + .../java/frc/robot/subsystems/Drivetrain.java | 33 ++++++++++++++----- 4 files changed, 30 insertions(+), 11 deletions(-) diff --git a/src/main/java/frc/robot/Constants.java b/src/main/java/frc/robot/Constants.java index 1693426..a473d0d 100644 --- a/src/main/java/frc/robot/Constants.java +++ b/src/main/java/frc/robot/Constants.java @@ -8,7 +8,7 @@ public final class Constants { // Drivetrain constants public static final double kFastDrive = 1.0; public static final double kSlowDrive = 0.5; - public static final double kCreep = 0.2; + public static final double kCreep = .6; public static final double kSlowish = 0.5; //Testing should be 0.5 public static final double kLineFollowStraight = 0.19; //0.27; public static final double kLineFollowTurn = 0.2; //0.5; @@ -36,7 +36,7 @@ public final class Constants { public static final double SHOOTER_OUTPUT = -.8; - public static final double DRIVETRAIN_OUTPUT = -.5; + public static final double DRIVETRAIN_OUTPUT = -1.0; public static final double SHOOTER_OUTPUT_PASSIVE = -.1; diff --git a/src/main/java/frc/robot/OI.java b/src/main/java/frc/robot/OI.java index ee37b8b..1c350c8 100644 --- a/src/main/java/frc/robot/OI.java +++ b/src/main/java/frc/robot/OI.java @@ -69,7 +69,8 @@ public OI() { initUsed(); driveButton.whileHeld(new DriveWithJoystick(driverStick, 0.1)); // TODO CHANGE DEADZONE VALUE IT MIGHT NOT BE THE SAME - //LEAVE OUT driverStart.whileHeld(new ExtendBothLifters(.8,false,driverStick)); + + //LEAVE OUT driverStart.whileHeld(new ExtendBothLifters(.8,false,driverStick)); //THESE TWO LINES ARE FOR TESTING //LEAVE OUT driverA.whenPressed(new AutoSetLifterPots()); diff --git a/src/main/java/frc/robot/commands/DriveWithJoystick.java b/src/main/java/frc/robot/commands/DriveWithJoystick.java index 3ff5a8e..2e6141d 100644 --- a/src/main/java/frc/robot/commands/DriveWithJoystick.java +++ b/src/main/java/frc/robot/commands/DriveWithJoystick.java @@ -65,6 +65,7 @@ else if(stick.getRawButton(5)) { double left = Math.max(Math.min(thrust + turn, 1), -1); double right = Math.max(Math.min(thrust - turn, 1), -1); + // Robot.drivetrain.setMotors(left, right); Robot.drivetrain.setMotors(left, right); } diff --git a/src/main/java/frc/robot/subsystems/Drivetrain.java b/src/main/java/frc/robot/subsystems/Drivetrain.java index 043d030..ef81edf 100644 --- a/src/main/java/frc/robot/subsystems/Drivetrain.java +++ b/src/main/java/frc/robot/subsystems/Drivetrain.java @@ -5,6 +5,9 @@ import com.ctre.phoenix.motorcontrol.ControlMode; import com.ctre.phoenix.motorcontrol.can.TalonSRX; +import com.revrobotics.CANEncoder; +import com.revrobotics.AlternateEncoderType; + import edu.wpi.first.wpilibj.CAN; import edu.wpi.first.wpilibj.command.Subsystem; import edu.wpi.first.wpilibj.smartdashboard.SmartDashboard; @@ -19,7 +22,11 @@ public class Drivetrain extends Subsystem { private CANSparkMax rightLeader; private CANSparkMax [] leftFollowers; private CANSparkMax [] rightFollowers; - + + private static final AlternateEncoderType kAltEncType = AlternateEncoderType.kQuadrature; + private CANEncoder m_leftAlternateEncoder; + private CANEncoder m_rightAlternateEncoder; + public Drivetrain() { @@ -28,6 +35,10 @@ public Drivetrain() { rightLeader = new CANSparkMax(RobotMap.kRightLeader, MotorType.kBrushless); rightLeader.setOpenLoopRampRate(Constants.kNeoRampTime); leftFollowers = new CANSparkMax[RobotMap.kLeftFollowers.length]; + + m_leftAlternateEncoder = leftLeader.getAlternateEncoder(kAltEncType, 4096); + m_rightAlternateEncoder = rightLeader.getAlternateEncoder(kAltEncType, 4096); + for(int i = 0; i < leftFollowers.length; ++i) { leftFollowers[i] = new CANSparkMax(RobotMap.kLeftFollowers[i], MotorType.kBrushless); leftFollowers[i].setOpenLoopRampRate(Constants.kNeoRampTime); @@ -49,29 +60,35 @@ public void initDefaultCommand() { public void setMotors(double left, double right) { leftLeader.set(-left); rightLeader.set(right); - } + } public double getLeftMotor(){ - return leftLeader.getEncoder().getVelocity(); + // return leftLeader.getEncoder().getVelocity(); + return m_leftAlternateEncoder.getVelocity(); } public double getRightMotor(){ - return rightLeader.getEncoder().getVelocity(); + // return rightLeader.getEncoder().getVelocity(); + return m_rightAlternateEncoder.getVelocity(); } public double getRightPosition(){ - return leftLeader.getAlternateEncoder().getPosition(); + // return leftLeader.getAlternateEncoder().getPosition(); + return m_leftAlternateEncoder.getPosition(); } public double getLeftPosition(){ - return rightLeader.getAlternateEncoder().getPosition(); + // return rightLeader.getAlternateEncoder().getPosition(); + return m_leftAlternateEncoder.getPosition(); } public double getLeftCPR(){ - return leftLeader.getAlternateEncoder().getCountsPerRevolution(); + // return leftLeader.getAlternateEncoder().getCountsPerRevolution(); + return m_leftAlternateEncoder.getCountsPerRevolution(); } public double getRightCPR(){ - return rightLeader.getAlternateEncoder().getCountsPerRevolution(); + // return rightLeader.getAlternateEncoder().getCountsPerRevolution(); + return m_leftAlternateEncoder.getCountsPerRevolution(); } public void debug() { SmartDashboard.putNumber("Get Left Velocity", getLeftMotor()); From 4c68e64a46cef12bedcda255efa65327c42834e7 Mon Sep 17 00:00:00 2001 From: fidgetspinnerkid <35818373+fidgetspinnerkid@users.noreply.github.com> Date: Wed, 12 Feb 2020 15:44:54 -0800 Subject: [PATCH 07/68] changed cpr for the encoders --- src/main/java/frc/robot/Constants.java | 2 +- src/main/java/frc/robot/subsystems/Drivetrain.java | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main/java/frc/robot/Constants.java b/src/main/java/frc/robot/Constants.java index a473d0d..6c0c847 100644 --- a/src/main/java/frc/robot/Constants.java +++ b/src/main/java/frc/robot/Constants.java @@ -8,7 +8,7 @@ public final class Constants { // Drivetrain constants public static final double kFastDrive = 1.0; public static final double kSlowDrive = 0.5; - public static final double kCreep = .6; + public static final double kCreep = .3; public static final double kSlowish = 0.5; //Testing should be 0.5 public static final double kLineFollowStraight = 0.19; //0.27; public static final double kLineFollowTurn = 0.2; //0.5; diff --git a/src/main/java/frc/robot/subsystems/Drivetrain.java b/src/main/java/frc/robot/subsystems/Drivetrain.java index ef81edf..3337c2b 100644 --- a/src/main/java/frc/robot/subsystems/Drivetrain.java +++ b/src/main/java/frc/robot/subsystems/Drivetrain.java @@ -36,8 +36,8 @@ public Drivetrain() { rightLeader.setOpenLoopRampRate(Constants.kNeoRampTime); leftFollowers = new CANSparkMax[RobotMap.kLeftFollowers.length]; - m_leftAlternateEncoder = leftLeader.getAlternateEncoder(kAltEncType, 4096); - m_rightAlternateEncoder = rightLeader.getAlternateEncoder(kAltEncType, 4096); + m_leftAlternateEncoder = leftLeader.getAlternateEncoder(kAltEncType, 1024); + m_rightAlternateEncoder = rightLeader.getAlternateEncoder(kAltEncType, 1024); for(int i = 0; i < leftFollowers.length; ++i) { leftFollowers[i] = new CANSparkMax(RobotMap.kLeftFollowers[i], MotorType.kBrushless); From e1a9ced631182eeb7bcdb5c49feebc287cdb71f9 Mon Sep 17 00:00:00 2001 From: fidgetspinnerkid <35818373+fidgetspinnerkid@users.noreply.github.com> Date: Sun, 16 Feb 2020 06:49:46 -0800 Subject: [PATCH 08/68] changed test values --- src/main/java/frc/robot/Robot.java | 1 + 1 file changed, 1 insertion(+) diff --git a/src/main/java/frc/robot/Robot.java b/src/main/java/frc/robot/Robot.java index baf8b88..c326476 100644 --- a/src/main/java/frc/robot/Robot.java +++ b/src/main/java/frc/robot/Robot.java @@ -10,6 +10,7 @@ import edu.wpi.first.wpilibj.Compressor; + public class Robot extends TimedRobot { long loopCounter = 0; From a3602d9c2403c819c27b7e6046736b713e58389c Mon Sep 17 00:00:00 2001 From: fidgetspinnerkid <35818373+fidgetspinnerkid@users.noreply.github.com> Date: Tue, 18 Feb 2020 09:19:16 -0800 Subject: [PATCH 09/68] deleted unnecessary commands --- .../robot/Autons/RunElevatorWithJoystick.java | 63 ------------------- .../robot/Autons/RunHopperWithJoystick.java | 63 ------------------- .../robot/Autons/runDrivetrainShooter.java | 38 ----------- .../frc/robot/Autons/runElevatorShooter.java | 38 ----------- .../frc/robot/Autons/runHopperElevator.java | 39 ------------ .../robot/Autons/stopDrivetrainShooter.java | 33 ---------- .../frc/robot/Autons/stopElevatorShooter.java | 38 ----------- .../frc/robot/Autons/stopHopperElevator.java | 38 ----------- src/main/java/frc/robot/OI.java | 19 ++---- src/main/java/frc/robot/Robot.java | 19 +++++- src/main/java/frc/robot/RobotMap.java | 12 ++++ .../java/frc/robot/commands/MoveElevator.java | 50 --------------- .../java/frc/robot/subsystems/Climber.java | 0 .../java/frc/robot/subsystems/ControlPan.java | 43 +++++++++++++ .../java/frc/robot/subsystems/Drivetrain.java | 2 +- .../java/frc/robot/subsystems/Hopper.java | 26 +++++--- .../java/frc/robot/subsystems/Intake.java | 44 +++++++++++++ .../java/frc/robot/subsystems/Shooter.java | 31 ++++----- 18 files changed, 157 insertions(+), 439 deletions(-) delete mode 100644 src/main/java/frc/robot/Autons/RunElevatorWithJoystick.java delete mode 100644 src/main/java/frc/robot/Autons/RunHopperWithJoystick.java delete mode 100644 src/main/java/frc/robot/Autons/runDrivetrainShooter.java delete mode 100644 src/main/java/frc/robot/Autons/runElevatorShooter.java delete mode 100644 src/main/java/frc/robot/Autons/runHopperElevator.java delete mode 100644 src/main/java/frc/robot/Autons/stopDrivetrainShooter.java delete mode 100644 src/main/java/frc/robot/Autons/stopElevatorShooter.java delete mode 100644 src/main/java/frc/robot/Autons/stopHopperElevator.java delete mode 100644 src/main/java/frc/robot/commands/MoveElevator.java create mode 100644 src/main/java/frc/robot/subsystems/Climber.java create mode 100644 src/main/java/frc/robot/subsystems/ControlPan.java create mode 100644 src/main/java/frc/robot/subsystems/Intake.java diff --git a/src/main/java/frc/robot/Autons/RunElevatorWithJoystick.java b/src/main/java/frc/robot/Autons/RunElevatorWithJoystick.java deleted file mode 100644 index 99e9323..0000000 --- a/src/main/java/frc/robot/Autons/RunElevatorWithJoystick.java +++ /dev/null @@ -1,63 +0,0 @@ -/*----------------------------------------------------------------------------*/ -/* Copyright (c) 2018 FIRST. All Rights Reserved. */ -/* Open Source Software - may be modified and shared by FRC teams. The code */ -/* must be accompanied by the FIRST BSD license file in the root directory of */ -/* the project. */ -/*----------------------------------------------------------------------------*/ - -package frc.robot.Autons; - -import edu.wpi.first.wpilibj.buttons.Button; -import edu.wpi.first.wpilibj.command.Command; -import frc.robot.Constants; -import frc.robot.OI; -import frc.robot.Robot; -import frc.robot.util.Util; - -public class RunElevatorWithJoystick extends Command { - Button elevator_button; - public RunElevatorWithJoystick(Button elevator_button) { - requires(Robot.elevator); - this.elevator_button = elevator_button; - // Use requires() here to declare subsystem dependencies - // eg. requires(chassis); - } - - // Called just before this Command runs the first time - @Override - protected void initialize() { - } - - // Called repeatedly when this Command is scheduled to run - @Override - protected void execute() { - double output = Util.deadzone(Constants.DEADZONE, OI.operatorStick.getRawAxis(1), 1.0) * Constants.MANUAL_POWER * -1; - if(Robot.oi.operatorLS.get()) { - Robot.elevator.setElevator(output); //THIS SHOULD BE SET MANUAL POWER - - } - - - - else{ - - } -} - - // Make this return true when this Command no longer needs to run execute() - @Override - protected boolean isFinished() { - return !elevator_button.get(); - } - - // Called once after isFinished returns true - @Override - protected void end() { - } - - // Called when another command which requires one or more of the same - // subsystems is scheduled to run - @Override - protected void interrupted() { - } -} diff --git a/src/main/java/frc/robot/Autons/RunHopperWithJoystick.java b/src/main/java/frc/robot/Autons/RunHopperWithJoystick.java deleted file mode 100644 index 2b6f72f..0000000 --- a/src/main/java/frc/robot/Autons/RunHopperWithJoystick.java +++ /dev/null @@ -1,63 +0,0 @@ -/*----------------------------------------------------------------------------*/ -/* Copyright (c) 2018 FIRST. All Rights Reserved. */ -/* Open Source Software - may be modified and shared by FRC teams. The code */ -/* must be accompanied by the FIRST BSD license file in the root directory of */ -/* the project. */ -/*----------------------------------------------------------------------------*/ - -package frc.robot.Autons; - -import edu.wpi.first.wpilibj.buttons.Button; -import edu.wpi.first.wpilibj.command.Command; -import frc.robot.Constants; -import frc.robot.OI; -import frc.robot.Robot; -import frc.robot.util.Util; - -public class RunHopperWithJoystick extends Command { - Button hopper_button; - public RunHopperWithJoystick(Button hopper_button) { - requires(Robot.shooter); - this.hopper_button = hopper_button; - // Use requires() here to declare subsystem dependencies - // eg. requires(chassis); - } - - // Called just before this Command runs the first time - @Override - protected void initialize() { - } - - // Called repeatedly when this Command is scheduled to run - @Override - protected void execute() { - double output = Util.deadzone(Constants.DEADZONE, OI.operatorStick.getRawAxis(1), 1.0) * Constants.MANUAL_POWER * -1; - if(Robot.oi.operatorLS.get()) { - Robot.hopper.setHopper(output); //THIS SHOULD BE SET MANUAL POWER - - } - - - - else{ - - } -} - - // Make this return true when this Command no longer needs to run execute() - @Override - protected boolean isFinished() { - return !hopper_button.get(); - } - - // Called once after isFinished returns true - @Override - protected void end() { - } - - // Called when another command which requires one or more of the same - // subsystems is scheduled to run - @Override - protected void interrupted() { - } -} diff --git a/src/main/java/frc/robot/Autons/runDrivetrainShooter.java b/src/main/java/frc/robot/Autons/runDrivetrainShooter.java deleted file mode 100644 index 62fece3..0000000 --- a/src/main/java/frc/robot/Autons/runDrivetrainShooter.java +++ /dev/null @@ -1,38 +0,0 @@ -/*----------------------------------------------------------------------------*/ -/* Copyright (c) 2018 FIRST. All Rights Reserved. */ -/* Open Source Software - may be modified and shared by FRC teams. The code */ -/* must be accompanied by the FIRST BSD license file in the root directory of */ -/* the project. */ -/*----------------------------------------------------------------------------*/ - -package frc.robot.Autons; - -import edu.wpi.first.wpilibj.command.CommandGroup; -import frc.robot.commands.MoveDrivetrain; -import frc.robot.commands.MoveShooter; - -public class runDrivetrainShooter extends CommandGroup { - /** - * Add your docs here. - */ - public runDrivetrainShooter() { - addParallel(new MoveDrivetrain()); - addParallel(new MoveShooter()); - // Add Commands here: - // e.g. addSequential(new Command1()); - // addSequential(new Command2()); - // these will run in order. - - // To run multiple commands at the same time, - // use addParallel() - // e.g. addParallel(new Command1()); - // addSequential(new Command2()); - // Command1 and Command2 will run in parallel. - - // A command group will require all of the subsystems that each member - // would require. - // e.g. if Command1 requires chassis, and Command2 requires arm, - // a CommandGroup containing them would require both the chassis and the - // arm. - } -} diff --git a/src/main/java/frc/robot/Autons/runElevatorShooter.java b/src/main/java/frc/robot/Autons/runElevatorShooter.java deleted file mode 100644 index 357d400..0000000 --- a/src/main/java/frc/robot/Autons/runElevatorShooter.java +++ /dev/null @@ -1,38 +0,0 @@ -// /*----------------------------------------------------------------------------*/ -// /* Copyright (c) 2018 FIRST. All Rights Reserved. */ -// /* Open Source Software - may be modified and shared by FRC teams. The code */ -// /* must be accompanied by the FIRST BSD license file in the root directory of */ -// /* the project. */ -// /*----------------------------------------------------------------------------*/ - -// package frc.robot.Autons; - -// import edu.wpi.first.wpilibj.command.CommandGroup; -// import frc.robot.commands.MoveElevator; -// import frc.robot.commands.MoveShooter; - -// public class runElevatorShooter extends CommandGroup { -// /** -// * Add your docs here. -// */ -// public runElevatorShooter() { -// addParallel(new MoveElevator()); -// addParallel(new MoveShooter()); -// // Add Commands here: -// // e.g. addSequential(new Command1()); -// // addSequential(new Command2()); -// // these will run in order. - -// // To run multiple commands at the same time, -// // use addParallel() -// // e.g. addParallel(new Command1()); -// // addSequential(new Command2()); -// // Command1 and Command2 will run in parallel. - -// // A command group will require all of the subsystems that each member -// // would require. -// // e.g. if Command1 requires chassis, and Command2 requires arm, -// // a CommandGroup containing them would require both the chassis and the -// // arm. -// } -// } diff --git a/src/main/java/frc/robot/Autons/runHopperElevator.java b/src/main/java/frc/robot/Autons/runHopperElevator.java deleted file mode 100644 index 7c96842..0000000 --- a/src/main/java/frc/robot/Autons/runHopperElevator.java +++ /dev/null @@ -1,39 +0,0 @@ -/*----------------------------------------------------------------------------*/ -/* Copyright (c) 2018 FIRST. All Rights Reserved. */ -/* Open Source Software - may be modified and shared by FRC teams. The code */ -/* must be accompanied by the FIRST BSD license file in the root directory of */ -/* the project. */ -/*----------------------------------------------------------------------------*/ - -package frc.robot.Autons; - -import edu.wpi.first.wpilibj.command.CommandGroup; -import frc.robot.commands.MoveElevator; -import frc.robot.commands.MoveHopper; - -public class runHopperElevator extends CommandGroup { - /** - * Add your docs here. - */ - public runHopperElevator() { - - addParallel(new MoveHopper()); - addParallel(new MoveElevator()); - // Add Commands here: - // e.g. addSequential(new Command1()); - // addSequential(new Command2()); - // these will run in order. - - // To run multiple commands at the same time, - // use addParallel() - // e.g. addParallel(new Command1()); - // addSequential(new Command2()); - // Command1 and Command2 will run in parallel. - - // A command group will require all of the subsystems that each member - // would require. - // e.g. if Command1 requires chassis, and Command2 requires arm, - // a CommandGroup containing them would require both the chassis and the - // arm. - } -} diff --git a/src/main/java/frc/robot/Autons/stopDrivetrainShooter.java b/src/main/java/frc/robot/Autons/stopDrivetrainShooter.java deleted file mode 100644 index e1f6e08..0000000 --- a/src/main/java/frc/robot/Autons/stopDrivetrainShooter.java +++ /dev/null @@ -1,33 +0,0 @@ -package frc.robot.Autons; - -import edu.wpi.first.wpilibj.command.CommandGroup; -import frc.robot.commands.MoveDrivetrain; -import frc.robot.commands.MoveShooter; -import frc.robot.commands.StopDrivetrain; -import frc.robot.commands.StopShooter; - -public class stopDrivetrainShooter extends CommandGroup { - /** - * Add your docs here. - */ - public stopDrivetrainShooter() { - addParallel(new StopDrivetrain()); - addParallel(new StopShooter()); - // Add Commands here: - // e.g. addSequential(new Command1()); - // addSequential(new Command2()); - // these will run in order. - - // To run multiple commands at the same time, - // use addParallel() - // e.g. addParallel(new Command1()); - // addSequential(new Command2()); - // Command1 and Command2 will run in parallel. - - // A command group will require all of the subsystems that each member - // would require. - // e.g. if Command1 requires chassis, and Command2 requires arm, - // a CommandGroup containing them would require both the chassis and the - // arm. - } -} diff --git a/src/main/java/frc/robot/Autons/stopElevatorShooter.java b/src/main/java/frc/robot/Autons/stopElevatorShooter.java deleted file mode 100644 index a163344..0000000 --- a/src/main/java/frc/robot/Autons/stopElevatorShooter.java +++ /dev/null @@ -1,38 +0,0 @@ -/*----------------------------------------------------------------------------*/ -/* Copyright (c) 2018 FIRST. All Rights Reserved. */ -/* Open Source Software - may be modified and shared by FRC teams. The code */ -/* must be accompanied by the FIRST BSD license file in the root directory of */ -/* the project. */ -/*----------------------------------------------------------------------------*/ - -package frc.robot.Autons; - -import edu.wpi.first.wpilibj.command.CommandGroup; -import frc.robot.commands.StopElevator; -import frc.robot.commands.StopShooter; - -public class stopElevatorShooter extends CommandGroup { - /** - * Add your docs here. - */ - public stopElevatorShooter() { - addParallel(new StopElevator()); - addParallel(new StopShooter()); - // Add Commands here: - // e.g. addSequential(new Command1()); - // addSequential(new Command2()); - // these will run in order. - - // To run multiple commands at the same time, - // use addParallel() - // e.g. addParallel(new Command1()); - // addSequential(new Command2()); - // Command1 and Command2 will run in parallel. - - // A command group will require all of the subsystems that each member - // would require. - // e.g. if Command1 requires chassis, and Command2 requires arm, - // a CommandGroup containing them would require both the chassis and the - // arm. - } -} diff --git a/src/main/java/frc/robot/Autons/stopHopperElevator.java b/src/main/java/frc/robot/Autons/stopHopperElevator.java deleted file mode 100644 index 3ff8a1e..0000000 --- a/src/main/java/frc/robot/Autons/stopHopperElevator.java +++ /dev/null @@ -1,38 +0,0 @@ -/*----------------------------------------------------------------------------*/ -/* Copyright (c) 2018 FIRST. All Rights Reserved. */ -/* Open Source Software - may be modified and shared by FRC teams. The code */ -/* must be accompanied by the FIRST BSD license file in the root directory of */ -/* the project. */ -/*----------------------------------------------------------------------------*/ - -package frc.robot.Autons; - -import edu.wpi.first.wpilibj.command.CommandGroup; -import frc.robot.commands.StopElevator; -import frc.robot.commands.StopHopper; - -public class stopHopperElevator extends CommandGroup { - /** - * Add your docs here. - */ - public stopHopperElevator() { - addParallel(new StopHopper()); - addParallel(new StopElevator()); - // Add Commands here: - // e.g. addSequential(new Command1()); - // addSequential(new Command2()); - // these will run in order. - - // To run multiple commands at the same time, - // use addParallel() - // e.g. addParallel(new Command1()); - // addSequential(new Command2()); - // Command1 and Command2 will run in parallel. - - // A command group will require all of the subsystems that each member - // would require. - // e.g. if Command1 requires chassis, and Command2 requires arm, - // a CommandGroup containing them would require both the chassis and the - // arm. - } -} diff --git a/src/main/java/frc/robot/OI.java b/src/main/java/frc/robot/OI.java index 1c350c8..7c51604 100644 --- a/src/main/java/frc/robot/OI.java +++ b/src/main/java/frc/robot/OI.java @@ -3,14 +3,7 @@ import edu.wpi.first.wpilibj.Joystick; import edu.wpi.first.wpilibj.buttons.Button; import edu.wpi.first.wpilibj.buttons.JoystickButton; -import frc.robot.Autons.RunElevatorWithJoystick; -import frc.robot.Autons.RunHopperWithJoystick; -import frc.robot.Autons.runDrivetrainShooter; -// import frc.robot.Autons.runElevatorShooter; -import frc.robot.Autons.runHopperElevator; -import frc.robot.Autons.stopDrivetrainShooter; -import frc.robot.Autons.stopElevatorShooter; -import frc.robot.Autons.stopHopperElevator; + import frc.robot.commands.*; // import frc.robot.commands.auto.SetLimit; import frc.robot.controller.AnalogButton; @@ -86,13 +79,11 @@ public OI() { driverB.whenReleased(new StopDrivetrain()); driverY.whenPressed(new MoveDrivetrain()); driverY.whenReleased(new StopDrivetrain()); - driverLB.whenPressed(new runHopperElevator()); - driverLB.whenReleased(new stopHopperElevator()); - driverRB.whenPressed(new runDrivetrainShooter()); - driverRB.whenReleased(new stopDrivetrainShooter()); + // driverLB.whenPressed(new runHopperElevator()); + // driverLB.whenReleased(new stopHopperElevator()); // driverLS.whenPressed(new runElevatorShooter()); - driverLS.whenReleased(new stopElevatorShooter()); - operatorLeftJoystickUsed.whenPressed(new RunHopperWithJoystick(operatorLeftJoystickUsed)); + // driverLS.whenReleased(new stopElevatorShooter()); + // operatorLeftJoystickUsed.whenPressed(new RunHopperWithJoystick(operatorLeftJoystickUsed)); // //true does right hp far rocket path, false does right hp bay 1 ship path // // driverY.whenReleased(new StopCargoMotor()); // driverRB.whileHeld(new DriveWithJoystickLeftTalon()); diff --git a/src/main/java/frc/robot/Robot.java b/src/main/java/frc/robot/Robot.java index c326476..b95e800 100644 --- a/src/main/java/frc/robot/Robot.java +++ b/src/main/java/frc/robot/Robot.java @@ -7,8 +7,10 @@ import frc.robot.subsystems.Elevator; import frc.robot.subsystems.Hopper; import frc.robot.subsystems.Shooter; +import frc.robot.subsystems.*; import edu.wpi.first.wpilibj.Compressor; +import edu.wpi.first.cameraserver.CameraServer; @@ -23,24 +25,37 @@ public class Robot extends TimedRobot { public static Elevator elevator; public static Hopper hopper; public static RobotMap robotmap; + public static Intake intake; + public static ControlPan controlPan; + + //public static final CameraServer CamServer = CameraServer.getInstance(); + @Override public void robotInit() { hopper = new Hopper(); - elevator = new Elevator(); shooter = new Shooter(); drivetrain = new Drivetrain(); + intake = new Intake(); + controlPan = new ControlPan(); + pdp = new PowerDistributionPanel(RobotMap.kPDP); - oi = new OI(); + oi = new OI(); robotmap = new RobotMap(); + + compressor = new Compressor(RobotMap.kPCM); + compressor.start(); + compressor.enabled(); } @Override public void robotPeriodic() { // //EACH debug only runs once per 10 loops + // DriveWithJoystick joystick_command = new DriveWithJoystick(OI.driverStick, 0.1) drivetrain.debug(); hopper.debug(); + // CamServer.startAutomaticCapture(0); } @Override diff --git a/src/main/java/frc/robot/RobotMap.java b/src/main/java/frc/robot/RobotMap.java index 2115963..96c9aa8 100644 --- a/src/main/java/frc/robot/RobotMap.java +++ b/src/main/java/frc/robot/RobotMap.java @@ -34,6 +34,18 @@ public class RobotMap { public static final int kLEDGreenSolenoid = 6; + public static final int kShooterLeft = 31; + public static final int kShooterRight = 32; + + public static final int kIntake = 40; + + public static final int kVertHopper = 41; + public static final int kHoriHopper = 42; + + public static final int kControlPan = 50; + + public static final int kWinch = 60; + public static final int kActivePos = 61; //Lifters public static final int kFrontLiftTalon = 23; public static final int kBackLiftTalon = 22; diff --git a/src/main/java/frc/robot/commands/MoveElevator.java b/src/main/java/frc/robot/commands/MoveElevator.java deleted file mode 100644 index 70c402f..0000000 --- a/src/main/java/frc/robot/commands/MoveElevator.java +++ /dev/null @@ -1,50 +0,0 @@ -/*----------------------------------------------------------------------------*/ -/* Copyright (c) 2018 FIRST. All Rights Reserved. */ -/* Open Source Software - may be modified and shared by FRC teams. The code */ -/* must be accompanied by the FIRST BSD license file in the root directory of */ -/* the project. */ -/*----------------------------------------------------------------------------*/ - -package frc.robot.commands; - -import edu.wpi.first.wpilibj.command.Command; -import frc.robot.Constants; -import frc.robot.Robot; - -public class MoveElevator extends Command { - public MoveElevator() { - super("MoveElevator"); - requires(Robot.elevator); - // Use requires() here to declare subsystem dependencies - // eg. requires(chassis); - } - - // Called just before this Command runs the first time - @Override - protected void initialize() { - } - - // Called repeatedly when this Command is scheduled to run - @Override - protected void execute() { - Robot.elevator.setElevator(Constants.ELEVATOR_OUTPUT); - } - - // Make this return true when this Command no longer needs to run execute() - @Override - protected boolean isFinished() { - return false; - } - - // Called once after isFinished returns true - @Override - protected void end() { - Robot.elevator.setElevator(0); - } - - // Called when another command which requires one or more of the same - // subsystems is scheduled to run - @Override - protected void interrupted() { - } -} diff --git a/src/main/java/frc/robot/subsystems/Climber.java b/src/main/java/frc/robot/subsystems/Climber.java new file mode 100644 index 0000000..e69de29 diff --git a/src/main/java/frc/robot/subsystems/ControlPan.java b/src/main/java/frc/robot/subsystems/ControlPan.java new file mode 100644 index 0000000..bc57b39 --- /dev/null +++ b/src/main/java/frc/robot/subsystems/ControlPan.java @@ -0,0 +1,43 @@ +/*----------------------------------------------------------------------------*/ +/* Copyright (c) 2018-2019 FIRST. All Rights Reserved. */ +/* Open Source Software - may be modified and shared by FRC teams. The code */ +/* must be accompanied by the FIRST BSD license file in the root directory of */ +/* the project. */ +/*----------------------------------------------------------------------------*/ +package frc.robot.subsystems; + +import com.revrobotics.CANSparkMax; +import com.revrobotics.CANSparkMaxLowLevel.MotorType; +import com.ctre.phoenix.motorcontrol.ControlMode; +import com.ctre.phoenix.motorcontrol.can.TalonSRX; + +import edu.wpi.first.wpilibj.command.Subsystem; +import edu.wpi.first.wpilibj.smartdashboard.SmartDashboard; + +import frc.robot.Constants; +import frc.robot.RobotMap; +import frc.robot.commands.MoveShooter; +import frc.robot.commands.MoveShooterPassive; +import frc.robot.util.Util; + +/** + * Add your docs here. + */ +public class ControlPan extends Subsystem { + private CANSparkMax ControlPan_motor; + private MoveShooterPassive defaultCommand; + + public ControlPan(){ + ControlPan_motor = new CANSparkMax(RobotMap.kControlPan, MotorType.kBrushless); + ControlPan_motor.setOpenLoopRampRate(Constants.kNeoRampTime); + ControlPan_motor.set(0); + } + + @Override + protected void initDefaultCommand() { + + } + + public void debug() { + } +} diff --git a/src/main/java/frc/robot/subsystems/Drivetrain.java b/src/main/java/frc/robot/subsystems/Drivetrain.java index 3337c2b..f5608ab 100644 --- a/src/main/java/frc/robot/subsystems/Drivetrain.java +++ b/src/main/java/frc/robot/subsystems/Drivetrain.java @@ -53,7 +53,7 @@ public Drivetrain() { } public void initDefaultCommand() { - + } diff --git a/src/main/java/frc/robot/subsystems/Hopper.java b/src/main/java/frc/robot/subsystems/Hopper.java index 0e845d9..2b3c061 100644 --- a/src/main/java/frc/robot/subsystems/Hopper.java +++ b/src/main/java/frc/robot/subsystems/Hopper.java @@ -8,8 +8,11 @@ package frc.robot.subsystems; import com.ctre.phoenix.motorcontrol.ControlMode; -import com.ctre.phoenix.motorcontrol.can.TalonSRX; +import com.revrobotics.CANSparkMax; +import com.revrobotics.CANSparkMaxLowLevel.MotorType; + +import frc.robot.Constants; import edu.wpi.first.wpilibj.command.Subsystem; import edu.wpi.first.wpilibj.smartdashboard.SmartDashboard; import frc.robot.RobotMap; @@ -18,22 +21,29 @@ * Add your docs here. */ public class Hopper extends Subsystem { - public TalonSRX hopper_talon; + public CANSparkMax vertHopper; + public CANSparkMax horiHopper; public Hopper(){ - hopper_talon = new TalonSRX(RobotMap.HOPPER_TALON); + vertHopper = new CANSparkMax(RobotMap.kVertHopper, MotorType.kBrushless); + vertHopper.setOpenLoopRampRate(Constants.kNeoRampTime); + horiHopper = new CANSparkMax(RobotMap.kHoriHopper, MotorType.kBrushless); + horiHopper.setOpenLoopRampRate(Constants.kNeoRampTime); + + vertHopper.set(0); + horiHopper.set(0); } public void setHopper(final double output){ - hopper_talon.set(ControlMode.PercentOutput, output); + // hopper_talon.set(ControlMode.PercentOutput, output); } - public double getHopperVoltage() { - return hopper_talon.getMotorOutputVoltage(); - } + // public double getHopperVoltage() { + // // return hopper_talon.getMotorOutputVoltage(); + // } public void debug(){ - SmartDashboard.putNumber("Hopper Voltage - ", getHopperVoltage()); + // SmartDashboard.putNumber("Hopper Voltage - ", getHopperVoltage()); } @Override diff --git a/src/main/java/frc/robot/subsystems/Intake.java b/src/main/java/frc/robot/subsystems/Intake.java new file mode 100644 index 0000000..8ab3731 --- /dev/null +++ b/src/main/java/frc/robot/subsystems/Intake.java @@ -0,0 +1,44 @@ +/*----------------------------------------------------------------------------*/ +/* Copyright (c) 2018-2019 FIRST. All Rights Reserved. */ +/* Open Source Software - may be modified and shared by FRC teams. The code */ +/* must be accompanied by the FIRST BSD license file in the root directory of */ +/* the project. */ +/*----------------------------------------------------------------------------*/ +package frc.robot.subsystems; + +import com.revrobotics.CANSparkMax; +import com.revrobotics.CANSparkMaxLowLevel.MotorType; +import com.ctre.phoenix.motorcontrol.ControlMode; +import com.ctre.phoenix.motorcontrol.can.TalonSRX; + +import edu.wpi.first.wpilibj.command.Subsystem; +import edu.wpi.first.wpilibj.smartdashboard.SmartDashboard; + +import frc.robot.Constants; +import frc.robot.RobotMap; +import frc.robot.commands.MoveShooter; +import frc.robot.commands.MoveShooterPassive; +import frc.robot.util.Util; + +/** + * Add your docs here. + */ +public class Intake extends Subsystem { + private CANSparkMax Intake_Motor; + private MoveShooterPassive defaultCommand; + + public Intake(){ + Intake_Motor = new CANSparkMax(RobotMap.kIntake, MotorType.kBrushless); + Intake_Motor.setOpenLoopRampRate(Constants.kNeoRampTime); + + Intake_Motor.set(0); + } + + @Override + protected void initDefaultCommand() { + + } + + public void debug() { + } +} diff --git a/src/main/java/frc/robot/subsystems/Shooter.java b/src/main/java/frc/robot/subsystems/Shooter.java index 6f3ef7c..b15bff4 100644 --- a/src/main/java/frc/robot/subsystems/Shooter.java +++ b/src/main/java/frc/robot/subsystems/Shooter.java @@ -24,25 +24,28 @@ * Add your docs here. */ public class Shooter extends Subsystem { - private CANSparkMax shooter_neo; + private CANSparkMax shooterLeft, shooterRight; private MoveShooterPassive defaultCommand; - - public Shooter(){ - shooter_neo = new CANSparkMax(RobotMap.SHOOTER_NEO, MotorType.kBrushless); - shooter_neo.setOpenLoopRampRate(Constants.kNeoRampTime); + shooterLeft = new CANSparkMax(RobotMap.kShooterLeft, MotorType.kBrushless); + shooterLeft.setOpenLoopRampRate(Constants.kNeoRampTime); + shooterRight = new CANSparkMax(RobotMap.kShooterRight, MotorType.kBrushless); + shooterRight.setOpenLoopRampRate(Constants.kNeoRampTime); + + shooterLeft.set(0); + shooterRight.set(0); } public void setShooter(final double output){ - shooter_neo.set(output); - } - public double getShooterVelocity(){ - return shooter_neo.getEncoder().getVelocity(); - } - public double getShooter(){ - return shooter_neo.getEncoder().getCountsPerRevolution(); + } + // public double getShooterVelocity(){ + // return shooter_neo.getEncoder().getVelocity(); + // } + // public double getShooter(){ + // return shooter_neo.getEncoder().getCountsPerRevolution(); + // } @Override protected void initDefaultCommand() { // defaultCommand = new MoveShooterPassive(); @@ -52,7 +55,7 @@ protected void initDefaultCommand() { } public void debug() { - SmartDashboard.putNumber("Shooter Neo Velocity -", getShooterVelocity()); - SmartDashboard.putNumber("Shooter Neo CPR -", getShooter()); + // SmartDashboard.putNumber("Shooter Neo Velocity -", getShooterVelocity()); + // SmartDashboard.putNumber("Shooter Neo CPR -", getShooter()); } } From 16386eb1ca811e1e753472c2f7d1b7fc8720bba0 Mon Sep 17 00:00:00 2001 From: Tim Oh - Team2791 Date: Tue, 18 Feb 2020 13:52:26 -0500 Subject: [PATCH 10/68] Uh oH yes --- .../java/frc/robot/Autons/ShooterGroup.java | 29 +++++ .../frc/robot/Autons/StopShooterGroup.java | 24 ++++ src/main/java/frc/robot/Constants.java | 82 +++++++++++++ .../robot/commands/Shooter/CheckHoodLong.java | 57 +++++++++ .../robot/commands/Shooter/CheckHoodWall.java | 57 +++++++++ .../commands/Shooter/CheckMotorLong.java | 57 +++++++++ .../commands/Shooter/CheckMotorWall.java | 57 +++++++++ .../commands/Shooter/MoveShooterLong.java | 51 ++++++++ .../commands/Shooter/MoveShooterWall.java | 51 ++++++++ .../commands/Shooter/OpenHopperPiston.java | 41 +++++++ .../frc/robot/commands/Shooter/Shoot.java | 51 ++++++++ .../java/frc/robot/subsystems/Hopper.java | 62 ++++++++++ .../java/frc/robot/subsystems/Shooter.java | 111 ++++++++++++++++++ 13 files changed, 730 insertions(+) create mode 100644 src/main/java/frc/robot/Autons/ShooterGroup.java create mode 100644 src/main/java/frc/robot/Autons/StopShooterGroup.java create mode 100644 src/main/java/frc/robot/Constants.java create mode 100644 src/main/java/frc/robot/commands/Shooter/CheckHoodLong.java create mode 100644 src/main/java/frc/robot/commands/Shooter/CheckHoodWall.java create mode 100644 src/main/java/frc/robot/commands/Shooter/CheckMotorLong.java create mode 100644 src/main/java/frc/robot/commands/Shooter/CheckMotorWall.java create mode 100644 src/main/java/frc/robot/commands/Shooter/MoveShooterLong.java create mode 100644 src/main/java/frc/robot/commands/Shooter/MoveShooterWall.java create mode 100644 src/main/java/frc/robot/commands/Shooter/OpenHopperPiston.java create mode 100644 src/main/java/frc/robot/commands/Shooter/Shoot.java create mode 100644 src/main/java/frc/robot/subsystems/Hopper.java create mode 100644 src/main/java/frc/robot/subsystems/Shooter.java diff --git a/src/main/java/frc/robot/Autons/ShooterGroup.java b/src/main/java/frc/robot/Autons/ShooterGroup.java new file mode 100644 index 0000000..21d47ce --- /dev/null +++ b/src/main/java/frc/robot/Autons/ShooterGroup.java @@ -0,0 +1,29 @@ +package frc.robot.Autons; + +import edu.wpi.first.wpilibj.command.CommandGroup; +import frc.robot.Robot; +import frc.robot.commands.MoveHopper; +//import frc.robot.commands.Shooter.CheckWheelSpeed; +//import frc.robot.commands.Shooter.RetractHood; +import frc.robot.commands.Shooter.RetractHopperPiston; +import frc.robot.subsystems.Shooter; + +public class ShooterGroup extends CommandGroup{ + + public ShooterGroup(){ + //must switch these errored ones to commands instead of or along with methods predefined. Honestly, just make a command + //with those methods and that is it ig? Or retry the command doing all of them. Problems with thht however. Harder to make + //stop method to stop everything you run and the old if statements make me feel lke it doesn't do wat I want it to. For example + //it will check the wheel speed and then run the hopper ... doesn't wait for wheel speed to be good. Didn't like old if + //statements for that because I felt like they would make the hopper stop moving and stop shooting balls continuously until + //shooter speed was back especially since the speed dips everytime a ball is shot + //This is the command group vs the command with everything is called Shoot() + //This command group is what is in oi + //addSequential(new RetractHood()); + //addSequential(new CheckWheelSpeed()); + addSequential(new MoveHopper()); + addSequential(new RetractHopperPiston()); + + + } +} \ No newline at end of file diff --git a/src/main/java/frc/robot/Autons/StopShooterGroup.java b/src/main/java/frc/robot/Autons/StopShooterGroup.java new file mode 100644 index 0000000..25f469a --- /dev/null +++ b/src/main/java/frc/robot/Autons/StopShooterGroup.java @@ -0,0 +1,24 @@ +package frc.robot.Autons; + +import edu.wpi.first.wpilibj.command.CommandGroup; +import frc.robot.Robot; +import frc.robot.commands.MoveHopper; +import frc.robot.commands.StopHopper; +//import frc.robot.commands.Shooter.CheckWheelSpeed; +//import frc.robot.commands.Shooter.RetractHood; +import frc.robot.commands.Shooter.RetractHopperPiston; +import frc.robot.commands.Shooter.StopShooter; +import frc.robot.subsystems.Shooter; + +public class StopShooterGroup extends CommandGroup{ + + //in theory this redoes everything the shooterGroup() command group changed + public StopShooterGroup(){ + //addParallel(new RetractHood()); + addParallel(new StopShooter()); + addParallel(new StopHopper()); + addParallel(new RetractHopperPiston()); + + + } +} \ No newline at end of file diff --git a/src/main/java/frc/robot/Constants.java b/src/main/java/frc/robot/Constants.java new file mode 100644 index 0000000..8b088a4 --- /dev/null +++ b/src/main/java/frc/robot/Constants.java @@ -0,0 +1,82 @@ +package frc.robot; + + +public final class Constants { + public static final boolean debugMode = false; + + + // Drivetrain constants + public static final double kFastDrive = 1.0; + public static final double kSlowDrive = 0.5; + public static final double kCreep = 0.2; + public static final double kSlowish = 0.5; //Testing should be 0.5 + public static final double kLineFollowStraight = 0.19; //0.27; + public static final double kLineFollowTurn = 0.2; //0.5; + public static final double kLineVoltCutoff = 1.0; //1.4 + public static final double kNeoRampTime = .05; + public static final int kNeoAmpLimit = 48; + public static final double kInchTime = 0.1; + public static final double kCamTurn = 0.5; + public static final double kCamStraightFast = 0.6; + public static final double kCamStraightSuperFast = 0.75; + public static final double kCamStraightMedium = 0.45; + public static final double kCamStraightSlow = 0.25; + + public static final double ShooterkP = 6e-4; + public static final double ShooterkI = 0; + public static final double ShooterkD = 1e-5; + public static final double ShooterkIz = 0; + public static final double ShooterkFF = 0; + public static final double ShooterMaxOutput = 1; + public static final double ShooterMinOutput = -1; // max and min outputs that pidcontroller can send to the sparkmax + public static final double ShootermaxRPM = 4500; + public static final double kGravity = 32.1741; //acceleration due to gravity in ft/s/s + public static final double ShooterDiameter = 6; //inches + public static final double ShooterGearing = 2; //Shooter spins twice for every one time motor spins + public static final double kDrag = 1; + public static final double kMagnus = 1; + + public static final double DrivekP = 6e-4; + public static final double DrivekI = 0; + public static final double DrivekD = 1e-5; + public static final double DriveIz = 0; + public static final double DrivekFF = 0; + public static final double DriveMaxOutput = 1; + public static final double DriveMinOutput = -1; + public static final double DrivemaxRPM = 4500; + + public static final double kDistInnerOuter = 8; + + public static final double kIrSensorVal = 20.0; //what the value of the ir sensor should read w/o a ball + + // public static final double kCamOffset = 0; + //Joystick constant + public static final double DEADZONE = 0.4; + + + public static final double ELEVATOR_OUTPUT = 1; //was at 1 + + + public static final double HOPPER_OUTPUT = -.17; //35% is sweet spot slowed down to 17% + + + public static final double SHOOTER_OUTPUT_WALL = 0.1; //89% for near trench 40% for wall shot 100% too short for long shot + + + public static final double SHOOTER_OUTPUT_LONG = 1; + + + public static final double DRIVETRAIN_OUTPUT = -.5; + + + public static final double SHOOTER_OUTPUT_PASSIVE = -.1; + + + public static final double MANUAL_POWER = .2; + + + public static final double INTAKE_MOTORSPEED = 0.75; //Temp value please test it out and do stuff yes + + + public static final double SHOOTER_VELOCITY = 100; //Temporary value +} \ No newline at end of file diff --git a/src/main/java/frc/robot/commands/Shooter/CheckHoodLong.java b/src/main/java/frc/robot/commands/Shooter/CheckHoodLong.java new file mode 100644 index 0000000..ad55848 --- /dev/null +++ b/src/main/java/frc/robot/commands/Shooter/CheckHoodLong.java @@ -0,0 +1,57 @@ +/*----------------------------------------------------------------------------*/ +/* Copyright (c) 2018 FIRST. All Rights Reserved. */ +/* Open Source Software - may be modified and shared by FRC teams. The code */ +/* must be accompanied by the FIRST BSD license file in the root directory of */ +/* the project. */ +/*----------------------------------------------------------------------------*/ + +package frc.robot.commands.Shooter; + +import edu.wpi.first.wpilibj.command.Command; +import frc.robot.Constants; +import frc.robot.Robot; + +public class CheckHoodLong extends Command { + public CheckHoodLong() { + super("CheckHoodLong"); + requires(Robot.shooter); + + // Use requires() here to declare subsystem dependencies + // eg. requires(chassis); + } + + // Called just before this Command runs the first time + @Override + protected void initialize() { + + } + + // Called repeatedly when this Command is scheduled to run + @Override + protected void execute() { + if(Robot.shooter.getHood1() != false) { + Robot.shooter.setHood1(false); + } + } + + // Make this return true when this Command no longer needs to run execute() + @Override + protected boolean isFinished() { + if(Robot.shooter.getHood1() == false) { + return true; + } + return false; + } + + // Called once after isFinished returns true + @Override + protected void end() { + // Robot.shooter.setHood1(0); + } + + // Called when another command which requires one or more of the same + // subsystems is scheduled to run + @Override + protected void interrupted() { + } +} diff --git a/src/main/java/frc/robot/commands/Shooter/CheckHoodWall.java b/src/main/java/frc/robot/commands/Shooter/CheckHoodWall.java new file mode 100644 index 0000000..d52f5cb --- /dev/null +++ b/src/main/java/frc/robot/commands/Shooter/CheckHoodWall.java @@ -0,0 +1,57 @@ +/*----------------------------------------------------------------------------*/ +/* Copyright (c) 2018 FIRST. All Rights Reserved. */ +/* Open Source Software - may be modified and shared by FRC teams. The code */ +/* must be accompanied by the FIRST BSD license file in the root directory of */ +/* the project. */ +/*----------------------------------------------------------------------------*/ + +package frc.robot.commands.Shooter; + +import edu.wpi.first.wpilibj.command.Command; +import frc.robot.Constants; +import frc.robot.Robot; + +public class CheckHoodWall extends Command { + public CheckHoodWall() { + super("CheckHoodWall"); + requires(Robot.shooter); + + // Use requires() here to declare subsystem dependencies + // eg. requires(chassis); + } + + // Called just before this Command runs the first time + @Override + protected void initialize() { + + } + + // Called repeatedly when this Command is scheduled to run + @Override + protected void execute() { + if(Robot.shooter.getHood1() != true) { + Robot.shooter.setHood1(true); + } + } + + // Make this return true when this Command no longer needs to run execute() + @Override + protected boolean isFinished() { + if(Robot.shooter.getHood1()) { + return true; + } + return false; + } + + // Called once after isFinished returns true + @Override + protected void end() { + // Robot.shooter.setHood1(0); + } + + // Called when another command which requires one or more of the same + // subsystems is scheduled to run + @Override + protected void interrupted() { + } +} diff --git a/src/main/java/frc/robot/commands/Shooter/CheckMotorLong.java b/src/main/java/frc/robot/commands/Shooter/CheckMotorLong.java new file mode 100644 index 0000000..2c74f4c --- /dev/null +++ b/src/main/java/frc/robot/commands/Shooter/CheckMotorLong.java @@ -0,0 +1,57 @@ +/*----------------------------------------------------------------------------*/ +/* Copyright (c) 2018 FIRST. All Rights Reserved. */ +/* Open Source Software - may be modified and shared by FRC teams. The code */ +/* must be accompanied by the FIRST BSD license file in the root directory of */ +/* the project. */ +/*----------------------------------------------------------------------------*/ + +package frc.robot.commands.Shooter; + +import edu.wpi.first.wpilibj.command.Command; +import frc.robot.Constants; +import frc.robot.Robot; + +public class CheckMotorLong extends Command { + public CheckMotorLong() { + super("CheckMotorLong"); + requires(Robot.shooter); + + // Use requires() here to declare subsystem dependencies + // eg. requires(chassis); + } + + // Called just before this Command runs the first time + @Override + protected void initialize() { + + } + + // Called repeatedly when this Command is scheduled to run + @Override + protected void execute() { + if(Robot.shooter.checkWheelSpeed_Long() != true) { + Robot.shooter.setShooter(Constants.SHOOTER_OUTPUT_LONG); + } + } + + // Make this return true when this Command no longer needs to run execute() + @Override + protected boolean isFinished() { + if(Robot.shooter.checkWheelSpeed_Long() == true) { + return true; + } + return false; + } + + // Called once after isFinished returns true + @Override + protected void end() { + // Robot.shooter.setShooter(0); + } + + // Called when another command which requires one or more of the same + // subsystems is scheduled to run + @Override + protected void interrupted() { + } +} diff --git a/src/main/java/frc/robot/commands/Shooter/CheckMotorWall.java b/src/main/java/frc/robot/commands/Shooter/CheckMotorWall.java new file mode 100644 index 0000000..2a943be --- /dev/null +++ b/src/main/java/frc/robot/commands/Shooter/CheckMotorWall.java @@ -0,0 +1,57 @@ +/*----------------------------------------------------------------------------*/ +/* Copyright (c) 2018 FIRST. All Rights Reserved. */ +/* Open Source Software - may be modified and shared by FRC teams. The code */ +/* must be accompanied by the FIRST BSD license file in the root directory of */ +/* the project. */ +/*----------------------------------------------------------------------------*/ + +package frc.robot.commands.Shooter; + +import edu.wpi.first.wpilibj.command.Command; +import frc.robot.Constants; +import frc.robot.Robot; + +public class CheckMotorWall extends Command { + public CheckMotorWall() { + super("CheckMotorWall"); + requires(Robot.shooter); + + // Use requires() here to declare subsystem dependencies + // eg. requires(chassis); + } + + // Called just before this Command runs the first time + @Override + protected void initialize() { + + } + + // Called repeatedly when this Command is scheduled to run + @Override + protected void execute() { + if(Robot.shooter.checkWheelSpeed_Wall() != true) { + Robot.shooter.setShooter(Constants.SHOOTER_OUTPUT_WALL); + } + } + + // Make this return true when this Command no longer needs to run execute() + @Override + protected boolean isFinished() { + if(Robot.shooter.checkWheelSpeed_Wall() == true) { + return true; + } + return false; + } + + // Called once after isFinished returns true + @Override + protected void end() { + // Robot.shooter.setShooter(0); + } + + // Called when another command which requires one or more of the same + // subsystems is scheduled to run + @Override + protected void interrupted() { + } +} diff --git a/src/main/java/frc/robot/commands/Shooter/MoveShooterLong.java b/src/main/java/frc/robot/commands/Shooter/MoveShooterLong.java new file mode 100644 index 0000000..4f96348 --- /dev/null +++ b/src/main/java/frc/robot/commands/Shooter/MoveShooterLong.java @@ -0,0 +1,51 @@ +/*----------------------------------------------------------------------------*/ +/* Copyright (c) 2018 FIRST. All Rights Reserved. */ +/* Open Source Software - may be modified and shared by FRC teams. The code */ +/* must be accompanied by the FIRST BSD license file in the root directory of */ +/* the project. */ +/*----------------------------------------------------------------------------*/ + +package frc.robot.commands.Shooter; + +import edu.wpi.first.wpilibj.command.Command; +import frc.robot.Constants; +import frc.robot.Robot; + +public class MoveShooterLong extends Command { + public MoveShooterLong() { + super("MoveShooterLong"); + requires(Robot.shooter); + // Use requires() here to declare subsystem dependencies + // eg. requires(chassis); + } + + // Called just before this Command runs the first time + @Override + protected void initialize() { + } + + // Called repeatedly when this Command is scheduled to run + @Override + protected void execute() { + + Robot.shooter.setShooter(Constants.SHOOTER_OUTPUT_LONG); + } + + // Make this return true when this Command no longer needs to run execute() + @Override + protected boolean isFinished() { + return false; + } + + // Called once after isFinished returns true + @Override + protected void end() { + Robot.shooter.setShooter(0); + } + + // Called when another command which requires one or more of the same + // subsystems is scheduled to run + @Override + protected void interrupted() { + } +} diff --git a/src/main/java/frc/robot/commands/Shooter/MoveShooterWall.java b/src/main/java/frc/robot/commands/Shooter/MoveShooterWall.java new file mode 100644 index 0000000..2b187a7 --- /dev/null +++ b/src/main/java/frc/robot/commands/Shooter/MoveShooterWall.java @@ -0,0 +1,51 @@ +/*----------------------------------------------------------------------------*/ +/* Copyright (c) 2018 FIRST. All Rights Reserved. */ +/* Open Source Software - may be modified and shared by FRC teams. The code */ +/* must be accompanied by the FIRST BSD license file in the root directory of */ +/* the project. */ +/*----------------------------------------------------------------------------*/ + +package frc.robot.commands.Shooter; + +import edu.wpi.first.wpilibj.command.Command; +import frc.robot.Constants; +import frc.robot.Robot; + +public class MoveShooterWall extends Command { + public MoveShooterWall() { + super("MoveShooterWall"); + requires(Robot.shooter); + // Use requires() here to declare subsystem dependencies + // eg. requires(chassis); + } + + // Called just before this Command runs the first time + @Override + protected void initialize() { + } + + // Called repeatedly when this Command is scheduled to run + @Override + protected void execute() { + + Robot.shooter.setShooter(Constants.SHOOTER_OUTPUT_WALL); + } + + // Make this return true when this Command no longer needs to run execute() + @Override + protected boolean isFinished() { + return false; + } + + // Called once after isFinished returns true + @Override + protected void end() { + Robot.shooter.setShooter(0); + } + + // Called when another command which requires one or more of the same + // subsystems is scheduled to run + @Override + protected void interrupted() { + } +} diff --git a/src/main/java/frc/robot/commands/Shooter/OpenHopperPiston.java b/src/main/java/frc/robot/commands/Shooter/OpenHopperPiston.java new file mode 100644 index 0000000..d6de556 --- /dev/null +++ b/src/main/java/frc/robot/commands/Shooter/OpenHopperPiston.java @@ -0,0 +1,41 @@ +package frc.robot.commands.Shooter; + +import edu.wpi.first.wpilibj.command.Command; +import frc.robot.Constants; +import frc.robot.Robot; +import frc.robot.commands.MoveHopper; +import frc.robot.subsystems.Shooter; + +//in theory this just chanes whether the hopper piston is retracted or not and then stops +public class OpenHopperPiston extends Command{ + private boolean retracted; + public OpenHopperPiston(){ + super("OpenHopperPiston"); + requires(Robot.hopper); + } + + @Override + protected void initialize(){ + retracted = Robot.hopper.getRetracted(); + } + + @Override + protected void execute() { + Robot.hopper.setRetracted(retracted); + + } + + @Override + protected boolean isFinished(){ + return true; + } + @Override + protected void end() { + + } + + @Override + + protected void interrupted(){ + } +} \ No newline at end of file diff --git a/src/main/java/frc/robot/commands/Shooter/Shoot.java b/src/main/java/frc/robot/commands/Shooter/Shoot.java new file mode 100644 index 0000000..2ac1acf --- /dev/null +++ b/src/main/java/frc/robot/commands/Shooter/Shoot.java @@ -0,0 +1,51 @@ +package frc.robot.commands.Shooter; + +import edu.wpi.first.wpilibj.command.Command; +import frc.robot.Constants; +import frc.robot.Robot; +import frc.robot.commands.MoveHopper; +import frc.robot.subsystems.Shooter; + +public class Shoot extends Command{ + private double wheelSpeed; + private boolean goodSpeed; + public Shoot(){ + super("Shoot"); + requires(Robot.shooter); + requires(Robot.hopper); + } + + @Override + + protected void initialize(){ + + } + + @Override + + protected void execute() { + Robot.shooter.setHood1(false); //change to true??? + //new CheckWheelSpeed(); + new MoveHopper(); + Robot.hopper.setRetracted(Robot.hopper.isRetracted()); //define isRetracted as true or false??? + + } + + @Override + + protected boolean isFinished(){ + return false; + } + @Override + + protected void end() { + Robot.shooter.setShooter(0); + Robot.hopper.setHopper(0); + Robot.hopper.setRetracted(Robot.hopper.isRetracted()); //if yes above, change here as well + } + + @Override + + protected void interrupted(){ + } +} \ No newline at end of file diff --git a/src/main/java/frc/robot/subsystems/Hopper.java b/src/main/java/frc/robot/subsystems/Hopper.java new file mode 100644 index 0000000..330bb40 --- /dev/null +++ b/src/main/java/frc/robot/subsystems/Hopper.java @@ -0,0 +1,62 @@ +/*----------------------------------------------------------------------------*/ +/* Copyright (c) 2018-2019 FIRST. All Rights Reserved. */ +/* Open Source Software - may be modified and shared by FRC teams. The code */ +/* must be accompanied by the FIRST BSD license file in the root directory of */ +/* the project. */ +/*----------------------------------------------------------------------------*/ + +package frc.robot.subsystems; + +import com.revrobotics.CANSparkMax; +import com.revrobotics.CANSparkMaxLowLevel.MotorType; + +import edu.wpi.first.wpilibj.command.Subsystem; +import edu.wpi.first.wpilibj.smartdashboard.SmartDashboard; +import edu.wpi.first.wpilibj.Solenoid; + +import frc.robot.RobotMap; +import frc.robot.util.IrSensor; + +/** + * Add your docs here. + */ +public class Hopper extends Subsystem { + public CANSparkMax hopper_horizontal; + public CANSparkMax hopper_vertical; + public Solenoid hopper_stopper; + public IrSensor irSensor = new IrSensor(RobotMap.kPDP); + + + public Hopper(){ + hopper_horizontal = new CANSparkMax(RobotMap.HORIZONTAL_HOPPER, MotorType.kBrushless); + hopper_vertical = new CANSparkMax(RobotMap.VERTICAL_HOPPER, MotorType.kBrushless); + hopper_stopper = new Solenoid(RobotMap.kPCM, RobotMap.HOPPER_SOLENOID); + } + + public void setHopper(final double output){ + hopper_horizontal.set(output); + hopper_vertical.set(output); + } + // public double getHopperVoltage() { + // return hopper_neo.ge + // } + public boolean isRetracted() { + return !hopper_stopper.get(); + } + public void setRetracted(boolean retract) { + hopper_stopper.set(retract); + } + public boolean getRetracted() { + return hopper_stopper.get(); + } + + public void debug(){ + //SmartDashboard.putNumber("Hopper Voltage - ", getHopperVoltage()); + SmartDashboard.putNumber("IR Value", irSensor.getValue()); + } + @Override + protected void initDefaultCommand() { + // TODO Auto-generated method stub + + } +} diff --git a/src/main/java/frc/robot/subsystems/Shooter.java b/src/main/java/frc/robot/subsystems/Shooter.java new file mode 100644 index 0000000..24fb351 --- /dev/null +++ b/src/main/java/frc/robot/subsystems/Shooter.java @@ -0,0 +1,111 @@ +/*----------------------------------------------------------------------------*/ +/* Copyright (c) 2018-2019 FIRST. All Rights Reserved. */ +/* Open Source Software - may be modified and shared by FRC teams. The code */ +/* must be accompanied by the FIRST BSD license file in the root directory of */ +/* the project. */ +/*----------------------------------------------------------------------------*/ +package frc.robot.subsystems; + +import com.revrobotics.CANSparkMax; +import com.revrobotics.CANSparkMaxLowLevel.MotorType; + +import edu.wpi.first.wpilibj.Solenoid; +import edu.wpi.first.wpilibj.command.Subsystem; +import edu.wpi.first.wpilibj.smartdashboard.SmartDashboard; + +import frc.robot.Constants; +import frc.robot.Robot; +import frc.robot.RobotMap; +// import frc.robot.commands.MoveShooterPassive; +/** + * Add your docs here. + */ +public class Shooter extends Subsystem { + private CANSparkMax shooter_leader; + private CANSparkMax shooter_follower; + private Solenoid hood_1; + // private MoveShooterPassive defaultCommand; + + + + public Shooter(){ + shooter_leader = new CANSparkMax(RobotMap.SHOOTER_NEO, MotorType.kBrushless); + shooter_follower = new CANSparkMax(RobotMap.SHOOTER_NEO, MotorType.kBrushless); + shooter_leader.setOpenLoopRampRate(Constants.kNeoRampTime); + shooter_follower.setOpenLoopRampRate(Constants.kNeoRampTime); + hood_1 = new Solenoid(RobotMap.kPCM, RobotMap.HOOD_1); + } + public double idealVelocity(double angle, double dist, double height){ + double gravityInches = Constants.kGravity*12; + angle = Math.toRadians(angle); + double velocity = Math.sqrt( (gravityInches*Math.pow(dist,2)) / (2*Math.pow(Math.cos(angle),2) * (dist*Math.tan(angle)-height))); //speed in inches/second + return velocity; + } + public double applyDrag(double velocity){ + velocity*=Constants.kDrag; + return velocity; + } + public double applyMagnus(double velocity){ + velocity/=Constants.kMagnus; + return velocity; + } + public double velocityToRPM(double velocity){ + double shooterRotationsPerSecond = velocity/(.5*Constants.ShooterDiameter); //rotation per second + double shooterRPM = shooterRotationsPerSecond*60; + double motorRPM = shooterRPM/Constants.ShooterGearing; + return motorRPM; + } + public void setShooter(final double output){ + shooter_leader.set(output); + shooter_follower.follow(shooter_leader, true); + } + public double getShooterVelocity(){ + return shooter_leader.getEncoder().getVelocity(); + } + + public boolean isShooterVelocityCorrect(){ + if(getShooterVelocity() != Constants.SHOOTER_VELOCITY){ + return false; + } + return true; + } + public double getShooter(){ + return shooter_leader.getEncoder().getCountsPerRevolution(); + } + public void setHood1(boolean extended) { + hood_1.set(extended); + } + + public boolean getHood1(){ + return hood_1.get(); + } + @Override + protected void initDefaultCommand() { + // defaultCommand = new MoveShooterPassive(); + // // TODO Auto-generated method stub + // defaultCommand.start(); + + } + public boolean checkWheelSpeed_Wall(){ + if(Robot.shooter.getShooterVelocity() >= Constants.SHOOTER_OUTPUT_WALL - .01 && Robot.shooter.getShooterVelocity() <= Constants.SHOOTER_OUTPUT_WALL + .01) { + return true; + } + else{ + return false; + } + } + public boolean checkWheelSpeed_Long() { + if(Robot.shooter.getShooterVelocity() >= Constants.SHOOTER_OUTPUT_LONG - .01 && Robot.shooter.getShooterVelocity() <= Constants.SHOOTER_OUTPUT_LONG + .01){ + return true; + } + else{ + return false; + } + } + + public void debug() { + SmartDashboard.putNumber("Shooter Neo Velocity -", getShooterVelocity()); + SmartDashboard.putNumber("Shooter Neo CPR -", getShooter()); + SmartDashboard.putBoolean("Hood Position", getHood1()); + } +} From a50ba83c94f615ee96b1975d906e86e2b3ded711 Mon Sep 17 00:00:00 2001 From: fidgetspinnerkid <35818373+fidgetspinnerkid@users.noreply.github.com> Date: Tue, 18 Feb 2020 10:52:49 -0800 Subject: [PATCH 11/68] made new changes for compressor --- src/main/java/frc/robot/Robot.java | 24 ++--- .../java/frc/robot/subsystems/Drivetrain.java | 61 +++++++++--- .../java/frc/robot/subsystems/Shooter.java | 19 ++-- .../util/Camera_Switch/CameraSwitch.java | 95 +++++++++++++++++++ .../util/Camera_Switch/RelayPortDevice.java | 27 ++++++ 5 files changed, 192 insertions(+), 34 deletions(-) create mode 100644 src/main/java/frc/robot/util/Camera_Switch/CameraSwitch.java create mode 100644 src/main/java/frc/robot/util/Camera_Switch/RelayPortDevice.java diff --git a/src/main/java/frc/robot/Robot.java b/src/main/java/frc/robot/Robot.java index b95e800..bbccac2 100644 --- a/src/main/java/frc/robot/Robot.java +++ b/src/main/java/frc/robot/Robot.java @@ -3,6 +3,7 @@ import edu.wpi.first.wpilibj.PowerDistributionPanel; import edu.wpi.first.wpilibj.TimedRobot; import edu.wpi.first.wpilibj.command.Scheduler; +import edu.wpi.first.wpilibj.smartdashboard.SmartDashboard; import frc.robot.subsystems.Drivetrain; import frc.robot.subsystems.Elevator; import frc.robot.subsystems.Hopper; @@ -27,25 +28,23 @@ public class Robot extends TimedRobot { public static RobotMap robotmap; public static Intake intake; public static ControlPan controlPan; + // public static CameraServer Cam; - //public static final CameraServer CamServer = CameraServer.getInstance(); @Override public void robotInit() { - hopper = new Hopper(); - shooter = new Shooter(); + // hopper = new Hopper(); + // shooter = new Shooter(); drivetrain = new Drivetrain(); - intake = new Intake(); - controlPan = new ControlPan(); - + // intake = new Intake(); + // controlPan = new ControlPan(); pdp = new PowerDistributionPanel(RobotMap.kPDP); oi = new OI(); robotmap = new RobotMap(); - + // Cam = CameraServer.getInstance(); compressor = new Compressor(RobotMap.kPCM); - compressor.start(); - compressor.enabled(); + compressor.start(); } @Override @@ -53,9 +52,11 @@ public void robotPeriodic() { // //EACH debug only runs once per 10 loops // DriveWithJoystick joystick_command = new DriveWithJoystick(OI.driverStick, 0.1) drivetrain.debug(); - hopper.debug(); + compressor.start(); + SmartDashboard.putBoolean("Compressor Status", compressor.enabled()); + // hopper.debug(); - // CamServer.startAutomaticCapture(0); + // Cam.startAutomaticCapture(0); } @Override @@ -78,6 +79,7 @@ public void autonomousPeriodic() { @Override public void teleopInit() { // autoCommand.cancel(); + compressor.start(); System.out.println("This is init"); diff --git a/src/main/java/frc/robot/subsystems/Drivetrain.java b/src/main/java/frc/robot/subsystems/Drivetrain.java index f5608ab..7ce2d14 100644 --- a/src/main/java/frc/robot/subsystems/Drivetrain.java +++ b/src/main/java/frc/robot/subsystems/Drivetrain.java @@ -1,20 +1,18 @@ package frc.robot.subsystems; import com.revrobotics.CANSparkMax; +import com.revrobotics.CANSparkMax.IdleMode; import com.revrobotics.CANSparkMaxLowLevel.MotorType; -import com.ctre.phoenix.motorcontrol.ControlMode; -import com.ctre.phoenix.motorcontrol.can.TalonSRX; import com.revrobotics.CANEncoder; import com.revrobotics.AlternateEncoderType; -import edu.wpi.first.wpilibj.CAN; import edu.wpi.first.wpilibj.command.Subsystem; import edu.wpi.first.wpilibj.smartdashboard.SmartDashboard; import frc.robot.Constants; import frc.robot.RobotMap; -import frc.robot.util.Util; +// import frc.robot.util.Camera_Switch.*; public class Drivetrain extends Subsystem { @@ -26,35 +24,54 @@ public class Drivetrain extends Subsystem { private static final AlternateEncoderType kAltEncType = AlternateEncoderType.kQuadrature; private CANEncoder m_leftAlternateEncoder; private CANEncoder m_rightAlternateEncoder; + // private CameraSwitch cam_switch; + public Drivetrain() { + + // Init Camera Switch + // cam_switch = new CameraSwitch(0, 1); + + // Init Left Leader leftLeader = new CANSparkMax(RobotMap.kLeftLeader, MotorType.kBrushless); leftLeader.setOpenLoopRampRate(Constants.kNeoRampTime); + + + // Init Right Leader rightLeader = new CANSparkMax(RobotMap.kRightLeader, MotorType.kBrushless); rightLeader.setOpenLoopRampRate(Constants.kNeoRampTime); - leftFollowers = new CANSparkMax[RobotMap.kLeftFollowers.length]; + // encoders m_leftAlternateEncoder = leftLeader.getAlternateEncoder(kAltEncType, 1024); m_rightAlternateEncoder = rightLeader.getAlternateEncoder(kAltEncType, 1024); + // init left followers + leftFollowers = new CANSparkMax[RobotMap.kLeftFollowers.length]; for(int i = 0; i < leftFollowers.length; ++i) { leftFollowers[i] = new CANSparkMax(RobotMap.kLeftFollowers[i], MotorType.kBrushless); leftFollowers[i].setOpenLoopRampRate(Constants.kNeoRampTime); leftFollowers[i].follow(leftLeader); } + + //init right followers rightFollowers = new CANSparkMax[RobotMap.kRightFollowers.length]; for(int i = 0; i < rightFollowers.length; ++i) { rightFollowers[i] = new CANSparkMax(RobotMap.kRightFollowers[i], MotorType.kBrushless); rightFollowers[i].setOpenLoopRampRate(Constants.kNeoRampTime); rightFollowers[i].follow(rightLeader); } + + setBrakeMode(true); } - public void initDefaultCommand() { - - } + public void initDefaultCommand() {} + + + // public void setCameraNum(int camNum) { + // cam_switch.select(camNum); + // } public void setMotors(double left, double right) { @@ -62,34 +79,49 @@ public void setMotors(double left, double right) { rightLeader.set(right); } + public double getLeftMotor(){ - // return leftLeader.getEncoder().getVelocity(); return m_leftAlternateEncoder.getVelocity(); } + public double getRightMotor(){ - // return rightLeader.getEncoder().getVelocity(); return m_rightAlternateEncoder.getVelocity(); } + public double getRightPosition(){ - // return leftLeader.getAlternateEncoder().getPosition(); return m_leftAlternateEncoder.getPosition(); } public double getLeftPosition(){ - // return rightLeader.getAlternateEncoder().getPosition(); return m_leftAlternateEncoder.getPosition(); } + + public double getLeftCPR(){ - // return leftLeader.getAlternateEncoder().getCountsPerRevolution(); return m_leftAlternateEncoder.getCountsPerRevolution(); } public double getRightCPR(){ - // return rightLeader.getAlternateEncoder().getCountsPerRevolution(); return m_leftAlternateEncoder.getCountsPerRevolution(); } + + public void setBrakeMode(boolean isbrake) { + IdleMode mode = isbrake ? IdleMode.kBrake : IdleMode.kCoast; + leftLeader.setIdleMode(mode); + rightLeader.setIdleMode(mode); + for(int i = 0; i < leftFollowers.length; ++i) { + leftFollowers[i].setIdleMode(mode); + } + + for(int i = 0; i < rightFollowers.length; ++i) { + rightFollowers[i].setIdleMode(mode); + } + + } + + public void debug() { SmartDashboard.putNumber("Get Left Velocity", getLeftMotor()); SmartDashboard.putNumber("Get Right Velocity", getRightMotor()); @@ -98,4 +130,5 @@ public void debug() { SmartDashboard.putNumber("Get Right CPR", getRightCPR()); SmartDashboard.putNumber("Get Left CPR", getLeftCPR()); } + } \ No newline at end of file diff --git a/src/main/java/frc/robot/subsystems/Shooter.java b/src/main/java/frc/robot/subsystems/Shooter.java index b15bff4..ad09aad 100644 --- a/src/main/java/frc/robot/subsystems/Shooter.java +++ b/src/main/java/frc/robot/subsystems/Shooter.java @@ -7,6 +7,7 @@ package frc.robot.subsystems; import com.revrobotics.CANSparkMax; +import com.revrobotics.CANSparkMax.IdleMode; import com.revrobotics.CANSparkMaxLowLevel.MotorType; import com.ctre.phoenix.motorcontrol.ControlMode; import com.ctre.phoenix.motorcontrol.can.TalonSRX; @@ -35,25 +36,25 @@ public Shooter(){ shooterLeft.set(0); shooterRight.set(0); + + setBrakeMode(false); } public void setShooter(final double output){ } - // public double getShooterVelocity(){ - // return shooter_neo.getEncoder().getVelocity(); - // } - // public double getShooter(){ - // return shooter_neo.getEncoder().getCountsPerRevolution(); - // } + @Override protected void initDefaultCommand() { - // defaultCommand = new MoveShooterPassive(); - // // TODO Auto-generated method stub - // defaultCommand.start(); } + public void setBrakeMode(boolean isbrake) { + IdleMode mode = isbrake ? IdleMode.kBrake : IdleMode.kCoast; + shooterLeft.setIdleMode(mode); + shooterRight.setIdleMode(mode); + } + public void debug() { // SmartDashboard.putNumber("Shooter Neo Velocity -", getShooterVelocity()); // SmartDashboard.putNumber("Shooter Neo CPR -", getShooter()); diff --git a/src/main/java/frc/robot/util/Camera_Switch/CameraSwitch.java b/src/main/java/frc/robot/util/Camera_Switch/CameraSwitch.java new file mode 100644 index 0000000..ef8c087 --- /dev/null +++ b/src/main/java/frc/robot/util/Camera_Switch/CameraSwitch.java @@ -0,0 +1,95 @@ +/************************************* +* @author Chris Lane | FRC 2791 | 2020 +* +* API for a multiplexer camera switch. +* +* The switch should plug into the relay +* port on the RoboRIO given in the +* constructor. Each relay value +* corresponds to a pin on the port being +* driven hi or lo (1/0). +* +* This API essentially utilizes the +* relay port as two DI/O ports right +* next to each other +* kforward = pin1 high/pin 2 low, +* kReverse = pin 1 low/pin 2 high, +* kON = pin 1 high/pin2 high, +* kOff = pin 1 low/pin 2 low. +* +**************************************/ +package frc.robot.util.Camera_Switch; + +import edu.wpi.first.wpilibj.Relay; +import edu.wpi.first.wpilibj.Relay.Value; + +public class CameraSwitch implements RelayPortDevice{ + + public static final int kcamera1 = 1; + public static final int kcamera2 = 2; + public static final int kcamera3 = 3; + public static final int kcamera4 = 4; + + + + public Relay camrelay1; + public Relay camrelay2; + + public CameraSwitch(int port1, int port2){ + + camrelay1 = new Relay(port1); + camrelay2 = new Relay(port2); + + }//Constructor for a CameraSwitch on a single relay port + + public void select(int camSelected){ + /* enter the constant strings for the switch into this method to select cameras + constants for cameras are- "kcamera(camera#)" (these can be changed in the switch statment) + This switch has four possible ports. */ + + switch (camSelected) { + case kcamera1 : + camrelay1.set(Value.kReverse); + // camrelay.set(Value.kForward); + break; + case kcamera2 : + camrelay1.set(Value.kForward); + break; + case kcamera3 : + camrelay2.set(Value.kReverse); + // camrelay.set(Value.kOn); + case kcamera4 : + camrelay2.set(Value.kForward); + // camrelay.set(Value.kOff); + break; + default: + camrelay1.set(Value.kReverse); + System.err.print("Camera not properly selected, setting to case 1,Camera1"); + break; + }//This switch statement is what actually writes to the relay port + + }//Use this method to select the desired camera to connect to the RoboRIO + + public void rawSetRelay(Relay.Value kvalue){ + + camrelay1.set(kvalue); + camrelay2.set(kvalue); + + }//Use this method to set the relay port to a regular relay value + + public void setDirection(Relay.Direction direction){ + + camrelay1.setDirection(direction); + camrelay2.setDirection(direction); + + }//Use this method to set valid directions for the local relay used in this class + + public void setLocalRelay(Relay.Value klocalValue) { + + //unused function + System.err.println("setLocalRelay(Relay.Value klocalValue); method not utilized in CameraSwitch.java"); + + }//DO NOT USE THIS METHOD + + } +//end of file----------------------------------------------------------------------- diff --git a/src/main/java/frc/robot/util/Camera_Switch/RelayPortDevice.java b/src/main/java/frc/robot/util/Camera_Switch/RelayPortDevice.java new file mode 100644 index 0000000..e4c1c08 --- /dev/null +++ b/src/main/java/frc/robot/util/Camera_Switch/RelayPortDevice.java @@ -0,0 +1,27 @@ +/**************************************** +* @author Chris Lane | FRC 2791 | 2020 +* +* Interface for a relay port device. +* +* This interface is for interfacing with +* devices that connect to the relay ports +* on the RoboRIO that are not regular IFI +* SPIKE or similar relays. +* +*****************************************/ + +package frc.robot.util.Camera_Switch; +import edu.wpi.first.wpilibj.Relay; + +public interface RelayPortDevice { + + +public void rawSetRelay(Relay.Value kValue);//Set the raw relay port + +public void setDirection(Relay.Direction direction);//Indirectly set relay port valid direction + +public void setLocalRelay(Relay.Value klocalValue);//Set the local relay values from a static field + + +} +//End of file----------------------------------------------------------------------- \ No newline at end of file From b5c28974671eb2df267d2137e2f54852293dd2b3 Mon Sep 17 00:00:00 2001 From: fidgetspinnerkid <35818373+fidgetspinnerkid@users.noreply.github.com> Date: Tue, 18 Feb 2020 16:10:02 -0800 Subject: [PATCH 12/68] changed shooter command groups --- .../java/frc/robot/Autons/ShooterGroup.java | 29 ----- .../frc/robot/Autons/ShooterGroupLong.java | 24 ++++ .../frc/robot/Autons/ShooterGroupWall.java | 22 ++++ ...erGroup.java => StopShooterGroupLong.java} | 11 +- .../robot/Autons/StopShooterGroupWall.java | 23 ++++ src/main/java/frc/robot/Constants.java | 16 ++- src/main/java/frc/robot/OI.java | 24 +++- src/main/java/frc/robot/Robot.java | 22 ++-- src/main/java/frc/robot/RobotMap.java | 11 +- .../java/frc/robot/commands/IrHopper.java | 49 +++++++++ .../frc/robot/commands/MoveManipulator.java | 47 ++++++++ .../java/frc/robot/commands/MoveShooter.java | 104 +++++++++--------- .../robot/commands/MoveShooterPassive.java | 104 +++++++++--------- .../commands/Shooter/CheckMotorWall.java | 4 +- .../commands/Shooter/OpenHopperPiston.java | 5 +- .../commands/Shooter/RetractHopperPiston.java | 42 +++++++ .../frc/robot/commands/Shooter/Shoot.java | 82 +++++++------- .../robot/commands/Shooter/StopShooter.java | 40 +++++++ .../frc/robot/commands/StopManipulator.java | 46 ++++++++ .../java/frc/robot/commands/StopShooter.java | 98 ++++++++--------- .../java/frc/robot/subsystems/Hopper.java | 43 +++++++- .../java/frc/robot/subsystems/Intake.java | 44 -------- .../frc/robot/subsystems/Manipulator.java | 44 ++++++++ .../{ControlPan.java => PanelMech.java} | 22 ++-- .../java/frc/robot/subsystems/Shooter.java | 2 +- 25 files changed, 643 insertions(+), 315 deletions(-) delete mode 100644 src/main/java/frc/robot/Autons/ShooterGroup.java create mode 100644 src/main/java/frc/robot/Autons/ShooterGroupLong.java create mode 100644 src/main/java/frc/robot/Autons/ShooterGroupWall.java rename src/main/java/frc/robot/Autons/{StopShooterGroup.java => StopShooterGroupLong.java} (69%) create mode 100644 src/main/java/frc/robot/Autons/StopShooterGroupWall.java create mode 100644 src/main/java/frc/robot/commands/IrHopper.java create mode 100644 src/main/java/frc/robot/commands/MoveManipulator.java create mode 100644 src/main/java/frc/robot/commands/Shooter/RetractHopperPiston.java create mode 100644 src/main/java/frc/robot/commands/Shooter/StopShooter.java create mode 100644 src/main/java/frc/robot/commands/StopManipulator.java delete mode 100644 src/main/java/frc/robot/subsystems/Intake.java create mode 100644 src/main/java/frc/robot/subsystems/Manipulator.java rename src/main/java/frc/robot/subsystems/{ControlPan.java => PanelMech.java} (66%) diff --git a/src/main/java/frc/robot/Autons/ShooterGroup.java b/src/main/java/frc/robot/Autons/ShooterGroup.java deleted file mode 100644 index 21d47ce..0000000 --- a/src/main/java/frc/robot/Autons/ShooterGroup.java +++ /dev/null @@ -1,29 +0,0 @@ -package frc.robot.Autons; - -import edu.wpi.first.wpilibj.command.CommandGroup; -import frc.robot.Robot; -import frc.robot.commands.MoveHopper; -//import frc.robot.commands.Shooter.CheckWheelSpeed; -//import frc.robot.commands.Shooter.RetractHood; -import frc.robot.commands.Shooter.RetractHopperPiston; -import frc.robot.subsystems.Shooter; - -public class ShooterGroup extends CommandGroup{ - - public ShooterGroup(){ - //must switch these errored ones to commands instead of or along with methods predefined. Honestly, just make a command - //with those methods and that is it ig? Or retry the command doing all of them. Problems with thht however. Harder to make - //stop method to stop everything you run and the old if statements make me feel lke it doesn't do wat I want it to. For example - //it will check the wheel speed and then run the hopper ... doesn't wait for wheel speed to be good. Didn't like old if - //statements for that because I felt like they would make the hopper stop moving and stop shooting balls continuously until - //shooter speed was back especially since the speed dips everytime a ball is shot - //This is the command group vs the command with everything is called Shoot() - //This command group is what is in oi - //addSequential(new RetractHood()); - //addSequential(new CheckWheelSpeed()); - addSequential(new MoveHopper()); - addSequential(new RetractHopperPiston()); - - - } -} \ No newline at end of file diff --git a/src/main/java/frc/robot/Autons/ShooterGroupLong.java b/src/main/java/frc/robot/Autons/ShooterGroupLong.java new file mode 100644 index 0000000..663f4d7 --- /dev/null +++ b/src/main/java/frc/robot/Autons/ShooterGroupLong.java @@ -0,0 +1,24 @@ +package frc.robot.Autons; + +import edu.wpi.first.wpilibj.command.CommandGroup; +import frc.robot.Robot; +import frc.robot.commands.MoveHopper; +import frc.robot.commands.Shooter.CheckHoodLong; +import frc.robot.commands.Shooter.CheckHoodWall; +import frc.robot.commands.Shooter.CheckMotorLong; +import frc.robot.commands.Shooter.CheckMotorWall; +import frc.robot.commands.Shooter.OpenHopperPiston; +//import frc.robot.commands.Shooter.CheckWheelSpeed; +//import frc.robot.commands.Shooter.RetractHood; +import frc.robot.commands.Shooter.RetractHopperPiston; +import frc.robot.subsystems.Shooter; + +public class ShooterGroupLong extends CommandGroup{ + + public ShooterGroupLong(){ + addSequential(new CheckHoodLong()); + addSequential(new CheckMotorLong()); + addSequential(new OpenHopperPiston()); + addSequential(new MoveHopper()); + } +} \ No newline at end of file diff --git a/src/main/java/frc/robot/Autons/ShooterGroupWall.java b/src/main/java/frc/robot/Autons/ShooterGroupWall.java new file mode 100644 index 0000000..5f134d2 --- /dev/null +++ b/src/main/java/frc/robot/Autons/ShooterGroupWall.java @@ -0,0 +1,22 @@ +package frc.robot.Autons; + +import edu.wpi.first.wpilibj.command.CommandGroup; +import frc.robot.Robot; +import frc.robot.commands.MoveHopper; +import frc.robot.commands.Shooter.CheckHoodWall; +import frc.robot.commands.Shooter.CheckMotorWall; +import frc.robot.commands.Shooter.OpenHopperPiston; +//import frc.robot.commands.Shooter.CheckWheelSpeed; +//import frc.robot.commands.Shooter.RetractHood; +import frc.robot.commands.Shooter.RetractHopperPiston; +import frc.robot.subsystems.Shooter; + +public class ShooterGroupWall extends CommandGroup{ + + public ShooterGroupWall(){ + addSequential(new CheckHoodWall()); + addSequential(new CheckMotorWall()); + addSequential(new OpenHopperPiston()); + addSequential(new MoveHopper()); + } +} \ No newline at end of file diff --git a/src/main/java/frc/robot/Autons/StopShooterGroup.java b/src/main/java/frc/robot/Autons/StopShooterGroupLong.java similarity index 69% rename from src/main/java/frc/robot/Autons/StopShooterGroup.java rename to src/main/java/frc/robot/Autons/StopShooterGroupLong.java index 25f469a..b8492eb 100644 --- a/src/main/java/frc/robot/Autons/StopShooterGroup.java +++ b/src/main/java/frc/robot/Autons/StopShooterGroupLong.java @@ -4,21 +4,20 @@ import frc.robot.Robot; import frc.robot.commands.MoveHopper; import frc.robot.commands.StopHopper; +import frc.robot.commands.Shooter.CheckHoodWall; +import frc.robot.commands.Shooter.CheckMotorWall; +import frc.robot.commands.Shooter.OpenHopperPiston; //import frc.robot.commands.Shooter.CheckWheelSpeed; //import frc.robot.commands.Shooter.RetractHood; import frc.robot.commands.Shooter.RetractHopperPiston; import frc.robot.commands.Shooter.StopShooter; import frc.robot.subsystems.Shooter; -public class StopShooterGroup extends CommandGroup{ +public class StopShooterGroupLong extends CommandGroup{ - //in theory this redoes everything the shooterGroup() command group changed - public StopShooterGroup(){ - //addParallel(new RetractHood()); + public StopShooterGroupLong(){ addParallel(new StopShooter()); addParallel(new StopHopper()); addParallel(new RetractHopperPiston()); - - } } \ No newline at end of file diff --git a/src/main/java/frc/robot/Autons/StopShooterGroupWall.java b/src/main/java/frc/robot/Autons/StopShooterGroupWall.java new file mode 100644 index 0000000..c60c20a --- /dev/null +++ b/src/main/java/frc/robot/Autons/StopShooterGroupWall.java @@ -0,0 +1,23 @@ +package frc.robot.Autons; + +import edu.wpi.first.wpilibj.command.CommandGroup; +import frc.robot.Robot; +import frc.robot.commands.MoveHopper; +import frc.robot.commands.StopHopper; +import frc.robot.commands.Shooter.CheckHoodWall; +import frc.robot.commands.Shooter.CheckMotorWall; +import frc.robot.commands.Shooter.OpenHopperPiston; +//import frc.robot.commands.Shooter.CheckWheelSpeed; +//import frc.robot.commands.Shooter.RetractHood; +import frc.robot.commands.Shooter.RetractHopperPiston; +import frc.robot.commands.Shooter.StopShooter; +import frc.robot.subsystems.Shooter; + +public class StopShooterGroupWall extends CommandGroup{ + + public StopShooterGroupWall(){ + addParallel(new StopShooter()); + addParallel(new StopHopper()); + addParallel(new RetractHopperPiston()); + } +} \ No newline at end of file diff --git a/src/main/java/frc/robot/Constants.java b/src/main/java/frc/robot/Constants.java index 8902194..856afd0 100644 --- a/src/main/java/frc/robot/Constants.java +++ b/src/main/java/frc/robot/Constants.java @@ -59,7 +59,7 @@ public final class Constants { public static final double ELEVATOR_OUTPUT = -.05; - public static final double HOPPER_OUTPUT = -.20; // 20% is sweet spot + public static final double HOPPER_OUTPUT = .20; // 20% is sweet spot public static final double SHOOTER_OUTPUT = -.8; @@ -76,8 +76,20 @@ public final class Constants { public static final double MANUAL_POWER = .2; - public static final double INTAKE_MOTORSPEED = 0.75; //Temp value please test it out and do stuff yes + public static final double INTAKE_MOTORSPEED = 0.50; //Temp value please test it out and do stuff yes public static final double SHOOTER_VELOCITY = 100; //Temporary value + + + public static final double SHOOTER_OUTPUT_LONG = 1; + + + public static final double SHOOTER_OUTPUT_WALL = .47; + + + public static final double TURN_FACTOR = 0.2; + + + public static final int BALL_VALUE = 1100; } \ No newline at end of file diff --git a/src/main/java/frc/robot/OI.java b/src/main/java/frc/robot/OI.java index 7c51604..83bd972 100644 --- a/src/main/java/frc/robot/OI.java +++ b/src/main/java/frc/robot/OI.java @@ -5,10 +5,16 @@ import edu.wpi.first.wpilibj.buttons.JoystickButton; import frc.robot.commands.*; +import frc.robot.commands.Shooter.RetractHopperPiston; +import frc.robot.commands.Shooter.OpenHopperPiston; // import frc.robot.commands.auto.SetLimit; import frc.robot.controller.AnalogButton; import frc.robot.controller.DPadButton; import frc.robot.controller.MultiButton; +import frc.robot.Autons.ShooterGroupLong; +import frc.robot.Autons.StopShooterGroupLong; +import frc.robot.Autons.ShooterGroupWall; +import frc.robot.Autons.StopShooterGroupWall; // import frc.robot.commands.Lifter.ExtendBothLifters; import frc.robot.util.Util; @@ -75,10 +81,20 @@ public OI() { // driverB.whenReleased(new StopElevator()); // driverX.whenPressed(new MoveHopper()); // driverX.whenReleased(new StopHopper()); - driverB.whenPressed(new DrivetrainBackwards()); - driverB.whenReleased(new StopDrivetrain()); - driverY.whenPressed(new MoveDrivetrain()); - driverY.whenReleased(new StopDrivetrain()); + // driverB.whenPressed(new DrivetrainBackwards()); + // driverB.whenReleased(new StopDrivetrain()); + // driverY.whenPressed(new MoveDrivetrain()); + // driverY.whenReleased(new StopDrivetrain()); + driverA.whenPressed(new MoveManipulator()); + driverA.whenReleased(new StopManipulator()); + driverX.whenPressed(new IrHopper()); + driverX.whenReleased(new StopHopper()); + driverB.whenPressed(new OpenHopperPiston()); + driverB.whenReleased(new RetractHopperPiston()); + driverRB.whenPressed(new ShooterGroupWall()); + driverRB.whenReleased(new StopShooterGroupWall()); + driverLB.whenPressed(new ShooterGroupLong()); + driverLB.whenReleased(new StopShooterGroupLong()); // driverLB.whenPressed(new runHopperElevator()); // driverLB.whenReleased(new stopHopperElevator()); // driverLS.whenPressed(new runElevatorShooter()); diff --git a/src/main/java/frc/robot/Robot.java b/src/main/java/frc/robot/Robot.java index bbccac2..6e78df0 100644 --- a/src/main/java/frc/robot/Robot.java +++ b/src/main/java/frc/robot/Robot.java @@ -4,10 +4,6 @@ import edu.wpi.first.wpilibj.TimedRobot; import edu.wpi.first.wpilibj.command.Scheduler; import edu.wpi.first.wpilibj.smartdashboard.SmartDashboard; -import frc.robot.subsystems.Drivetrain; -import frc.robot.subsystems.Elevator; -import frc.robot.subsystems.Hopper; -import frc.robot.subsystems.Shooter; import frc.robot.subsystems.*; import edu.wpi.first.wpilibj.Compressor; @@ -26,23 +22,21 @@ public class Robot extends TimedRobot { public static Elevator elevator; public static Hopper hopper; public static RobotMap robotmap; - public static Intake intake; - public static ControlPan controlPan; - // public static CameraServer Cam; - - + public static Manipulator manipulator; + // public static PanelMech panelMech; + public static CameraServer Cam; @Override public void robotInit() { - // hopper = new Hopper(); - // shooter = new Shooter(); + hopper = new Hopper(); + shooter = new Shooter(); drivetrain = new Drivetrain(); - // intake = new Intake(); + manipulator = new Manipulator(); // controlPan = new ControlPan(); pdp = new PowerDistributionPanel(RobotMap.kPDP); oi = new OI(); robotmap = new RobotMap(); - // Cam = CameraServer.getInstance(); + Cam = CameraServer.getInstance(); compressor = new Compressor(RobotMap.kPCM); compressor.start(); } @@ -54,7 +48,7 @@ public void robotPeriodic() { drivetrain.debug(); compressor.start(); SmartDashboard.putBoolean("Compressor Status", compressor.enabled()); - // hopper.debug(); + hopper.debug(); // Cam.startAutomaticCapture(0); } diff --git a/src/main/java/frc/robot/RobotMap.java b/src/main/java/frc/robot/RobotMap.java index 96c9aa8..02161e2 100644 --- a/src/main/java/frc/robot/RobotMap.java +++ b/src/main/java/frc/robot/RobotMap.java @@ -42,7 +42,6 @@ public class RobotMap { public static final int kVertHopper = 41; public static final int kHoriHopper = 42; - public static final int kControlPan = 50; public static final int kWinch = 60; public static final int kActivePos = 61; @@ -86,9 +85,15 @@ public class RobotMap { public static final int ELEVATOR_TALON = 23; //Hopper - - public static final int HOPPER_TALON = 24; + // public static final int HOPPER_TALON = 40; //Drivetrain public static final int DRIVETRAIN_NEO = 3; +public static final int HOOD_SOLENOID = 3; +public static final int HOPPER_SOLENOID = 1; +public static final int VERTICAL_HOPPER = 41; +public static final int HORIZONTAL_HOPPER = 42; +public static final int MANIPULATOR_SOLENOID = 6; +public static final int MANIPULATOR_NEO = 40; +public static final int MECHNECK = 50; } diff --git a/src/main/java/frc/robot/commands/IrHopper.java b/src/main/java/frc/robot/commands/IrHopper.java new file mode 100644 index 0000000..07ec5dd --- /dev/null +++ b/src/main/java/frc/robot/commands/IrHopper.java @@ -0,0 +1,49 @@ +/*----------------------------------------------------------------------------*/ +/* Copyright (c) 2018 FIRST. All Rights Reserved. */ +/* Open Source Software - may be modified and shared by FRC teams. The code */ +/* must be accompanied by the FIRST BSD license file in the root directory of */ +/* the project. */ +/*----------------------------------------------------------------------------*/ + +package frc.robot.commands; + +import edu.wpi.first.wpilibj.command.Command; +import frc.robot.Robot; + +public class IrHopper extends Command { + public IrHopper() { + super("IrHopper"); + requires(Robot.hopper); + // Use requires() here to declare subsystem dependencies + // eg. requires(chassis); + } + + // Called just before this Command runs the first time + @Override + protected void initialize() { + } + + // Called repeatedly when this Command is scheduled to run + @Override + protected void execute() { + Robot.hopper.poopBall(); + } + + // Make this return true when this Command no longer needs to run execute() + @Override + protected boolean isFinished() { + return false; + } + + // Called once after isFinished returns true + @Override + protected void end() { + Robot.hopper.setHopper(0); + } + + // Called when another command which requires one or more of the same + // subsystems is scheduled to run + @Override + protected void interrupted() { + } +} diff --git a/src/main/java/frc/robot/commands/MoveManipulator.java b/src/main/java/frc/robot/commands/MoveManipulator.java new file mode 100644 index 0000000..c05baee --- /dev/null +++ b/src/main/java/frc/robot/commands/MoveManipulator.java @@ -0,0 +1,47 @@ +package frc.robot.commands; + +import edu.wpi.first.wpilibj.command.Command; +import frc.robot.Constants; +import frc.robot.Robot; + +public class MoveManipulator extends Command { + public MoveManipulator() { + super("MoveManipulator"); + requires(Robot.manipulator); + //Use requires() here to declare subsystem dependencies + //eg. requires(chassis); + } + + //Called just before this Command runs the first time + @Override + protected void initialize() { + + } + + //Called repeatedly when this Command is scheduled to run + @Override + protected void execute() { + Robot.manipulator.setRetracted(true); + Robot.manipulator.setManipulator(0); + } + + //Make this return true when this Command no longer needs to run execute() + @Override + protected boolean isFinished() { + return false; + } + + //Called once after isFinished returns true + @Override + protected void end() { + Robot.manipulator.setManipulator(0); + } + + //Called when another command which requires one or more of the same + //subsystems is scheduled to run + + @Override + protected void interrupted() { + //Yes + } +} diff --git a/src/main/java/frc/robot/commands/MoveShooter.java b/src/main/java/frc/robot/commands/MoveShooter.java index d479b14..aff7ba9 100644 --- a/src/main/java/frc/robot/commands/MoveShooter.java +++ b/src/main/java/frc/robot/commands/MoveShooter.java @@ -1,52 +1,52 @@ -/*----------------------------------------------------------------------------*/ -/* Copyright (c) 2018 FIRST. All Rights Reserved. */ -/* Open Source Software - may be modified and shared by FRC teams. The code */ -/* must be accompanied by the FIRST BSD license file in the root directory of */ -/* the project. */ -/*----------------------------------------------------------------------------*/ - -package frc.robot.commands; - -import edu.wpi.first.wpilibj.command.Command; -import frc.robot.Constants; -import frc.robot.Robot; - -public class MoveShooter extends Command { - public MoveShooter() { - super("MoveShooter"); - requires(Robot.shooter); - - // Use requires() here to declare subsystem dependencies - // eg. requires(chassis); - } - - // Called just before this Command runs the first time - @Override - protected void initialize() { - - } - - // Called repeatedly when this Command is scheduled to run - @Override - protected void execute() { - Robot.shooter.setShooter(Constants.SHOOTER_OUTPUT); - } - - // Make this return true when this Command no longer needs to run execute() - @Override - protected boolean isFinished() { - return false; - } - - // Called once after isFinished returns true - @Override - protected void end() { - Robot.shooter.setShooter(0); - } - - // Called when another command which requires one or more of the same - // subsystems is scheduled to run - @Override - protected void interrupted() { - } -} +// /*----------------------------------------------------------------------------*/ +// /* Copyright (c) 2018 FIRST. All Rights Reserved. */ +// /* Open Source Software - may be modified and shared by FRC teams. The code */ +// /* must be accompanied by the FIRST BSD license file in the root directory of */ +// /* the project. */ +// /*----------------------------------------------------------------------------*/ + +// package frc.robot.commands; + +// import edu.wpi.first.wpilibj.command.Command; +// import frc.robot.Constants; +// import frc.robot.Robot; + +// public class MoveShooter extends Command { +// public MoveShooter() { +// super("MoveShooter"); +// requires(Robot.shooter); + +// // Use requires() here to declare subsystem dependencies +// // eg. requires(chassis); +// } + +// // Called just before this Command runs the first time +// @Override +// protected void initialize() { + +// } + +// // Called repeatedly when this Command is scheduled to run +// @Override +// protected void execute() { +// Robot.shooter.setShooter(Constants.SHOOTER_OUTPUT); +// } + +// // Make this return true when this Command no longer needs to run execute() +// @Override +// protected boolean isFinished() { +// return false; +// } + +// // Called once after isFinished returns true +// @Override +// protected void end() { +// Robot.shooter.setShooter(0); +// } + +// // Called when another command which requires one or more of the same +// // subsystems is scheduled to run +// @Override +// protected void interrupted() { +// } +// } diff --git a/src/main/java/frc/robot/commands/MoveShooterPassive.java b/src/main/java/frc/robot/commands/MoveShooterPassive.java index d7eb505..a72c83f 100644 --- a/src/main/java/frc/robot/commands/MoveShooterPassive.java +++ b/src/main/java/frc/robot/commands/MoveShooterPassive.java @@ -1,52 +1,52 @@ -/*----------------------------------------------------------------------------*/ -/* Copyright (c) 2018 FIRST. All Rights Reserved. */ -/* Open Source Software - may be modified and shared by FRC teams. The code */ -/* must be accompanied by the FIRST BSD license file in the root directory of */ -/* the project. */ -/*----------------------------------------------------------------------------*/ - -package frc.robot.commands; - -import edu.wpi.first.wpilibj.command.Command; -import frc.robot.Constants; -import frc.robot.Robot; - -public class MoveShooterPassive extends Command { - public MoveShooterPassive() { - super("MoveShooterPassive"); - requires(Robot.shooter); - - // Use requires() here to declare subsystem dependencies - // eg. requires(chassis); - } - - // Called just before this Command runs the first time - @Override - protected void initialize() { - - } - - // Called repeatedly when this Command is scheduled to run - @Override - protected void execute() { - Robot.shooter.setShooter(Constants.SHOOTER_OUTPUT_PASSIVE); - } - - // Make this return true when this Command no longer needs to run execute() - @Override - protected boolean isFinished() { - return false; - } - - // Called once after isFinished returns true - @Override - protected void end() { - Robot.shooter.setShooter(0); - } - - // Called when another command which requires one or more of the same - // subsystems is scheduled to run - @Override - protected void interrupted() { - } -} +// /*----------------------------------------------------------------------------*/ +// /* Copyright (c) 2018 FIRST. All Rights Reserved. */ +// /* Open Source Software - may be modified and shared by FRC teams. The code */ +// /* must be accompanied by the FIRST BSD license file in the root directory of */ +// /* the project. */ +// /*----------------------------------------------------------------------------*/ + +// package frc.robot.commands; + +// import edu.wpi.first.wpilibj.command.Command; +// import frc.robot.Constants; +// import frc.robot.Robot; + +// public class MoveShooterPassive extends Command { +// public MoveShooterPassive() { +// super("MoveShooterPassive"); +// requires(Robot.shooter); + +// // Use requires() here to declare subsystem dependencies +// // eg. requires(chassis); +// } + +// // Called just before this Command runs the first time +// @Override +// protected void initialize() { + +// } + +// // Called repeatedly when this Command is scheduled to run +// @Override +// protected void execute() { +// Robot.shooter.setShooter(Constants.SHOOTER_OUTPUT_PASSIVE); +// } + +// // Make this return true when this Command no longer needs to run execute() +// @Override +// protected boolean isFinished() { +// return false; +// } + +// // Called once after isFinished returns true +// @Override +// protected void end() { +// Robot.shooter.setShooter(0); +// } + +// // Called when another command which requires one or more of the same +// // subsystems is scheduled to run +// @Override +// protected void interrupted() { +// } +// } diff --git a/src/main/java/frc/robot/commands/Shooter/CheckMotorWall.java b/src/main/java/frc/robot/commands/Shooter/CheckMotorWall.java index 2a943be..882204d 100644 --- a/src/main/java/frc/robot/commands/Shooter/CheckMotorWall.java +++ b/src/main/java/frc/robot/commands/Shooter/CheckMotorWall.java @@ -30,14 +30,14 @@ protected void initialize() { @Override protected void execute() { if(Robot.shooter.checkWheelSpeed_Wall() != true) { - Robot.shooter.setShooter(Constants.SHOOTER_OUTPUT_WALL); + Robot.shooter.setShooter(Constants.SHOOTER_OUTPUT_WALL); //Utilize PIDs for this (and Longshot as well) } } // Make this return true when this Command no longer needs to run execute() @Override protected boolean isFinished() { - if(Robot.shooter.checkWheelSpeed_Wall() == true) { + if(Robot.shooter.checkWheelSpeed_Wall()) { return true; } return false; diff --git a/src/main/java/frc/robot/commands/Shooter/OpenHopperPiston.java b/src/main/java/frc/robot/commands/Shooter/OpenHopperPiston.java index d6de556..4793f16 100644 --- a/src/main/java/frc/robot/commands/Shooter/OpenHopperPiston.java +++ b/src/main/java/frc/robot/commands/Shooter/OpenHopperPiston.java @@ -4,7 +4,7 @@ import frc.robot.Constants; import frc.robot.Robot; import frc.robot.commands.MoveHopper; -import frc.robot.subsystems.Shooter; +// import frc.robot.subsystems.Shooter; //in theory this just chanes whether the hopper piston is retracted or not and then stops public class OpenHopperPiston extends Command{ @@ -16,12 +16,11 @@ public OpenHopperPiston(){ @Override protected void initialize(){ - retracted = Robot.hopper.getRetracted(); } @Override protected void execute() { - Robot.hopper.setRetracted(retracted); + Robot.hopper.setRetracted(false); } diff --git a/src/main/java/frc/robot/commands/Shooter/RetractHopperPiston.java b/src/main/java/frc/robot/commands/Shooter/RetractHopperPiston.java new file mode 100644 index 0000000..4af4736 --- /dev/null +++ b/src/main/java/frc/robot/commands/Shooter/RetractHopperPiston.java @@ -0,0 +1,42 @@ +package frc.robot.commands.Shooter; + +import edu.wpi.first.wpilibj.command.Command; +import frc.robot.Constants; +import frc.robot.Robot; +import frc.robot.commands.MoveHopper; +// import frc.robot.subsystems.Shooter; + +//in theory this just chanes whether the hopper piston is retracted or not and then stops +public class RetractHopperPiston extends Command{ + private boolean retracted; + public RetractHopperPiston(){ + super("RetractHopperPiston"); + requires(Robot.hopper); + } + + @Override + protected void initialize(){ + retracted = Robot.hopper.getRetracted(); + } + + @Override + protected void execute() { + Robot.hopper.setRetracted(true); + + } + + @Override + + protected boolean isFinished(){ + return true; + } + @Override + protected void end() { + + } + + @Override + + protected void interrupted(){ + } +} \ No newline at end of file diff --git a/src/main/java/frc/robot/commands/Shooter/Shoot.java b/src/main/java/frc/robot/commands/Shooter/Shoot.java index 2ac1acf..29706dc 100644 --- a/src/main/java/frc/robot/commands/Shooter/Shoot.java +++ b/src/main/java/frc/robot/commands/Shooter/Shoot.java @@ -1,51 +1,51 @@ -package frc.robot.commands.Shooter; - -import edu.wpi.first.wpilibj.command.Command; -import frc.robot.Constants; -import frc.robot.Robot; -import frc.robot.commands.MoveHopper; -import frc.robot.subsystems.Shooter; - -public class Shoot extends Command{ - private double wheelSpeed; - private boolean goodSpeed; - public Shoot(){ - super("Shoot"); - requires(Robot.shooter); - requires(Robot.hopper); - } - - @Override +// package frc.robot.commands.Shooter; + +// import edu.wpi.first.wpilibj.command.Command; +// import frc.robot.Constants; +// import frc.robot.Robot; +// import frc.robot.commands.MoveHopper; +// import frc.robot.subsystems.Shooter; + +// public class Shoot extends Command{ +// private double wheelSpeed; +// private boolean goodSpeed; +// public Shoot(){ +// super("Shoot"); +// requires(Robot.shooter); +// requires(Robot.hopper); +// } + +// @Override - protected void initialize(){ +// protected void initialize(){ - } +// } - @Override +// @Override - protected void execute() { - Robot.shooter.setHood1(false); //change to true??? - //new CheckWheelSpeed(); - new MoveHopper(); - Robot.hopper.setRetracted(Robot.hopper.isRetracted()); //define isRetracted as true or false??? +// protected void execute() { +// Robot.shooter.setHood1(false); //change to true??? +// //new CheckWheelSpeed(); +// new MoveHopper(); +// Robot.hopper.setRetracted(Robot.hopper.isRetracted()); //define isRetracted as true or false??? - } +// } - @Override +// @Override - protected boolean isFinished(){ - return false; - } - @Override +// protected boolean isFinished(){ +// return false; +// } +// @Override - protected void end() { - Robot.shooter.setShooter(0); - Robot.hopper.setHopper(0); - Robot.hopper.setRetracted(Robot.hopper.isRetracted()); //if yes above, change here as well - } +// protected void end() { +// Robot.shooter.setShooter(0); +// Robot.hopper.setHopper(0); +// Robot.hopper.setRetracted(Robot.hopper.isRetracted()); //if yes above, change here as well +// } - @Override +// @Override - protected void interrupted(){ - } -} \ No newline at end of file +// protected void interrupted(){ +// } +// } \ No newline at end of file diff --git a/src/main/java/frc/robot/commands/Shooter/StopShooter.java b/src/main/java/frc/robot/commands/Shooter/StopShooter.java new file mode 100644 index 0000000..81b4940 --- /dev/null +++ b/src/main/java/frc/robot/commands/Shooter/StopShooter.java @@ -0,0 +1,40 @@ +package frc.robot.commands.Shooter; + +import edu.wpi.first.wpilibj.command.Command; +import frc.robot.Constants; +import frc.robot.Robot; +import frc.robot.commands.MoveHopper; +import frc.robot.subsystems.Shooter; + +//in theory this just chanes whether the hopper piston is retracted or not and then stops +public class StopShooter extends Command{ + private boolean retracted; + public StopShooter(){ + super("StopShooter"); + requires(Robot.hopper); + } + + @Override + protected void initialize(){ + } + + @Override + protected void execute() { + Robot.shooter.setShooter(0); + + } + + @Override + protected boolean isFinished(){ + return false; + } + @Override + protected void end() { + Robot.shooter.setShooter(0); + } + + @Override + + protected void interrupted(){ + } +} \ No newline at end of file diff --git a/src/main/java/frc/robot/commands/StopManipulator.java b/src/main/java/frc/robot/commands/StopManipulator.java new file mode 100644 index 0000000..3ed750b --- /dev/null +++ b/src/main/java/frc/robot/commands/StopManipulator.java @@ -0,0 +1,46 @@ +package frc.robot.commands; + +import edu.wpi.first.wpilibj.command.Command; +import frc.robot.Robot; + +public class StopManipulator extends Command { + public StopManipulator() { + super("StopManipulator"); + requires(Robot.manipulator); + //Use requires() here to declare subsystem dependencies + //eg. requires(chassis); + } + + //Called just before this Command runs the first time + @Override + protected void initialize() { + + } + + //Called repeatedly when this Command is scheduled to run + @Override + protected void execute() { + Robot.manipulator.setManipulator(0); + Robot.manipulator.setRetracted(false); + } + + //Make this return true when this Command no longer needs to run execute() + @Override + protected boolean isFinished() { + return false; + } + + //Called once after isFinished returns true + @Override + protected void end() { + Robot.manipulator.setManipulator(0); + } + + //Called when another command which requires one or more of the same + //subsystems is scheduled to run + + @Override + protected void interrupted() { + //Yes + } +} \ No newline at end of file diff --git a/src/main/java/frc/robot/commands/StopShooter.java b/src/main/java/frc/robot/commands/StopShooter.java index 714ce9c..4e75c67 100644 --- a/src/main/java/frc/robot/commands/StopShooter.java +++ b/src/main/java/frc/robot/commands/StopShooter.java @@ -1,49 +1,49 @@ -/*----------------------------------------------------------------------------*/ -/* Copyright (c) 2018 FIRST. All Rights Reserved. */ -/* Open Source Software - may be modified and shared by FRC teams. The code */ -/* must be accompanied by the FIRST BSD license file in the root directory of */ -/* the project. */ -/*----------------------------------------------------------------------------*/ - -package frc.robot.commands; - -import edu.wpi.first.wpilibj.command.Command; -import frc.robot.Robot; - -public class StopShooter extends Command { - public StopShooter() { - super("StopShooter"); - requires(Robot.shooter); - // Use requires() here to declare subsystem dependencies - // eg. requires(chassis); - } - - // Called just before this Command runs the first time - @Override - protected void initialize() { - } - - // Called repeatedly when this Command is scheduled to run - @Override - protected void execute() { - Robot.shooter.setShooter(0); - } - - // Make this return true when this Command no longer needs to run execute() - @Override - protected boolean isFinished() { - return false; - } - - // Called once after isFinished returns true - @Override - protected void end() { - Robot.shooter.setShooter(0); - } - - // Called when another command which requires one or more of the same - // subsystems is scheduled to run - @Override - protected void interrupted() { - } -} +// /*----------------------------------------------------------------------------*/ +// /* Copyright (c) 2018 FIRST. All Rights Reserved. */ +// /* Open Source Software - may be modified and shared by FRC teams. The code */ +// /* must be accompanied by the FIRST BSD license file in the root directory of */ +// /* the project. */ +// /*----------------------------------------------------------------------------*/ + +// package frc.robot.commands; + +// import edu.wpi.first.wpilibj.command.Command; +// import frc.robot.Robot; + +// public class StopShooter extends Command { +// public StopShooter() { +// super("StopShooter"); +// requires(Robot.shooter); +// // Use requires() here to declare subsystem dependencies +// // eg. requires(chassis); +// } + +// // Called just before this Command runs the first time +// @Override +// protected void initialize() { +// } + +// // Called repeatedly when this Command is scheduled to run +// @Override +// protected void execute() { +// Robot.shooter.setShooter(0); +// } + +// // Make this return true when this Command no longer needs to run execute() +// @Override +// protected boolean isFinished() { +// return false; +// } + +// // Called once after isFinished returns true +// @Override +// protected void end() { +// Robot.shooter.setShooter(0); +// } + +// // Called when another command which requires one or more of the same +// // subsystems is scheduled to run +// @Override +// protected void interrupted() { +// } +// } diff --git a/src/main/java/frc/robot/subsystems/Hopper.java b/src/main/java/frc/robot/subsystems/Hopper.java index 324fd66..5c69178 100644 --- a/src/main/java/frc/robot/subsystems/Hopper.java +++ b/src/main/java/frc/robot/subsystems/Hopper.java @@ -13,10 +13,11 @@ import com.revrobotics.CANSparkMaxLowLevel.MotorType; import frc.robot.Constants; +import edu.wpi.first.wpilibj.Solenoid; import edu.wpi.first.wpilibj.command.Subsystem; import edu.wpi.first.wpilibj.smartdashboard.SmartDashboard; import frc.robot.RobotMap; - +import frc.robot.util.IrSensor; /** * Add your docs here. @@ -26,18 +27,20 @@ public class Hopper extends Subsystem { public CANSparkMax hopper_horizontal; public CANSparkMax hopper_vertical; public Solenoid hopper_stopper; - public IrSensor irSensor = new IrSensor(RobotMap.kPDP); + public IrSensor irSensor; public Hopper(){ hopper_horizontal = new CANSparkMax(RobotMap.HORIZONTAL_HOPPER, MotorType.kBrushless); hopper_vertical = new CANSparkMax(RobotMap.VERTICAL_HOPPER, MotorType.kBrushless); hopper_stopper = new Solenoid(RobotMap.kPCM, RobotMap.HOPPER_SOLENOID); + irSensor = new IrSensor(RobotMap.kPDP); + } public void setHopper(final double output){ hopper_horizontal.set(output); - hopper_vertical.set(output); + hopper_vertical.set(-output); } // public double getHopperVoltage() { // return hopper_neo.ge @@ -52,9 +55,43 @@ public boolean getRetracted() { return hopper_stopper.get(); } + public int getIRSensor() { + return irSensor.getValue(); + } + + public double getHorizontalCurrent() { + return hopper_horizontal.getOutputCurrent(); + } + + public double getVerticalCurrent() { + return hopper_vertical.getOutputCurrent(); + } + + public boolean isBall(){ + if(Constants.BALL_VALUE < getIRSensor()){ + return true; + } + else{ + return false; + } + } + + public void poopBall(){ + if(Constants.BALL_VALUE < getIRSensor()){ + setHopper(Constants.HOPPER_OUTPUT); + } else{ + setHopper(0); + } + } + public void debug(){ //SmartDashboard.putNumber("Hopper Voltage - ", getHopperVoltage()); SmartDashboard.putNumber("IR Value", irSensor.getValue()); + SmartDashboard.putBoolean("Got Balls?", isBall()); + SmartDashboard.putNumber("Horizontal Current", getHorizontalCurrent()); + SmartDashboard.putNumber("Vertical Current", getVerticalCurrent()); + + } @Override protected void initDefaultCommand() { diff --git a/src/main/java/frc/robot/subsystems/Intake.java b/src/main/java/frc/robot/subsystems/Intake.java deleted file mode 100644 index 8ab3731..0000000 --- a/src/main/java/frc/robot/subsystems/Intake.java +++ /dev/null @@ -1,44 +0,0 @@ -/*----------------------------------------------------------------------------*/ -/* Copyright (c) 2018-2019 FIRST. All Rights Reserved. */ -/* Open Source Software - may be modified and shared by FRC teams. The code */ -/* must be accompanied by the FIRST BSD license file in the root directory of */ -/* the project. */ -/*----------------------------------------------------------------------------*/ -package frc.robot.subsystems; - -import com.revrobotics.CANSparkMax; -import com.revrobotics.CANSparkMaxLowLevel.MotorType; -import com.ctre.phoenix.motorcontrol.ControlMode; -import com.ctre.phoenix.motorcontrol.can.TalonSRX; - -import edu.wpi.first.wpilibj.command.Subsystem; -import edu.wpi.first.wpilibj.smartdashboard.SmartDashboard; - -import frc.robot.Constants; -import frc.robot.RobotMap; -import frc.robot.commands.MoveShooter; -import frc.robot.commands.MoveShooterPassive; -import frc.robot.util.Util; - -/** - * Add your docs here. - */ -public class Intake extends Subsystem { - private CANSparkMax Intake_Motor; - private MoveShooterPassive defaultCommand; - - public Intake(){ - Intake_Motor = new CANSparkMax(RobotMap.kIntake, MotorType.kBrushless); - Intake_Motor.setOpenLoopRampRate(Constants.kNeoRampTime); - - Intake_Motor.set(0); - } - - @Override - protected void initDefaultCommand() { - - } - - public void debug() { - } -} diff --git a/src/main/java/frc/robot/subsystems/Manipulator.java b/src/main/java/frc/robot/subsystems/Manipulator.java new file mode 100644 index 0000000..9ac765a --- /dev/null +++ b/src/main/java/frc/robot/subsystems/Manipulator.java @@ -0,0 +1,44 @@ +package frc.robot.subsystems; + +import com.revrobotics.CANSparkMax; +import com.revrobotics.CANSparkMaxLowLevel.MotorType; + +import edu.wpi.first.wpilibj.command.Subsystem; +import edu.wpi.first.wpilibj.smartdashboard.SmartDashboard; +import edu.wpi.first.wpilibj.Solenoid; + +import frc.robot.Constants; +import frc.robot.RobotMap; + +public class Manipulator extends Subsystem { + + private CANSparkMax manipulator_neo; + private Solenoid extender; + + public Manipulator() { + manipulator_neo = new CANSparkMax(RobotMap.MANIPULATOR_NEO, MotorType.kBrushless); + manipulator_neo.setOpenLoopRampRate(Constants.kNeoRampTime); + extender = new Solenoid(RobotMap.kPCM, RobotMap.MANIPULATOR_SOLENOID); + } + + public void initDefaultCommand() { + //TODO: Find out what goes in here + } + + public void setManipulator(final double velocity) { + manipulator_neo.set(velocity); + } + public boolean isRetracted() { + //I think extender.get() returns false when it's extended + return !extender.get(); + } + public void setRetracted(boolean retract) { + extender.set(retract); + } + public boolean getRetracted() { + return extender.get(); + } + public void debug() { + SmartDashboard.putBoolean("Manipulator Extender Solenoid", extender.get()); + } +} \ No newline at end of file diff --git a/src/main/java/frc/robot/subsystems/ControlPan.java b/src/main/java/frc/robot/subsystems/PanelMech.java similarity index 66% rename from src/main/java/frc/robot/subsystems/ControlPan.java rename to src/main/java/frc/robot/subsystems/PanelMech.java index bc57b39..0179ab3 100644 --- a/src/main/java/frc/robot/subsystems/ControlPan.java +++ b/src/main/java/frc/robot/subsystems/PanelMech.java @@ -11,26 +11,28 @@ import com.ctre.phoenix.motorcontrol.ControlMode; import com.ctre.phoenix.motorcontrol.can.TalonSRX; +import edu.wpi.first.wpilibj.Solenoid; import edu.wpi.first.wpilibj.command.Subsystem; import edu.wpi.first.wpilibj.smartdashboard.SmartDashboard; import frc.robot.Constants; import frc.robot.RobotMap; -import frc.robot.commands.MoveShooter; -import frc.robot.commands.MoveShooterPassive; +// import frc.robot.commands.MoveShooter; +// import frc.robot.commands.MoveShooterPassive; import frc.robot.util.Util; /** * Add your docs here. */ -public class ControlPan extends Subsystem { - private CANSparkMax ControlPan_motor; - private MoveShooterPassive defaultCommand; - - public ControlPan(){ - ControlPan_motor = new CANSparkMax(RobotMap.kControlPan, MotorType.kBrushless); - ControlPan_motor.setOpenLoopRampRate(Constants.kNeoRampTime); - ControlPan_motor.set(0); +public class PanelMech extends Subsystem { + private CANSparkMax panelMech_motor; + private Solenoid panelMech_soleinoid; + //private MoveShooterPassive defaultCommand; + + public PanelMech(){ + panelMech_motor = new CANSparkMax(RobotMap.MECHNECK, MotorType.kBrushless); + panelMech_motor.setOpenLoopRampRate(Constants.kNeoRampTime); + panelMech_motor.set(0); } @Override diff --git a/src/main/java/frc/robot/subsystems/Shooter.java b/src/main/java/frc/robot/subsystems/Shooter.java index 76a7b6c..ff3e38f 100644 --- a/src/main/java/frc/robot/subsystems/Shooter.java +++ b/src/main/java/frc/robot/subsystems/Shooter.java @@ -36,7 +36,7 @@ public Shooter(){ shooter_follower = new CANSparkMax(RobotMap.SHOOTER_NEO, MotorType.kBrushless); shooter_leader.setOpenLoopRampRate(Constants.kNeoRampTime); shooter_follower.setOpenLoopRampRate(Constants.kNeoRampTime); - hood_1 = new Solenoid(RobotMap.kPCM, RobotMap.HOOD_1); + hood_1 = new Solenoid(RobotMap.kPCM, RobotMap.HOOD_SOLENOID); } public double idealVelocity(double angle, double dist, double height){ double gravityInches = Constants.kGravity*12; From 78d9dcfe57465f5b630deb00139d99daef5e70f0 Mon Sep 17 00:00:00 2001 From: fidgetspinnerkid <35818373+fidgetspinnerkid@users.noreply.github.com> Date: Wed, 19 Feb 2020 15:27:45 -0800 Subject: [PATCH 13/68] changed hopper to two outputs --- .../frc/robot/Autons/ShooterGroupLong.java | 1 - .../frc/robot/Autons/ShooterGroupWall.java | 1 - .../robot/Autons/StopShooterGroupLong.java | 4 +- .../robot/Autons/StopShooterGroupWall.java | 4 +- src/main/java/frc/robot/Constants.java | 14 ++- src/main/java/frc/robot/OI.java | 23 +++-- src/main/java/frc/robot/Robot.java | 12 ++- src/main/java/frc/robot/RobotMap.java | 2 +- .../java/frc/robot/commands/IrHopper.java | 2 +- .../java/frc/robot/commands/MoveHopper.java | 4 +- .../frc/robot/commands/ReverseHopper.java | 50 ++++++++++ ...pperPiston.java => CloseHopperPiston.java} | 8 +- .../commands/Shooter/OpenHopperPiston.java | 2 +- .../java/frc/robot/commands/StopHopper.java | 4 +- .../java/frc/robot/commands/StopShooter.java | 98 +++++++++---------- .../frc/robot/commands/SwitchCameras.java | 50 ++++++++++ .../java/frc/robot/commands/setCameraOne.java | 4 + .../java/frc/robot/commands/setCameraTwo.java | 4 + .../java/frc/robot/subsystems/Camera.java | 33 +++++++ .../java/frc/robot/subsystems/Drivetrain.java | 11 +-- .../java/frc/robot/subsystems/Hopper.java | 8 +- .../java/frc/robot/subsystems/Shooter.java | 4 +- .../util/Camera_Switch/CameraSwitch.java | 27 +++-- 23 files changed, 265 insertions(+), 105 deletions(-) create mode 100644 src/main/java/frc/robot/commands/ReverseHopper.java rename src/main/java/frc/robot/commands/Shooter/{RetractHopperPiston.java => CloseHopperPiston.java} (81%) create mode 100644 src/main/java/frc/robot/commands/SwitchCameras.java create mode 100644 src/main/java/frc/robot/subsystems/Camera.java diff --git a/src/main/java/frc/robot/Autons/ShooterGroupLong.java b/src/main/java/frc/robot/Autons/ShooterGroupLong.java index 663f4d7..4234d06 100644 --- a/src/main/java/frc/robot/Autons/ShooterGroupLong.java +++ b/src/main/java/frc/robot/Autons/ShooterGroupLong.java @@ -10,7 +10,6 @@ import frc.robot.commands.Shooter.OpenHopperPiston; //import frc.robot.commands.Shooter.CheckWheelSpeed; //import frc.robot.commands.Shooter.RetractHood; -import frc.robot.commands.Shooter.RetractHopperPiston; import frc.robot.subsystems.Shooter; public class ShooterGroupLong extends CommandGroup{ diff --git a/src/main/java/frc/robot/Autons/ShooterGroupWall.java b/src/main/java/frc/robot/Autons/ShooterGroupWall.java index 5f134d2..93cd52a 100644 --- a/src/main/java/frc/robot/Autons/ShooterGroupWall.java +++ b/src/main/java/frc/robot/Autons/ShooterGroupWall.java @@ -8,7 +8,6 @@ import frc.robot.commands.Shooter.OpenHopperPiston; //import frc.robot.commands.Shooter.CheckWheelSpeed; //import frc.robot.commands.Shooter.RetractHood; -import frc.robot.commands.Shooter.RetractHopperPiston; import frc.robot.subsystems.Shooter; public class ShooterGroupWall extends CommandGroup{ diff --git a/src/main/java/frc/robot/Autons/StopShooterGroupLong.java b/src/main/java/frc/robot/Autons/StopShooterGroupLong.java index b8492eb..7332566 100644 --- a/src/main/java/frc/robot/Autons/StopShooterGroupLong.java +++ b/src/main/java/frc/robot/Autons/StopShooterGroupLong.java @@ -6,10 +6,10 @@ import frc.robot.commands.StopHopper; import frc.robot.commands.Shooter.CheckHoodWall; import frc.robot.commands.Shooter.CheckMotorWall; +import frc.robot.commands.Shooter.CloseHopperPiston; import frc.robot.commands.Shooter.OpenHopperPiston; //import frc.robot.commands.Shooter.CheckWheelSpeed; //import frc.robot.commands.Shooter.RetractHood; -import frc.robot.commands.Shooter.RetractHopperPiston; import frc.robot.commands.Shooter.StopShooter; import frc.robot.subsystems.Shooter; @@ -18,6 +18,6 @@ public class StopShooterGroupLong extends CommandGroup{ public StopShooterGroupLong(){ addParallel(new StopShooter()); addParallel(new StopHopper()); - addParallel(new RetractHopperPiston()); + addParallel(new CloseHopperPiston()); } } \ No newline at end of file diff --git a/src/main/java/frc/robot/Autons/StopShooterGroupWall.java b/src/main/java/frc/robot/Autons/StopShooterGroupWall.java index c60c20a..b2ebe65 100644 --- a/src/main/java/frc/robot/Autons/StopShooterGroupWall.java +++ b/src/main/java/frc/robot/Autons/StopShooterGroupWall.java @@ -6,10 +6,10 @@ import frc.robot.commands.StopHopper; import frc.robot.commands.Shooter.CheckHoodWall; import frc.robot.commands.Shooter.CheckMotorWall; +import frc.robot.commands.Shooter.CloseHopperPiston; import frc.robot.commands.Shooter.OpenHopperPiston; //import frc.robot.commands.Shooter.CheckWheelSpeed; //import frc.robot.commands.Shooter.RetractHood; -import frc.robot.commands.Shooter.RetractHopperPiston; import frc.robot.commands.Shooter.StopShooter; import frc.robot.subsystems.Shooter; @@ -18,6 +18,6 @@ public class StopShooterGroupWall extends CommandGroup{ public StopShooterGroupWall(){ addParallel(new StopShooter()); addParallel(new StopHopper()); - addParallel(new RetractHopperPiston()); + addParallel(new CloseHopperPiston()); } } \ No newline at end of file diff --git a/src/main/java/frc/robot/Constants.java b/src/main/java/frc/robot/Constants.java index 856afd0..7b4f412 100644 --- a/src/main/java/frc/robot/Constants.java +++ b/src/main/java/frc/robot/Constants.java @@ -59,7 +59,13 @@ public final class Constants { public static final double ELEVATOR_OUTPUT = -.05; - public static final double HOPPER_OUTPUT = .20; // 20% is sweet spot + public static final double HOPPER_HORIZONTAL_OUTPUT = .25; // 20% is sweet spot + + + public static final double HOPPER_VERTICAL_OUTPUT = .35; + + + public static final double REVERSE_HOPPER = -.20; public static final double SHOOTER_OUTPUT = -.8; @@ -82,14 +88,14 @@ public final class Constants { public static final double SHOOTER_VELOCITY = 100; //Temporary value - public static final double SHOOTER_OUTPUT_LONG = 1; + public static final double SHOOTER_OUTPUT_LONG = -1; - public static final double SHOOTER_OUTPUT_WALL = .47; + public static final double SHOOTER_OUTPUT_WALL = -.4; //changed from .47 //definitely make negative though public static final double TURN_FACTOR = 0.2; - public static final int BALL_VALUE = 1100; + public static final int BALL_VALUE = 2050; } \ No newline at end of file diff --git a/src/main/java/frc/robot/OI.java b/src/main/java/frc/robot/OI.java index 83bd972..f392812 100644 --- a/src/main/java/frc/robot/OI.java +++ b/src/main/java/frc/robot/OI.java @@ -5,7 +5,9 @@ import edu.wpi.first.wpilibj.buttons.JoystickButton; import frc.robot.commands.*; -import frc.robot.commands.Shooter.RetractHopperPiston; +import frc.robot.commands.Shooter.StopShooter; +import frc.robot.commands.Shooter.CloseHopperPiston; +import frc.robot.commands.Shooter.MoveShooterWall; import frc.robot.commands.Shooter.OpenHopperPiston; // import frc.robot.commands.auto.SetLimit; import frc.robot.controller.AnalogButton; @@ -15,6 +17,7 @@ import frc.robot.Autons.StopShooterGroupLong; import frc.robot.Autons.ShooterGroupWall; import frc.robot.Autons.StopShooterGroupWall; +//import frc.robot.subsystems.Camera; // import frc.robot.commands.Lifter.ExtendBothLifters; import frc.robot.util.Util; @@ -86,15 +89,21 @@ public OI() { // driverY.whenPressed(new MoveDrivetrain()); // driverY.whenReleased(new StopDrivetrain()); driverA.whenPressed(new MoveManipulator()); - driverA.whenReleased(new StopManipulator()); + driverY.whenPressed(new StopManipulator()); driverX.whenPressed(new IrHopper()); driverX.whenReleased(new StopHopper()); driverB.whenPressed(new OpenHopperPiston()); - driverB.whenReleased(new RetractHopperPiston()); - driverRB.whenPressed(new ShooterGroupWall()); - driverRB.whenReleased(new StopShooterGroupWall()); - driverLB.whenPressed(new ShooterGroupLong()); - driverLB.whenReleased(new StopShooterGroupLong()); + driverB.whenReleased(new CloseHopperPiston()); + // driverRB.whenPressed(new ShooterGroupWall()); + // driverRB.whenReleased(new StopShooterGroupWall()); + // driverLB.whenPressed(new ShooterGroupLong()); + // driverLB.whenReleased(new StopShooterGroupLong()); + driverDPadLeft.whenPressed(new setCameraTwo()); + driverDPadLeft.whenReleased(new setCameraOne()); + driverDPadDown.whenPressed(new ReverseHopper()); + driverDPadDown.whenReleased(new StopHopper()); + driverDPadRight.whenPressed(new MoveShooterWall()); + driverDPadRight.whenReleased(new StopShooter()); // driverLB.whenPressed(new runHopperElevator()); // driverLB.whenReleased(new stopHopperElevator()); // driverLS.whenPressed(new runElevatorShooter()); diff --git a/src/main/java/frc/robot/Robot.java b/src/main/java/frc/robot/Robot.java index 6e78df0..fda2b89 100644 --- a/src/main/java/frc/robot/Robot.java +++ b/src/main/java/frc/robot/Robot.java @@ -2,9 +2,11 @@ import edu.wpi.first.wpilibj.PowerDistributionPanel; import edu.wpi.first.wpilibj.TimedRobot; +import edu.wpi.first.wpilibj.Relay.Value; import edu.wpi.first.wpilibj.command.Scheduler; import edu.wpi.first.wpilibj.smartdashboard.SmartDashboard; import frc.robot.subsystems.*; +import frc.robot.util.Camera_Switch.CameraSwitch; import edu.wpi.first.wpilibj.Compressor; import edu.wpi.first.cameraserver.CameraServer; @@ -12,7 +14,8 @@ public class Robot extends TimedRobot { - long loopCounter = 0; + + long loopCounter = 0; public static OI oi; public static Drivetrain drivetrain; @@ -25,6 +28,7 @@ public class Robot extends TimedRobot { public static Manipulator manipulator; // public static PanelMech panelMech; public static CameraServer Cam; + public static CameraSwitch Cam_switch; @Override public void robotInit() { @@ -36,9 +40,11 @@ public void robotInit() { pdp = new PowerDistributionPanel(RobotMap.kPDP); oi = new OI(); robotmap = new RobotMap(); + Cam_switch = new CameraSwitch(0,1); Cam = CameraServer.getInstance(); compressor = new Compressor(RobotMap.kPCM); compressor.start(); + Cam.startAutomaticCapture(0); } @Override @@ -50,7 +56,7 @@ public void robotPeriodic() { SmartDashboard.putBoolean("Compressor Status", compressor.enabled()); hopper.debug(); - // Cam.startAutomaticCapture(0); + } @Override @@ -85,7 +91,7 @@ public void teleopPeriodic() { // Robot.hopper.setHopper(-1); // Robot.shooter.setShooter(-1); // Robot.drivetrain.setMotors(-1); - + // Robot.drivetrain.setMotors(-.0000001); // Robot.drivetrain.setRightTalon(-1); // Robot.drivetrain.setLeftNeo(-1); diff --git a/src/main/java/frc/robot/RobotMap.java b/src/main/java/frc/robot/RobotMap.java index 02161e2..63df49a 100644 --- a/src/main/java/frc/robot/RobotMap.java +++ b/src/main/java/frc/robot/RobotMap.java @@ -79,7 +79,7 @@ public class RobotMap { public static final int kCargoLimitSwitch = 0; // Shoooter - public static final int SHOOTER_NEO = 2; + public static final int SHOOTER_NEO = 2; //what is this for??? // Elevator public static final int ELEVATOR_TALON = 23; diff --git a/src/main/java/frc/robot/commands/IrHopper.java b/src/main/java/frc/robot/commands/IrHopper.java index 07ec5dd..9b09dd1 100644 --- a/src/main/java/frc/robot/commands/IrHopper.java +++ b/src/main/java/frc/robot/commands/IrHopper.java @@ -38,7 +38,7 @@ protected boolean isFinished() { // Called once after isFinished returns true @Override protected void end() { - Robot.hopper.setHopper(0); + Robot.hopper.setHopper(0, 0); } // Called when another command which requires one or more of the same diff --git a/src/main/java/frc/robot/commands/MoveHopper.java b/src/main/java/frc/robot/commands/MoveHopper.java index 4b04e0c..7791a36 100644 --- a/src/main/java/frc/robot/commands/MoveHopper.java +++ b/src/main/java/frc/robot/commands/MoveHopper.java @@ -27,7 +27,7 @@ protected void initialize() { // Called repeatedly when this Command is scheduled to run @Override protected void execute() { - Robot.hopper.setHopper(Constants.HOPPER_OUTPUT); + Robot.hopper.setHopper(Constants.HOPPER_HORIZONTAL_OUTPUT, Constants.HOPPER_VERTICAL_OUTPUT); } // Make this return true when this Command no longer needs to run execute() @@ -39,7 +39,7 @@ protected boolean isFinished() { // Called once after isFinished returns true @Override protected void end() { - Robot.hopper.setHopper(0); + Robot.hopper.setHopper(0, 0); } // Called when another command which requires one or more of the same diff --git a/src/main/java/frc/robot/commands/ReverseHopper.java b/src/main/java/frc/robot/commands/ReverseHopper.java new file mode 100644 index 0000000..e459742 --- /dev/null +++ b/src/main/java/frc/robot/commands/ReverseHopper.java @@ -0,0 +1,50 @@ +/*----------------------------------------------------------------------------*/ +/* Copyright (c) 2018 FIRST. All Rights Reserved. */ +/* Open Source Software - may be modified and shared by FRC teams. The code */ +/* must be accompanied by the FIRST BSD license file in the root directory of */ +/* the project. */ +/*----------------------------------------------------------------------------*/ + +package frc.robot.commands; + +import edu.wpi.first.wpilibj.command.Command; +import frc.robot.Constants; +import frc.robot.Robot; + +public class ReverseHopper extends Command { + public ReverseHopper() { + super("ReverseHopper"); + requires(Robot.hopper); + // Use requires() here to declare subsystem dependencies + // eg. requires(chassis); + } + + // Called just before this Command runs the first time + @Override + protected void initialize() { + } + + // Called repeatedly when this Command is scheduled to run + @Override + protected void execute() { + Robot.hopper.setHopper(Constants.REVERSE_HOPPER, Constants.REVERSE_HOPPER); + } + + // Make this return true when this Command no longer needs to run execute() + @Override + protected boolean isFinished() { + return false; + } + + // Called once after isFinished returns true + @Override + protected void end() { + Robot.hopper.setHopper(0, 0); + } + + // Called when another command which requires one or more of the same + // subsystems is scheduled to run + @Override + protected void interrupted() { + } +} \ No newline at end of file diff --git a/src/main/java/frc/robot/commands/Shooter/RetractHopperPiston.java b/src/main/java/frc/robot/commands/Shooter/CloseHopperPiston.java similarity index 81% rename from src/main/java/frc/robot/commands/Shooter/RetractHopperPiston.java rename to src/main/java/frc/robot/commands/Shooter/CloseHopperPiston.java index 4af4736..c08d3c5 100644 --- a/src/main/java/frc/robot/commands/Shooter/RetractHopperPiston.java +++ b/src/main/java/frc/robot/commands/Shooter/CloseHopperPiston.java @@ -7,10 +7,10 @@ // import frc.robot.subsystems.Shooter; //in theory this just chanes whether the hopper piston is retracted or not and then stops -public class RetractHopperPiston extends Command{ +public class CloseHopperPiston extends Command{ private boolean retracted; - public RetractHopperPiston(){ - super("RetractHopperPiston"); + public CloseHopperPiston(){ + super("CloseHopperPiston"); requires(Robot.hopper); } @@ -21,7 +21,7 @@ protected void initialize(){ @Override protected void execute() { - Robot.hopper.setRetracted(true); + Robot.hopper.setRetracted(false); } diff --git a/src/main/java/frc/robot/commands/Shooter/OpenHopperPiston.java b/src/main/java/frc/robot/commands/Shooter/OpenHopperPiston.java index 4793f16..e0aaf81 100644 --- a/src/main/java/frc/robot/commands/Shooter/OpenHopperPiston.java +++ b/src/main/java/frc/robot/commands/Shooter/OpenHopperPiston.java @@ -20,7 +20,7 @@ protected void initialize(){ @Override protected void execute() { - Robot.hopper.setRetracted(false); + Robot.hopper.setRetracted(true); } diff --git a/src/main/java/frc/robot/commands/StopHopper.java b/src/main/java/frc/robot/commands/StopHopper.java index 26c2f5b..b8dd1a8 100644 --- a/src/main/java/frc/robot/commands/StopHopper.java +++ b/src/main/java/frc/robot/commands/StopHopper.java @@ -26,7 +26,7 @@ protected void initialize() { // Called repeatedly when this Command is scheduled to run @Override protected void execute() { - Robot.hopper.setHopper(0); + Robot.hopper.setHopper(0, 0); } // Make this return true when this Command no longer needs to run execute() @@ -38,7 +38,7 @@ protected boolean isFinished() { // Called once after isFinished returns true @Override protected void end() { - Robot.hopper.setHopper(0); + Robot.hopper.setHopper(0, 0); } // Called when another command which requires one or more of the same diff --git a/src/main/java/frc/robot/commands/StopShooter.java b/src/main/java/frc/robot/commands/StopShooter.java index 4e75c67..714ce9c 100644 --- a/src/main/java/frc/robot/commands/StopShooter.java +++ b/src/main/java/frc/robot/commands/StopShooter.java @@ -1,49 +1,49 @@ -// /*----------------------------------------------------------------------------*/ -// /* Copyright (c) 2018 FIRST. All Rights Reserved. */ -// /* Open Source Software - may be modified and shared by FRC teams. The code */ -// /* must be accompanied by the FIRST BSD license file in the root directory of */ -// /* the project. */ -// /*----------------------------------------------------------------------------*/ - -// package frc.robot.commands; - -// import edu.wpi.first.wpilibj.command.Command; -// import frc.robot.Robot; - -// public class StopShooter extends Command { -// public StopShooter() { -// super("StopShooter"); -// requires(Robot.shooter); -// // Use requires() here to declare subsystem dependencies -// // eg. requires(chassis); -// } - -// // Called just before this Command runs the first time -// @Override -// protected void initialize() { -// } - -// // Called repeatedly when this Command is scheduled to run -// @Override -// protected void execute() { -// Robot.shooter.setShooter(0); -// } - -// // Make this return true when this Command no longer needs to run execute() -// @Override -// protected boolean isFinished() { -// return false; -// } - -// // Called once after isFinished returns true -// @Override -// protected void end() { -// Robot.shooter.setShooter(0); -// } - -// // Called when another command which requires one or more of the same -// // subsystems is scheduled to run -// @Override -// protected void interrupted() { -// } -// } +/*----------------------------------------------------------------------------*/ +/* Copyright (c) 2018 FIRST. All Rights Reserved. */ +/* Open Source Software - may be modified and shared by FRC teams. The code */ +/* must be accompanied by the FIRST BSD license file in the root directory of */ +/* the project. */ +/*----------------------------------------------------------------------------*/ + +package frc.robot.commands; + +import edu.wpi.first.wpilibj.command.Command; +import frc.robot.Robot; + +public class StopShooter extends Command { + public StopShooter() { + super("StopShooter"); + requires(Robot.shooter); + // Use requires() here to declare subsystem dependencies + // eg. requires(chassis); + } + + // Called just before this Command runs the first time + @Override + protected void initialize() { + } + + // Called repeatedly when this Command is scheduled to run + @Override + protected void execute() { + Robot.shooter.setShooter(0); + } + + // Make this return true when this Command no longer needs to run execute() + @Override + protected boolean isFinished() { + return false; + } + + // Called once after isFinished returns true + @Override + protected void end() { + Robot.shooter.setShooter(0); + } + + // Called when another command which requires one or more of the same + // subsystems is scheduled to run + @Override + protected void interrupted() { + } +} diff --git a/src/main/java/frc/robot/commands/SwitchCameras.java b/src/main/java/frc/robot/commands/SwitchCameras.java new file mode 100644 index 0000000..2bccfad --- /dev/null +++ b/src/main/java/frc/robot/commands/SwitchCameras.java @@ -0,0 +1,50 @@ +// /*----------------------------------------------------------------------------*/ +// /* Copyright (c) 2018 FIRST. All Rights Reserved. */ +// /* Open Source Software - may be modified and shared by FRC teams. The code */ +// /* must be accompanied by the FIRST BSD license file in the root directory of */ +// /* the project. */ +// /*----------------------------------------------------------------------------*/ + +// package frc.robot.commands; + +// import edu.wpi.first.wpilibj.command.Command; +// import frc.robot.Constants; +// import frc.robot.Robot; + +// public class SwitchCameras extends Command { +// public SwitchCameras() { +// super("SwitchCameras"); +// requires(Robot.drivetrain); +// // Use requires() here to declare subsystem dependencies +// // eg. requires(chassis); +// } + +// // Called just before this Command runs the first time +// @Override +// protected void initialize() { +// } + +// // Called repeatedly when this Command is scheduled to run +// @Override +// protected void execute() { + +// } + +// // Make this return true when this Command no longer needs to run execute() +// @Override +// protected boolean isFinished() { +// return false; +// } + +// // Called once after isFinished returns true +// @Override +// protected void end() { +// Robot.drivetrain.setMotors(0,0); +// } + +// // Called when another command which requires one or more of the same +// // subsystems is scheduled to run +// @Override +// protected void interrupted() { +// } +// } diff --git a/src/main/java/frc/robot/commands/setCameraOne.java b/src/main/java/frc/robot/commands/setCameraOne.java index 9ddbd09..d65e6d4 100644 --- a/src/main/java/frc/robot/commands/setCameraOne.java +++ b/src/main/java/frc/robot/commands/setCameraOne.java @@ -8,6 +8,9 @@ package frc.robot.commands; import edu.wpi.first.wpilibj.command.Command; +import frc.robot.Robot; +// import frc.robot.subsystems.Camera; +import frc.robot.util.Camera_Switch.CameraSwitch; public class setCameraOne extends Command { public setCameraOne() { @@ -23,6 +26,7 @@ protected void initialize() { // Called repeatedly when this Command is scheduled to run @Override protected void execute() { + Robot.Cam_switch.select(CameraSwitch.kcamera1); } // Make this return true when this Command no longer needs to run execute() diff --git a/src/main/java/frc/robot/commands/setCameraTwo.java b/src/main/java/frc/robot/commands/setCameraTwo.java index cff84d2..02f9afb 100644 --- a/src/main/java/frc/robot/commands/setCameraTwo.java +++ b/src/main/java/frc/robot/commands/setCameraTwo.java @@ -8,6 +8,9 @@ package frc.robot.commands; import edu.wpi.first.wpilibj.command.Command; +import frc.robot.Robot; +//import frc.robot.subsystems.Camera; +import frc.robot.util.Camera_Switch.CameraSwitch; public class setCameraTwo extends Command { public setCameraTwo() { @@ -23,6 +26,7 @@ protected void initialize() { // Called repeatedly when this Command is scheduled to run @Override protected void execute() { + Robot.Cam_switch.select(CameraSwitch.kcamera2); } // Make this return true when this Command no longer needs to run execute() diff --git a/src/main/java/frc/robot/subsystems/Camera.java b/src/main/java/frc/robot/subsystems/Camera.java new file mode 100644 index 0000000..543a3be --- /dev/null +++ b/src/main/java/frc/robot/subsystems/Camera.java @@ -0,0 +1,33 @@ +// package frc.robot.subsystems; + +// import com.revrobotics.CANSparkMax; +// import com.revrobotics.CANSparkMax.IdleMode; +// import com.revrobotics.CANSparkMaxLowLevel.MotorType; + +// import com.revrobotics.CANEncoder; +// import com.revrobotics.AlternateEncoderType; + +// import edu.wpi.first.wpilibj.command.Subsystem; +// import edu.wpi.first.wpilibj.smartdashboard.SmartDashboard; + +// import frc.robot.Constants; +// import frc.robot.RobotMap; + +// import frc.robot.util.Camera_Switch.*; + +// public class Camera extends Subsystem{ +// public CameraSwitch cam_switch; +// public Camera() { + +// //Initialize Cameron Switch +// cam_switch = new CameraSwitch(0, 1); +// } +// public void initDefaultCommand() { + +// } +// public void setCameraNum(int camNum) { +// cam_switch.select(camNum); +// } +// public void debug (){} + +// } byeeeee \ No newline at end of file diff --git a/src/main/java/frc/robot/subsystems/Drivetrain.java b/src/main/java/frc/robot/subsystems/Drivetrain.java index 7ce2d14..438207a 100644 --- a/src/main/java/frc/robot/subsystems/Drivetrain.java +++ b/src/main/java/frc/robot/subsystems/Drivetrain.java @@ -12,7 +12,8 @@ import frc.robot.Constants; import frc.robot.RobotMap; -// import frc.robot.util.Camera_Switch.*; + +import frc.robot.util.Camera_Switch.*; public class Drivetrain extends Subsystem { @@ -24,15 +25,11 @@ public class Drivetrain extends Subsystem { private static final AlternateEncoderType kAltEncType = AlternateEncoderType.kQuadrature; private CANEncoder m_leftAlternateEncoder; private CANEncoder m_rightAlternateEncoder; - // private CameraSwitch cam_switch; public Drivetrain() { - - // Init Camera Switch - // cam_switch = new CameraSwitch(0, 1); // Init Left Leader leftLeader = new CANSparkMax(RobotMap.kLeftLeader, MotorType.kBrushless); @@ -69,10 +66,6 @@ public Drivetrain() { public void initDefaultCommand() {} - // public void setCameraNum(int camNum) { - // cam_switch.select(camNum); - // } - public void setMotors(double left, double right) { leftLeader.set(-left); diff --git a/src/main/java/frc/robot/subsystems/Hopper.java b/src/main/java/frc/robot/subsystems/Hopper.java index 5c69178..d823a64 100644 --- a/src/main/java/frc/robot/subsystems/Hopper.java +++ b/src/main/java/frc/robot/subsystems/Hopper.java @@ -38,9 +38,9 @@ public Hopper(){ } - public void setHopper(final double output){ + public void setHopper(final double output, final double vOutput){ hopper_horizontal.set(output); - hopper_vertical.set(-output); + hopper_vertical.set(-vOutput); } // public double getHopperVoltage() { // return hopper_neo.ge @@ -78,9 +78,9 @@ public boolean isBall(){ public void poopBall(){ if(Constants.BALL_VALUE < getIRSensor()){ - setHopper(Constants.HOPPER_OUTPUT); + setHopper(Constants.HOPPER_HORIZONTAL_OUTPUT, Constants.HOPPER_VERTICAL_OUTPUT); } else{ - setHopper(0); + setHopper(0, 0); } } diff --git a/src/main/java/frc/robot/subsystems/Shooter.java b/src/main/java/frc/robot/subsystems/Shooter.java index ff3e38f..e7d9c8a 100644 --- a/src/main/java/frc/robot/subsystems/Shooter.java +++ b/src/main/java/frc/robot/subsystems/Shooter.java @@ -32,8 +32,8 @@ public class Shooter extends Subsystem { public Shooter(){ - shooter_leader = new CANSparkMax(RobotMap.SHOOTER_NEO, MotorType.kBrushless); - shooter_follower = new CANSparkMax(RobotMap.SHOOTER_NEO, MotorType.kBrushless); + shooter_leader = new CANSparkMax(RobotMap.kShooterLeft, MotorType.kBrushless); + shooter_follower = new CANSparkMax(RobotMap.kShooterRight, MotorType.kBrushless); shooter_leader.setOpenLoopRampRate(Constants.kNeoRampTime); shooter_follower.setOpenLoopRampRate(Constants.kNeoRampTime); hood_1 = new Solenoid(RobotMap.kPCM, RobotMap.HOOD_SOLENOID); diff --git a/src/main/java/frc/robot/util/Camera_Switch/CameraSwitch.java b/src/main/java/frc/robot/util/Camera_Switch/CameraSwitch.java index ef8c087..a9cadc4 100644 --- a/src/main/java/frc/robot/util/Camera_Switch/CameraSwitch.java +++ b/src/main/java/frc/robot/util/Camera_Switch/CameraSwitch.java @@ -22,6 +22,8 @@ import edu.wpi.first.wpilibj.Relay; import edu.wpi.first.wpilibj.Relay.Value; +import edu.wpi.first.wpilibj.DigitalOutput; +import edu.wpi.first.wpilibj.Victor; public class CameraSwitch implements RelayPortDevice{ @@ -32,14 +34,17 @@ public class CameraSwitch implements RelayPortDevice{ - public Relay camrelay1; + public static Relay camrelay1; public Relay camrelay2; + public DigitalOutput DO; - public CameraSwitch(int port1, int port2){ +public Victor pwm; + public CameraSwitch(int port1, int port2){ + camrelay1 = new Relay(port1); camrelay2 = new Relay(port2); - + }//Constructor for a CameraSwitch on a single relay port public void select(int camSelected){ @@ -49,23 +54,25 @@ public void select(int camSelected){ switch (camSelected) { case kcamera1 : - camrelay1.set(Value.kReverse); + // camrelay1.set(Value.kReverse); // camrelay.set(Value.kForward); - break; + + break; case kcamera2 : - camrelay1.set(Value.kForward); - break; + // camrelay1.set(Value.kForward); + + break; case kcamera3 : - camrelay2.set(Value.kReverse); + camrelay2.set(Value.kReverse); // camrelay.set(Value.kOn); case kcamera4 : - camrelay2.set(Value.kForward); + camrelay2.set(Value.kForward); // camrelay.set(Value.kOff); break; default: camrelay1.set(Value.kReverse); System.err.print("Camera not properly selected, setting to case 1,Camera1"); - break; + break; }//This switch statement is what actually writes to the relay port }//Use this method to select the desired camera to connect to the RoboRIO From e2b0bce11e0c954973a8cdc3630511dd7e4ab5d1 Mon Sep 17 00:00:00 2001 From: fidgetspinnerkid <35818373+fidgetspinnerkid@users.noreply.github.com> Date: Mon, 24 Feb 2020 12:35:02 -0800 Subject: [PATCH 14/68] Saturday Changes Need to change command group linings --- .../frc/robot/Autons/ShooterGroupLong.java | 6 +- .../frc/robot/Autons/ShooterGroupWall.java | 8 +- ...topShooterGroupWall.java => WallShot.java} | 15 ++- ...hooterGroupLong.java => WallShotStop.java} | 14 ++- src/main/java/frc/robot/Constants.java | 16 ++- src/main/java/frc/robot/OI.java | 36 ++++-- .../{MoveHopper.java => MoveHopperLong.java} | 8 +- .../frc/robot/commands/MoveHopperWall.java | 50 +++++++++ .../frc/robot/commands/MoveManipulator.java | 2 +- .../java/frc/robot/commands/MoveShooter.java | 104 +++++++++--------- .../robot/commands/Shooter/CheckHoodLong.java | 16 +-- .../robot/commands/Shooter/CheckHoodWall.java | 4 +- .../commands/Shooter/CheckMotorLong.java | 13 ++- .../commands/Shooter/CheckMotorWall.java | 13 ++- .../commands/Shooter/CloseHopperPiston.java | 1 - .../commands/Shooter/OpenHopperPiston.java | 1 - .../robot/commands/Shooter/StopShooter.java | 1 - .../java/frc/robot/subsystems/Hopper.java | 2 +- .../java/frc/robot/subsystems/Shooter.java | 14 +++ 19 files changed, 205 insertions(+), 119 deletions(-) rename src/main/java/frc/robot/Autons/{StopShooterGroupWall.java => WallShot.java} (58%) rename src/main/java/frc/robot/Autons/{StopShooterGroupLong.java => WallShotStop.java} (60%) rename src/main/java/frc/robot/commands/{MoveHopper.java => MoveHopperLong.java} (87%) create mode 100644 src/main/java/frc/robot/commands/MoveHopperWall.java diff --git a/src/main/java/frc/robot/Autons/ShooterGroupLong.java b/src/main/java/frc/robot/Autons/ShooterGroupLong.java index 4234d06..28fe00d 100644 --- a/src/main/java/frc/robot/Autons/ShooterGroupLong.java +++ b/src/main/java/frc/robot/Autons/ShooterGroupLong.java @@ -2,7 +2,7 @@ import edu.wpi.first.wpilibj.command.CommandGroup; import frc.robot.Robot; -import frc.robot.commands.MoveHopper; +import frc.robot.commands.MoveHopperLong; import frc.robot.commands.Shooter.CheckHoodLong; import frc.robot.commands.Shooter.CheckHoodWall; import frc.robot.commands.Shooter.CheckMotorLong; @@ -17,7 +17,7 @@ public class ShooterGroupLong extends CommandGroup{ public ShooterGroupLong(){ addSequential(new CheckHoodLong()); addSequential(new CheckMotorLong()); - addSequential(new OpenHopperPiston()); - addSequential(new MoveHopper()); + //addSequential(new OpenHopperPiston()); + //addSequential(new MoveHopperLong()); } } \ No newline at end of file diff --git a/src/main/java/frc/robot/Autons/ShooterGroupWall.java b/src/main/java/frc/robot/Autons/ShooterGroupWall.java index 93cd52a..4ac1a6b 100644 --- a/src/main/java/frc/robot/Autons/ShooterGroupWall.java +++ b/src/main/java/frc/robot/Autons/ShooterGroupWall.java @@ -2,7 +2,7 @@ import edu.wpi.first.wpilibj.command.CommandGroup; import frc.robot.Robot; -import frc.robot.commands.MoveHopper; +import frc.robot.commands.MoveHopperWall; import frc.robot.commands.Shooter.CheckHoodWall; import frc.robot.commands.Shooter.CheckMotorWall; import frc.robot.commands.Shooter.OpenHopperPiston; @@ -13,9 +13,9 @@ public class ShooterGroupWall extends CommandGroup{ public ShooterGroupWall(){ - addSequential(new CheckHoodWall()); + // addSequential(new CheckHoodWall()); addSequential(new CheckMotorWall()); - addSequential(new OpenHopperPiston()); - addSequential(new MoveHopper()); + // addSequential(new OpenHopperPiston()); + // addSequential(new MoveHopperWall()); } } \ No newline at end of file diff --git a/src/main/java/frc/robot/Autons/StopShooterGroupWall.java b/src/main/java/frc/robot/Autons/WallShot.java similarity index 58% rename from src/main/java/frc/robot/Autons/StopShooterGroupWall.java rename to src/main/java/frc/robot/Autons/WallShot.java index b2ebe65..bac0c52 100644 --- a/src/main/java/frc/robot/Autons/StopShooterGroupWall.java +++ b/src/main/java/frc/robot/Autons/WallShot.java @@ -2,9 +2,11 @@ import edu.wpi.first.wpilibj.command.CommandGroup; import frc.robot.Robot; -import frc.robot.commands.MoveHopper; +import frc.robot.commands.MoveHopperWall; import frc.robot.commands.StopHopper; +import frc.robot.commands.Shooter.CheckHoodLong; import frc.robot.commands.Shooter.CheckHoodWall; +import frc.robot.commands.Shooter.CheckMotorLong; import frc.robot.commands.Shooter.CheckMotorWall; import frc.robot.commands.Shooter.CloseHopperPiston; import frc.robot.commands.Shooter.OpenHopperPiston; @@ -13,11 +15,12 @@ import frc.robot.commands.Shooter.StopShooter; import frc.robot.subsystems.Shooter; -public class StopShooterGroupWall extends CommandGroup{ +public class WallShot extends CommandGroup{ - public StopShooterGroupWall(){ - addParallel(new StopShooter()); - addParallel(new StopHopper()); - addParallel(new CloseHopperPiston()); + public WallShot(){ + addSequential(new CheckHoodLong()); + addSequential(new CheckMotorLong()); + addParallel(new OpenHopperPiston()); + addParallel(new MoveHopperWall()); } } \ No newline at end of file diff --git a/src/main/java/frc/robot/Autons/StopShooterGroupLong.java b/src/main/java/frc/robot/Autons/WallShotStop.java similarity index 60% rename from src/main/java/frc/robot/Autons/StopShooterGroupLong.java rename to src/main/java/frc/robot/Autons/WallShotStop.java index 7332566..1ea2d70 100644 --- a/src/main/java/frc/robot/Autons/StopShooterGroupLong.java +++ b/src/main/java/frc/robot/Autons/WallShotStop.java @@ -2,9 +2,11 @@ import edu.wpi.first.wpilibj.command.CommandGroup; import frc.robot.Robot; -import frc.robot.commands.MoveHopper; +import frc.robot.commands.MoveHopperWall; import frc.robot.commands.StopHopper; +import frc.robot.commands.Shooter.CheckHoodLong; import frc.robot.commands.Shooter.CheckHoodWall; +import frc.robot.commands.Shooter.CheckMotorLong; import frc.robot.commands.Shooter.CheckMotorWall; import frc.robot.commands.Shooter.CloseHopperPiston; import frc.robot.commands.Shooter.OpenHopperPiston; @@ -13,11 +15,11 @@ import frc.robot.commands.Shooter.StopShooter; import frc.robot.subsystems.Shooter; -public class StopShooterGroupLong extends CommandGroup{ +public class WallShotStop extends CommandGroup{ - public StopShooterGroupLong(){ - addParallel(new StopShooter()); - addParallel(new StopHopper()); - addParallel(new CloseHopperPiston()); + public WallShotStop(){ + addSequential(new StopShooter()); + addSequential(new CloseHopperPiston()); + addSequential(new StopHopper()); } } \ No newline at end of file diff --git a/src/main/java/frc/robot/Constants.java b/src/main/java/frc/robot/Constants.java index 7b4f412..97975eb 100644 --- a/src/main/java/frc/robot/Constants.java +++ b/src/main/java/frc/robot/Constants.java @@ -59,10 +59,16 @@ public final class Constants { public static final double ELEVATOR_OUTPUT = -.05; - public static final double HOPPER_HORIZONTAL_OUTPUT = .25; // 20% is sweet spot + public static final double HOPPER_LOADING_HORIZONTAL_OUTPUT = .40; // 20% is sweet spot - public static final double HOPPER_VERTICAL_OUTPUT = .35; + public static final double HOPPER_WALL_HORIZONTAL_OUTPUT = 0.30; + + + public static final double HOPPER_LONG_HORIZONTAL_OUTPUT = 0.20; + + + public static final double HOPPER_VERTICAL_OUTPUT = .55; public static final double REVERSE_HOPPER = -.20; @@ -82,13 +88,13 @@ public final class Constants { public static final double MANUAL_POWER = .2; - public static final double INTAKE_MOTORSPEED = 0.50; //Temp value please test it out and do stuff yes + public static final double INTAKE_MOTORSPEED = 0.15; //Temp value please test it out and do stuff yes public static final double SHOOTER_VELOCITY = 100; //Temporary value - public static final double SHOOTER_OUTPUT_LONG = -1; + public static final double SHOOTER_OUTPUT_LONG = -1; public static final double SHOOTER_OUTPUT_WALL = -.4; //changed from .47 //definitely make negative though @@ -97,5 +103,5 @@ public final class Constants { public static final double TURN_FACTOR = 0.2; - public static final int BALL_VALUE = 2050; + public static final int BALL_VALUE = 2300; } \ No newline at end of file diff --git a/src/main/java/frc/robot/OI.java b/src/main/java/frc/robot/OI.java index f392812..bc413dd 100644 --- a/src/main/java/frc/robot/OI.java +++ b/src/main/java/frc/robot/OI.java @@ -3,20 +3,26 @@ import edu.wpi.first.wpilibj.Joystick; import edu.wpi.first.wpilibj.buttons.Button; import edu.wpi.first.wpilibj.buttons.JoystickButton; - +import frc.robot.Autons.ShooterGroupLong; +import frc.robot.Autons.ShooterGroupWall; +import frc.robot.Autons.WallShot; +import frc.robot.Autons.WallShotStop; import frc.robot.commands.*; import frc.robot.commands.Shooter.StopShooter; import frc.robot.commands.Shooter.CloseHopperPiston; +import frc.robot.commands.Shooter.MoveShooterLong; import frc.robot.commands.Shooter.MoveShooterWall; +import frc.robot.commands.Shooter.CheckHoodWall; +import frc.robot.commands.Shooter.CheckHoodLong; import frc.robot.commands.Shooter.OpenHopperPiston; // import frc.robot.commands.auto.SetLimit; import frc.robot.controller.AnalogButton; import frc.robot.controller.DPadButton; import frc.robot.controller.MultiButton; -import frc.robot.Autons.ShooterGroupLong; -import frc.robot.Autons.StopShooterGroupLong; -import frc.robot.Autons.ShooterGroupWall; -import frc.robot.Autons.StopShooterGroupWall; +// import frc.robot.Autons.ShooterGroupLong; +// import frc.robot.Autons.StopShooterGroupLong; +// import frc.robot.Autons.ShooterGroupWall; +// import frc.robot.Autons.StopShooterGroupWall; //import frc.robot.subsystems.Camera; // import frc.robot.commands.Lifter.ExtendBothLifters; @@ -82,7 +88,10 @@ public OI() { // driverA.whenReleased(new StopShooter()); // driverB.whenPressed(new MoveElevator()); // driverB.whenReleased(new StopElevator()); - // driverX.whenPressed(new MoveHopper()); + operatorA.whenPressed(new MoveHopperLong()); + operatorA.whenReleased(new StopHopper()); + operatorB.whenPressed(new CheckHoodLong()); + operatorB.whenReleased(new CheckHoodWall()); // driverX.whenReleased(new StopHopper()); // driverB.whenPressed(new DrivetrainBackwards()); // driverB.whenReleased(new StopDrivetrain()); @@ -94,17 +103,22 @@ public OI() { driverX.whenReleased(new StopHopper()); driverB.whenPressed(new OpenHopperPiston()); driverB.whenReleased(new CloseHopperPiston()); + // driverRB.whenPressed(new ShooterGroupWall()); // driverRB.whenReleased(new StopShooterGroupWall()); - // driverLB.whenPressed(new ShooterGroupLong()); + operatorX.whenPressed(new StopShooter()); + operatorX.whenPressed(new CheckHoodWall()); + operatorRB.whenPressed(new ShooterGroupWall()); + operatorRB.whenReleased(new StopShooter()); // driverLB.whenReleased(new StopShooterGroupLong()); - driverDPadLeft.whenPressed(new setCameraTwo()); - driverDPadLeft.whenReleased(new setCameraOne()); + driverDPadLeft.whenPressed(new ShooterGroupLong()); + driverDPadLeft.whenReleased(new StopShooter()); driverDPadDown.whenPressed(new ReverseHopper()); driverDPadDown.whenReleased(new StopHopper()); - driverDPadRight.whenPressed(new MoveShooterWall()); + driverDPadRight.whenPressed(new ShooterGroupWall()); driverDPadRight.whenReleased(new StopShooter()); - // driverLB.whenPressed(new runHopperElevator()); + operatorY.whileHeld(new WallShot()); + operatorB.whenPressed(new WallShotStop()); // driverLB.whenReleased(new stopHopperElevator()); // driverLS.whenPressed(new runElevatorShooter()); // driverLS.whenReleased(new stopElevatorShooter()); diff --git a/src/main/java/frc/robot/commands/MoveHopper.java b/src/main/java/frc/robot/commands/MoveHopperLong.java similarity index 87% rename from src/main/java/frc/robot/commands/MoveHopper.java rename to src/main/java/frc/robot/commands/MoveHopperLong.java index 7791a36..95b988f 100644 --- a/src/main/java/frc/robot/commands/MoveHopper.java +++ b/src/main/java/frc/robot/commands/MoveHopperLong.java @@ -11,9 +11,9 @@ import frc.robot.Constants; import frc.robot.Robot; -public class MoveHopper extends Command { - public MoveHopper() { - super("MoveHopper"); +public class MoveHopperLong extends Command { + public MoveHopperLong() { + super("MoveHopperLong"); requires(Robot.hopper); // Use requires() here to declare subsystem dependencies // eg. requires(chassis); @@ -27,7 +27,7 @@ protected void initialize() { // Called repeatedly when this Command is scheduled to run @Override protected void execute() { - Robot.hopper.setHopper(Constants.HOPPER_HORIZONTAL_OUTPUT, Constants.HOPPER_VERTICAL_OUTPUT); + Robot.hopper.setHopper(Constants.HOPPER_LONG_HORIZONTAL_OUTPUT, Constants.HOPPER_VERTICAL_OUTPUT); } // Make this return true when this Command no longer needs to run execute() diff --git a/src/main/java/frc/robot/commands/MoveHopperWall.java b/src/main/java/frc/robot/commands/MoveHopperWall.java new file mode 100644 index 0000000..7711e69 --- /dev/null +++ b/src/main/java/frc/robot/commands/MoveHopperWall.java @@ -0,0 +1,50 @@ +/*----------------------------------------------------------------------------*/ +/* Copyright (c) 2018 FIRST. All Rights Reserved. */ +/* Open Source Software - may be modified and shared by FRC teams. The code */ +/* must be accompanied by the FIRST BSD license file in the root directory of */ +/* the project. */ +/*----------------------------------------------------------------------------*/ + +package frc.robot.commands; + +import edu.wpi.first.wpilibj.command.Command; +import frc.robot.Constants; +import frc.robot.Robot; + +public class MoveHopperWall extends Command { + public MoveHopperWall() { + super("MoveHopperWall"); + requires(Robot.hopper); + // Use requires() here to declare subsystem dependencies + // eg. requires(chassis); + } + + // Called just before this Command runs the first time + @Override + protected void initialize() { + } + + // Called repeatedly when this Command is scheduled to run + @Override + protected void execute() { + Robot.hopper.setHopper(Constants.HOPPER_WALL_HORIZONTAL_OUTPUT, Constants.HOPPER_VERTICAL_OUTPUT); + } + + // Make this return true when this Command no longer needs to run execute() + @Override + protected boolean isFinished() { + return false; + } + + // Called once after isFinished returns true + @Override + protected void end() { + Robot.hopper.setHopper(0, 0); + } + + // Called when another command which requires one or more of the same + // subsystems is scheduled to run + @Override + protected void interrupted() { + } +} diff --git a/src/main/java/frc/robot/commands/MoveManipulator.java b/src/main/java/frc/robot/commands/MoveManipulator.java index c05baee..07259f2 100644 --- a/src/main/java/frc/robot/commands/MoveManipulator.java +++ b/src/main/java/frc/robot/commands/MoveManipulator.java @@ -22,7 +22,7 @@ protected void initialize() { @Override protected void execute() { Robot.manipulator.setRetracted(true); - Robot.manipulator.setManipulator(0); + Robot.manipulator.setManipulator(Constants.INTAKE_MOTORSPEED); } //Make this return true when this Command no longer needs to run execute() diff --git a/src/main/java/frc/robot/commands/MoveShooter.java b/src/main/java/frc/robot/commands/MoveShooter.java index aff7ba9..d479b14 100644 --- a/src/main/java/frc/robot/commands/MoveShooter.java +++ b/src/main/java/frc/robot/commands/MoveShooter.java @@ -1,52 +1,52 @@ -// /*----------------------------------------------------------------------------*/ -// /* Copyright (c) 2018 FIRST. All Rights Reserved. */ -// /* Open Source Software - may be modified and shared by FRC teams. The code */ -// /* must be accompanied by the FIRST BSD license file in the root directory of */ -// /* the project. */ -// /*----------------------------------------------------------------------------*/ - -// package frc.robot.commands; - -// import edu.wpi.first.wpilibj.command.Command; -// import frc.robot.Constants; -// import frc.robot.Robot; - -// public class MoveShooter extends Command { -// public MoveShooter() { -// super("MoveShooter"); -// requires(Robot.shooter); - -// // Use requires() here to declare subsystem dependencies -// // eg. requires(chassis); -// } - -// // Called just before this Command runs the first time -// @Override -// protected void initialize() { - -// } - -// // Called repeatedly when this Command is scheduled to run -// @Override -// protected void execute() { -// Robot.shooter.setShooter(Constants.SHOOTER_OUTPUT); -// } - -// // Make this return true when this Command no longer needs to run execute() -// @Override -// protected boolean isFinished() { -// return false; -// } - -// // Called once after isFinished returns true -// @Override -// protected void end() { -// Robot.shooter.setShooter(0); -// } - -// // Called when another command which requires one or more of the same -// // subsystems is scheduled to run -// @Override -// protected void interrupted() { -// } -// } +/*----------------------------------------------------------------------------*/ +/* Copyright (c) 2018 FIRST. All Rights Reserved. */ +/* Open Source Software - may be modified and shared by FRC teams. The code */ +/* must be accompanied by the FIRST BSD license file in the root directory of */ +/* the project. */ +/*----------------------------------------------------------------------------*/ + +package frc.robot.commands; + +import edu.wpi.first.wpilibj.command.Command; +import frc.robot.Constants; +import frc.robot.Robot; + +public class MoveShooter extends Command { + public MoveShooter() { + super("MoveShooter"); + requires(Robot.shooter); + + // Use requires() here to declare subsystem dependencies + // eg. requires(chassis); + } + + // Called just before this Command runs the first time + @Override + protected void initialize() { + + } + + // Called repeatedly when this Command is scheduled to run + @Override + protected void execute() { + Robot.shooter.setShooter(Constants.SHOOTER_OUTPUT); + } + + // Make this return true when this Command no longer needs to run execute() + @Override + protected boolean isFinished() { + return false; + } + + // Called once after isFinished returns true + @Override + protected void end() { + Robot.shooter.setShooter(0); + } + + // Called when another command which requires one or more of the same + // subsystems is scheduled to run + @Override + protected void interrupted() { + } +} diff --git a/src/main/java/frc/robot/commands/Shooter/CheckHoodLong.java b/src/main/java/frc/robot/commands/Shooter/CheckHoodLong.java index ad55848..da77a7f 100644 --- a/src/main/java/frc/robot/commands/Shooter/CheckHoodLong.java +++ b/src/main/java/frc/robot/commands/Shooter/CheckHoodLong.java @@ -29,19 +29,19 @@ protected void initialize() { // Called repeatedly when this Command is scheduled to run @Override protected void execute() { - if(Robot.shooter.getHood1() != false) { - Robot.shooter.setHood1(false); - } + Robot.shooter.setHood1(true); + } // Make this return true when this Command no longer needs to run execute() @Override protected boolean isFinished() { - if(Robot.shooter.getHood1() == false) { - return true; - } - return false; - } + return true; + // if(Robot.shooter.getHood1() == false) { + // return true; + // } + // return false; + } // Called once after isFinished returns true @Override diff --git a/src/main/java/frc/robot/commands/Shooter/CheckHoodWall.java b/src/main/java/frc/robot/commands/Shooter/CheckHoodWall.java index d52f5cb..0cb5353 100644 --- a/src/main/java/frc/robot/commands/Shooter/CheckHoodWall.java +++ b/src/main/java/frc/robot/commands/Shooter/CheckHoodWall.java @@ -29,9 +29,7 @@ protected void initialize() { // Called repeatedly when this Command is scheduled to run @Override protected void execute() { - if(Robot.shooter.getHood1() != true) { - Robot.shooter.setHood1(true); - } + Robot.shooter.setHood1(false); } // Make this return true when this Command no longer needs to run execute() diff --git a/src/main/java/frc/robot/commands/Shooter/CheckMotorLong.java b/src/main/java/frc/robot/commands/Shooter/CheckMotorLong.java index 2c74f4c..6572359 100644 --- a/src/main/java/frc/robot/commands/Shooter/CheckMotorLong.java +++ b/src/main/java/frc/robot/commands/Shooter/CheckMotorLong.java @@ -29,19 +29,20 @@ protected void initialize() { // Called repeatedly when this Command is scheduled to run @Override protected void execute() { - if(Robot.shooter.checkWheelSpeed_Long() != true) { Robot.shooter.setShooter(Constants.SHOOTER_OUTPUT_LONG); - } } // Make this return true when this Command no longer needs to run execute() @Override protected boolean isFinished() { - if(Robot.shooter.checkWheelSpeed_Long() == true) { - return true; - } - return false; + return true; } + // if(Robot.shooter.checkWheelSpeed_Long() == true) { + // return true; + // } + + // return false; + // } // Called once after isFinished returns true @Override diff --git a/src/main/java/frc/robot/commands/Shooter/CheckMotorWall.java b/src/main/java/frc/robot/commands/Shooter/CheckMotorWall.java index 882204d..2779b4f 100644 --- a/src/main/java/frc/robot/commands/Shooter/CheckMotorWall.java +++ b/src/main/java/frc/robot/commands/Shooter/CheckMotorWall.java @@ -29,18 +29,19 @@ protected void initialize() { // Called repeatedly when this Command is scheduled to run @Override protected void execute() { - if(Robot.shooter.checkWheelSpeed_Wall() != true) { + Robot.shooter.setShooter(Constants.SHOOTER_OUTPUT_WALL); //Utilize PIDs for this (and Longshot as well) - } + } // Make this return true when this Command no longer needs to run execute() @Override protected boolean isFinished() { - if(Robot.shooter.checkWheelSpeed_Wall()) { - return true; - } - return false; + // if(Robot.shooter.checkWheelSpeed_Wall()) { + // return true; + // } + // return false; + return true; } // Called once after isFinished returns true diff --git a/src/main/java/frc/robot/commands/Shooter/CloseHopperPiston.java b/src/main/java/frc/robot/commands/Shooter/CloseHopperPiston.java index c08d3c5..5e361c5 100644 --- a/src/main/java/frc/robot/commands/Shooter/CloseHopperPiston.java +++ b/src/main/java/frc/robot/commands/Shooter/CloseHopperPiston.java @@ -3,7 +3,6 @@ import edu.wpi.first.wpilibj.command.Command; import frc.robot.Constants; import frc.robot.Robot; -import frc.robot.commands.MoveHopper; // import frc.robot.subsystems.Shooter; //in theory this just chanes whether the hopper piston is retracted or not and then stops diff --git a/src/main/java/frc/robot/commands/Shooter/OpenHopperPiston.java b/src/main/java/frc/robot/commands/Shooter/OpenHopperPiston.java index e0aaf81..cff08a5 100644 --- a/src/main/java/frc/robot/commands/Shooter/OpenHopperPiston.java +++ b/src/main/java/frc/robot/commands/Shooter/OpenHopperPiston.java @@ -3,7 +3,6 @@ import edu.wpi.first.wpilibj.command.Command; import frc.robot.Constants; import frc.robot.Robot; -import frc.robot.commands.MoveHopper; // import frc.robot.subsystems.Shooter; //in theory this just chanes whether the hopper piston is retracted or not and then stops diff --git a/src/main/java/frc/robot/commands/Shooter/StopShooter.java b/src/main/java/frc/robot/commands/Shooter/StopShooter.java index 81b4940..4efe6b7 100644 --- a/src/main/java/frc/robot/commands/Shooter/StopShooter.java +++ b/src/main/java/frc/robot/commands/Shooter/StopShooter.java @@ -3,7 +3,6 @@ import edu.wpi.first.wpilibj.command.Command; import frc.robot.Constants; import frc.robot.Robot; -import frc.robot.commands.MoveHopper; import frc.robot.subsystems.Shooter; //in theory this just chanes whether the hopper piston is retracted or not and then stops diff --git a/src/main/java/frc/robot/subsystems/Hopper.java b/src/main/java/frc/robot/subsystems/Hopper.java index d823a64..c584a41 100644 --- a/src/main/java/frc/robot/subsystems/Hopper.java +++ b/src/main/java/frc/robot/subsystems/Hopper.java @@ -78,7 +78,7 @@ public boolean isBall(){ public void poopBall(){ if(Constants.BALL_VALUE < getIRSensor()){ - setHopper(Constants.HOPPER_HORIZONTAL_OUTPUT, Constants.HOPPER_VERTICAL_OUTPUT); + setHopper(Constants.HOPPER_LOADING_HORIZONTAL_OUTPUT, Constants.HOPPER_VERTICAL_OUTPUT); } else{ setHopper(0, 0); } diff --git a/src/main/java/frc/robot/subsystems/Shooter.java b/src/main/java/frc/robot/subsystems/Shooter.java index e7d9c8a..11a8f97 100644 --- a/src/main/java/frc/robot/subsystems/Shooter.java +++ b/src/main/java/frc/robot/subsystems/Shooter.java @@ -66,6 +66,17 @@ public double getShooterVelocity(){ return shooter_leader.getEncoder().getVelocity(); } + public double getShooterVoltage(){ + return shooter_leader.getBusVoltage(); + } + + public double getShooterConversionFactor(){ + return shooter_leader.getEncoder().getVelocityConversionFactor(); + } + public double getShooterVelocity2(){ + double velocity = getShooterVoltage() * getShooterConversionFactor(); + return velocity; + } public boolean isShooterVelocityCorrect(){ if(getShooterVelocity() != Constants.SHOOTER_VELOCITY){ return false; @@ -110,5 +121,8 @@ public void debug() { SmartDashboard.putNumber("Shooter Neo Velocity -", getShooterVelocity()); SmartDashboard.putNumber("Shooter Neo CPR -", getShooter()); SmartDashboard.putBoolean("Hood Position", getHood1()); + SmartDashboard.putNumber("Voltage", getShooterVoltage()); + SmartDashboard.putNumber("Calculated Velcoity", getShooterVelocity2()); + } } From fd109b81b37b19946c20a82bd9a99f41be621452 Mon Sep 17 00:00:00 2001 From: fidgetspinnerkid <35818373+fidgetspinnerkid@users.noreply.github.com> Date: Mon, 24 Feb 2020 12:38:26 -0800 Subject: [PATCH 15/68] Panel Mech Mech Neck initialize --- .../java/frc/robot/commands/SetPanelmech.java | 49 +++++++++++++++++++ .../java/frc/robot/subsystems/PanelMech.java | 13 +++-- 2 files changed, 59 insertions(+), 3 deletions(-) create mode 100644 src/main/java/frc/robot/commands/SetPanelmech.java diff --git a/src/main/java/frc/robot/commands/SetPanelmech.java b/src/main/java/frc/robot/commands/SetPanelmech.java new file mode 100644 index 0000000..d0b2aea --- /dev/null +++ b/src/main/java/frc/robot/commands/SetPanelmech.java @@ -0,0 +1,49 @@ +//IMPORTED FROM CLIMBER-MAAZ BRANCH!!!! + +package frc.robot.commands; + +import edu.wpi.first.wpilibj.command.Command; +import frc.robot.Constants; +import frc.robot.Robot; + +public class SetPanelMech extends Command { + public SetPanelMech() { + super("SetPanelMech"); + requires(Robot.panelMech); + //Use requires() here to declare subsystem dependencies + //eg. requires(chassis); + } + + //Called just before this Command runs the first time + @Override + protected void initialize() { + + } + + //Called repeatedly when this Command is scheduled to run + @Override + protected void execute() { + Robot.panelMech.extendPanelMech(true); + Robot.panelMech.setPanelMech(Constants.PANEL_MECH_FAST); + } + + //Make this return true when this Command no longer needs to run execute() + @Override + protected boolean isFinished() { + return false; + } + + //Called once after isFinished returns true + @Override + protected void end() { + + } + + //Called when another command which requires one or more of the same + //subsystems is scheduled to run + + @Override + protected void interrupted() { + //Yes + } +} \ No newline at end of file diff --git a/src/main/java/frc/robot/subsystems/PanelMech.java b/src/main/java/frc/robot/subsystems/PanelMech.java index 0179ab3..05f63f9 100644 --- a/src/main/java/frc/robot/subsystems/PanelMech.java +++ b/src/main/java/frc/robot/subsystems/PanelMech.java @@ -4,6 +4,7 @@ /* must be accompanied by the FIRST BSD license file in the root directory of */ /* the project. */ /*----------------------------------------------------------------------------*/ +//IMPORTED FROM CLIMBER-MAAZ BRANCH!!! package frc.robot.subsystems; import com.revrobotics.CANSparkMax; @@ -30,11 +31,17 @@ public class PanelMech extends Subsystem { //private MoveShooterPassive defaultCommand; public PanelMech(){ - panelMech_motor = new CANSparkMax(RobotMap.MECHNECK, MotorType.kBrushless); + panelMech_motor = new CANSparkMax(RobotMap.PANEL_NEO, MotorType.kBrushless); panelMech_motor.setOpenLoopRampRate(Constants.kNeoRampTime); panelMech_motor.set(0); + panelMech_soleinoid= new Solenoid(RobotMap.kPCM, RobotMap.PANEL_SOLENOID); + } + public void setPanelMech(final double velocity) { + panelMech_motor.set(velocity); + } + public void extendPanelMech(boolean extend) { + panelMech_soleinoid.set(extend); } - @Override protected void initDefaultCommand() { @@ -42,4 +49,4 @@ protected void initDefaultCommand() { public void debug() { } -} +} \ No newline at end of file From 52a3cc52777525b22b70e24d9095dbe567c8e7ed Mon Sep 17 00:00:00 2001 From: John Date: Tue, 25 Feb 2020 16:22:46 -0500 Subject: [PATCH 16/68] cleaned up code --- PathWeaver/Groups/Unnamed | 0 PathWeaver/Paths/Unnamed.path | 3 ++ PathWeaver/Paths/Unnamed_0.path | 3 ++ PathWeaver/pathweaver.json | 8 +++ .../frc/robot/Autons/ShooterGroupLong.java | 13 ++--- .../frc/robot/Autons/ShooterGroupWall.java | 11 ++-- src/main/java/frc/robot/Autons/WallShot.java | 17 ++++--- .../java/frc/robot/Autons/WallShotStop.java | 4 -- .../{CheckMotorLong.java => LongShot.java} | 6 +-- .../{CheckHoodLong.java => LongShotHood.java} | 6 +-- .../commands/Shooter/MoveShooterLong.java | 51 ------------------- .../commands/Shooter/MoveShooterWall.java | 51 ------------------- .../{CheckMotorWall.java => WallShot.java} | 6 +-- .../{CheckHoodWall.java => WallShotHood.java} | 6 +-- 14 files changed, 47 insertions(+), 138 deletions(-) create mode 100644 PathWeaver/Groups/Unnamed create mode 100644 PathWeaver/Paths/Unnamed.path create mode 100644 PathWeaver/Paths/Unnamed_0.path create mode 100644 PathWeaver/pathweaver.json rename src/main/java/frc/robot/commands/Shooter/{CheckMotorLong.java => LongShot.java} (93%) rename src/main/java/frc/robot/commands/Shooter/{CheckHoodLong.java => LongShotHood.java} (93%) delete mode 100644 src/main/java/frc/robot/commands/Shooter/MoveShooterLong.java delete mode 100644 src/main/java/frc/robot/commands/Shooter/MoveShooterWall.java rename src/main/java/frc/robot/commands/Shooter/{CheckMotorWall.java => WallShot.java} (93%) rename src/main/java/frc/robot/commands/Shooter/{CheckHoodWall.java => WallShotHood.java} (93%) diff --git a/PathWeaver/Groups/Unnamed b/PathWeaver/Groups/Unnamed new file mode 100644 index 0000000..e69de29 diff --git a/PathWeaver/Paths/Unnamed.path b/PathWeaver/Paths/Unnamed.path new file mode 100644 index 0000000..610bd7c --- /dev/null +++ b/PathWeaver/Paths/Unnamed.path @@ -0,0 +1,3 @@ +X,Y,Tangent X,Tangent Y,Fixed Theta,Name +0.0,0.0,10.0,0.0,true, +10.0,-10.0,0.0,-10.0,true, diff --git a/PathWeaver/Paths/Unnamed_0.path b/PathWeaver/Paths/Unnamed_0.path new file mode 100644 index 0000000..610bd7c --- /dev/null +++ b/PathWeaver/Paths/Unnamed_0.path @@ -0,0 +1,3 @@ +X,Y,Tangent X,Tangent Y,Fixed Theta,Name +0.0,0.0,10.0,0.0,true, +10.0,-10.0,0.0,-10.0,true, diff --git a/PathWeaver/pathweaver.json b/PathWeaver/pathweaver.json new file mode 100644 index 0000000..b5ebd1b --- /dev/null +++ b/PathWeaver/pathweaver.json @@ -0,0 +1,8 @@ +{ + "lengthUnit": "Foot", + "maxVelocity": 10.0, + "maxAcceleration": 5.0, + "wheelBase": 4.0, + "gameName": "Destination: Deep Space", + "outputDir": "" +} \ No newline at end of file diff --git a/src/main/java/frc/robot/Autons/ShooterGroupLong.java b/src/main/java/frc/robot/Autons/ShooterGroupLong.java index 28fe00d..d5bf911 100644 --- a/src/main/java/frc/robot/Autons/ShooterGroupLong.java +++ b/src/main/java/frc/robot/Autons/ShooterGroupLong.java @@ -3,10 +3,9 @@ import edu.wpi.first.wpilibj.command.CommandGroup; import frc.robot.Robot; import frc.robot.commands.MoveHopperLong; -import frc.robot.commands.Shooter.CheckHoodLong; -import frc.robot.commands.Shooter.CheckHoodWall; -import frc.robot.commands.Shooter.CheckMotorLong; -import frc.robot.commands.Shooter.CheckMotorWall; + +import frc.robot.commands.Shooter.LongShot; +import frc.robot.commands.Shooter.LongShotHood; import frc.robot.commands.Shooter.OpenHopperPiston; //import frc.robot.commands.Shooter.CheckWheelSpeed; //import frc.robot.commands.Shooter.RetractHood; @@ -15,8 +14,10 @@ public class ShooterGroupLong extends CommandGroup{ public ShooterGroupLong(){ - addSequential(new CheckHoodLong()); - addSequential(new CheckMotorLong()); + addSequential(new LongShotHood()); + addSequential(new LongShot(), 5.0); + addSequential(new OpenHopperPiston()); + addSequential(new MoveHopperLong()); //addSequential(new OpenHopperPiston()); //addSequential(new MoveHopperLong()); } diff --git a/src/main/java/frc/robot/Autons/ShooterGroupWall.java b/src/main/java/frc/robot/Autons/ShooterGroupWall.java index 4ac1a6b..6ab8a75 100644 --- a/src/main/java/frc/robot/Autons/ShooterGroupWall.java +++ b/src/main/java/frc/robot/Autons/ShooterGroupWall.java @@ -3,9 +3,8 @@ import edu.wpi.first.wpilibj.command.CommandGroup; import frc.robot.Robot; import frc.robot.commands.MoveHopperWall; -import frc.robot.commands.Shooter.CheckHoodWall; -import frc.robot.commands.Shooter.CheckMotorWall; import frc.robot.commands.Shooter.OpenHopperPiston; +import frc.robot.commands.Shooter.WallShotHood; //import frc.robot.commands.Shooter.CheckWheelSpeed; //import frc.robot.commands.Shooter.RetractHood; import frc.robot.subsystems.Shooter; @@ -13,9 +12,9 @@ public class ShooterGroupWall extends CommandGroup{ public ShooterGroupWall(){ - // addSequential(new CheckHoodWall()); - addSequential(new CheckMotorWall()); - // addSequential(new OpenHopperPiston()); - // addSequential(new MoveHopperWall()); + addSequential(new WallShotHood()); + addSequential(new WallShot(), 5.0); + addSequential(new OpenHopperPiston()); + addSequential(new MoveHopperWall()); } } \ No newline at end of file diff --git a/src/main/java/frc/robot/Autons/WallShot.java b/src/main/java/frc/robot/Autons/WallShot.java index bac0c52..2c7acf2 100644 --- a/src/main/java/frc/robot/Autons/WallShot.java +++ b/src/main/java/frc/robot/Autons/WallShot.java @@ -4,23 +4,24 @@ import frc.robot.Robot; import frc.robot.commands.MoveHopperWall; import frc.robot.commands.StopHopper; -import frc.robot.commands.Shooter.CheckHoodLong; -import frc.robot.commands.Shooter.CheckHoodWall; -import frc.robot.commands.Shooter.CheckMotorLong; -import frc.robot.commands.Shooter.CheckMotorWall; import frc.robot.commands.Shooter.CloseHopperPiston; import frc.robot.commands.Shooter.OpenHopperPiston; //import frc.robot.commands.Shooter.CheckWheelSpeed; //import frc.robot.commands.Shooter.RetractHood; import frc.robot.commands.Shooter.StopShooter; +import frc.robot.commands.Shooter.WallShotHood; import frc.robot.subsystems.Shooter; public class WallShot extends CommandGroup{ public WallShot(){ - addSequential(new CheckHoodLong()); - addSequential(new CheckMotorLong()); - addParallel(new OpenHopperPiston()); - addParallel(new MoveHopperWall()); + addSequential(new WallShotHood()); + addSequential(new WallShot(), 0.5); + addSequential(new OpenHopperPiston()); + addSequential(new MoveHopperWall()); + // addSequential(new CheckHoodLong()); + // addSequential(new CheckMotorLong()); + // addParallel(new OpenHopperPiston()); + // addParallel(new MoveHopperWall()); } } \ No newline at end of file diff --git a/src/main/java/frc/robot/Autons/WallShotStop.java b/src/main/java/frc/robot/Autons/WallShotStop.java index 1ea2d70..b5581e6 100644 --- a/src/main/java/frc/robot/Autons/WallShotStop.java +++ b/src/main/java/frc/robot/Autons/WallShotStop.java @@ -4,10 +4,6 @@ import frc.robot.Robot; import frc.robot.commands.MoveHopperWall; import frc.robot.commands.StopHopper; -import frc.robot.commands.Shooter.CheckHoodLong; -import frc.robot.commands.Shooter.CheckHoodWall; -import frc.robot.commands.Shooter.CheckMotorLong; -import frc.robot.commands.Shooter.CheckMotorWall; import frc.robot.commands.Shooter.CloseHopperPiston; import frc.robot.commands.Shooter.OpenHopperPiston; //import frc.robot.commands.Shooter.CheckWheelSpeed; diff --git a/src/main/java/frc/robot/commands/Shooter/CheckMotorLong.java b/src/main/java/frc/robot/commands/Shooter/LongShot.java similarity index 93% rename from src/main/java/frc/robot/commands/Shooter/CheckMotorLong.java rename to src/main/java/frc/robot/commands/Shooter/LongShot.java index 6572359..0915ea8 100644 --- a/src/main/java/frc/robot/commands/Shooter/CheckMotorLong.java +++ b/src/main/java/frc/robot/commands/Shooter/LongShot.java @@ -11,9 +11,9 @@ import frc.robot.Constants; import frc.robot.Robot; -public class CheckMotorLong extends Command { - public CheckMotorLong() { - super("CheckMotorLong"); +public class LongShot extends Command { + public LongShot() { + super("LongShot"); requires(Robot.shooter); // Use requires() here to declare subsystem dependencies diff --git a/src/main/java/frc/robot/commands/Shooter/CheckHoodLong.java b/src/main/java/frc/robot/commands/Shooter/LongShotHood.java similarity index 93% rename from src/main/java/frc/robot/commands/Shooter/CheckHoodLong.java rename to src/main/java/frc/robot/commands/Shooter/LongShotHood.java index da77a7f..c1529f8 100644 --- a/src/main/java/frc/robot/commands/Shooter/CheckHoodLong.java +++ b/src/main/java/frc/robot/commands/Shooter/LongShotHood.java @@ -11,9 +11,9 @@ import frc.robot.Constants; import frc.robot.Robot; -public class CheckHoodLong extends Command { - public CheckHoodLong() { - super("CheckHoodLong"); +public class LongShotHood extends Command { + public LongShotHood() { + super("LongShotHood"); requires(Robot.shooter); // Use requires() here to declare subsystem dependencies diff --git a/src/main/java/frc/robot/commands/Shooter/MoveShooterLong.java b/src/main/java/frc/robot/commands/Shooter/MoveShooterLong.java deleted file mode 100644 index 4f96348..0000000 --- a/src/main/java/frc/robot/commands/Shooter/MoveShooterLong.java +++ /dev/null @@ -1,51 +0,0 @@ -/*----------------------------------------------------------------------------*/ -/* Copyright (c) 2018 FIRST. All Rights Reserved. */ -/* Open Source Software - may be modified and shared by FRC teams. The code */ -/* must be accompanied by the FIRST BSD license file in the root directory of */ -/* the project. */ -/*----------------------------------------------------------------------------*/ - -package frc.robot.commands.Shooter; - -import edu.wpi.first.wpilibj.command.Command; -import frc.robot.Constants; -import frc.robot.Robot; - -public class MoveShooterLong extends Command { - public MoveShooterLong() { - super("MoveShooterLong"); - requires(Robot.shooter); - // Use requires() here to declare subsystem dependencies - // eg. requires(chassis); - } - - // Called just before this Command runs the first time - @Override - protected void initialize() { - } - - // Called repeatedly when this Command is scheduled to run - @Override - protected void execute() { - - Robot.shooter.setShooter(Constants.SHOOTER_OUTPUT_LONG); - } - - // Make this return true when this Command no longer needs to run execute() - @Override - protected boolean isFinished() { - return false; - } - - // Called once after isFinished returns true - @Override - protected void end() { - Robot.shooter.setShooter(0); - } - - // Called when another command which requires one or more of the same - // subsystems is scheduled to run - @Override - protected void interrupted() { - } -} diff --git a/src/main/java/frc/robot/commands/Shooter/MoveShooterWall.java b/src/main/java/frc/robot/commands/Shooter/MoveShooterWall.java deleted file mode 100644 index 2b187a7..0000000 --- a/src/main/java/frc/robot/commands/Shooter/MoveShooterWall.java +++ /dev/null @@ -1,51 +0,0 @@ -/*----------------------------------------------------------------------------*/ -/* Copyright (c) 2018 FIRST. All Rights Reserved. */ -/* Open Source Software - may be modified and shared by FRC teams. The code */ -/* must be accompanied by the FIRST BSD license file in the root directory of */ -/* the project. */ -/*----------------------------------------------------------------------------*/ - -package frc.robot.commands.Shooter; - -import edu.wpi.first.wpilibj.command.Command; -import frc.robot.Constants; -import frc.robot.Robot; - -public class MoveShooterWall extends Command { - public MoveShooterWall() { - super("MoveShooterWall"); - requires(Robot.shooter); - // Use requires() here to declare subsystem dependencies - // eg. requires(chassis); - } - - // Called just before this Command runs the first time - @Override - protected void initialize() { - } - - // Called repeatedly when this Command is scheduled to run - @Override - protected void execute() { - - Robot.shooter.setShooter(Constants.SHOOTER_OUTPUT_WALL); - } - - // Make this return true when this Command no longer needs to run execute() - @Override - protected boolean isFinished() { - return false; - } - - // Called once after isFinished returns true - @Override - protected void end() { - Robot.shooter.setShooter(0); - } - - // Called when another command which requires one or more of the same - // subsystems is scheduled to run - @Override - protected void interrupted() { - } -} diff --git a/src/main/java/frc/robot/commands/Shooter/CheckMotorWall.java b/src/main/java/frc/robot/commands/Shooter/WallShot.java similarity index 93% rename from src/main/java/frc/robot/commands/Shooter/CheckMotorWall.java rename to src/main/java/frc/robot/commands/Shooter/WallShot.java index 2779b4f..6a36500 100644 --- a/src/main/java/frc/robot/commands/Shooter/CheckMotorWall.java +++ b/src/main/java/frc/robot/commands/Shooter/WallShot.java @@ -11,9 +11,9 @@ import frc.robot.Constants; import frc.robot.Robot; -public class CheckMotorWall extends Command { - public CheckMotorWall() { - super("CheckMotorWall"); +public class WallShot extends Command { + public WallShot() { + super("WallShot"); requires(Robot.shooter); // Use requires() here to declare subsystem dependencies diff --git a/src/main/java/frc/robot/commands/Shooter/CheckHoodWall.java b/src/main/java/frc/robot/commands/Shooter/WallShotHood.java similarity index 93% rename from src/main/java/frc/robot/commands/Shooter/CheckHoodWall.java rename to src/main/java/frc/robot/commands/Shooter/WallShotHood.java index 0cb5353..10120b3 100644 --- a/src/main/java/frc/robot/commands/Shooter/CheckHoodWall.java +++ b/src/main/java/frc/robot/commands/Shooter/WallShotHood.java @@ -11,9 +11,9 @@ import frc.robot.Constants; import frc.robot.Robot; -public class CheckHoodWall extends Command { - public CheckHoodWall() { - super("CheckHoodWall"); +public class WallShotHood extends Command { + public WallShotHood() { + super("WallShotHood"); requires(Robot.shooter); // Use requires() here to declare subsystem dependencies From 142f4473a4f2e151e4aa42ae828625b4a5cbf3c1 Mon Sep 17 00:00:00 2001 From: John Date: Tue, 25 Feb 2020 16:49:40 -0500 Subject: [PATCH 17/68] finished cleaning code --- .../frc/robot/Autons/ShooterGroupWall.java | 1 + .../Autons/{WallShotStop.java => Stop.java} | 4 +- src/main/java/frc/robot/Autons/WallShot.java | 27 -------- src/main/java/frc/robot/OI.java | 66 +++++++++++-------- 4 files changed, 43 insertions(+), 55 deletions(-) rename src/main/java/frc/robot/Autons/{WallShotStop.java => Stop.java} (89%) delete mode 100644 src/main/java/frc/robot/Autons/WallShot.java diff --git a/src/main/java/frc/robot/Autons/ShooterGroupWall.java b/src/main/java/frc/robot/Autons/ShooterGroupWall.java index 6ab8a75..04eef0f 100644 --- a/src/main/java/frc/robot/Autons/ShooterGroupWall.java +++ b/src/main/java/frc/robot/Autons/ShooterGroupWall.java @@ -4,6 +4,7 @@ import frc.robot.Robot; import frc.robot.commands.MoveHopperWall; import frc.robot.commands.Shooter.OpenHopperPiston; +import frc.robot.commands.Shooter.WallShot; import frc.robot.commands.Shooter.WallShotHood; //import frc.robot.commands.Shooter.CheckWheelSpeed; //import frc.robot.commands.Shooter.RetractHood; diff --git a/src/main/java/frc/robot/Autons/WallShotStop.java b/src/main/java/frc/robot/Autons/Stop.java similarity index 89% rename from src/main/java/frc/robot/Autons/WallShotStop.java rename to src/main/java/frc/robot/Autons/Stop.java index b5581e6..4b3df3c 100644 --- a/src/main/java/frc/robot/Autons/WallShotStop.java +++ b/src/main/java/frc/robot/Autons/Stop.java @@ -11,9 +11,9 @@ import frc.robot.commands.Shooter.StopShooter; import frc.robot.subsystems.Shooter; -public class WallShotStop extends CommandGroup{ +public class Stop extends CommandGroup { - public WallShotStop(){ + public Stop() { addSequential(new StopShooter()); addSequential(new CloseHopperPiston()); addSequential(new StopHopper()); diff --git a/src/main/java/frc/robot/Autons/WallShot.java b/src/main/java/frc/robot/Autons/WallShot.java deleted file mode 100644 index 2c7acf2..0000000 --- a/src/main/java/frc/robot/Autons/WallShot.java +++ /dev/null @@ -1,27 +0,0 @@ -package frc.robot.Autons; - -import edu.wpi.first.wpilibj.command.CommandGroup; -import frc.robot.Robot; -import frc.robot.commands.MoveHopperWall; -import frc.robot.commands.StopHopper; -import frc.robot.commands.Shooter.CloseHopperPiston; -import frc.robot.commands.Shooter.OpenHopperPiston; -//import frc.robot.commands.Shooter.CheckWheelSpeed; -//import frc.robot.commands.Shooter.RetractHood; -import frc.robot.commands.Shooter.StopShooter; -import frc.robot.commands.Shooter.WallShotHood; -import frc.robot.subsystems.Shooter; - -public class WallShot extends CommandGroup{ - - public WallShot(){ - addSequential(new WallShotHood()); - addSequential(new WallShot(), 0.5); - addSequential(new OpenHopperPiston()); - addSequential(new MoveHopperWall()); - // addSequential(new CheckHoodLong()); - // addSequential(new CheckMotorLong()); - // addParallel(new OpenHopperPiston()); - // addParallel(new MoveHopperWall()); - } -} \ No newline at end of file diff --git a/src/main/java/frc/robot/OI.java b/src/main/java/frc/robot/OI.java index bc413dd..f35b7f8 100644 --- a/src/main/java/frc/robot/OI.java +++ b/src/main/java/frc/robot/OI.java @@ -5,15 +5,15 @@ import edu.wpi.first.wpilibj.buttons.JoystickButton; import frc.robot.Autons.ShooterGroupLong; import frc.robot.Autons.ShooterGroupWall; -import frc.robot.Autons.WallShot; -import frc.robot.Autons.WallShotStop; +import frc.robot.Autons.Stop; +import frc.robot.commands.Shooter.*; + import frc.robot.commands.*; import frc.robot.commands.Shooter.StopShooter; +import frc.robot.commands.Shooter.WallShotHood; import frc.robot.commands.Shooter.CloseHopperPiston; -import frc.robot.commands.Shooter.MoveShooterLong; -import frc.robot.commands.Shooter.MoveShooterWall; -import frc.robot.commands.Shooter.CheckHoodWall; -import frc.robot.commands.Shooter.CheckHoodLong; +import frc.robot.commands.Shooter.LongShotHood; + import frc.robot.commands.Shooter.OpenHopperPiston; // import frc.robot.commands.auto.SetLimit; import frc.robot.controller.AnalogButton; @@ -68,7 +68,7 @@ public class OI { private Button driverX; private Button driverRS, driverLS; private Button driverRX; - protected Button operatorLeftJoystickUsed, operatorRightJoystickUsed, operatorDPadDown, operatorDPadLeft; + protected Button operatorLeftJoystickUsed, operatorRightJoystickUsed, operatorDPadDown, operatorDPadLeft, operatorDPadRight; private Button operatorA, operatorB, operatorX, operatorY; public OI() { driverStick = new Joystick(0); @@ -88,37 +88,51 @@ public OI() { // driverA.whenReleased(new StopShooter()); // driverB.whenPressed(new MoveElevator()); // driverB.whenReleased(new StopElevator()); - operatorA.whenPressed(new MoveHopperLong()); - operatorA.whenReleased(new StopHopper()); - operatorB.whenPressed(new CheckHoodLong()); - operatorB.whenReleased(new CheckHoodWall()); + // driverX.whenReleased(new StopHopper()); // driverB.whenPressed(new DrivetrainBackwards()); // driverB.whenReleased(new StopDrivetrain()); // driverY.whenPressed(new MoveDrivetrain()); // driverY.whenReleased(new StopDrivetrain()); driverA.whenPressed(new MoveManipulator()); - driverY.whenPressed(new StopManipulator()); - driverX.whenPressed(new IrHopper()); - driverX.whenReleased(new StopHopper()); + driverA.whenReleased(new StopManipulator()); + + driverB.whenPressed(new OpenHopperPiston()); driverB.whenReleased(new CloseHopperPiston()); // driverRB.whenPressed(new ShooterGroupWall()); // driverRB.whenReleased(new StopShooterGroupWall()); - operatorX.whenPressed(new StopShooter()); - operatorX.whenPressed(new CheckHoodWall()); - operatorRB.whenPressed(new ShooterGroupWall()); - operatorRB.whenReleased(new StopShooter()); + + // driverLB.whenReleased(new StopShooterGroupLong()); - driverDPadLeft.whenPressed(new ShooterGroupLong()); - driverDPadLeft.whenReleased(new StopShooter()); - driverDPadDown.whenPressed(new ReverseHopper()); - driverDPadDown.whenReleased(new StopHopper()); - driverDPadRight.whenPressed(new ShooterGroupWall()); - driverDPadRight.whenReleased(new StopShooter()); - operatorY.whileHeld(new WallShot()); - operatorB.whenPressed(new WallShotStop()); + operatorDPadLeft.whenPressed(new ShooterGroupLong()); + operatorDPadLeft.whenReleased(new Stop()); + + + operatorDPadRight.whenPressed(new ShooterGroupWall()); + operatorDPadRight.whenReleased(new Stop()); + + operatorA.whenPressed(new MoveHopperLong()); + operatorA.whenReleased(new StopHopper()); + + operatorB.whenPressed(new LongShotHood()); + operatorB.whenReleased(new WallShotHood()); + + operatorY.whenPressed(new ReverseHopper()); + operatorY.whenReleased(new StopHopper()); + + operatorX.whenPressed(new IrHopper()); + operatorX.whenReleased(new StopHopper()); + + operatorRB.whenPressed(new WallShot()); + operatorRB.whenReleased(new StopShooter()); + + operatorLB.whenPressed(new LongShot()); + operatorLB.whenReleased(new StopShooter()); + + + // driverLB.whenReleased(new stopHopperElevator()); // driverLS.whenPressed(new runElevatorShooter()); // driverLS.whenReleased(new stopElevatorShooter()); From 0a3a015ed6c2806b3d842ea32229eec2a7665ba7 Mon Sep 17 00:00:00 2001 From: John Date: Tue, 25 Feb 2020 17:07:21 -0500 Subject: [PATCH 18/68] added in contral panel constants and ids --- src/main/java/frc/robot/Constants.java | 5 +++++ src/main/java/frc/robot/Robot.java | 4 ++-- src/main/java/frc/robot/RobotMap.java | 3 ++- 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/src/main/java/frc/robot/Constants.java b/src/main/java/frc/robot/Constants.java index 97975eb..c46ddd7 100644 --- a/src/main/java/frc/robot/Constants.java +++ b/src/main/java/frc/robot/Constants.java @@ -104,4 +104,9 @@ public final class Constants { public static final int BALL_VALUE = 2300; + + + public static final double PANEL_MECH_FAST = 0.45; + + } \ No newline at end of file diff --git a/src/main/java/frc/robot/Robot.java b/src/main/java/frc/robot/Robot.java index fda2b89..bee0a38 100644 --- a/src/main/java/frc/robot/Robot.java +++ b/src/main/java/frc/robot/Robot.java @@ -26,7 +26,7 @@ public class Robot extends TimedRobot { public static Hopper hopper; public static RobotMap robotmap; public static Manipulator manipulator; - // public static PanelMech panelMech; + public static PanelMech panelMech; public static CameraServer Cam; public static CameraSwitch Cam_switch; @@ -36,7 +36,7 @@ public void robotInit() { shooter = new Shooter(); drivetrain = new Drivetrain(); manipulator = new Manipulator(); - // controlPan = new ControlPan(); + panelMech = new PanelMech(); pdp = new PowerDistributionPanel(RobotMap.kPDP); oi = new OI(); robotmap = new RobotMap(); diff --git a/src/main/java/frc/robot/RobotMap.java b/src/main/java/frc/robot/RobotMap.java index 63df49a..b569018 100644 --- a/src/main/java/frc/robot/RobotMap.java +++ b/src/main/java/frc/robot/RobotMap.java @@ -94,6 +94,7 @@ public class RobotMap { public static final int HORIZONTAL_HOPPER = 42; public static final int MANIPULATOR_SOLENOID = 6; public static final int MANIPULATOR_NEO = 40; -public static final int MECHNECK = 50; +public static final int PANEL_NEO = 50; +public static final int PANEL_SOLENOID = 2; } From d52d55b49f07aee43f5e0eaf2203f69425e15b9d Mon Sep 17 00:00:00 2001 From: frcteam2791 Date: Tue, 25 Feb 2020 18:46:26 -0500 Subject: [PATCH 19/68] Adds Shooter PID Subsystem --- src/main/java/frc/robot/Constants.java | 18 +++++++++--------- .../java/frc/robot/commands/SetPanelmech.java | 15 ++++++++++----- .../java/frc/robot/subsystems/Shooter.java | 10 +++++++++- 3 files changed, 28 insertions(+), 15 deletions(-) diff --git a/src/main/java/frc/robot/Constants.java b/src/main/java/frc/robot/Constants.java index 0ab3860..65823f7 100644 --- a/src/main/java/frc/robot/Constants.java +++ b/src/main/java/frc/robot/Constants.java @@ -24,20 +24,21 @@ public final class Constants { public static final double kCamStraightSlow = 0.25; - public static final double ShooterkP = 6e-4; + public static final double ShooterkP = 5e-5; public static final double ShooterkI = 0; - public static final double ShooterkD = 1e-5; + public static final double ShooterkD = 0; public static final double ShooterkIz = 0; - public static final double ShooterkFF = 0; + public static final double ShooterkFF = 1e-4; public static final double ShooterMaxOutput = 1; public static final double ShooterMinOutput = -1; // max and min outputs that pidcontroller can send to the sparkmax - public static final double ShootermaxRPM = 4500; public static final double kGravity = 32.1741; //acceleration due to gravity in ft/s/s public static final double ShooterDiameter = 6; //inches public static final double ShooterGearing = 2; //Shooter spins twice for every one time motor spins public static final double kDrag = 1; public static final double kMagnus = 1; + + public static final double DrivekP = 6e-4; public static final double DrivekI = 0; public static final double DrivekD = 1e-5; @@ -47,6 +48,10 @@ public final class Constants { public static final double DriveMinOutput = -1; public static final double DrivemaxRPM = 4500; + public static final double LimelightkP = 0.35; + public static final double LimelightkI = 0.0; + public static final double LimelightkD = 0.0; + public static final double kDistInnerOuter = 8; public static final double kIrSensorVal = 20.0; //what the value of the ir sensor should read w/o a ball @@ -65,9 +70,6 @@ public final class Constants { public static final double HOPPER_WALL_HORIZONTAL_OUTPUT = 0.30; - public static final double HOPPER_LONG_HORIZONTAL_OUTPUT = 0.20; - - public static final double HOPPER_VERTICAL_OUTPUT = .55; @@ -119,6 +121,4 @@ public final class Constants { //Panel Mech public static final double PANEL_MECH_CREEP = 0.1; - public static final double PANEL_MECH_FAST = 0.5; - } \ No newline at end of file diff --git a/src/main/java/frc/robot/commands/SetPanelmech.java b/src/main/java/frc/robot/commands/SetPanelmech.java index d0b2aea..cd8318b 100644 --- a/src/main/java/frc/robot/commands/SetPanelmech.java +++ b/src/main/java/frc/robot/commands/SetPanelmech.java @@ -1,4 +1,9 @@ -//IMPORTED FROM CLIMBER-MAAZ BRANCH!!!! +/*----------------------------------------------------------------------------*/ +/* Copyright (c) 2018-2019 FIRST. All Rights Reserved. */ +/* Open Source Software - may be modified and shared by FRC teams. The code */ +/* must be accompanied by the FIRST BSD license file in the root directory of */ +/* the project. */ +/*----------------------------------------------------------------------------*/ package frc.robot.commands; @@ -23,8 +28,8 @@ protected void initialize() { //Called repeatedly when this Command is scheduled to run @Override protected void execute() { - Robot.panelMech.extendPanelMech(true); - Robot.panelMech.setPanelMech(Constants.PANEL_MECH_FAST); + Robot.panelMech.setPanelMech(0); + // Robot.panelMech.setManipulator(0); } //Make this return true when this Command no longer needs to run execute() @@ -36,7 +41,7 @@ protected boolean isFinished() { //Called once after isFinished returns true @Override protected void end() { - + Robot.panelMech.setPanelMech(0); } //Called when another command which requires one or more of the same @@ -46,4 +51,4 @@ protected void end() { protected void interrupted() { //Yes } -} \ No newline at end of file +} diff --git a/src/main/java/frc/robot/subsystems/Shooter.java b/src/main/java/frc/robot/subsystems/Shooter.java index 11a8f97..54705be 100644 --- a/src/main/java/frc/robot/subsystems/Shooter.java +++ b/src/main/java/frc/robot/subsystems/Shooter.java @@ -7,7 +7,7 @@ package frc.robot.subsystems; import com.revrobotics.CANSparkMax; - +import com.revrobotics.ControlType; import com.revrobotics.CANSparkMaxLowLevel.MotorType; import edu.wpi.first.wpilibj.Solenoid; @@ -37,6 +37,10 @@ public Shooter(){ shooter_leader.setOpenLoopRampRate(Constants.kNeoRampTime); shooter_follower.setOpenLoopRampRate(Constants.kNeoRampTime); hood_1 = new Solenoid(RobotMap.kPCM, RobotMap.HOOD_SOLENOID); + + shooter_leader.getPIDController().setP(Constants.ShooterkP); + shooter_leader.getPIDController().setFF(Constants.ShooterkFF); + shooter_leader.getPIDController().setOutputRange(-1, 1); } public double idealVelocity(double angle, double dist, double height){ double gravityInches = Constants.kGravity*12; @@ -62,6 +66,10 @@ public void setShooter(final double output){ shooter_leader.set(output); shooter_follower.follow(shooter_leader, true); } + public void setShooterPID(final double setpoint){ + shooter_leader.getPIDController().setReference(setpoint, ControlType.kVelocity); + shooter_follower.follow(shooter_leader, true); + } public double getShooterVelocity(){ return shooter_leader.getEncoder().getVelocity(); } From fabf11abc20dda937b8f8d9368bc8964aecaaa9b Mon Sep 17 00:00:00 2001 From: frcteam2791 Date: Tue, 25 Feb 2020 15:49:48 -0800 Subject: [PATCH 20/68] Added Camera Switching --- src/main/java/frc/robot/OI.java | 10 +- src/main/java/frc/robot/Robot.java | 34 ++++++- .../java/frc/robot/commands/SetPanelmech.java | 82 ++++++++-------- .../frc/robot/commands/SwitchCameras.java | 98 +++++++++---------- .../java/frc/robot/commands/setCameraOne.java | 2 + .../java/frc/robot/subsystems/Camera.java | 43 +++----- .../java/frc/robot/subsystems/Drivetrain.java | 4 + .../java/frc/robot/subsystems/PanelMech.java | 90 ++++++++--------- .../util/Camera_Switch/CameraSwitch.java | 20 ++-- 9 files changed, 206 insertions(+), 177 deletions(-) diff --git a/src/main/java/frc/robot/OI.java b/src/main/java/frc/robot/OI.java index bc413dd..36a77f9 100644 --- a/src/main/java/frc/robot/OI.java +++ b/src/main/java/frc/robot/OI.java @@ -88,10 +88,12 @@ public OI() { // driverA.whenReleased(new StopShooter()); // driverB.whenPressed(new MoveElevator()); // driverB.whenReleased(new StopElevator()); - operatorA.whenPressed(new MoveHopperLong()); - operatorA.whenReleased(new StopHopper()); - operatorB.whenPressed(new CheckHoodLong()); - operatorB.whenReleased(new CheckHoodWall()); + //operatorA.whenPressed(new MoveHopperLong()); + //operatorA.whenReleased(new StopHopper()); + //operatorB.whenPressed(new CheckHoodLong()); + //operatorB.whenReleased(new CheckHoodWall()); + // operatorA.whenPressed(new setCameraOne()); + // operatorB.whenPressed(new setCameraTwo()); // driverX.whenReleased(new StopHopper()); // driverB.whenPressed(new DrivetrainBackwards()); // driverB.whenReleased(new StopDrivetrain()); diff --git a/src/main/java/frc/robot/Robot.java b/src/main/java/frc/robot/Robot.java index fda2b89..b212ff5 100644 --- a/src/main/java/frc/robot/Robot.java +++ b/src/main/java/frc/robot/Robot.java @@ -3,12 +3,17 @@ import edu.wpi.first.wpilibj.PowerDistributionPanel; import edu.wpi.first.wpilibj.TimedRobot; import edu.wpi.first.wpilibj.Relay.Value; +import edu.wpi.first.wpilibj.buttons.Button; +import edu.wpi.first.wpilibj.buttons.JoystickButton; import edu.wpi.first.wpilibj.command.Scheduler; import edu.wpi.first.wpilibj.smartdashboard.SmartDashboard; +import frc.robot.commands.setCameraOne; import frc.robot.subsystems.*; import frc.robot.util.Camera_Switch.CameraSwitch; -import edu.wpi.first.wpilibj.Compressor; +import frc.robot.OI.*; +import edu.wpi.first.wpilibj.Compressor; +import edu.wpi.first.wpilibj.Joystick; import edu.wpi.first.cameraserver.CameraServer; @@ -17,6 +22,7 @@ public class Robot extends TimedRobot { long loopCounter = 0; + public static Joystick operatorStick; public static OI oi; public static Drivetrain drivetrain; public static PowerDistributionPanel pdp; @@ -29,6 +35,7 @@ public class Robot extends TimedRobot { // public static PanelMech panelMech; public static CameraServer Cam; public static CameraSwitch Cam_switch; + private Button operatorA, operatorB; @Override public void robotInit() { @@ -45,6 +52,9 @@ public void robotInit() { compressor = new Compressor(RobotMap.kPCM); compressor.start(); Cam.startAutomaticCapture(0); + operatorStick = new Joystick(1); + operatorA = new JoystickButton(operatorStick, 1); + operatorB = new JoystickButton(operatorStick, 2); } @Override @@ -53,20 +63,38 @@ public void robotPeriodic() { // DriveWithJoystick joystick_command = new DriveWithJoystick(OI.driverStick, 0.1) drivetrain.debug(); compressor.start(); + Cam_switch.debug(); SmartDashboard.putBoolean("Compressor Status", compressor.enabled()); hopper.debug(); - - + if(operatorA.get() == true) { + Cam_switch.select(CameraSwitch.kcamera1); + } + else if (operatorB.get() == true) { + Cam_switch.select(CameraSwitch.kcamera2); + } + else { + Cam_switch.select(CameraSwitch.kcamera3); + } } @Override public void disabledInit() { drivetrain.setMotors(0,0); + hopper.setHopper(0,0); + manipulator.setManipulator(0); + manipulator.setRetracted(true); + shooter.setShooter(0); + //add emergency stops for panelMech } @Override public void disabledPeriodic() { drivetrain.setMotors(0,0); + hopper.setHopper(0,0); + manipulator.setManipulator(0); + manipulator.setRetracted(true); + shooter.setShooter(0); + //add emergency stops for panelMech // Robot.drivetrain.resetGyro(); // autoCommand.start(); } diff --git a/src/main/java/frc/robot/commands/SetPanelmech.java b/src/main/java/frc/robot/commands/SetPanelmech.java index d0b2aea..2aa5f8d 100644 --- a/src/main/java/frc/robot/commands/SetPanelmech.java +++ b/src/main/java/frc/robot/commands/SetPanelmech.java @@ -1,49 +1,49 @@ -//IMPORTED FROM CLIMBER-MAAZ BRANCH!!!! +// //IMPORTED FROM CLIMBER-MAAZ BRANCH!!!! -package frc.robot.commands; +// package frc.robot.commands; -import edu.wpi.first.wpilibj.command.Command; -import frc.robot.Constants; -import frc.robot.Robot; +// import edu.wpi.first.wpilibj.command.Command; +// import frc.robot.Constants; +// import frc.robot.Robot; -public class SetPanelMech extends Command { - public SetPanelMech() { - super("SetPanelMech"); - requires(Robot.panelMech); - //Use requires() here to declare subsystem dependencies - //eg. requires(chassis); - } +// public class SetPanelMech extends Command { +// public SetPanelMech() { +// super("SetPanelMech"); +// requires(Robot.panelMech); +// //Use requires() here to declare subsystem dependencies +// //eg. requires(chassis); +// } - //Called just before this Command runs the first time - @Override - protected void initialize() { +// //Called just before this Command runs the first time +// @Override +// protected void initialize() { - } - - //Called repeatedly when this Command is scheduled to run - @Override - protected void execute() { - Robot.panelMech.extendPanelMech(true); - Robot.panelMech.setPanelMech(Constants.PANEL_MECH_FAST); - } - - //Make this return true when this Command no longer needs to run execute() - @Override - protected boolean isFinished() { - return false; - } - - //Called once after isFinished returns true - @Override - protected void end() { +// } + +// //Called repeatedly when this Command is scheduled to run +// @Override +// protected void execute() { +// Robot.panelMech.extendPanelMech(true); +// Robot.panelMech.setPanelMech(Constants.PANEL_MECH_FAST); +// } + +// //Make this return true when this Command no longer needs to run execute() +// @Override +// protected boolean isFinished() { +// return false; +// } + +// //Called once after isFinished returns true +// @Override +// protected void end() { - } +// } - //Called when another command which requires one or more of the same - //subsystems is scheduled to run +// //Called when another command which requires one or more of the same +// //subsystems is scheduled to run - @Override - protected void interrupted() { - //Yes - } -} \ No newline at end of file +// @Override +// protected void interrupted() { +// //Yes +// } +// } \ No newline at end of file diff --git a/src/main/java/frc/robot/commands/SwitchCameras.java b/src/main/java/frc/robot/commands/SwitchCameras.java index 2bccfad..2b6c270 100644 --- a/src/main/java/frc/robot/commands/SwitchCameras.java +++ b/src/main/java/frc/robot/commands/SwitchCameras.java @@ -1,50 +1,50 @@ -// /*----------------------------------------------------------------------------*/ -// /* Copyright (c) 2018 FIRST. All Rights Reserved. */ -// /* Open Source Software - may be modified and shared by FRC teams. The code */ -// /* must be accompanied by the FIRST BSD license file in the root directory of */ -// /* the project. */ -// /*----------------------------------------------------------------------------*/ - -// package frc.robot.commands; - -// import edu.wpi.first.wpilibj.command.Command; -// import frc.robot.Constants; -// import frc.robot.Robot; - -// public class SwitchCameras extends Command { -// public SwitchCameras() { -// super("SwitchCameras"); -// requires(Robot.drivetrain); -// // Use requires() here to declare subsystem dependencies -// // eg. requires(chassis); -// } - -// // Called just before this Command runs the first time -// @Override -// protected void initialize() { -// } - -// // Called repeatedly when this Command is scheduled to run -// @Override -// protected void execute() { +/*----------------------------------------------------------------------------*/ +/* Copyright (c) 2018 FIRST. All Rights Reserved. */ +/* Open Source Software - may be modified and shared by FRC teams. The code */ +/* must be accompanied by the FIRST BSD license file in the root directory of */ +/* the project. */ +/*----------------------------------------------------------------------------*/ + +package frc.robot.commands; + +import edu.wpi.first.wpilibj.command.Command; +import frc.robot.Constants; +import frc.robot.Robot; + +public class SwitchCameras extends Command { + public SwitchCameras() { + super("SwitchCameras"); + requires(Robot.drivetrain); + // Use requires() here to declare subsystem dependencies + // eg. requires(chassis); + } + + // Called just before this Command runs the first time + @Override + protected void initialize() { + } + + // Called repeatedly when this Command is scheduled to run + @Override + protected void execute() { -// } - -// // Make this return true when this Command no longer needs to run execute() -// @Override -// protected boolean isFinished() { -// return false; -// } - -// // Called once after isFinished returns true -// @Override -// protected void end() { -// Robot.drivetrain.setMotors(0,0); -// } - -// // Called when another command which requires one or more of the same -// // subsystems is scheduled to run -// @Override -// protected void interrupted() { -// } -// } + } + + // Make this return true when this Command no longer needs to run execute() + @Override + protected boolean isFinished() { + return false; + } + + // Called once after isFinished returns true + @Override + protected void end() { + Robot.drivetrain.setMotors(0,0); + } + + // Called when another command which requires one or more of the same + // subsystems is scheduled to run + @Override + protected void interrupted() { + } +} diff --git a/src/main/java/frc/robot/commands/setCameraOne.java b/src/main/java/frc/robot/commands/setCameraOne.java index d65e6d4..6ebc0fe 100644 --- a/src/main/java/frc/robot/commands/setCameraOne.java +++ b/src/main/java/frc/robot/commands/setCameraOne.java @@ -45,4 +45,6 @@ protected void end() { @Override protected void interrupted() { } + + } diff --git a/src/main/java/frc/robot/subsystems/Camera.java b/src/main/java/frc/robot/subsystems/Camera.java index 543a3be..88f14a4 100644 --- a/src/main/java/frc/robot/subsystems/Camera.java +++ b/src/main/java/frc/robot/subsystems/Camera.java @@ -1,33 +1,22 @@ -// package frc.robot.subsystems; +package frc.robot.subsystems; -// import com.revrobotics.CANSparkMax; -// import com.revrobotics.CANSparkMax.IdleMode; -// import com.revrobotics.CANSparkMaxLowLevel.MotorType; +import edu.wpi.first.wpilibj.command.Subsystem; +import frc.robot.util.Camera_Switch.*; -// import com.revrobotics.CANEncoder; -// import com.revrobotics.AlternateEncoderType; +public class Camera extends Subsystem{ + public CameraSwitch cam_switch; + public Camera() { -// import edu.wpi.first.wpilibj.command.Subsystem; -// import edu.wpi.first.wpilibj.smartdashboard.SmartDashboard; + //Initialize Cameron Switch + cam_switch = new CameraSwitch(0, 1); + } + public void initDefaultCommand() { -// import frc.robot.Constants; -// import frc.robot.RobotMap; + } + public void setCameraNum(int camNum) { + cam_switch.select(camNum); + } -// import frc.robot.util.Camera_Switch.*; + public void debug (){} -// public class Camera extends Subsystem{ -// public CameraSwitch cam_switch; -// public Camera() { - -// //Initialize Cameron Switch -// cam_switch = new CameraSwitch(0, 1); -// } -// public void initDefaultCommand() { - -// } -// public void setCameraNum(int camNum) { -// cam_switch.select(camNum); -// } -// public void debug (){} - -// } byeeeee \ No newline at end of file +} \ No newline at end of file diff --git a/src/main/java/frc/robot/subsystems/Drivetrain.java b/src/main/java/frc/robot/subsystems/Drivetrain.java index 438207a..f71e8b7 100644 --- a/src/main/java/frc/robot/subsystems/Drivetrain.java +++ b/src/main/java/frc/robot/subsystems/Drivetrain.java @@ -113,6 +113,10 @@ public void setBrakeMode(boolean isbrake) { } } + public void stopCompletely() { + leftLeader.set(0); + rightLeader.set(0); + } public void debug() { diff --git a/src/main/java/frc/robot/subsystems/PanelMech.java b/src/main/java/frc/robot/subsystems/PanelMech.java index 05f63f9..10a19ba 100644 --- a/src/main/java/frc/robot/subsystems/PanelMech.java +++ b/src/main/java/frc/robot/subsystems/PanelMech.java @@ -1,52 +1,52 @@ -/*----------------------------------------------------------------------------*/ -/* Copyright (c) 2018-2019 FIRST. All Rights Reserved. */ -/* Open Source Software - may be modified and shared by FRC teams. The code */ -/* must be accompanied by the FIRST BSD license file in the root directory of */ -/* the project. */ -/*----------------------------------------------------------------------------*/ -//IMPORTED FROM CLIMBER-MAAZ BRANCH!!! -package frc.robot.subsystems; +// /*----------------------------------------------------------------------------*/ +// /* Copyright (c) 2018-2019 FIRST. All Rights Reserved. */ +// /* Open Source Software - may be modified and shared by FRC teams. The code */ +// /* must be accompanied by the FIRST BSD license file in the root directory of */ +// /* the project. */ +// /*----------------------------------------------------------------------------*/ +// //IMPORTED FROM CLIMBER-MAAZ BRANCH!!! +// package frc.robot.subsystems; -import com.revrobotics.CANSparkMax; -import com.revrobotics.CANSparkMaxLowLevel.MotorType; -import com.ctre.phoenix.motorcontrol.ControlMode; -import com.ctre.phoenix.motorcontrol.can.TalonSRX; +// import com.revrobotics.CANSparkMax; +// import com.revrobotics.CANSparkMaxLowLevel.MotorType; +// import com.ctre.phoenix.motorcontrol.ControlMode; +// import com.ctre.phoenix.motorcontrol.can.TalonSRX; -import edu.wpi.first.wpilibj.Solenoid; -import edu.wpi.first.wpilibj.command.Subsystem; -import edu.wpi.first.wpilibj.smartdashboard.SmartDashboard; +// import edu.wpi.first.wpilibj.Solenoid; +// import edu.wpi.first.wpilibj.command.Subsystem; +// import edu.wpi.first.wpilibj.smartdashboard.SmartDashboard; -import frc.robot.Constants; -import frc.robot.RobotMap; -// import frc.robot.commands.MoveShooter; -// import frc.robot.commands.MoveShooterPassive; -import frc.robot.util.Util; +// import frc.robot.Constants; +// import frc.robot.RobotMap; +// // import frc.robot.commands.MoveShooter; +// // import frc.robot.commands.MoveShooterPassive; +// import frc.robot.util.Util; -/** - * Add your docs here. - */ -public class PanelMech extends Subsystem { - private CANSparkMax panelMech_motor; - private Solenoid panelMech_soleinoid; - //private MoveShooterPassive defaultCommand; +// /** +// * Add your docs here. +// */ +// public class PanelMech extends Subsystem { +// private CANSparkMax panelMech_motor; +// private Solenoid panelMech_soleinoid; +// //private MoveShooterPassive defaultCommand; - public PanelMech(){ - panelMech_motor = new CANSparkMax(RobotMap.PANEL_NEO, MotorType.kBrushless); - panelMech_motor.setOpenLoopRampRate(Constants.kNeoRampTime); - panelMech_motor.set(0); - panelMech_soleinoid= new Solenoid(RobotMap.kPCM, RobotMap.PANEL_SOLENOID); - } - public void setPanelMech(final double velocity) { - panelMech_motor.set(velocity); - } - public void extendPanelMech(boolean extend) { - panelMech_soleinoid.set(extend); - } - @Override - protected void initDefaultCommand() { +// public PanelMech(){ +// panelMech_motor = new CANSparkMax(RobotMap.PANEL_NEO, MotorType.kBrushless); +// panelMech_motor.setOpenLoopRampRate(Constants.kNeoRampTime); +// panelMech_motor.set(0); +// panelMech_soleinoid= new Solenoid(RobotMap.kPCM, RobotMap.PANEL_SOLENOID); +// } +// public void setPanelMech(final double velocity) { +// panelMech_motor.set(velocity); +// } +// public void extendPanelMech(boolean extend) { +// panelMech_soleinoid.set(extend); +// } +// @Override +// protected void initDefaultCommand() { - } +// } - public void debug() { - } -} \ No newline at end of file +// public void debug() { +// } +// } \ No newline at end of file diff --git a/src/main/java/frc/robot/util/Camera_Switch/CameraSwitch.java b/src/main/java/frc/robot/util/Camera_Switch/CameraSwitch.java index a9cadc4..89a421c 100644 --- a/src/main/java/frc/robot/util/Camera_Switch/CameraSwitch.java +++ b/src/main/java/frc/robot/util/Camera_Switch/CameraSwitch.java @@ -22,6 +22,7 @@ import edu.wpi.first.wpilibj.Relay; import edu.wpi.first.wpilibj.Relay.Value; +import edu.wpi.first.wpilibj.smartdashboard.SmartDashboard; import edu.wpi.first.wpilibj.DigitalOutput; import edu.wpi.first.wpilibj.Victor; @@ -39,7 +40,7 @@ public class CameraSwitch implements RelayPortDevice{ public DigitalOutput DO; public Victor pwm; - + private int cameraState; public CameraSwitch(int port1, int port2){ camrelay1 = new Relay(port1); @@ -51,23 +52,23 @@ public void select(int camSelected){ /* enter the constant strings for the switch into this method to select cameras constants for cameras are- "kcamera(camera#)" (these can be changed in the switch statment) This switch has four possible ports. */ - + cameraState = camSelected; switch (camSelected) { case kcamera1 : - // camrelay1.set(Value.kReverse); - // camrelay.set(Value.kForward); - + camrelay1.set(Value.kReverse); + camrelay2.set(Value.kOff); break; case kcamera2 : - // camrelay1.set(Value.kForward); + camrelay1.set(Value.kForward); + camrelay2.set(Value.kOff); break; case kcamera3 : camrelay2.set(Value.kReverse); - // camrelay.set(Value.kOn); + camrelay1.set(Value.kOff); case kcamera4 : camrelay2.set(Value.kForward); - // camrelay.set(Value.kOff); + camrelay1.set(Value.kOff); break; default: camrelay1.set(Value.kReverse); @@ -97,6 +98,9 @@ public void setLocalRelay(Relay.Value klocalValue) { System.err.println("setLocalRelay(Relay.Value klocalValue); method not utilized in CameraSwitch.java"); }//DO NOT USE THIS METHOD + public void debug() { + SmartDashboard.putNumber("Camera Number: ", cameraState); + } } //end of file----------------------------------------------------------------------- From 75062f8943cd978d43eedba5c44f0d25620d89ef Mon Sep 17 00:00:00 2001 From: John Date: Tue, 25 Feb 2020 22:38:57 -0500 Subject: [PATCH 21/68] reorganized a couple things --- src/main/java/frc/robot/Constants.java | 5 +- src/main/java/frc/robot/OI.java | 140 +++---- src/main/java/frc/robot/Robot.java | 3 - src/main/java/frc/robot/RobotMap.java | 4 +- .../java/frc/robot/commands/SetPanelmech.java | 15 +- .../java/frc/robot/subsystems/Drivetrain.java | 1 + .../LSM9DS1_Accelerometer_Range.java | 8 + .../util/IMU/Constants/LSM9DS1_Constants.java | 41 ++ .../Constants/LSM9DS1_Gyroscope_Scale.java | 7 + .../Constants/LSM9DS1_Magnetometer_Gain.java | 8 + src/main/java/frc/robot/util/IMU/LSM9DS1.java | 369 ++++++++++++++++++ 11 files changed, 517 insertions(+), 84 deletions(-) create mode 100644 src/main/java/frc/robot/util/IMU/Constants/LSM9DS1_Accelerometer_Range.java create mode 100644 src/main/java/frc/robot/util/IMU/Constants/LSM9DS1_Constants.java create mode 100644 src/main/java/frc/robot/util/IMU/Constants/LSM9DS1_Gyroscope_Scale.java create mode 100644 src/main/java/frc/robot/util/IMU/Constants/LSM9DS1_Magnetometer_Gain.java create mode 100644 src/main/java/frc/robot/util/IMU/LSM9DS1.java diff --git a/src/main/java/frc/robot/Constants.java b/src/main/java/frc/robot/Constants.java index 0ab3860..7498ffa 100644 --- a/src/main/java/frc/robot/Constants.java +++ b/src/main/java/frc/robot/Constants.java @@ -106,7 +106,6 @@ public final class Constants { public static final int BALL_VALUE = 2300; - public static final double PANEL_MECH_FAST = 0.45; //climber @@ -119,6 +118,6 @@ public final class Constants { //Panel Mech public static final double PANEL_MECH_CREEP = 0.1; - public static final double PANEL_MECH_FAST = 0.5; - + public static final double PANEL_MECH_FAST = 0.45; + } \ No newline at end of file diff --git a/src/main/java/frc/robot/OI.java b/src/main/java/frc/robot/OI.java index 04cf451..c6d0db5 100644 --- a/src/main/java/frc/robot/OI.java +++ b/src/main/java/frc/robot/OI.java @@ -109,30 +109,30 @@ public OI() { // // driverLB.whenReleased(new StopShooterGroupLong()); -// operatorDPadLeft.whenPressed(new ShooterGroupLong()); -// operatorDPadLeft.whenReleased(new Stop()); + operatorDPadLeft.whenPressed(new ShooterGroupLong()); + operatorDPadLeft.whenReleased(new Stop()); -// operatorDPadRight.whenPressed(new ShooterGroupWall()); -// operatorDPadRight.whenReleased(new Stop()); + operatorDPadRight.whenPressed(new ShooterGroupWall()); + operatorDPadRight.whenReleased(new Stop()); -// operatorA.whenPressed(new MoveHopperLong()); -// operatorA.whenReleased(new StopHopper()); + operatorA.whenPressed(new MoveHopperLong()); + operatorA.whenReleased(new StopHopper()); -// operatorB.whenPressed(new LongShotHood()); -// operatorB.whenReleased(new WallShotHood()); + operatorB.whenPressed(new LongShotHood()); + operatorB.whenReleased(new WallShotHood()); -// operatorY.whenPressed(new ReverseHopper()); -// operatorY.whenReleased(new StopHopper()); + operatorY.whenPressed(new ReverseHopper()); + operatorY.whenReleased(new StopHopper()); -// operatorX.whenPressed(new IrHopper()); -// operatorX.whenReleased(new StopHopper()); + operatorX.whenPressed(new IrHopper()); + operatorX.whenReleased(new StopHopper()); -// operatorRB.whenPressed(new WallShot()); -// operatorRB.whenReleased(new StopShooter()); + operatorRB.whenPressed(new WallShot()); + operatorRB.whenReleased(new StopShooter()); -// operatorLB.whenPressed(new LongShot()); -// operatorLB.whenReleased(new StopShooter()); + operatorLB.whenPressed(new LongShot()); + operatorLB.whenReleased(new StopShooter()); @@ -182,58 +182,58 @@ public OI() { } -// private void initButtons(){ -// try{ -// //DRIVER BUTTONS// -// driverA = new JoystickButton(driverStick, 1); -// driverB = new JoystickButton(driverStick, 2); -// driverX = new JoystickButton(driverStick,3); -// driverY = new JoystickButton(driverStick,4); -// driverBack = new JoystickButton(driverStick, 7); -// driverStart = new JoystickButton(driverStick, 8); -// driverRB = new JoystickButton(driverStick, 6); -// driverLB = new JoystickButton(driverStick, 5); -// driverLS = new JoystickButton(driverStick,9); -// // driverRS = new JoystickButton(driverStick,10); -// driverRX = new AnalogButton(driverStick, 4); -// driverDPadDown = new DPadButton(driverStick, DPadButton.kDPadDown); -// driverDPadRight = new DPadButton(driverStick, DPadButton.kDPadRight); -// // driverDPadUp = new DPadButton(driverStick, DPadButton.kDPadUp); -// driverDPadLeft = new DPadButton(driverStick, DPadButton.kDPadLeft); -// driveButton = new MultiButton(new Button[] { -// new AnalogButton(driverStick, 3, 2, 0, 0.2), -// driverRB, -// driverLB -// }); - -// //OPERATOR BUTTONS// -// operatorA = new JoystickButton(operatorStick, 1); -// operatorB = new JoystickButton(operatorStick, 2); -// operatorX = new JoystickButton(operatorStick, 3); -// operatorY = new JoystickButton(operatorStick, 4); -// operatorBack = new JoystickButton(operatorStick,7); -// operatorStart = new JoystickButton(driverStick, 8); -// operatorRB = new JoystickButton(operatorStick, 6); -// operatorLB = new JoystickButton(operatorStick, 5); -// operatorLT = new AnalogButton(operatorStick, 2); -// operatorRT = new AnalogButton(operatorStick, 3); -// operatorLS = new AnalogButton(operatorStick, 1); -// operatorDPadDown = new DPadButton(operatorStick, DPadButton.kDPadDown); -// operatorDPadLeft = new DPadButton(operatorStick, DPadButton.kDPadLeft); -// } - -// catch (Exception error){ -// System.out.println("Error Init With Buttons"); -// error.printStackTrace(); -// } -// } + private void initButtons(){ + try{ +//DRIVER BUTTONS// + driverA = new JoystickButton(driverStick, 1); + driverB = new JoystickButton(driverStick, 2); + driverX = new JoystickButton(driverStick,3); + driverY = new JoystickButton(driverStick,4); + driverBack = new JoystickButton(driverStick, 7); + driverStart = new JoystickButton(driverStick, 8); + driverRB = new JoystickButton(driverStick, 6); + driverLB = new JoystickButton(driverStick, 5); + driverLS = new JoystickButton(driverStick,9); + // driverRS = new JoystickButton(driverStick,10); + driverRX = new AnalogButton(driverStick, 4); + driverDPadDown = new DPadButton(driverStick, DPadButton.kDPadDown); + driverDPadRight = new DPadButton(driverStick, DPadButton.kDPadRight); + // driverDPadUp = new DPadButton(driverStick, DPadButton.kDPadUp); + driverDPadLeft = new DPadButton(driverStick, DPadButton.kDPadLeft); + driveButton = new MultiButton(new Button[] { + new AnalogButton(driverStick, 3, 2, 0, 0.2), + driverRB, + driverLB + }); + +//OPERATOR BUTTONS// + operatorA = new JoystickButton(operatorStick, 1); + operatorB = new JoystickButton(operatorStick, 2); + operatorX = new JoystickButton(operatorStick, 3); + operatorY = new JoystickButton(operatorStick, 4); + operatorBack = new JoystickButton(operatorStick,7); + operatorStart = new JoystickButton(driverStick, 8); + operatorRB = new JoystickButton(operatorStick, 6); + operatorLB = new JoystickButton(operatorStick, 5); + operatorLT = new AnalogButton(operatorStick, 2); + operatorRT = new AnalogButton(operatorStick, 3); + operatorLS = new AnalogButton(operatorStick, 1); + operatorDPadDown = new DPadButton(operatorStick, DPadButton.kDPadDown); + operatorDPadLeft = new DPadButton(operatorStick, DPadButton.kDPadLeft); + } + + catch (Exception error){ + System.out.println("Error Init With Buttons"); + error.printStackTrace(); + } + } -// private void initUsed(){ -// operatorLeftJoystickUsed = new Button() { -// @Override -// public boolean get() { -// return Math.abs(Util.deadzone(Constants.DEADZONE, operatorStick.getRawAxis(1), 1.0)) > 0.08; -// } -// }; -// } -// } + private void initUsed(){ + operatorLeftJoystickUsed = new Button() { + @Override + public boolean get() { + return Math.abs(Util.deadzone(Constants.DEADZONE, operatorStick.getRawAxis(1), 1.0)) > 0.08; + } + }; + } +} diff --git a/src/main/java/frc/robot/Robot.java b/src/main/java/frc/robot/Robot.java index 5fb4cc0..698b6a6 100644 --- a/src/main/java/frc/robot/Robot.java +++ b/src/main/java/frc/robot/Robot.java @@ -12,7 +12,6 @@ import edu.wpi.first.cameraserver.CameraServer; -======= import frc.robot.subsystems.Climber; import frc.robot.subsystems.*; @@ -36,7 +35,6 @@ public class Robot extends TimedRobot { public static CameraServer Cam; public static CameraSwitch Cam_switch; -======= public static Climber climber; @Override @@ -55,7 +53,6 @@ public void robotInit() { compressor = new Compressor(RobotMap.kPCM); compressor.start(); Cam.startAutomaticCapture(0); -======= climber = new Climber(); } diff --git a/src/main/java/frc/robot/RobotMap.java b/src/main/java/frc/robot/RobotMap.java index c218e62..e28fb7d 100644 --- a/src/main/java/frc/robot/RobotMap.java +++ b/src/main/java/frc/robot/RobotMap.java @@ -87,15 +87,13 @@ public class RobotMap { //Hopper // public static final int HOPPER_TALON = 40; //Drivetrain - public static final int DRIVETRAIN_NEO = 3; public static final int HOOD_SOLENOID = 3; public static final int HOPPER_SOLENOID = 1; public static final int VERTICAL_HOPPER = 41; public static final int HORIZONTAL_HOPPER = 42; public static final int MANIPULATOR_SOLENOID = 6; public static final int MANIPULATOR_NEO = 40; -public static final int PANEL_NEO = 50; -public static final int PANEL_SOLENOID = 2; + public static final int DRIVETRAIN_NEO = 22; diff --git a/src/main/java/frc/robot/commands/SetPanelmech.java b/src/main/java/frc/robot/commands/SetPanelmech.java index d0b2aea..cd8318b 100644 --- a/src/main/java/frc/robot/commands/SetPanelmech.java +++ b/src/main/java/frc/robot/commands/SetPanelmech.java @@ -1,4 +1,9 @@ -//IMPORTED FROM CLIMBER-MAAZ BRANCH!!!! +/*----------------------------------------------------------------------------*/ +/* Copyright (c) 2018-2019 FIRST. All Rights Reserved. */ +/* Open Source Software - may be modified and shared by FRC teams. The code */ +/* must be accompanied by the FIRST BSD license file in the root directory of */ +/* the project. */ +/*----------------------------------------------------------------------------*/ package frc.robot.commands; @@ -23,8 +28,8 @@ protected void initialize() { //Called repeatedly when this Command is scheduled to run @Override protected void execute() { - Robot.panelMech.extendPanelMech(true); - Robot.panelMech.setPanelMech(Constants.PANEL_MECH_FAST); + Robot.panelMech.setPanelMech(0); + // Robot.panelMech.setManipulator(0); } //Make this return true when this Command no longer needs to run execute() @@ -36,7 +41,7 @@ protected boolean isFinished() { //Called once after isFinished returns true @Override protected void end() { - + Robot.panelMech.setPanelMech(0); } //Called when another command which requires one or more of the same @@ -46,4 +51,4 @@ protected void end() { protected void interrupted() { //Yes } -} \ No newline at end of file +} diff --git a/src/main/java/frc/robot/subsystems/Drivetrain.java b/src/main/java/frc/robot/subsystems/Drivetrain.java index 438207a..27a405e 100644 --- a/src/main/java/frc/robot/subsystems/Drivetrain.java +++ b/src/main/java/frc/robot/subsystems/Drivetrain.java @@ -13,6 +13,7 @@ import frc.robot.Constants; import frc.robot.RobotMap; + import frc.robot.util.Camera_Switch.*; public class Drivetrain extends Subsystem { diff --git a/src/main/java/frc/robot/util/IMU/Constants/LSM9DS1_Accelerometer_Range.java b/src/main/java/frc/robot/util/IMU/Constants/LSM9DS1_Accelerometer_Range.java new file mode 100644 index 0000000..20e3f2f --- /dev/null +++ b/src/main/java/frc/robot/util/IMU/Constants/LSM9DS1_Accelerometer_Range.java @@ -0,0 +1,8 @@ +package frc.robot.util.LSM9DS1_Accelerometer_Range; + +public enum LSM9DS1_Accelerometer_Range { + LSM9DS1_ACCELEROMETER_2G, + LSM9DS1_ACCELEROMETER_4G, + LSM9DS1_ACCELEROMETER_8G, + LSM9DS1_ACCELEROMETER_16G +} diff --git a/src/main/java/frc/robot/util/IMU/Constants/LSM9DS1_Constants.java b/src/main/java/frc/robot/util/IMU/Constants/LSM9DS1_Constants.java new file mode 100644 index 0000000..d3a6b54 --- /dev/null +++ b/src/main/java/frc/robot/util/IMU/Constants/LSM9DS1_Constants.java @@ -0,0 +1,41 @@ +package com.varel.gereon.components.IMU.Constants; + +public final class LSM9DS1_Constants { + + public static final float EARTH_GRAVITY = 9.80665f; + public static final float DPS_TO_RADS = 0.017453293f; + + public static final byte LSM9DS1_M_ADDR = (byte)0x1E; + public static final byte LSM9DS1_XG_ADDR = (byte)0x6B; + + public static final byte LSM9DS1_REGISTER_WHO_AM_I_XG = 0x0F; + public static final byte LSM9DS1_REGISTER_CTRL_REG1_G = 0x10; + public static final byte LSM9DS1_REGISTER_CTRL_REG2_G = 0x11; + public static final byte LSM9DS1_REGISTER_CTRL_REG3_G = 0x12; + public static final byte LSM9DS1_REGISTER_STATUS_REG = 0x17; + public static final byte LSM9DS1_REGISTER_OUT_X_L_G = 0x18; + public static final byte LSM9DS1_REGISTER_OUT_X_H_G = 0x19; + public static final byte LSM9DS1_REGISTER_OUT_Y_L_G = 0x1A; + public static final byte LSM9DS1_REGISTER_OUT_Y_H_G = 0x1B; + public static final byte LSM9DS1_REGISTER_OUT_Z_L_G = 0x1C; + public static final byte LSM9DS1_REGISTER_OUT_Z_H_G = 0x1D; + public static final byte LSM9DS1_REGISTER_CTRL_REG4 = 0x1E; + public static final byte LSM9DS1_REGISTER_CTRL_REG5_XL = 0x1F; + public static final byte LSM9DS1_REGISTER_CTRL_REG6_XL = 0x20; + public static final byte LSM9DS1_REGISTER_CTRL_REG7_XL = 0x21; + public static final byte LSM9DS1_REGISTER_CTRL_REG8 = 0x22; + public static final byte LSM9DS1_REGISTER_CTRL_REG9 = 0x23; + public static final byte LSM9DS1_REGISTER_CTRL_REG10 = 0x24; + + public static final byte LSM9DS1_REGISTER_TEMP_OUT_L = 0x05; + public static final byte LSM9DS1_REGISTER_TEMP_OUT_H = 0x06; + public static final byte LSM9DS1_REGISTER_OUT_X_L_XL = 0x28; + public static final byte LSM9DS1_REGISTER_OUT_X_H_XL = 0x29; + public static final byte LSM9DS1_REGISTER_OUT_Y_L_XL = 0x2A; + public static final byte LSM9DS1_REGISTER_OUT_Y_H_XL = 0x2B; + public static final byte LSM9DS1_REGISTER_OUT_Z_L_XL = 0x2C; + public static final byte LSM9DS1_REGISTER_OUT_Z_H_XL = 0x2D; + + private LSM9DS1_Constants() { } + +} diff --git a/src/main/java/frc/robot/util/IMU/Constants/LSM9DS1_Gyroscope_Scale.java b/src/main/java/frc/robot/util/IMU/Constants/LSM9DS1_Gyroscope_Scale.java new file mode 100644 index 0000000..e98d868 --- /dev/null +++ b/src/main/java/frc/robot/util/IMU/Constants/LSM9DS1_Gyroscope_Scale.java @@ -0,0 +1,7 @@ +package com.varel.gereon.components.IMU.Constants; + +public enum LSM9DS1_Gyroscope_Scale { + LSM9DS1_GYROSCOPE_245DPS, + LSM9DS1_GYROSCOPE_500DPS, + LSM9DS1_GYROSCOPE_2000DPS +} diff --git a/src/main/java/frc/robot/util/IMU/Constants/LSM9DS1_Magnetometer_Gain.java b/src/main/java/frc/robot/util/IMU/Constants/LSM9DS1_Magnetometer_Gain.java new file mode 100644 index 0000000..021ed2e --- /dev/null +++ b/src/main/java/frc/robot/util/IMU/Constants/LSM9DS1_Magnetometer_Gain.java @@ -0,0 +1,8 @@ +package com.varel.gereon.components.IMU.Constants; + +public enum LSM9DS1_Magnetometer_Gain { + LSM9DS1_MAGNETOMETER_4GAUSS, + LSM9DS1_MAGNETOMETER_8GAUSS, + LSM9DS1_MAGNETOMETER_12GAUSS, + LSM9DS1_MAGNETOMETER_16GAUSS +} diff --git a/src/main/java/frc/robot/util/IMU/LSM9DS1.java b/src/main/java/frc/robot/util/IMU/LSM9DS1.java new file mode 100644 index 0000000..389ef4e --- /dev/null +++ b/src/main/java/frc/robot/util/IMU/LSM9DS1.java @@ -0,0 +1,369 @@ +// package frc.robot.util.IMU; + +// import com.pi4j.io.i2c.I2CBus; +// import com.pi4j.io.i2c.I2CDevice; +// import com.pi4j.io.i2c.I2CFactory; + +// import edu.wpi.first.wpilibj.I2C; +// import edu.wpi.first.wpilibj.I2C.Port; + +// import java.io.IOException; +// import java.text.DecimalFormat; +// import frc.robot.util.IMU.Constants.*; + +// public class LSM9DS1 { + +// private int temperature = 0; +// private long deltaTime = 0; +// private double rollXLFilteredOld = 0.0d; +// private double pitchXLFilteredOld = 0.0d; +// private double roll = 0.0d; +// private double pitch = 0.0d; +// private double yaw = 0.0d; +// private I2C bus; +// private I2CDevice magnetometer; +// private I2CDevice accelerometerGyro; +// private AccelerometerData accelerometerData; +// private GyroscopeData gyroscopeData; +// private MagnetometerData magnetometerData; + +// /** +// * Creates an instance using the default settings. (2G, 245DPS, 4GAUSS) +// */ +// public LSM9DS1() { +// this.setup(LSM9DS1_Accelerometer_Range.LSM9DS1_ACCELEROMETER_2G, LSM9DS1_Gyroscope_Scale.LSM9DS1_GYROSCOPE_245DPS, LSM9DS1_Magnetometer_Gain.LSM9DS1_MAGNETOMETER_4GAUSS); +// } + +// /** +// * Creates an instance using the specified settings. +// * +// * @param accelerometerRange AccelerometerRange that will be used. +// * @param gyroscopeScale GyroscopeScale that will be used. +// * @param magnetometerRange MagnetometerRange that will be used. +// */ +// public LSM9DS1(LSM9DS1_Accelerometer_Range accelerometerRange, LSM9DS1_Gyroscope_Scale gyroscopeScale, LSM9DS1_Magnetometer_Gain magnetometerRange) { +// this.setup(accelerometerRange, gyroscopeScale, magnetometerRange); +// } + +// private void setup(LSM9DS1_Accelerometer_Range accelerometerRange, LSM9DS1_Gyroscope_Scale gyroscopeRange, LSM9DS1_Magnetometer_Gain magnetometerRange) { +// try { +// this.bus = I2CFactory.getInstance(I2CBus.BUS_1); +// this.magnetometer = this.bus.getDevice(LSM9DS1_M_ADDR); +// this.accelerometerGyro = this.bus.getDevice(LSM9DS1_XG_ADDR); +// this.accelerometerData = new AccelerometerData(); +// this.gyroscopeData = new GyroscopeData(); +// this.magnetometerData = new MagnetometerData(); +// this.begin(accelerometerRange, gyroscopeRange, magnetometerRange); +// } catch (I2CFactory.UnsupportedBusNumberException | IOException ex) { +// ex.printStackTrace(); +// } +// } + +// private void begin(LSM9DS1_Accelerometer_Range accelerometerRange, LSM9DS1_Gyroscope_Scale gyroscopeRange, LSM9DS1_Magnetometer_Gain magnetometerRange) { +// // soft reset & reboot accelerometer/gyroscope +// this.writeRegister(true, LSM9DS1_REGISTER_CTRL_REG8, (byte) 0x05); +// try { // TODO: might be unnecessary +// Thread.sleep(10); +// } catch (InterruptedException ex) { +// ex.printStackTrace(); +// } +// int id = readRegister(true, LSM9DS1_REGISTER_WHO_AM_I_XG); +// if (id != 104) { +// System.out.println("Error identifying the device!"); +// return; +// } +// // TODO: enable temperature sensor +// // this.write8(true, LSM9DS1_REGISTER_CTRL_REG10, (byte)0xF4); + +// // enable gyro continuous +// this.writeRegister(true, LSM9DS1_REGISTER_CTRL_REG4, (byte) 0x38); + +// // enable the accelerometer continuously +// this.writeRegister(true, LSM9DS1_REGISTER_CTRL_REG5_XL, (byte) 0x38); +// this.writeRegister(true, LSM9DS1_REGISTER_CTRL_REG6_XL, (byte) 0xC0); +// // activate accelerometer high resolution mode +// this.writeRegister(true, LSM9DS1_REGISTER_CTRL_REG7_XL, (byte) 0x80); + +// // set default ranges for the various sensors +// this.setupAccelerometer(accelerometerRange); +// this.setupGyroscope(gyroscopeRange); +// this.setupMagnetometer(magnetometerRange); +// } + +// private void setupAccelerometer(LSM9DS1_Accelerometer_Range range) { +// int reg = readRegister(true, LSM9DS1_REGISTER_CTRL_REG6_XL); +// reg &= ~(0b00011000); +// byte rangeData = 0b00; +// if (range == LSM9DS1_Accelerometer_Range.LSM9DS1_ACCELEROMETER_2G) { +// this.accelerometerData.setAccelerometerMgLsb(0.061f); +// } else if (range == LSM9DS1_Accelerometer_Range.LSM9DS1_ACCELEROMETER_4G) { +// rangeData = (0b10 << 3); +// this.accelerometerData.setAccelerometerMgLsb(0.122f); +// } else if (range == LSM9DS1_Accelerometer_Range.LSM9DS1_ACCELEROMETER_8G) { +// rangeData = (0b11 << 3); +// this.accelerometerData.setAccelerometerMgLsb(0.244f); +// } else if (range == LSM9DS1_Accelerometer_Range.LSM9DS1_ACCELEROMETER_16G) { +// rangeData = (0b01 << 3); +// this.accelerometerData.setAccelerometerMgLsb(0.732f); +// } +// reg |= rangeData; +// writeRegister(true, LSM9DS1_REGISTER_CTRL_REG6_XL, (byte)reg); +// } + +// private void setupGyroscope(LSM9DS1_Gyroscope_Scale range) { +// int reg = readRegister(true, LSM9DS1_REGISTER_CTRL_REG1_G); +// reg &= ~(0b00110000); +// byte rangeData = 0b00; +// if (range == LSM9DS1_Gyroscope_Scale.LSM9DS1_GYROSCOPE_245DPS) { +// this.gyroscopeData.setGyroDpsDigit(0.00875f); +// } else if (range == LSM9DS1_Gyroscope_Scale.LSM9DS1_GYROSCOPE_500DPS) { +// rangeData = (0b01 << 4); +// this.gyroscopeData.setGyroDpsDigit(0.01750f); +// } else if (range == LSM9DS1_Gyroscope_Scale.LSM9DS1_GYROSCOPE_2000DPS) { +// rangeData = (0b11 << 4); +// this.gyroscopeData.setGyroDpsDigit(0.07000f); +// } +// reg |= rangeData; +// writeRegister(true, LSM9DS1_REGISTER_CTRL_REG1_G, (byte)reg); +// } + +// private void setupMagnetometer(LSM9DS1_Magnetometer_Gain range) { +// // TODO +// } + +// private void readAccelerometerOrGyroscope(boolean readAccelerometer) { +// byte reg; +// if (readAccelerometer) { +// reg = (byte)(0x80 | LSM9DS1_REGISTER_OUT_X_L_XL); +// } else { +// reg = (byte)(0x80 | LSM9DS1_REGISTER_OUT_X_L_G); +// } +// byte[] buffer = this.readBuffer(true, reg, (byte)6); + +// int xAxis = (((int) buffer[1]) << 8) | (buffer[0] & 0xFF); +// int yAxis = (((int) buffer[3]) << 8) | (buffer[2] & 0xFF); +// int zAxis = (((int) buffer[5]) << 8) | (buffer[4] & 0xFF); + +// if (readAccelerometer) { +// this.accelerometerData.x = xAxis; +// this.accelerometerData.y = yAxis; +// this.accelerometerData.z = zAxis; +// } else { +// this.gyroscopeData.x = xAxis; +// this.gyroscopeData.y = yAxis; +// this.gyroscopeData.z = zAxis; +// } +// } + +// private void readMagnetometer() { +// // TODO +// } + +// private void readTemperature() { +// byte reg = (byte)(0x80 | LSM9DS1_REGISTER_TEMP_OUT_L); +// byte[] buffer = this.readBuffer(true, reg, (byte)2); +// this.temperature = (((int) buffer[1] << 8) | (buffer[0] & 0xFF)); +// } + +// private void writeRegister(boolean writerAccelerometerGyroscope, byte register, byte value) { +// try { +// if (writerAccelerometerGyroscope) { +// this.accelerometerGyro.write(register, value); +// } else { +// this.magnetometer.write(register, value); +// } +// } catch (IOException ex) { +// ex.printStackTrace(); +// } +// } + +// private byte readRegister(boolean readAccelerometerGyroscope, byte register) { +// byte[] value = this.readBuffer(readAccelerometerGyroscope, register, (byte)1); +// return value[0]; +// } + +// private byte[] readBuffer(boolean readAccelerometerGyro, byte register, byte length) { +// byte[] buffer = new byte[length]; +// try { +// if (readAccelerometerGyro) { +// this.accelerometerGyro.write(register); +// this.accelerometerGyro.read(buffer, 0, length); +// } else { +// // TODO Magnetometer read +// } +// } catch (IOException ex) { +// ex.printStackTrace(); +// } +// return buffer; +// } + +// /** +// * Reads and stores all data from the IMU. Also calculates Euler angles. +// */ +// public void read() { +// this.readAccelerometerOrGyroscope(true); +// this.readAccelerometerOrGyroscope(false); +// this.readMagnetometer(); +// // this.readTemperature(); +// this.calculateEulerAngles(); +// } + +// /** +// * @return Returns the last saved data from the accelerometer. +// */ +// public float[] getAccelerometerData() { +// float[] accelerometerData = new float[3]; +// accelerometerData[0] = this.accelerometerData.getX(); +// accelerometerData[1] = this.accelerometerData.getY(); +// accelerometerData[2] = this.accelerometerData.getZ(); +// return accelerometerData; +// } + +// /** +// * @return Returns the last saved data from the gyroscope. +// */ +// public float[] getGyroscopeData() { +// float[] gyroscopeData = new float[3]; +// gyroscopeData[0] = this.gyroscopeData.getX(); +// gyroscopeData[1] = this.gyroscopeData.getY(); +// gyroscopeData[2] = this.gyroscopeData.getZ(); +// return gyroscopeData; +// } + +// /** +// * @return Returns the last saved data from the magnetometer. +// */ +// public float[] getMagnetometerData() { +// float[] magnetometerData = new float[3]; +// magnetometerData[0] = this.magnetometerData.getX(); +// magnetometerData[1] = this.magnetometerData.getY(); +// magnetometerData[2] = this.magnetometerData.getZ(); +// return magnetometerData; +// } + +// /** +// * @return Returns the last saved raw data from the temperature sensor. +// */ +// public int getTemperature() { +// return this.temperature; +// } + +// /** +// * @return Returns the last calculated pitch. +// */ +// public double getPitch() { +// return this.pitch; +// } + +// /** +// * @return Returns the last calculated roll. +// */ +// public double getRoll() { +// return this.roll; +// } + +// /** +// * @return Returns the last calculated yaw. +// */ +// public double getYaw() { +// return this.yaw; +// } + +// private void calculateEulerAngles() { +// // Measured angle by the accelerometer +// double rollXLMeasured = Math.atan2(this.accelerometerData.getX() / EARTH_GRAVITY, this.accelerometerData.getZ() / EARTH_GRAVITY) / 2 / Math.PI * 360; +// double pitchXLMeasured = Math.atan2(this.accelerometerData.getY() / EARTH_GRAVITY, this.accelerometerData.getZ() / EARTH_GRAVITY) / 2 / Math.PI * 360; + +// // Adding a low pass filter +// double rollXLFiltered = 0.9f * rollXLFilteredOld + 0.1f * rollXLMeasured; +// double pitchXLFiltered = 0.9f * pitchXLFilteredOld + 0.1f * pitchXLMeasured; +// this.rollXLFilteredOld = rollXLFiltered; +// this.pitchXLFilteredOld = pitchXLFiltered; + +// // Calculating deltaTime +// long time = System.nanoTime(); +// int difference = (int) ((time - this.deltaTime) / 1000000000); +// this.deltaTime = time; + +// // Adding a complementary filter +// this.roll = 0.95f * (this.roll + this.gyroscopeData.getY() * difference) + 0.05f * rollXLMeasured; +// this.pitch = 0.95f * (this.pitch - this.gyroscopeData.getX() * difference) + 0.05f * pitchXLMeasured; +// } + +// /** +// * Closes the currently used I2C bus. +// * +// * @throws IOException Throws when the I2C bus could not be closed. +// */ +// public void close() throws IOException { +// this.bus.close(); +// } + +// private static class AccelerometerData { +// private float x = 0.0f; +// private float y = 0.0f; +// private float z = 0.0f; +// private float accelerometerMgLsb = 0.0f; + +// public void setAccelerometerMgLsb(float accelerometerMgLsb) { +// this.accelerometerMgLsb = accelerometerMgLsb; +// } + +// public float getX() { +// return (x * accelerometerMgLsb / 1000 * EARTH_GRAVITY); +// } + +// public float getY() { +// return (y * accelerometerMgLsb / 1000 * EARTH_GRAVITY); +// } + +// public float getZ() { +// return (z * accelerometerMgLsb / 1000 * EARTH_GRAVITY); +// } + +// } + +// private static class GyroscopeData { +// private float x = 0.0f; +// private float y = 0.0f; +// private float z = 0.0f; +// private float gyroDpsDigit = 0.0f; + + +// public void setGyroDpsDigit(float gyroDpsDigit) { +// this.gyroDpsDigit = gyroDpsDigit; +// } + +// public float getX() { +// return (x * gyroDpsDigit * DPS_TO_RADS); +// } + +// public float getY() { +// return (y * gyroDpsDigit * DPS_TO_RADS); +// } + +// public float getZ() { +// return (z * gyroDpsDigit * DPS_TO_RADS); +// } + +// } + +// private static class MagnetometerData { +// private float x = 0.0f; +// private float y = 0.0f; +// private float z = 0.0f; + +// public float getX() { +// return x; +// } + +// public float getY() { +// return y; +// } + +// public float getZ() { +// return z; +// } + +// } +// } From f249020850aee32641bf1ba134bf367ac6b904cc Mon Sep 17 00:00:00 2001 From: frcteam2791 Date: Wed, 26 Feb 2020 13:30:21 -0800 Subject: [PATCH 22/68] merged climb --- src/main/java/frc/robot/Constants.java | 10 +- src/main/java/frc/robot/RobotMap.java | 3 - .../robot/commands/Climb/ActivePosition.java | 128 +++++++++--------- .../java/frc/robot/commands/SetPanelMech.java | 84 ++++++------ .../java/frc/robot/subsystems/Climber.java | 121 +++++++++-------- 5 files changed, 174 insertions(+), 172 deletions(-) diff --git a/src/main/java/frc/robot/Constants.java b/src/main/java/frc/robot/Constants.java index 65823f7..3cb4761 100644 --- a/src/main/java/frc/robot/Constants.java +++ b/src/main/java/frc/robot/Constants.java @@ -64,11 +64,13 @@ public final class Constants { public static final double ELEVATOR_OUTPUT = -.05; - public static final double HOPPER_LOADING_HORIZONTAL_OUTPUT = .40; // 20% is sweet spot + public static final double HOPPER_LOADING_HORIZONTAL_OUTPUT = .40; public static final double HOPPER_WALL_HORIZONTAL_OUTPUT = 0.30; + public static final double HOPPER_LONG_HORIZONTAL_OUTPUT = .2; + public static final double HOPPER_VERTICAL_OUTPUT = .55; @@ -121,4 +123,10 @@ public final class Constants { //Panel Mech public static final double PANEL_MECH_CREEP = 0.1; + + + public static final double kSelfClimbGoRight = 0; //change + + + public static final double kSelfClimbGoLeft = 0; //change } \ No newline at end of file diff --git a/src/main/java/frc/robot/RobotMap.java b/src/main/java/frc/robot/RobotMap.java index c218e62..e1d59db 100644 --- a/src/main/java/frc/robot/RobotMap.java +++ b/src/main/java/frc/robot/RobotMap.java @@ -87,15 +87,12 @@ public class RobotMap { //Hopper // public static final int HOPPER_TALON = 40; //Drivetrain - public static final int DRIVETRAIN_NEO = 3; public static final int HOOD_SOLENOID = 3; public static final int HOPPER_SOLENOID = 1; public static final int VERTICAL_HOPPER = 41; public static final int HORIZONTAL_HOPPER = 42; public static final int MANIPULATOR_SOLENOID = 6; public static final int MANIPULATOR_NEO = 40; -public static final int PANEL_NEO = 50; -public static final int PANEL_SOLENOID = 2; public static final int DRIVETRAIN_NEO = 22; diff --git a/src/main/java/frc/robot/commands/Climb/ActivePosition.java b/src/main/java/frc/robot/commands/Climb/ActivePosition.java index 9d39358..59f4e8c 100644 --- a/src/main/java/frc/robot/commands/Climb/ActivePosition.java +++ b/src/main/java/frc/robot/commands/Climb/ActivePosition.java @@ -1,83 +1,77 @@ -/*----------------------------------------------------------------------------*/ -/* Copyright (c) 2018 FIRST. All Rights Reserved. */ -/* Open Source Software - may be modified and shared by FRC teams. The code */ -/* must be accompanied by the FIRST BSD license file in the root directory of */ -/* the project. */ -/*----------------------------------------------------------------------------*/ +package frc.robot.commands.Climb; -// package frc.robot.commands.Climb; +import edu.wpi.first.wpilibj.command.Command; +import frc.robot.Robot; +import edu.wpi.first.wpilibj.GyroBase; +import frc.robot.Constants; -// import edu.wpi.first.wpilibj.command.Command; -// import frc.robot.Robot; -// import edu.wpi.first.wpilibj.GyroBase; -// import frc.robot.Constants; +public class ActivePosition extends Command { + private GyroBase climbGyro; + double angle, turn; + public ActivePosition() { + super("ActivePosition"); + // requires(Robot.Climber); + } -// public class ActivePosition extends Command { -// private GyroBase climbGyro; -// double angle, turn; -// public ActivePosition() { -// super("ActivePosition"); -// // requires(Robot.Climber); -// } + public double getGyroAngle() { -// public double getGyroAngle() { - -// angle=climbGyro.getAngle(); -// return climbGyro.getAngle(); + angle=climbGyro.getAngle(); + return climbGyro.getAngle(); -// } +} -// // Called just before this Command runs the first time -// @Override -// protected void initialize() { -// } + // Called just before this Command runs the first time + @Override + protected void initialize() { + } -// // Called repeatedly when this Command is scheduled to run -// @Override -// protected void execute() { -// angle=climbGyro.getAngle(); + // Called repeatedly when this Command is scheduled to run + @Override + protected void execute() { + angle=climbGyro.getAngle(); -// if(angle==0){ -// turn=0; - -// } -// else if(angle/360==0){ - -// turn=0; -// } -// else if(angle>270&&angle<360){ - -// turn=Constants.kSelfClimbGoRight; -// } - -// else if(angle<90&&angle>0){ -// turn=Constants.kSelfClimbGoLeft; -// } + if(angle==0){ + turn=0; + Robot.climber.setSelfClimbOutput(turn); + } + else if(angle/360==0){ + turn=0; + Robot.climber.setSelfClimbOutput(turn); + } + else if(angle>270&&angle<360){ + turn=Constants.kSelfClimbGoRight; + Robot.climber.setSelfClimbOutput(turn); + } + + else if(angle<90&&angle>0){ + turn=Constants.kSelfClimbGoLeft; + Robot.climber.setSelfClimbOutput(turn); + } -// Robot.climber.setSelfClimbOutput(turn); -// } + + } -// // Make this return true when this Command no longer needs to run execute() -// @Override -// protected boolean isFinished() { -// return false; -// } - -// // Called once after isFinished returns true -// @Override -// protected void end() { -// Robot.climber.setSelfClimbOutput(0); -// } - -// // Called when another command which requires one or more of the same -// // subsystems is scheduled to run -// @Override -// protected void interrupted() { -// } -// } + // Make this return true when this Command no longer needs to run execute() + @Override + protected boolean isFinished() { + return false; + } + + // Called once after isFinished returns true + @Override + protected void end() { + Robot.climber.setSelfClimbOutput(0); + } + + // Called when another command which requires one or more of the same + // subsystems is scheduled to run + @Override + protected void interrupted() { + } +} diff --git a/src/main/java/frc/robot/commands/SetPanelMech.java b/src/main/java/frc/robot/commands/SetPanelMech.java index cd8318b..28d5a8c 100644 --- a/src/main/java/frc/robot/commands/SetPanelMech.java +++ b/src/main/java/frc/robot/commands/SetPanelMech.java @@ -5,50 +5,50 @@ /* the project. */ /*----------------------------------------------------------------------------*/ -package frc.robot.commands; - -import edu.wpi.first.wpilibj.command.Command; -import frc.robot.Constants; -import frc.robot.Robot; - -public class SetPanelMech extends Command { - public SetPanelMech() { - super("SetPanelMech"); - requires(Robot.panelMech); - //Use requires() here to declare subsystem dependencies - //eg. requires(chassis); - } - - //Called just before this Command runs the first time - @Override - protected void initialize() { +// package frc.robot.commands; + +// import edu.wpi.first.wpilibj.command.Command; +// import frc.robot.Constants; +// import frc.robot.Robot; + +// public class SetPanelMech extends Command { +// public SetPanelMech() { +// super("SetPanelMech"); +// requires(Robot.panelMech); +// //Use requires() here to declare subsystem dependencies +// //eg. requires(chassis); +// } + +// //Called just before this Command runs the first time +// @Override +// protected void initialize() { - } + // //Called repeatedly when this Command is scheduled to run - @Override - protected void execute() { - Robot.panelMech.setPanelMech(0); - // Robot.panelMech.setManipulator(0); - } - - //Make this return true when this Command no longer needs to run execute() - @Override - protected boolean isFinished() { - return false; - } + // @Override + // protected void execute() { + // Robot.panelMech.setPanelMech(0); + // // Robot.panelMech.setManipulator(0); + // } + + // //Make this return true when this Command no longer needs to run execute() + // @Override + // protected boolean isFinished() { + // return false; + // } //Called once after isFinished returns true - @Override - protected void end() { - Robot.panelMech.setPanelMech(0); - } - - //Called when another command which requires one or more of the same - //subsystems is scheduled to run - - @Override - protected void interrupted() { - //Yes - } -} +// @Override +// protected void end() { +// Robot.panelMech.setPanelMech(0); +// } + +// // //Called when another command which requires one or more of the same +// // //subsystems is scheduled to run + +// @Override +// protected void interrupted() { +// //Yes +// } +//} \ No newline at end of file diff --git a/src/main/java/frc/robot/subsystems/Climber.java b/src/main/java/frc/robot/subsystems/Climber.java index 2a08628..752b26d 100644 --- a/src/main/java/frc/robot/subsystems/Climber.java +++ b/src/main/java/frc/robot/subsystems/Climber.java @@ -9,7 +9,7 @@ import edu.wpi.first.wpilibj.smartdashboard.SmartDashboard; import edu.wpi.first.wpilibj.command.Subsystem; - +import edu.wpi.first.wpilibj.interfaces.Gyro; import frc.robot.Constants; import frc.robot.RobotMap; import com.revrobotics.CANSparkMax; @@ -29,86 +29,89 @@ public class Climber extends Subsystem { private Solenoid Extender; - private GyroBase climbGyro; + public GyroBase climbGyro; public double angle; + private Gyro gyro; public Climber(){ winch_Neo = new CANSparkMax(RobotMap.WINCH_NEO, MotorType.kBrushless); Extender = new Solenoid(RobotMap.kPCM, RobotMap.CLIMB_SOLENOID); - } - // selfClimb_Neo= new CANSparkMax(RobotMap.SELFCLIMB_NEO, MotorType.kBrushless); - // climbGyro = new GyroBase(){ + selfClimb_Neo= new CANSparkMax(RobotMap.SELFCLIMB_NEO, MotorType.kBrushless); + + climbGyro = new GyroBase(){ - // @Override - // public void close() throws Exception { - // // TODO Auto-generated method stub + @Override + public void close() throws Exception { + // TODO Auto-generated method stub - // } + } - // @Override - // public void reset() { - // // TODO Auto-generated method stub + @Override + public void reset() { + // TODO Auto-generated method stub - // } + } - // @Override - // public double getRate() { - // // TODO Auto-generated method stub - // return 0; - // } + @Override + public double getRate() { + // TODO Auto-generated method stub + return 0; + } - // @Override - // public double getAngle() { - // // TODO Auto-generated method stub - // return 0; - // } + @Override + public double getAngle() { + // TODO Auto-generated method stub + return 0; + } - // @Override - // public void calibrate() { - // // TODO Auto-generated method stub + @Override + public void calibrate() { + // TODO Auto-generated method stub - // } - // }; - // } + } + + + + }; + +} + public void initDefaultCommand() { - // setDefaultCommand(new DefaultExtension()); + // setDefaultCommand(new DefaultExtension()); } - public void setPinExtender(boolean extended){ - Extender.set(extended); - } - - public boolean getPinExtender(){ - return Extender.get(); - } - public void setWinchOutput(double outputWinch){ - winch_Neo.set(outputWinch); - } + public void setPinExtender(boolean extended){ + Extender.set(extended); + } - // public void calibrateGyro(){ - // climbGyro.calibrate(); - // } + public boolean getPinExtender(){ + return Extender.get(); + } + + public void setWinchOutput(double outputWinch){ + winch_Neo.set(outputWinch); + } - // public void setSelfClimbOutput(double outputSelf){ - // selfClimb_Neo.set(outputSelf); - // } + public void calibrateGyro(){ + climbGyro.calibrate(); + } - // public double getGyroAngle() { - // return climbGyro.getAngle(); - // } - - public void debug(){ - SmartDashboard.putBoolean("Pin Extender Status - ", getPinExtender()); - // SmartDashboard.putNumber("Gyro angle", climbGyro.getAngle()); - } + public void setSelfClimbOutput(double outputSelf){ + selfClimb_Neo.set(outputSelf); + } - + public double getGyroAngle() { + return climbGyro.getAngle(); + } - + public void debug(){ + SmartDashboard.putBoolean("Pin Extender Status - ", getPinExtender()); + //SmartDashboard.putNumber("Gyro angle", climbGyro.getAngle()); + } + // public void setSelfClimbOutput(double turn) { + // } } - - - \ No newline at end of file + \ No newline at end of file From 71bebe22cb94f601d10ad27d117d23c61c3d8131 Mon Sep 17 00:00:00 2001 From: frcteam2791 Date: Wed, 26 Feb 2020 16:05:10 -0800 Subject: [PATCH 23/68] Climber code Added iterative based crap in the subsystems because if/else in commands was buggy NEED TO ADD command based if/else and replace subsytem methods --- src/main/java/frc/robot/Constants.java | 2 - src/main/java/frc/robot/OI.java | 61 +++++++++++-------- src/main/java/frc/robot/Robot.java | 4 ++ .../frc/robot/commands/Climb/ReleasePin.java | 10 +-- .../frc/robot/commands/Climb/WinchClimb.java | 14 ++++- .../java/frc/robot/subsystems/Climber.java | 41 ++++++++++++- 6 files changed, 94 insertions(+), 38 deletions(-) diff --git a/src/main/java/frc/robot/Constants.java b/src/main/java/frc/robot/Constants.java index c4d2c0d..d484c5d 100644 --- a/src/main/java/frc/robot/Constants.java +++ b/src/main/java/frc/robot/Constants.java @@ -69,8 +69,6 @@ public final class Constants { public static final double HOPPER_WALL_HORIZONTAL_OUTPUT = 0.30; - public static final double HOPPER_LONG_HORIZONTAL_OUTPUT = .2; - public static final double HOPPER_VERTICAL_OUTPUT = .55; diff --git a/src/main/java/frc/robot/OI.java b/src/main/java/frc/robot/OI.java index 894c35c..22e5a96 100644 --- a/src/main/java/frc/robot/OI.java +++ b/src/main/java/frc/robot/OI.java @@ -54,8 +54,8 @@ public class OI { public OI() { driverStick = new Joystick(0); operatorStick = new Joystick(1); - // initButtons(); - // initUsed(); + initButtons(); + initUsed(); driveButton.whileHeld(new DriveWithJoystick(driverStick, 0.1)); // TODO CHANGE DEADZONE VALUE IT MIGHT NOT BE THE SAME @@ -65,24 +65,32 @@ public OI() { //LEAVE OUT driverA.whenPressed(new AutoSetLifterPots()); //LEAVE OUT driverB.whenPressed(new ExtendBothLifters(.8,false,driverStick,false)); - driverA.whenPressed(new MoveShooter()); - driverA.whenReleased(new StopShooter()); - driverB.whenReleased(new StopElevator()); - operatorA.whenPressed(new MoveHopperLong()); - operatorA.whenReleased(new StopHopper());; - operatorA.whenPressed(new setCameraOne()); - operatorB.whenPressed(new setCameraTwo()); - driverX.whenReleased(new StopHopper()); - driverB.whenPressed(new DrivetrainBackwards()); - driverB.whenReleased(new StopDrivetrain()); - driverY.whenPressed(new MoveDrivetrain()); - driverY.whenReleased(new StopDrivetrain()); - driverA.whenPressed(new MoveManipulator()); - driverA.whenReleased(new StopManipulator()); - - - driverB.whenPressed(new OpenHopperPiston()); - driverB.whenReleased(new CloseHopperPiston()); + // driverA.whenPressed(new MoveShooter()); + // driverA.whenReleased(new StopShooter()); + + // operatorA.whenPressed(new MoveHopperLong()); + // operatorA.whenReleased(new StopHopper());; + // operatorA.whenPressed(new setCameraOne()); + // operatorB.whenPressed(new setCameraTwo()); + // // driverX.whenReleased(new StopHopper()); + // driverB.whenPressed(new DrivetrainBackwards()); + // driverB.whenReleased(new StopDrivetrain()); + // driverY.whenPressed(new MoveDrivetrain()); + // driverY.whenReleased(new StopDrivetrain()); + // driverA.whenPressed(new MoveManipulator()); + // driverA.whenReleased(new StopManipulator()); + + // driverX.whenPressed(new WinchClimb(false)); + // driverX.whenReleased(new StopWinchClimb()); + // driverA.whenPressed(new WinchClimb(true)); + // driverA.whenReleased(new StopWinchClimb()); + // // driverY.whenPressed(new ReleasePin(true)); + // driverB.whenPressed(new ReleasePin(false)); + + + + // driverB.whenPressed(new OpenHopperPiston()); + // driverB.whenReleased(new CloseHopperPiston()); driverRB.whenPressed(new ShooterGroupWall()); driverRB.whenReleased(new Stop()); @@ -121,18 +129,18 @@ public OI() { operatorLB.whenReleased(new StopShooter()); - + driverDPadRight.whenPressed(new StopManipulator()); // driverLB.whenReleased(new stopHopperElevator()); // driverLS.whenPressed(new runElevatorShooter()); // driverLS.whenReleased(new stopElevatorShooter()); // operatorLeftJoystickUsed.whenPressed(new RunHopperWithJoystick(operatorLeftJoystickUsed)); - - driverX.whenPressed(new ReleasePin()); - driverY.whenPressed(new WinchClimb()); - driverY.whenReleased(new StopWinchClimb()); - driverA.whenPressed(new ActivePosition()); + + // driverX.whenPressed(new ReleasePin()); + // driverY.whenPressed(new WinchClimb()); + // driverY.whenReleased(new StopWinchClimb()); + // driverA.whenPressed(new ActivePosition()); // //true does right hp far rocket path, false does right hp bay 1 ship path @@ -186,6 +194,7 @@ private void initButtons(){ operatorLS = new AnalogButton(operatorStick, 1); operatorDPadDown = new DPadButton(operatorStick, DPadButton.kDPadDown); operatorDPadLeft = new DPadButton(operatorStick, DPadButton.kDPadLeft); + operatorDPadRight = new DPadButton(operatorStick, DPadButton.kDPadRight); } catch (Exception error){ diff --git a/src/main/java/frc/robot/Robot.java b/src/main/java/frc/robot/Robot.java index 8eeb385..df863b0 100644 --- a/src/main/java/frc/robot/Robot.java +++ b/src/main/java/frc/robot/Robot.java @@ -63,6 +63,7 @@ public void robotInit() { operatorStick = new Joystick(1); operatorA = new JoystickButton(operatorStick, 1); operatorB = new JoystickButton(operatorStick, 2); + climber = new Climber(); } @@ -75,6 +76,7 @@ public void robotPeriodic() { Cam_switch.debug(); SmartDashboard.putBoolean("Compressor Status", compressor.enabled()); hopper.debug(); + climber.debug(); if(operatorA.get() == true) { Cam_switch.select(CameraSwitch.kcamera1); } @@ -84,6 +86,8 @@ else if (operatorB.get() == true) { else { Cam_switch.select(CameraSwitch.kcamera3); } + climber.setPinExtenderByButton(); + climber.setWinchOutputByButton(); } @Override diff --git a/src/main/java/frc/robot/commands/Climb/ReleasePin.java b/src/main/java/frc/robot/commands/Climb/ReleasePin.java index b2ecf11..fd30e5b 100644 --- a/src/main/java/frc/robot/commands/Climb/ReleasePin.java +++ b/src/main/java/frc/robot/commands/Climb/ReleasePin.java @@ -11,9 +11,11 @@ import frc.robot.subsystems.Climber; public class ReleasePin extends Command { - public ReleasePin() { + private boolean lock; + public ReleasePin(boolean extend) { super("ReleasePin"); - requires(Robot.climber); + // requires(Robot.climber); + lock = extend; } @@ -22,7 +24,7 @@ protected void initialize() { } protected void execute() { - Robot.climber.setPinExtender(false); + Robot.climber.setPinExtender(lock); } protected boolean isFinished() { @@ -31,7 +33,7 @@ protected boolean isFinished() { protected void end() { - Robot.climber.setPinExtender(true); + // Robot.climber.setPinExtender(true); } protected void interrupted() { diff --git a/src/main/java/frc/robot/commands/Climb/WinchClimb.java b/src/main/java/frc/robot/commands/Climb/WinchClimb.java index 990f8e9..8a83fa9 100644 --- a/src/main/java/frc/robot/commands/Climb/WinchClimb.java +++ b/src/main/java/frc/robot/commands/Climb/WinchClimb.java @@ -11,9 +11,12 @@ import frc.robot.Robot; public class WinchClimb extends Command { - public WinchClimb() { + private boolean direction; + public WinchClimb(boolean down) { + super("WinchClimb"); // Use requires() here to declare subsystem dependencies // eg. requires(chassis); + direction = down; } // Called just before this Command runs the first time @@ -24,7 +27,12 @@ protected void initialize() { // Called repeatedly when this Command is scheduled to run @Override protected void execute() { - Robot.climber.setWinchOutput(1); + if (direction){ + Robot.climber.setWinchOutput(-1); + } + else if (!direction){ + Robot.climber.setWinchOutput(1); + } } // Make this return true when this Command no longer needs to run execute() @@ -36,7 +44,7 @@ protected boolean isFinished() { // Called once after isFinished returns true @Override protected void end() { - Robot.climber.setWinchOutput(1); + Robot.climber.setWinchOutput(0); } diff --git a/src/main/java/frc/robot/subsystems/Climber.java b/src/main/java/frc/robot/subsystems/Climber.java index 752b26d..0886538 100644 --- a/src/main/java/frc/robot/subsystems/Climber.java +++ b/src/main/java/frc/robot/subsystems/Climber.java @@ -13,11 +13,14 @@ import frc.robot.Constants; import frc.robot.RobotMap; import com.revrobotics.CANSparkMax; +import com.revrobotics.CANSparkMax.IdleMode; import com.revrobotics.CANSparkMaxLowLevel.MotorType; import edu.wpi.first.wpilibj.Solenoid; - +import edu.wpi.first.wpilibj.buttons.Button; import edu.wpi.first.wpilibj.GyroBase; +import edu.wpi.first.wpilibj.Joystick; import frc.robot.commands.*; +import edu.wpi.first.wpilibj.buttons.JoystickButton; public class Climber extends Subsystem { private CANSparkMax winch_Neo; @@ -32,13 +35,25 @@ public class Climber extends Subsystem { public GyroBase climbGyro; public double angle; private Gyro gyro; - + + public static Joystick driverStick; + private Button driverA, driverB, driverY, driverX; + public Climber(){ winch_Neo = new CANSparkMax(RobotMap.WINCH_NEO, MotorType.kBrushless); Extender = new Solenoid(RobotMap.kPCM, RobotMap.CLIMB_SOLENOID); selfClimb_Neo= new CANSparkMax(RobotMap.SELFCLIMB_NEO, MotorType.kBrushless); - + driverStick = new Joystick(0); + driverY = new JoystickButton(driverStick,4); + driverB = new JoystickButton(driverStick,2); + driverA = new JoystickButton(driverStick, 1); + driverX = new JoystickButton(driverStick, 3); + + + winch_Neo.setIdleMode(IdleMode.kBrake); + climbGyro = new GyroBase(){ + @Override public void close() throws Exception { @@ -85,6 +100,14 @@ public void initDefaultCommand() { public void setPinExtender(boolean extended){ Extender.set(extended); } + public void setPinExtenderByButton(){ + if(driverY.get()){ + Extender.set(true); + } + else if(driverB.get()){ + Extender.set(false); + } + } public boolean getPinExtender(){ return Extender.get(); @@ -94,6 +117,18 @@ public void setWinchOutput(double outputWinch){ winch_Neo.set(outputWinch); } + public void setWinchOutputByButton(){ + if (driverA.get()){ + winch_Neo.set(1); + } + else if (driverX.get()){ + winch_Neo.set(-1); + } + else { + winch_Neo.set(0); + } + } + public void calibrateGyro(){ climbGyro.calibrate(); } From 5faf552b092545538cb06eb66da7d11892ff2057 Mon Sep 17 00:00:00 2001 From: frcteam2791 Date: Fri, 28 Feb 2020 16:31:31 -0800 Subject: [PATCH 24/68] Shooter PID & hopper tuning from the tech park with Justin (Friday night) --- .../frc/robot/Autons/ShooterGroupWall.java | 2 +- src/main/java/frc/robot/Constants.java | 14 +-- src/main/java/frc/robot/OI.java | 107 +++++------------- src/main/java/frc/robot/Robot.java | 24 +++- .../frc/robot/commands/DefaultPanelMech.java | 4 +- .../frc/robot/commands/ExtendPanelMech.java | 2 +- .../java/frc/robot/commands/IrHopper.java | 6 +- .../frc/robot/commands/MoveHopperWall.java | 4 +- .../frc/robot/commands/MoveManipulator.java | 4 +- .../frc/robot/commands/ReverseHopper.java | 4 +- .../java/frc/robot/subsystems/Climber.java | 6 +- .../java/frc/robot/subsystems/Hopper.java | 2 + .../java/frc/robot/subsystems/Shooter.java | 12 +- 13 files changed, 85 insertions(+), 106 deletions(-) diff --git a/src/main/java/frc/robot/Autons/ShooterGroupWall.java b/src/main/java/frc/robot/Autons/ShooterGroupWall.java index 04eef0f..07567f9 100644 --- a/src/main/java/frc/robot/Autons/ShooterGroupWall.java +++ b/src/main/java/frc/robot/Autons/ShooterGroupWall.java @@ -14,7 +14,7 @@ public class ShooterGroupWall extends CommandGroup{ public ShooterGroupWall(){ addSequential(new WallShotHood()); - addSequential(new WallShot(), 5.0); + addSequential(new WallShot()); addSequential(new OpenHopperPiston()); addSequential(new MoveHopperWall()); } diff --git a/src/main/java/frc/robot/Constants.java b/src/main/java/frc/robot/Constants.java index d484c5d..b60524c 100644 --- a/src/main/java/frc/robot/Constants.java +++ b/src/main/java/frc/robot/Constants.java @@ -24,11 +24,11 @@ public final class Constants { public static final double kCamStraightSlow = 0.25; - public static final double ShooterkP = 5e-5; + public static final double ShooterkP = 0.002525; public static final double ShooterkI = 0; - public static final double ShooterkD = 0; + public static final double ShooterkD = 0.22; public static final double ShooterkIz = 0; - public static final double ShooterkFF = 1e-4; + public static final double ShooterkFF = 0.0002; public static final double ShooterMaxOutput = 1; public static final double ShooterMinOutput = -1; // max and min outputs that pidcontroller can send to the sparkmax public static final double kGravity = 32.1741; //acceleration due to gravity in ft/s/s @@ -70,7 +70,7 @@ public final class Constants { public static final double HOPPER_WALL_HORIZONTAL_OUTPUT = 0.30; - public static final double HOPPER_VERTICAL_OUTPUT = .55; + public static final double HOPPER_VERTICAL_OUTPUT = .20; public static final double REVERSE_HOPPER = -.20; @@ -100,12 +100,12 @@ public final class Constants { public static final double SHOOTER_OUTPUT_WALL = -.4; //changed from .47 //definitely make negative though + public static final double SHOOTER_OUTPUT_WALL_RPM = -3500; + public static final double TURN_FACTOR = 0.7; - public static final double TURN_FACTOR = 0.2; - - public static final int BALL_VALUE = 2300; + public static final int BALL_VALUE = 2425; diff --git a/src/main/java/frc/robot/OI.java b/src/main/java/frc/robot/OI.java index 22e5a96..48e5e94 100644 --- a/src/main/java/frc/robot/OI.java +++ b/src/main/java/frc/robot/OI.java @@ -3,6 +3,7 @@ import edu.wpi.first.wpilibj.Joystick; import edu.wpi.first.wpilibj.buttons.Button; import edu.wpi.first.wpilibj.buttons.JoystickButton; +import edu.wpi.first.wpilibj.command.InstantCommand; import frc.robot.Autons.ShooterGroupLong; import frc.robot.Autons.ShooterGroupWall; import frc.robot.Autons.Stop; @@ -11,12 +12,6 @@ import frc.robot.commands.*; import frc.robot.commands.Shooter.StopShooter; -import frc.robot.commands.Shooter.WallShotHood; -import frc.robot.commands.Shooter.CloseHopperPiston; -import frc.robot.commands.Shooter.LongShotHood; - -import frc.robot.commands.Shooter.OpenHopperPiston; - import frc.robot.commands.Climb.*; // import frc.robot.commands.auto.SetLimit; import frc.robot.controller.AnalogButton; @@ -59,100 +54,54 @@ public OI() { driveButton.whileHeld(new DriveWithJoystick(driverStick, 0.1)); // TODO CHANGE DEADZONE VALUE IT MIGHT NOT BE THE SAME - //LEAVE OUT driverStart.whileHeld(new ExtendBothLifters(.8,false,driverStick)); - - //THESE TWO LINES ARE FOR TESTING - //LEAVE OUT driverA.whenPressed(new AutoSetLifterPots()); - //LEAVE OUT driverB.whenPressed(new ExtendBothLifters(.8,false,driverStick,false)); - - // driverA.whenPressed(new MoveShooter()); - // driverA.whenReleased(new StopShooter()); - - // operatorA.whenPressed(new MoveHopperLong()); - // operatorA.whenReleased(new StopHopper());; - // operatorA.whenPressed(new setCameraOne()); - // operatorB.whenPressed(new setCameraTwo()); - // // driverX.whenReleased(new StopHopper()); - // driverB.whenPressed(new DrivetrainBackwards()); - // driverB.whenReleased(new StopDrivetrain()); - // driverY.whenPressed(new MoveDrivetrain()); - // driverY.whenReleased(new StopDrivetrain()); - // driverA.whenPressed(new MoveManipulator()); - // driverA.whenReleased(new StopManipulator()); - - // driverX.whenPressed(new WinchClimb(false)); - // driverX.whenReleased(new StopWinchClimb()); - // driverA.whenPressed(new WinchClimb(true)); - // driverA.whenReleased(new StopWinchClimb()); - // // driverY.whenPressed(new ReleasePin(true)); - // driverB.whenPressed(new ReleasePin(false)); - - - - // driverB.whenPressed(new OpenHopperPiston()); - // driverB.whenReleased(new CloseHopperPiston()); - - driverRB.whenPressed(new ShooterGroupWall()); - driverRB.whenReleased(new Stop()); + // driverRB.whenPressed(new ShooterGroupWall()); + // driverRB.whileHeld(new WallShot()); + // driverRB.whenReleased(new Stop()); // driverLB.whenReleased(new StopShooterGroupLong()); - operatorDPadLeft.whenPressed(new ShooterGroupLong()); - operatorDPadLeft.whenReleased(new Stop()); + // operatorDPadLeft.whenPressed(new ShooterGroupLong()); + operatorDPadLeft.whenPressed(new Stop()); operatorDPadRight.whenPressed(new ShooterGroupWall()); operatorDPadRight.whenReleased(new Stop()); - operatorA.whenPressed(new MoveHopperLong()); - operatorA.whenReleased(new StopHopper()); + operatorDPadDown.whenPressed(new ReverseHopper()); + operatorDPadDown.whenReleased(new StopHopper()); + // operatorA.whenPressed(new MoveHopperLong()); + // operatorA.whenReleased(new StopHopper()); - operatorB.whenPressed(new LongShotHood()); - operatorB.whenReleased(new WallShotHood()); + // operatorB.whenPressed(new LongShotHood()); + // operatorB.whenReleased(new WallShotHood()); - operatorY.whenPressed(new ReverseHopper()); - operatorY.whenReleased(new StopHopper()); + operatorA.whenPressed(new InstantCommand(() -> { + Robot.hopper.hopper_stopper.set(true); + })); - operatorX.whenPressed(new IrHopper()); - operatorX.whenReleased(new StopHopper()); + operatorB.whenPressed(new InstantCommand(() -> { + Robot.hopper.hopper_stopper.set(false); + })); - operatorRB.whenPressed(new WallShot()); - operatorRB.whenReleased(new StopShooter()); + operatorY.whileHeld(new MoveHopperWall()); + operatorY.whenReleased(new StopHopper()); - operatorLB.whenPressed(new LongShot()); - operatorLB.whenReleased(new StopShooter()); + operatorX.whileHeld(new IrHopper()); + operatorX.whenReleased(new StopHopper()); operatorRB.whenPressed(new WallShot()); - operatorRB.whenReleased(new StopShooter()); + // operatorRB.whenReleased(new StopShooter()); operatorLB.whenPressed(new LongShot()); operatorLB.whenReleased(new StopShooter()); + driverDPadLeft.whenPressed(new MoveManipulator()); //moves wheels as well so don't be surprised + driverDPadLeft.whenReleased(new StopManipulator()); - driverDPadRight.whenPressed(new StopManipulator()); - // driverLB.whenReleased(new stopHopperElevator()); - // driverLS.whenPressed(new runElevatorShooter()); - // driverLS.whenReleased(new stopElevatorShooter()); - // operatorLeftJoystickUsed.whenPressed(new RunHopperWithJoystick(operatorLeftJoystickUsed)); - - - - // driverX.whenPressed(new ReleasePin()); - // driverY.whenPressed(new WinchClimb()); - // driverY.whenReleased(new StopWinchClimb()); - // driverA.whenPressed(new ActivePosition()); - + driverDPadRight.whenPressed(new ExtendPanelMech()); + driverDPadRight.whenReleased(new DefaultPanelMech()); - // //true does right hp far rocket path, false does right hp bay 1 ship path - // // driverY.whenReleased(new StopCargoMotor()); - //driverRB.whileHeld(new DriveWithJoystickLeftTalon()); - //driverLB.whileHeld(new DriveWithJoystickRightTalon()); - // driverY.whileHeld(new DriveWithJoystickLeftTalon()); - //driverX.whenPressed(new DriveWithJoystickLeft(driverStick, 0.1)); - //driverB.whileHeld(new DriveWithJoystickRight()); - // driverX.whenPressed(new DriveWithJoystickLeft()); - //driverX.whenReleased(new StopDrive()); - // driverRX.whileHeld(new PreciseTurnJoystick(driverStick, 0.1)); + //driverDPadDown.whenPressed(new SetPanelMech()); } diff --git a/src/main/java/frc/robot/Robot.java b/src/main/java/frc/robot/Robot.java index df863b0..8908e3a 100644 --- a/src/main/java/frc/robot/Robot.java +++ b/src/main/java/frc/robot/Robot.java @@ -50,7 +50,7 @@ public void robotInit() { shooter = new Shooter(); drivetrain = new Drivetrain(); manipulator = new Manipulator(); - //panelMech = new PanelMech(); + panelMech = new PanelMech(); pdp = new PowerDistributionPanel(RobotMap.kPDP); oi = new OI(); robotmap = new RobotMap(); @@ -71,7 +71,7 @@ public void robotInit() { public void robotPeriodic() { // //EACH debug only runs once per 10 loops // DriveWithJoystick joystick_command = new DriveWithJoystick(OI.driverStick, 0.1) - //drivetrain.debug(); + drivetrain.debug(); compressor.start(); Cam_switch.debug(); SmartDashboard.putBoolean("Compressor Status", compressor.enabled()); @@ -124,6 +124,10 @@ public void teleopInit() { System.out.println("This is init"); + SmartDashboard.putNumber("Shooter kP", Constants.ShooterkP); + SmartDashboard.putNumber("Shooter kF", Constants.ShooterkFF); + SmartDashboard.putNumber("Shooter kD", Constants.ShooterkD); + SmartDashboard.putNumber("Shooter setpoint", 0); } @Override @@ -140,6 +144,22 @@ public void teleopPeriodic() { // Robot.drivetrain.setRightNeo(1); // 0.5 power is the sweet spot for wall, 0.8 for current at angle of 39 degrees Scheduler.getInstance().run(); + + SmartDashboard.putNumber("Shooter velocity", shooter.getShooterVelocity()); + + + // double kp = SmartDashboard.getNumber("Shooter kP", 0); + // double kf = SmartDashboard.getNumber("Shooter kF", 0); + // double kd = SmartDashboard.getNumber("Shooter kD", 0); + + // shooter.shooter_leader.getPIDController().setP(kp); + // shooter.shooter_leader.getPIDController().setFF(kf); + // shooter.shooter_leader.getPIDController().setD(kd); + + // double setpoint = SmartDashboard.getNumber("Shooter setpoint", 0); + // shooter.setShooterPID(setpoint); + + } @Override public void testPeriodic() { diff --git a/src/main/java/frc/robot/commands/DefaultPanelMech.java b/src/main/java/frc/robot/commands/DefaultPanelMech.java index 67d26f6..6b402a5 100644 --- a/src/main/java/frc/robot/commands/DefaultPanelMech.java +++ b/src/main/java/frc/robot/commands/DefaultPanelMech.java @@ -8,6 +8,7 @@ package frc.robot.commands; import edu.wpi.first.wpilibj.command.Command; +import frc.robot.Robot; public class DefaultPanelMech extends Command { public DefaultPanelMech() { @@ -23,12 +24,13 @@ protected void initialize() { // Called repeatedly when this Command is scheduled to run @Override protected void execute() { + Robot.panelMech.extendPanelMech(false); } // Make this return true when this Command no longer needs to run execute() @Override protected boolean isFinished() { - return false; + return true; } // Called once after isFinished returns true diff --git a/src/main/java/frc/robot/commands/ExtendPanelMech.java b/src/main/java/frc/robot/commands/ExtendPanelMech.java index 531f6aa..3cc42fd 100644 --- a/src/main/java/frc/robot/commands/ExtendPanelMech.java +++ b/src/main/java/frc/robot/commands/ExtendPanelMech.java @@ -33,7 +33,7 @@ protected void execute() { // Make this return true when this Command no longer needs to run execute() @Override protected boolean isFinished() { - return false; + return true; } // Called once after isFinished returns true diff --git a/src/main/java/frc/robot/commands/IrHopper.java b/src/main/java/frc/robot/commands/IrHopper.java index 9b09dd1..399512a 100644 --- a/src/main/java/frc/robot/commands/IrHopper.java +++ b/src/main/java/frc/robot/commands/IrHopper.java @@ -8,6 +8,7 @@ package frc.robot.commands; import edu.wpi.first.wpilibj.command.Command; +import frc.robot.Constants; import frc.robot.Robot; public class IrHopper extends Command { @@ -26,13 +27,14 @@ protected void initialize() { // Called repeatedly when this Command is scheduled to run @Override protected void execute() { - Robot.hopper.poopBall(); + Robot.hopper.setHopper(Constants.HOPPER_LOADING_HORIZONTAL_OUTPUT, Constants.HOPPER_VERTICAL_OUTPUT); } // Make this return true when this Command no longer needs to run execute() @Override + protected boolean isFinished() { - return false; + return !Robot.hopper.isBall(); } // Called once after isFinished returns true diff --git a/src/main/java/frc/robot/commands/MoveHopperWall.java b/src/main/java/frc/robot/commands/MoveHopperWall.java index 7711e69..017969a 100644 --- a/src/main/java/frc/robot/commands/MoveHopperWall.java +++ b/src/main/java/frc/robot/commands/MoveHopperWall.java @@ -33,13 +33,13 @@ protected void execute() { // Make this return true when this Command no longer needs to run execute() @Override protected boolean isFinished() { - return false; + return true; } // Called once after isFinished returns true @Override protected void end() { - Robot.hopper.setHopper(0, 0); + // Robot.hopper.setHopper(0, 0); } // Called when another command which requires one or more of the same diff --git a/src/main/java/frc/robot/commands/MoveManipulator.java b/src/main/java/frc/robot/commands/MoveManipulator.java index 07259f2..02a69e2 100644 --- a/src/main/java/frc/robot/commands/MoveManipulator.java +++ b/src/main/java/frc/robot/commands/MoveManipulator.java @@ -28,13 +28,13 @@ protected void execute() { //Make this return true when this Command no longer needs to run execute() @Override protected boolean isFinished() { - return false; + return true; } //Called once after isFinished returns true @Override protected void end() { - Robot.manipulator.setManipulator(0); + // Robot.manipulator.setManipulator(0); } //Called when another command which requires one or more of the same diff --git a/src/main/java/frc/robot/commands/ReverseHopper.java b/src/main/java/frc/robot/commands/ReverseHopper.java index e459742..acf3e1e 100644 --- a/src/main/java/frc/robot/commands/ReverseHopper.java +++ b/src/main/java/frc/robot/commands/ReverseHopper.java @@ -33,13 +33,13 @@ protected void execute() { // Make this return true when this Command no longer needs to run execute() @Override protected boolean isFinished() { - return false; + return true; } // Called once after isFinished returns true @Override protected void end() { - Robot.hopper.setHopper(0, 0); + // Robot.hopper.setHopper(0, 0); } // Called when another command which requires one or more of the same diff --git a/src/main/java/frc/robot/subsystems/Climber.java b/src/main/java/frc/robot/subsystems/Climber.java index 0886538..4a6dc3b 100644 --- a/src/main/java/frc/robot/subsystems/Climber.java +++ b/src/main/java/frc/robot/subsystems/Climber.java @@ -24,7 +24,7 @@ public class Climber extends Subsystem { private CANSparkMax winch_Neo; - private CANSparkMax selfClimb_Neo; + // private CANSparkMax selfClimb_Neo; public static double bottom_penetrometer; public static double top_penetrometer; @@ -42,7 +42,7 @@ public class Climber extends Subsystem { public Climber(){ winch_Neo = new CANSparkMax(RobotMap.WINCH_NEO, MotorType.kBrushless); Extender = new Solenoid(RobotMap.kPCM, RobotMap.CLIMB_SOLENOID); - selfClimb_Neo= new CANSparkMax(RobotMap.SELFCLIMB_NEO, MotorType.kBrushless); + // selfClimb_Neo= new CANSparkMax(RobotMap.SELFCLIMB_NEO, MotorType.kBrushless); driverStick = new Joystick(0); driverY = new JoystickButton(driverStick,4); driverB = new JoystickButton(driverStick,2); @@ -134,7 +134,7 @@ public void calibrateGyro(){ } public void setSelfClimbOutput(double outputSelf){ - selfClimb_Neo.set(outputSelf); + // selfClimb_Neo.set(outputSelf); } public double getGyroAngle() { diff --git a/src/main/java/frc/robot/subsystems/Hopper.java b/src/main/java/frc/robot/subsystems/Hopper.java index c584a41..70c6321 100644 --- a/src/main/java/frc/robot/subsystems/Hopper.java +++ b/src/main/java/frc/robot/subsystems/Hopper.java @@ -36,6 +36,8 @@ public Hopper(){ hopper_stopper = new Solenoid(RobotMap.kPCM, RobotMap.HOPPER_SOLENOID); irSensor = new IrSensor(RobotMap.kPDP); + hopper_horizontal.setSmartCurrentLimit(20); + hopper_vertical.setSmartCurrentLimit(20); } public void setHopper(final double output, final double vOutput){ diff --git a/src/main/java/frc/robot/subsystems/Shooter.java b/src/main/java/frc/robot/subsystems/Shooter.java index 54705be..6becffb 100644 --- a/src/main/java/frc/robot/subsystems/Shooter.java +++ b/src/main/java/frc/robot/subsystems/Shooter.java @@ -24,7 +24,7 @@ */ public class Shooter extends Subsystem { - private CANSparkMax shooter_leader; + public CANSparkMax shooter_leader; private CANSparkMax shooter_follower; private Solenoid hood_1; // private MoveShooterPassive defaultCommand; @@ -36,10 +36,12 @@ public Shooter(){ shooter_follower = new CANSparkMax(RobotMap.kShooterRight, MotorType.kBrushless); shooter_leader.setOpenLoopRampRate(Constants.kNeoRampTime); shooter_follower.setOpenLoopRampRate(Constants.kNeoRampTime); + shooter_follower.follow(shooter_leader, true); hood_1 = new Solenoid(RobotMap.kPCM, RobotMap.HOOD_SOLENOID); shooter_leader.getPIDController().setP(Constants.ShooterkP); shooter_leader.getPIDController().setFF(Constants.ShooterkFF); + shooter_leader.getPIDController().setD(Constants.ShooterkD); shooter_leader.getPIDController().setOutputRange(-1, 1); } public double idealVelocity(double angle, double dist, double height){ @@ -64,11 +66,13 @@ public double velocityToRPM(double velocity){ } public void setShooter(final double output){ shooter_leader.set(output); - shooter_follower.follow(shooter_leader, true); } public void setShooterPID(final double setpoint){ - shooter_leader.getPIDController().setReference(setpoint, ControlType.kVelocity); - shooter_follower.follow(shooter_leader, true); + if (setpoint == 0) { + setShooter(setpoint); + } else { + shooter_leader.getPIDController().setReference(setpoint, ControlType.kVelocity); + } } public double getShooterVelocity(){ return shooter_leader.getEncoder().getVelocity(); From 6d10d579272d0ceeaaf2bbeda5706fbf2d6344a5 Mon Sep 17 00:00:00 2001 From: frcteam2791 Date: Sat, 29 Feb 2020 08:47:19 -0800 Subject: [PATCH 25/68] Close trench shot and wall shot tuned --- src/main/java/frc/robot/OI.java | 11 +++++--- src/main/java/frc/robot/Robot.java | 26 +++++++++---------- .../{ => IntakeToHopper}/IrHopper.java | 2 +- .../{ => IntakeToHopper}/MoveManipulator.java | 2 +- .../commands/{ => Shooter}/MoveShooter.java | 0 .../{ => Shooter}/MoveShooterPassive.java | 0 .../java/frc/robot/subsystems/Drivetrain.java | 2 ++ .../java/frc/robot/subsystems/Shooter.java | 3 +++ 8 files changed, 27 insertions(+), 19 deletions(-) rename src/main/java/frc/robot/commands/{ => IntakeToHopper}/IrHopper.java (97%) rename src/main/java/frc/robot/commands/{ => IntakeToHopper}/MoveManipulator.java (96%) rename src/main/java/frc/robot/commands/{ => Shooter}/MoveShooter.java (100%) rename src/main/java/frc/robot/commands/{ => Shooter}/MoveShooterPassive.java (100%) diff --git a/src/main/java/frc/robot/OI.java b/src/main/java/frc/robot/OI.java index 48e5e94..e37702c 100644 --- a/src/main/java/frc/robot/OI.java +++ b/src/main/java/frc/robot/OI.java @@ -9,6 +9,7 @@ import frc.robot.Autons.Stop; import frc.robot.commands.Shooter.*; import frc.robot.commands.Climb.*; +import frc.robot.commands.IntakeToHopper.*; import frc.robot.commands.*; import frc.robot.commands.Shooter.StopShooter; @@ -61,11 +62,13 @@ public OI() { // driverLB.whenReleased(new StopShooterGroupLong()); // operatorDPadLeft.whenPressed(new ShooterGroupLong()); - operatorDPadLeft.whenPressed(new Stop()); + // operatorDPadLeft.whenPressed(new Stop()); - - operatorDPadRight.whenPressed(new ShooterGroupWall()); - operatorDPadRight.whenReleased(new Stop()); + // operatorDPadRight.whenPressed(new ShooterGroupWall()); + // operatorDPadRight.whenReleased(new Stop()); + + operatorDPadLeft.whenPressed(new LongShotHood()); + operatorDPadRight.whenPressed(new WallShotHood()); operatorDPadDown.whenPressed(new ReverseHopper()); operatorDPadDown.whenReleased(new StopHopper()); diff --git a/src/main/java/frc/robot/Robot.java b/src/main/java/frc/robot/Robot.java index 8908e3a..fb1c0db 100644 --- a/src/main/java/frc/robot/Robot.java +++ b/src/main/java/frc/robot/Robot.java @@ -77,15 +77,15 @@ public void robotPeriodic() { SmartDashboard.putBoolean("Compressor Status", compressor.enabled()); hopper.debug(); climber.debug(); - if(operatorA.get() == true) { - Cam_switch.select(CameraSwitch.kcamera1); - } - else if (operatorB.get() == true) { - Cam_switch.select(CameraSwitch.kcamera2); - } - else { - Cam_switch.select(CameraSwitch.kcamera3); - } + // if(operatorA.get() == true) { + // Cam_switch.select(CameraSwitch.kcamera1); + // } + // else if (operatorB.get() == true) { + // Cam_switch.select(CameraSwitch.kcamera2); + // } + // else { + // Cam_switch.select(CameraSwitch.kcamera3); + // } climber.setPinExtenderByButton(); climber.setWinchOutputByButton(); } @@ -128,6 +128,8 @@ public void teleopInit() { SmartDashboard.putNumber("Shooter kF", Constants.ShooterkFF); SmartDashboard.putNumber("Shooter kD", Constants.ShooterkD); SmartDashboard.putNumber("Shooter setpoint", 0); + + manipulator.setRetracted(false); } @Override @@ -156,10 +158,8 @@ public void teleopPeriodic() { // shooter.shooter_leader.getPIDController().setFF(kf); // shooter.shooter_leader.getPIDController().setD(kd); - // double setpoint = SmartDashboard.getNumber("Shooter setpoint", 0); - // shooter.setShooterPID(setpoint); - - + double setpoint = SmartDashboard.getNumber("Shooter setpoint", 0); + shooter.setShooterPID(setpoint); } @Override public void testPeriodic() { diff --git a/src/main/java/frc/robot/commands/IrHopper.java b/src/main/java/frc/robot/commands/IntakeToHopper/IrHopper.java similarity index 97% rename from src/main/java/frc/robot/commands/IrHopper.java rename to src/main/java/frc/robot/commands/IntakeToHopper/IrHopper.java index 399512a..1236b08 100644 --- a/src/main/java/frc/robot/commands/IrHopper.java +++ b/src/main/java/frc/robot/commands/IntakeToHopper/IrHopper.java @@ -5,7 +5,7 @@ /* the project. */ /*----------------------------------------------------------------------------*/ -package frc.robot.commands; +package frc.robot.commands.IntakeToHopper; import edu.wpi.first.wpilibj.command.Command; import frc.robot.Constants; diff --git a/src/main/java/frc/robot/commands/MoveManipulator.java b/src/main/java/frc/robot/commands/IntakeToHopper/MoveManipulator.java similarity index 96% rename from src/main/java/frc/robot/commands/MoveManipulator.java rename to src/main/java/frc/robot/commands/IntakeToHopper/MoveManipulator.java index 02a69e2..596179f 100644 --- a/src/main/java/frc/robot/commands/MoveManipulator.java +++ b/src/main/java/frc/robot/commands/IntakeToHopper/MoveManipulator.java @@ -1,4 +1,4 @@ -package frc.robot.commands; +package frc.robot.commands.IntakeToHopper; import edu.wpi.first.wpilibj.command.Command; import frc.robot.Constants; diff --git a/src/main/java/frc/robot/commands/MoveShooter.java b/src/main/java/frc/robot/commands/Shooter/MoveShooter.java similarity index 100% rename from src/main/java/frc/robot/commands/MoveShooter.java rename to src/main/java/frc/robot/commands/Shooter/MoveShooter.java diff --git a/src/main/java/frc/robot/commands/MoveShooterPassive.java b/src/main/java/frc/robot/commands/Shooter/MoveShooterPassive.java similarity index 100% rename from src/main/java/frc/robot/commands/MoveShooterPassive.java rename to src/main/java/frc/robot/commands/Shooter/MoveShooterPassive.java diff --git a/src/main/java/frc/robot/subsystems/Drivetrain.java b/src/main/java/frc/robot/subsystems/Drivetrain.java index debd3ea..0ae00d5 100644 --- a/src/main/java/frc/robot/subsystems/Drivetrain.java +++ b/src/main/java/frc/robot/subsystems/Drivetrain.java @@ -35,11 +35,13 @@ public Drivetrain() { // Init Left Leader leftLeader = new CANSparkMax(RobotMap.kLeftLeader, MotorType.kBrushless); leftLeader.setOpenLoopRampRate(Constants.kNeoRampTime); + leftLeader.setSmartCurrentLimit(60); // Init Right Leader rightLeader = new CANSparkMax(RobotMap.kRightLeader, MotorType.kBrushless); rightLeader.setOpenLoopRampRate(Constants.kNeoRampTime); + rightLeader.setSmartCurrentLimit(60); // encoders m_leftAlternateEncoder = leftLeader.getAlternateEncoder(kAltEncType, 1024); diff --git a/src/main/java/frc/robot/subsystems/Shooter.java b/src/main/java/frc/robot/subsystems/Shooter.java index 6becffb..f167a5d 100644 --- a/src/main/java/frc/robot/subsystems/Shooter.java +++ b/src/main/java/frc/robot/subsystems/Shooter.java @@ -43,6 +43,8 @@ public Shooter(){ shooter_leader.getPIDController().setFF(Constants.ShooterkFF); shooter_leader.getPIDController().setD(Constants.ShooterkD); shooter_leader.getPIDController().setOutputRange(-1, 1); + + shooter_leader.enableVoltageCompensation(12.4); } public double idealVelocity(double angle, double dist, double height){ double gravityInches = Constants.kGravity*12; @@ -52,6 +54,7 @@ public double idealVelocity(double angle, double dist, double height){ } public double applyDrag(double velocity){ velocity*=Constants.kDrag; + return velocity; } public double applyMagnus(double velocity){ From 654fe9128c5da5defc759e5b7c7f5eca8a470fd1 Mon Sep 17 00:00:00 2001 From: frcteam2791 Date: Sat, 29 Feb 2020 12:24:28 -0800 Subject: [PATCH 26/68] End of saturday at tech park --- src/main/java/frc/robot/Constants.java | 8 +- src/main/java/frc/robot/OI.java | 39 ++- src/main/java/frc/robot/Robot.java | 18 +- .../frc/robot/commands/Climb/ReleasePin.java | 27 +- .../robot/commands/Climb/StopWinchClimb.java | 6 +- .../frc/robot/commands/Climb/WinchClimb.java | 23 +- .../robot/commands/DrivetrainAlignToGoal.java | 66 ++++ .../IntakeToHopper/MoveManipulator.java | 2 +- .../frc/robot/commands/Shooter/LongShot.java | 2 +- .../robot/commands/Shooter/MoveShooter.java | 2 +- .../robot/commands/Shooter/StopShooter.java | 6 +- .../frc/robot/commands/Shooter/WallShot.java | 2 +- .../frc/robot/commands/StopManipulator.java | 2 +- .../java/frc/robot/subsystems/Climber.java | 75 +---- .../java/frc/robot/subsystems/Hopper.java | 31 +- .../java/frc/robot/subsystems/Limelight.java | 290 ++++++++++++++++++ .../frc/robot/subsystems/Manipulator.java | 10 +- .../java/frc/robot/subsystems/Shooter.java | 3 +- 18 files changed, 495 insertions(+), 117 deletions(-) create mode 100644 src/main/java/frc/robot/commands/DrivetrainAlignToGoal.java create mode 100644 src/main/java/frc/robot/subsystems/Limelight.java diff --git a/src/main/java/frc/robot/Constants.java b/src/main/java/frc/robot/Constants.java index b60524c..e8b1ceb 100644 --- a/src/main/java/frc/robot/Constants.java +++ b/src/main/java/frc/robot/Constants.java @@ -39,9 +39,9 @@ public final class Constants { - public static final double DrivekP = 6e-4; + public static final double DrivekP = 0.025; public static final double DrivekI = 0; - public static final double DrivekD = 1e-5; + public static final double DrivekD = 0; public static final double DriveIz = 0; public static final double DrivekFF = 0; public static final double DriveMaxOutput = 1; @@ -64,13 +64,13 @@ public final class Constants { public static final double ELEVATOR_OUTPUT = -.05; - public static final double HOPPER_LOADING_HORIZONTAL_OUTPUT = .40; + public static final double HOPPER_LOADING_HORIZONTAL_OUTPUT = .60; public static final double HOPPER_WALL_HORIZONTAL_OUTPUT = 0.30; - public static final double HOPPER_VERTICAL_OUTPUT = .20; + public static final double HOPPER_VERTICAL_OUTPUT = .35; public static final double REVERSE_HOPPER = -.20; diff --git a/src/main/java/frc/robot/OI.java b/src/main/java/frc/robot/OI.java index e37702c..32cf40e 100644 --- a/src/main/java/frc/robot/OI.java +++ b/src/main/java/frc/robot/OI.java @@ -3,6 +3,7 @@ import edu.wpi.first.wpilibj.Joystick; import edu.wpi.first.wpilibj.buttons.Button; import edu.wpi.first.wpilibj.buttons.JoystickButton; +import edu.wpi.first.wpilibj.buttons.Trigger; import edu.wpi.first.wpilibj.command.InstantCommand; import frc.robot.Autons.ShooterGroupLong; import frc.robot.Autons.ShooterGroupWall; @@ -39,7 +40,7 @@ public class OI { private Button driverStart, driverBack; private Button operatorStart; private Button driverA, driverB, driverY; - private Button driverDPadDown, driverDPadRight, driverDPadLeft; + private Button driverDPadDown, driverDPadRight, driverDPadLeft, driverDPadUp; private Button operatorRB, operatorLT, operatorLB, operatorRT; public Button operatorLS, operatorBack; private Button driverX; @@ -96,16 +97,34 @@ public OI() { // operatorRB.whenReleased(new StopShooter()); operatorLB.whenPressed(new LongShot()); - operatorLB.whenReleased(new StopShooter()); - - driverDPadLeft.whenPressed(new MoveManipulator()); //moves wheels as well so don't be surprised - driverDPadLeft.whenReleased(new StopManipulator()); - - driverDPadRight.whenPressed(new ExtendPanelMech()); - driverDPadRight.whenReleased(new DefaultPanelMech()); + // operatorLB.whenReleased(new StopShooter()); + // operatorStart.whenPressed(new StopShooter()); + new Trigger(){ + @Override + public boolean get() { + // TODO Auto-generated method stub + return operatorStick.getRawAxis(3) > 0.25; + } + }.whenActive(new StopShooter()); + + // driverA.whenPressed(new MoveManipulator()); //moves wheels as well so don't be surprised + // driverA.whenReleased(new StopManipulator()); + + driverDPadRight.whileHeld(new DrivetrainAlignToGoal()); + driverDPadLeft.whenPressed(new MoveManipulator()); + driverDPadLeft.whenReleased(new StopManipulator() + ); + + // driverDPadRight.whenPressed(new ExtendPanelMech()); + // driverDPadRight.whenReleased(new DefaultPanelMech()); //driverDPadDown.whenPressed(new SetPanelMech()); - + driverX.whenPressed(new ReleasePin(true, false)); + driverA.whenPressed(new ReleasePin(false, false)); + driverY.whileHeld(new WinchClimb(true)); + driverY.whenReleased(new StopWinchClimb()); + driverB.whileHeld(new WinchClimb(false)); + driverB.whenReleased(new StopWinchClimb()); } private void initButtons(){ @@ -124,7 +143,7 @@ private void initButtons(){ driverRX = new AnalogButton(driverStick, 4); driverDPadDown = new DPadButton(driverStick, DPadButton.kDPadDown); driverDPadRight = new DPadButton(driverStick, DPadButton.kDPadRight); - // driverDPadUp = new DPadButton(driverStick, DPadButton.kDPadUp); + driverDPadUp = new DPadButton(driverStick, DPadButton.kDPadUp); driverDPadLeft = new DPadButton(driverStick, DPadButton.kDPadLeft); driveButton = new MultiButton(new Button[] { new AnalogButton(driverStick, 3, 2, 0, 0.2), diff --git a/src/main/java/frc/robot/Robot.java b/src/main/java/frc/robot/Robot.java index fb1c0db..b740b18 100644 --- a/src/main/java/frc/robot/Robot.java +++ b/src/main/java/frc/robot/Robot.java @@ -9,6 +9,7 @@ import edu.wpi.first.wpilibj.smartdashboard.SmartDashboard; import frc.robot.commands.setCameraOne; import frc.robot.subsystems.*; +import frc.robot.util.LedMode; import frc.robot.util.Camera_Switch.CameraSwitch; import frc.robot.OI.*; @@ -34,6 +35,7 @@ public class Robot extends TimedRobot { public static Shooter shooter; public static Elevator elevator; public static Hopper hopper; + public static Limelight limelight; public static RobotMap robotmap; public static Manipulator manipulator; @@ -51,6 +53,8 @@ public void robotInit() { drivetrain = new Drivetrain(); manipulator = new Manipulator(); panelMech = new PanelMech(); + limelight = new Limelight(); + climber = new Climber(); pdp = new PowerDistributionPanel(RobotMap.kPDP); oi = new OI(); robotmap = new RobotMap(); @@ -64,7 +68,8 @@ public void robotInit() { operatorA = new JoystickButton(operatorStick, 1); operatorB = new JoystickButton(operatorStick, 2); - climber = new Climber(); + + SmartDashboard.putBoolean("Drivetrain Align Complete", false); } // @Override @@ -86,8 +91,6 @@ public void robotPeriodic() { // else { // Cam_switch.select(CameraSwitch.kcamera3); // } - climber.setPinExtenderByButton(); - climber.setWinchOutputByButton(); } @Override @@ -95,7 +98,7 @@ public void disabledInit() { drivetrain.setMotors(0,0); hopper.setHopper(0,0); manipulator.setManipulator(0); - manipulator.setRetracted(true); + manipulator.setRetracted(); shooter.setShooter(0); //add emergency stops for panelMech } @@ -105,7 +108,7 @@ public void disabledPeriodic() { drivetrain.setMotors(0,0); hopper.setHopper(0,0); manipulator.setManipulator(0); - manipulator.setRetracted(true); + manipulator.setRetracted(); shooter.setShooter(0); //add emergency stops for panelMech // Robot.drivetrain.resetGyro(); @@ -129,7 +132,8 @@ public void teleopInit() { SmartDashboard.putNumber("Shooter kD", Constants.ShooterkD); SmartDashboard.putNumber("Shooter setpoint", 0); - manipulator.setRetracted(false); + manipulator.setRetracted(); + Robot.hopper.hopper_stopper.set(true); } @Override @@ -159,7 +163,7 @@ public void teleopPeriodic() { // shooter.shooter_leader.getPIDController().setD(kd); double setpoint = SmartDashboard.getNumber("Shooter setpoint", 0); - shooter.setShooterPID(setpoint); + // shooter.setShooterPID(setpoint); } @Override public void testPeriodic() { diff --git a/src/main/java/frc/robot/commands/Climb/ReleasePin.java b/src/main/java/frc/robot/commands/Climb/ReleasePin.java index fd30e5b..a074ee3 100644 --- a/src/main/java/frc/robot/commands/Climb/ReleasePin.java +++ b/src/main/java/frc/robot/commands/Climb/ReleasePin.java @@ -7,28 +7,43 @@ package frc.robot.commands.Climb; import frc.robot.Robot; +import edu.wpi.first.wpilibj.Timer; import edu.wpi.first.wpilibj.command.Command; import frc.robot.subsystems.Climber; public class ReleasePin extends Command { - private boolean lock; - public ReleasePin(boolean extend) { + private boolean lock, lowerIntake; + private Timer intakeRetractTimer; + public ReleasePin(boolean extend, boolean lowerIntake) { super("ReleasePin"); - // requires(Robot.climber); + requires(Robot.climber); + requires(Robot.manipulator); lock = extend; + this.lowerIntake = lowerIntake; + intakeRetractTimer = new Timer(); } protected void initialize() { - + intakeRetractTimer.start(); } protected void execute() { - Robot.climber.setPinExtender(lock); + if (intakeRetractTimer.get() > 0.25) { + Robot.climber.setPinExtender(lock); + } + + if (lowerIntake) { + if (intakeRetractTimer.get() < 2) { + Robot.manipulator.setExtended(); + } else { + Robot.manipulator.setRetracted(); + } + } } protected boolean isFinished() { - return false; + return intakeRetractTimer.get() > 0.1 && Robot.manipulator.getRetracted(); } protected void end() { diff --git a/src/main/java/frc/robot/commands/Climb/StopWinchClimb.java b/src/main/java/frc/robot/commands/Climb/StopWinchClimb.java index 832de5e..63f8a59 100644 --- a/src/main/java/frc/robot/commands/Climb/StopWinchClimb.java +++ b/src/main/java/frc/robot/commands/Climb/StopWinchClimb.java @@ -14,6 +14,7 @@ public class StopWinchClimb extends Command { public StopWinchClimb() { // Use requires() here to declare subsystem dependencies // eg. requires(chassis); + requires(Robot.climber); } // Called just before this Command runs the first time @@ -25,18 +26,19 @@ protected void initialize() { @Override protected void execute() { Robot.climber.setWinchOutput(0); + Robot.climber.setPinExtender(false); } // Make this return true when this Command no longer needs to run execute() @Override protected boolean isFinished() { - return false; + return true; } // Called once after isFinished returns true @Override protected void end() { - Robot.climber.setWinchOutput(0); + // Robot.climber.setWinchOutput(0); } diff --git a/src/main/java/frc/robot/commands/Climb/WinchClimb.java b/src/main/java/frc/robot/commands/Climb/WinchClimb.java index 8a83fa9..d1cf6a6 100644 --- a/src/main/java/frc/robot/commands/Climb/WinchClimb.java +++ b/src/main/java/frc/robot/commands/Climb/WinchClimb.java @@ -7,44 +7,53 @@ package frc.robot.commands.Climb; +import edu.wpi.first.wpilibj.Timer; import edu.wpi.first.wpilibj.command.Command; import frc.robot.Robot; public class WinchClimb extends Command { private boolean direction; + private Timer waitTimer; public WinchClimb(boolean down) { super("WinchClimb"); // Use requires() here to declare subsystem dependencies // eg. requires(chassis); direction = down; + waitTimer = new Timer(); + requires(Robot.climber); } // Called just before this Command runs the first time @Override protected void initialize() { + waitTimer.start(); } // Called repeatedly when this Command is scheduled to run @Override protected void execute() { - if (direction){ - Robot.climber.setWinchOutput(-1); + Robot.climber.setPinExtender(true); + if (waitTimer.get() > 0.25) { + if (direction){ + Robot.climber.setWinchOutput(-1); + } + else if (!direction){ + Robot.climber.setWinchOutput(1); + } } - else if (!direction){ - Robot.climber.setWinchOutput(1); - } + Robot.manipulator.setRetracted(); } // Make this return true when this Command no longer needs to run execute() @Override protected boolean isFinished() { - return false; + return waitTimer.get() > 0.27; } // Called once after isFinished returns true @Override protected void end() { - Robot.climber.setWinchOutput(0); + // Robot.climber.setWinchOutput(0); } diff --git a/src/main/java/frc/robot/commands/DrivetrainAlignToGoal.java b/src/main/java/frc/robot/commands/DrivetrainAlignToGoal.java new file mode 100644 index 0000000..471a48a --- /dev/null +++ b/src/main/java/frc/robot/commands/DrivetrainAlignToGoal.java @@ -0,0 +1,66 @@ +/*----------------------------------------------------------------------------*/ +/* Copyright (c) 2018 FIRST. All Rights Reserved. */ +/* Open Source Software - may be modified and shared by FRC teams. The code */ +/* must be accompanied by the FIRST BSD license file in the root directory of */ +/* the project. */ +/*----------------------------------------------------------------------------*/ + +package frc.robot.commands; + +import edu.wpi.first.wpilibj.command.Command; +import edu.wpi.first.wpilibj.controller.PIDController; +import edu.wpi.first.wpilibj.smartdashboard.SmartDashboard; +import frc.robot.Constants; +import frc.robot.Robot; +import frc.robot.subsystems.Limelight.CamMode; +import frc.robot.subsystems.Limelight.LedMode; + +public class DrivetrainAlignToGoal extends Command { + + PIDController pid; + + public DrivetrainAlignToGoal() { + // Use requires() here to declare subsystem dependencies + // eg. requires(chassis); + requires(Robot.drivetrain); + requires(Robot.limelight); + pid = new PIDController(Constants.DrivekP, Constants.DrivekI, Constants.DrivekD); + } + + // Called just before this Command runs the first time + @Override + protected void initialize() { + Robot.limelight.setCamMode(CamMode.VISION_CAM); + Robot.limelight.setLedMode(LedMode.PIPELINE); + pid.setSetpoint(0.0); + pid.setTolerance(0.3); + } + + // Called repeatedly when this Command is scheduled to run + @Override + protected void execute() { + double output = pid.calculate(Robot.limelight.getHorizontalOffset()); + Robot.drivetrain.setMotors(-output, output); + SmartDashboard.putBoolean("Drivetrain Align Complete", false); + } + + // Make this return true when this Command no longer needs to run execute() + @Override + protected boolean isFinished() { + return pid.atSetpoint(); + } + + // Called once after isFinished returns true + @Override + protected void end() { + // Robot.limelight.setCamMode(CamMode.DRIVER_CAM); + SmartDashboard.putBoolean("Drivetrain Align Complete", true); + Robot.drivetrain.setMotors(0, 0); + } + + // Called when another command which requires one or more of the same + // subsystems is scheduled to run + @Override + protected void interrupted() { + } +} diff --git a/src/main/java/frc/robot/commands/IntakeToHopper/MoveManipulator.java b/src/main/java/frc/robot/commands/IntakeToHopper/MoveManipulator.java index 596179f..496f586 100644 --- a/src/main/java/frc/robot/commands/IntakeToHopper/MoveManipulator.java +++ b/src/main/java/frc/robot/commands/IntakeToHopper/MoveManipulator.java @@ -21,7 +21,7 @@ protected void initialize() { //Called repeatedly when this Command is scheduled to run @Override protected void execute() { - Robot.manipulator.setRetracted(true); + Robot.manipulator.setExtended(); Robot.manipulator.setManipulator(Constants.INTAKE_MOTORSPEED); } diff --git a/src/main/java/frc/robot/commands/Shooter/LongShot.java b/src/main/java/frc/robot/commands/Shooter/LongShot.java index 0915ea8..3ff7cb4 100644 --- a/src/main/java/frc/robot/commands/Shooter/LongShot.java +++ b/src/main/java/frc/robot/commands/Shooter/LongShot.java @@ -29,7 +29,7 @@ protected void initialize() { // Called repeatedly when this Command is scheduled to run @Override protected void execute() { - Robot.shooter.setShooter(Constants.SHOOTER_OUTPUT_LONG); + Robot.shooter.setShooterPID(-2791); } // Make this return true when this Command no longer needs to run execute() diff --git a/src/main/java/frc/robot/commands/Shooter/MoveShooter.java b/src/main/java/frc/robot/commands/Shooter/MoveShooter.java index d479b14..d9b31a2 100644 --- a/src/main/java/frc/robot/commands/Shooter/MoveShooter.java +++ b/src/main/java/frc/robot/commands/Shooter/MoveShooter.java @@ -5,7 +5,7 @@ /* the project. */ /*----------------------------------------------------------------------------*/ -package frc.robot.commands; +package frc.robot.commands.Shooter; import edu.wpi.first.wpilibj.command.Command; import frc.robot.Constants; diff --git a/src/main/java/frc/robot/commands/Shooter/StopShooter.java b/src/main/java/frc/robot/commands/Shooter/StopShooter.java index 4efe6b7..fbde93e 100644 --- a/src/main/java/frc/robot/commands/Shooter/StopShooter.java +++ b/src/main/java/frc/robot/commands/Shooter/StopShooter.java @@ -10,7 +10,7 @@ public class StopShooter extends Command{ private boolean retracted; public StopShooter(){ super("StopShooter"); - requires(Robot.hopper); + requires(Robot.shooter); } @Override @@ -20,16 +20,14 @@ protected void initialize(){ @Override protected void execute() { Robot.shooter.setShooter(0); - } @Override protected boolean isFinished(){ - return false; + return true; } @Override protected void end() { - Robot.shooter.setShooter(0); } @Override diff --git a/src/main/java/frc/robot/commands/Shooter/WallShot.java b/src/main/java/frc/robot/commands/Shooter/WallShot.java index 6a36500..f160958 100644 --- a/src/main/java/frc/robot/commands/Shooter/WallShot.java +++ b/src/main/java/frc/robot/commands/Shooter/WallShot.java @@ -30,7 +30,7 @@ protected void initialize() { @Override protected void execute() { - Robot.shooter.setShooter(Constants.SHOOTER_OUTPUT_WALL); //Utilize PIDs for this (and Longshot as well) + Robot.shooter.setShooterPID(-1300); //Utilize PIDs for this (and Longshot as well) } diff --git a/src/main/java/frc/robot/commands/StopManipulator.java b/src/main/java/frc/robot/commands/StopManipulator.java index 3ed750b..3d767cf 100644 --- a/src/main/java/frc/robot/commands/StopManipulator.java +++ b/src/main/java/frc/robot/commands/StopManipulator.java @@ -21,7 +21,7 @@ protected void initialize() { @Override protected void execute() { Robot.manipulator.setManipulator(0); - Robot.manipulator.setRetracted(false); + Robot.manipulator.setRetracted(); } //Make this return true when this Command no longer needs to run execute() diff --git a/src/main/java/frc/robot/subsystems/Climber.java b/src/main/java/frc/robot/subsystems/Climber.java index 4a6dc3b..4318cf7 100644 --- a/src/main/java/frc/robot/subsystems/Climber.java +++ b/src/main/java/frc/robot/subsystems/Climber.java @@ -44,53 +44,10 @@ public Climber(){ Extender = new Solenoid(RobotMap.kPCM, RobotMap.CLIMB_SOLENOID); // selfClimb_Neo= new CANSparkMax(RobotMap.SELFCLIMB_NEO, MotorType.kBrushless); driverStick = new Joystick(0); - driverY = new JoystickButton(driverStick,4); - driverB = new JoystickButton(driverStick,2); - driverA = new JoystickButton(driverStick, 1); - driverX = new JoystickButton(driverStick, 3); - - winch_Neo.setIdleMode(IdleMode.kBrake); - - climbGyro = new GyroBase(){ - - - @Override - public void close() throws Exception { - // TODO Auto-generated method stub - - } - - @Override - public void reset() { - // TODO Auto-generated method stub - - } - - @Override - public double getRate() { - // TODO Auto-generated method stub - return 0; - } - - @Override - public double getAngle() { - // TODO Auto-generated method stub - return 0; - } - - @Override - public void calibrate() { - // TODO Auto-generated method stub - - } - - - - }; -} + } public void initDefaultCommand() { // setDefaultCommand(new DefaultExtension()); @@ -101,12 +58,12 @@ public void setPinExtender(boolean extended){ Extender.set(extended); } public void setPinExtenderByButton(){ - if(driverY.get()){ - Extender.set(true); - } - else if(driverB.get()){ - Extender.set(false); - } + // if(driverY.get()){ + // Extender.set(true); + // } + // else if(driverB.get()){ + // Extender.set(false); + // } } public boolean getPinExtender(){ @@ -118,15 +75,15 @@ public void setWinchOutput(double outputWinch){ } public void setWinchOutputByButton(){ - if (driverA.get()){ - winch_Neo.set(1); - } - else if (driverX.get()){ - winch_Neo.set(-1); - } - else { - winch_Neo.set(0); - } + // if (driverA.get()){ + // winch_Neo.set(1); + // } + // else if (driverX.get()){ + // winch_Neo.set(-1); + // } + // else { + // winch_Neo.set(0); + // } } public void calibrateGyro(){ diff --git a/src/main/java/frc/robot/subsystems/Hopper.java b/src/main/java/frc/robot/subsystems/Hopper.java index 70c6321..7f7f6ad 100644 --- a/src/main/java/frc/robot/subsystems/Hopper.java +++ b/src/main/java/frc/robot/subsystems/Hopper.java @@ -27,14 +27,15 @@ public class Hopper extends Subsystem { public CANSparkMax hopper_horizontal; public CANSparkMax hopper_vertical; public Solenoid hopper_stopper; - public IrSensor irSensor; + public IrSensor entrySensor, upperSensor; public Hopper(){ hopper_horizontal = new CANSparkMax(RobotMap.HORIZONTAL_HOPPER, MotorType.kBrushless); hopper_vertical = new CANSparkMax(RobotMap.VERTICAL_HOPPER, MotorType.kBrushless); hopper_stopper = new Solenoid(RobotMap.kPCM, RobotMap.HOPPER_SOLENOID); - irSensor = new IrSensor(RobotMap.kPDP); + entrySensor = new IrSensor(RobotMap.kPDP); + upperSensor = new IrSensor(2); hopper_horizontal.setSmartCurrentLimit(20); hopper_vertical.setSmartCurrentLimit(20); @@ -50,15 +51,17 @@ public void setHopper(final double output, final double vOutput){ public boolean isRetracted() { return !hopper_stopper.get(); } + public void setRetracted(boolean retract) { hopper_stopper.set(retract); } + public boolean getRetracted() { return hopper_stopper.get(); } - + public int getIRSensor() { - return irSensor.getValue(); + return entrySensor.getValue(); } public double getHorizontalCurrent() { @@ -78,9 +81,21 @@ public boolean isBall(){ } } + public boolean isUpperSensorTripped() { + return 1750 <= upperSensor.getValue(); + } + public void poopBall(){ if(Constants.BALL_VALUE < getIRSensor()){ - setHopper(Constants.HOPPER_LOADING_HORIZONTAL_OUTPUT, Constants.HOPPER_VERTICAL_OUTPUT); + if (isUpperSensorTripped()) { + setHopper( + Constants.HOPPER_LOADING_HORIZONTAL_OUTPUT, + 0); + } else { + setHopper( + Constants.HOPPER_LOADING_HORIZONTAL_OUTPUT, + Constants.HOPPER_VERTICAL_OUTPUT); + } } else{ setHopper(0, 0); } @@ -88,12 +103,12 @@ public void poopBall(){ public void debug(){ //SmartDashboard.putNumber("Hopper Voltage - ", getHopperVoltage()); - SmartDashboard.putNumber("IR Value", irSensor.getValue()); + SmartDashboard.putNumber("Entry IR Value", entrySensor.getValue()); SmartDashboard.putBoolean("Got Balls?", isBall()); SmartDashboard.putNumber("Horizontal Current", getHorizontalCurrent()); SmartDashboard.putNumber("Vertical Current", getVerticalCurrent()); - - + SmartDashboard.putBoolean("Hopper Stopper Out", isRetracted()); + SmartDashboard.putNumber("Upper IR Value", upperSensor.getValue()); } @Override protected void initDefaultCommand() { diff --git a/src/main/java/frc/robot/subsystems/Limelight.java b/src/main/java/frc/robot/subsystems/Limelight.java new file mode 100644 index 0000000..f1e0588 --- /dev/null +++ b/src/main/java/frc/robot/subsystems/Limelight.java @@ -0,0 +1,290 @@ +package frc.robot.subsystems; + +import edu.wpi.first.networktables.NetworkTable; +import edu.wpi.first.networktables.NetworkTableEntry; +import edu.wpi.first.networktables.NetworkTableInstance; +import edu.wpi.first.wpilibj.command.Subsystem; + +public class Limelight extends Subsystem { + + private NetworkTable getTable() { + return NetworkTableInstance.getDefault().getTable("limelight"); + } + + private NetworkTableEntry getEntry(String entryName) { + return getTable().getEntry(entryName); + } + + private double getValue(String entryName) { + return getEntry(entryName).getDouble(0); + } + + private void setValue(String entryName, double value) { + getEntry(entryName).setNumber(value); + } + + /** @return true if the Limelight has any valid targets */ + public boolean hasValidTargets() { + return getValue("tv") == 1; + } + + public double getTargetValue() { + return getValue("tv"); + } + + /** @return horizontal offset from crosshair to target (-27 degrees to 27 degrees) */ + public double getHorizontalOffset() { + return getValue("tx"); + } + + /** @return vertical offset from crosshair to target (-20.5 degrees to 20.5 degrees) */ + public double getVerticalOffset() { + return getValue("ty"); + } + + /** @return target area (0% of image to 100% of image) */ + public double getTargetArea() { + return getValue("ta"); + } + + /** @return skew or rotation (-90 degrees to 0 degrees) */ + public double getSkewOrRotation() { + return getValue("ts"); + } + + /** @return pipeline's latency contribution (ms); add 11ms for image capture */ + public double getLatency() { + return getValue("tl"); + } + + /** @return sidelength of shortest side of the fitted bounding box (pixels) */ + public double getShortSideLength() { + return getValue("tshort"); + } + + /** @return sidelength of longest side of the fitted bounding box (pixels) */ + public double getLongSideLength() { + return getValue("tlong"); + } + + /** @return Horizontal sidelength of the rough bounding box (0 - 320 pixels) */ + public double getHorizontalSidelength() { + return getValue("thor"); + } + + /** @return Vertical sidelength of the rough bounding box (0 - 320 pixels) */ + public double getVerticalSidelength() { + return getValue("tvert"); + } + + /** @return True active pipeline index of the camera (0 .. 9) */ + public double getPipeline() { + return getValue("getpipe"); + } + + /** + * @return Results of a 3D position solution, 6 numbers: Translation (x,y,y) + * Rotation(pitch,yaw,roll) + */ + public Double[] getCamtran() { + return getEntry("camtran").getDoubleArray(new Double[] {}); + } + + public enum LedMode { + PIPELINE(0), + FORCE_OFF(1), + FORCE_BLINK(2), + FORCE_ON(3), + UNKNOWN(-1); + public double value; + + LedMode(double value) { + this.value = value; + } + } + + /** @return The current LED mode set on the Limelight */ + public LedMode getLedMode() { + double mode = getValue("ledMode"); + if (mode == 0) { + return LedMode.PIPELINE; // Uses the LED mode set in the pipeliine + } else if (mode == 1) { + return LedMode.FORCE_OFF; + } else if (mode == 2) { + return LedMode.FORCE_BLINK; + } else if (mode == 3) { + return LedMode.FORCE_ON; + } else { + System.out.println("[Limelight] UNKNOWN LED MODE -- " + mode); + return LedMode.UNKNOWN; + } + } + + /** @param mode The LED Mode to set on the Limelight */ + public void setLedMode(LedMode mode) { + if (mode != LedMode.UNKNOWN) { + setValue("ledMode", mode.value); + } + } + + public enum CamMode { + VISION_CAM(0), + DRIVER_CAM(1), + UNKNOWN(-1); + public double value; + + CamMode(double value) { + this.value = value; + } + } + + /** @return The current LED mode set on the Limelight */ + public CamMode getCamMode() { + double mode = getValue("camMode"); + if (mode == 0) { + return CamMode.VISION_CAM; + } else if (mode == 1) { + return CamMode.DRIVER_CAM; + } else { + System.out.println("[Limelight] UNKNOWN CAMERA MODE -- " + mode); + return CamMode.UNKNOWN; + } + } + + /** @param mode The LED Mode to set on the Limelight */ + public void setCamMode(CamMode mode) { + if (mode != CamMode.UNKNOWN) { + setValue("camMode", mode.value); + } + } + + public enum Pipeline { + PIPELINE0(0), + PIPELINE1(1), + PIPELINE2(2), + PIPELINE3(3), + PIPELINE4(4), + PIPELINE5(5), + PIPELINE6(6), + PIPELINE7(7), + PIPELINE8(8), + PIPELINE9(9), + UNKNOWN(-1); + + public double value; + + Pipeline(double value) { + this.value = value; + } + } + + /** @return The current LED mode set on the Limelight */ + public Pipeline getCurrentPipeline() { + double mode = getValue("pipeline"); + if (mode == 0) { + return Pipeline.PIPELINE0; + } else if (mode == 1) { + return Pipeline.PIPELINE1; + } else if (mode == 2) { + return Pipeline.PIPELINE2; + } else if (mode == 3) { + return Pipeline.PIPELINE3; + } else if (mode == 4) { + return Pipeline.PIPELINE4; + } else if (mode == 5) { + return Pipeline.PIPELINE5; + } else if (mode == 6) { + return Pipeline.PIPELINE6; + } else if (mode == 7) { + return Pipeline.PIPELINE7; + } else if (mode == 8) { + return Pipeline.PIPELINE8; + } else if (mode == 9) { + return Pipeline.PIPELINE9; + } else { + System.out.println("[Limelight] UNKNOWN Pipeline -- " + mode); + return Pipeline.UNKNOWN; + } + } + + /** @param mode The LED Mode to set on the Limelight */ + public void setPipeline(Pipeline mode) { + if (mode != Pipeline.UNKNOWN) { + setValue("pipeline", mode.value); + } + } + + public enum StreamMode { + STANDARD(0), + PIP_MAIN(1), + PIP_SECONDARY(2), + UNKNOWN(-1); + + public double value; + + StreamMode(double value) { + this.value = value; + } + } + + /** @return The current LED mode set on the Limelight */ + public StreamMode getCurrentStreamMode() { + double mode = getValue("stream"); + if (mode == 0) { + return StreamMode.STANDARD; // Side-by-side streams if a webcam is attached to Limelight + } else if (mode == 1) { + return StreamMode + .PIP_MAIN; // The secondary camera stream is placed in the lower-right corner of the + // primary camera stream + } else if (mode == 2) { + return StreamMode.PIP_SECONDARY; + } else { + System.out.println("[Limelight] UNKNOWN StreamMode -- " + mode); + return StreamMode.UNKNOWN; + } + } + + /** @param mode The LED Mode to set on the Limelight */ + public void setStreamMode(StreamMode mode) { + if (mode != StreamMode.UNKNOWN) { + setValue("stream", mode.value); + } + } + + public enum SnapshotMode { + OFF(0), + TWO_PER_SECOND(1), + UNKNOWN(-1); + + public double value; + + SnapshotMode(double value) { + this.value = value; + } + } + + /** @return The current LED mode set on the Limelight */ + public SnapshotMode getCurrentSnapShotMode() { + double mode = getValue("snapshot"); + if (mode == 0) { + return SnapshotMode.OFF; + } else if (mode == 1) { + return SnapshotMode.TWO_PER_SECOND; + } else { + System.out.println("[Limelight] UNKNOWN SnapshotMode -- " + mode); + return SnapshotMode.UNKNOWN; + } + } + + /** @param mode The LED Mode to set on the Limelight */ + public void setSnapshotMode(SnapshotMode mode) { + if (mode != SnapshotMode.UNKNOWN) { + setValue("snapshot", mode.value); + } + } + + @Override + protected void initDefaultCommand() { + // TODO Auto-generated method stub + } +} \ No newline at end of file diff --git a/src/main/java/frc/robot/subsystems/Manipulator.java b/src/main/java/frc/robot/subsystems/Manipulator.java index 9ac765a..b3b3002 100644 --- a/src/main/java/frc/robot/subsystems/Manipulator.java +++ b/src/main/java/frc/robot/subsystems/Manipulator.java @@ -32,12 +32,16 @@ public boolean isRetracted() { //I think extender.get() returns false when it's extended return !extender.get(); } - public void setRetracted(boolean retract) { - extender.set(retract); + public void setExtended() { + extender.set(true); + } + public void setRetracted() { + extender.set(false); } public boolean getRetracted() { - return extender.get(); + return !extender.get(); } + public void debug() { SmartDashboard.putBoolean("Manipulator Extender Solenoid", extender.get()); } diff --git a/src/main/java/frc/robot/subsystems/Shooter.java b/src/main/java/frc/robot/subsystems/Shooter.java index f167a5d..dd406ba 100644 --- a/src/main/java/frc/robot/subsystems/Shooter.java +++ b/src/main/java/frc/robot/subsystems/Shooter.java @@ -54,7 +54,7 @@ public double idealVelocity(double angle, double dist, double height){ } public double applyDrag(double velocity){ velocity*=Constants.kDrag; - + return velocity; } public double applyMagnus(double velocity){ @@ -138,6 +138,5 @@ public void debug() { SmartDashboard.putBoolean("Hood Position", getHood1()); SmartDashboard.putNumber("Voltage", getShooterVoltage()); SmartDashboard.putNumber("Calculated Velcoity", getShooterVelocity2()); - } } From e9f92c83cf9003267656355e569677f52659a18a Mon Sep 17 00:00:00 2001 From: frcteam2791 Date: Sun, 1 Mar 2020 08:18:30 -0800 Subject: [PATCH 27/68] Added Two Cameras --- src/main/java/frc/robot/OI.java | 27 +++++++++++++++---- src/main/java/frc/robot/Robot.java | 2 ++ .../commands/IntakeToHopper/IrHopper.java | 7 ++++- .../IntakeToHopper/ManipulatorToIrHopper.java | 14 ++++++++++ .../frc/robot/commands/Shooter/LongShot.java | 1 + .../java/frc/robot/subsystems/Hopper.java | 4 +++ .../java/frc/robot/subsystems/Shooter.java | 2 +- 7 files changed, 50 insertions(+), 7 deletions(-) create mode 100644 src/main/java/frc/robot/commands/IntakeToHopper/ManipulatorToIrHopper.java diff --git a/src/main/java/frc/robot/OI.java b/src/main/java/frc/robot/OI.java index 32cf40e..322dfec 100644 --- a/src/main/java/frc/robot/OI.java +++ b/src/main/java/frc/robot/OI.java @@ -19,6 +19,8 @@ import frc.robot.controller.AnalogButton; import frc.robot.controller.DPadButton; import frc.robot.controller.MultiButton; + +import frc.robot.util.Camera_Switch.CameraSwitch; // import frc.robot.Autons.ShooterGroupLong; // import frc.robot.Autons.StopShooterGroupLong; // import frc.robot.Autons.ShooterGroupWall; @@ -94,9 +96,17 @@ public OI() { operatorX.whenReleased(new StopHopper()); operatorRB.whenPressed(new WallShot()); + operatorRB.whenPressed(new InstantCommand(() -> { + Robot.Cam_switch.select(CameraSwitch.kcamera1);; + })); + // operatorRB.whenPressed(new setCameraOne()); // operatorRB.whenReleased(new StopShooter()); operatorLB.whenPressed(new LongShot()); + operatorLB.whenPressed(new InstantCommand(() -> { + Robot.Cam_switch.select(CameraSwitch.kcamera1);; + })); + // operatorLB.whenPressed(new setCameraOne()); // operatorLB.whenReleased(new StopShooter()); // operatorStart.whenPressed(new StopShooter()); new Trigger(){ @@ -107,8 +117,14 @@ public boolean get() { } }.whenActive(new StopShooter()); - // driverA.whenPressed(new MoveManipulator()); //moves wheels as well so don't be surprised - // driverA.whenReleased(new StopManipulator()); + driverA.whenPressed(new MoveManipulator()); //moves wheels as well so don't be surprised + driverA.whenReleased(new StopManipulator()); + driverA.whenPressed(new InstantCommand(() -> { + Robot.Cam_switch.select(CameraSwitch.kcamera2);; + })); + // driverA.whileHeld(new ManipulatorToIrHopper()); + // driverA.whenReleased(new StopManipulator()); + // // driverA.whenReleased(new StopHopper()); driverDPadRight.whileHeld(new DrivetrainAlignToGoal()); driverDPadLeft.whenPressed(new MoveManipulator()); @@ -119,8 +135,9 @@ public boolean get() { // driverDPadRight.whenReleased(new DefaultPanelMech()); //driverDPadDown.whenPressed(new SetPanelMech()); - driverX.whenPressed(new ReleasePin(true, false)); - driverA.whenPressed(new ReleasePin(false, false)); + + // driverX.whenPressed(new ReleasePin(true, false)); + // driverA.whenPressed(new ReleasePin(false, false)); driverY.whileHeld(new WinchClimb(true)); driverY.whenReleased(new StopWinchClimb()); driverB.whileHeld(new WinchClimb(false)); @@ -182,4 +199,4 @@ public boolean get() { } }; } -} +} \ No newline at end of file diff --git a/src/main/java/frc/robot/Robot.java b/src/main/java/frc/robot/Robot.java index b740b18..7f9fb73 100644 --- a/src/main/java/frc/robot/Robot.java +++ b/src/main/java/frc/robot/Robot.java @@ -82,6 +82,7 @@ public void robotPeriodic() { SmartDashboard.putBoolean("Compressor Status", compressor.enabled()); hopper.debug(); climber.debug(); + shooter.debug(); // if(operatorA.get() == true) { // Cam_switch.select(CameraSwitch.kcamera1); // } @@ -134,6 +135,7 @@ public void teleopInit() { manipulator.setRetracted(); Robot.hopper.hopper_stopper.set(true); + Robot.shooter.setHood1(false); } @Override diff --git a/src/main/java/frc/robot/commands/IntakeToHopper/IrHopper.java b/src/main/java/frc/robot/commands/IntakeToHopper/IrHopper.java index 1236b08..c3dc6e3 100644 --- a/src/main/java/frc/robot/commands/IntakeToHopper/IrHopper.java +++ b/src/main/java/frc/robot/commands/IntakeToHopper/IrHopper.java @@ -8,8 +8,10 @@ package frc.robot.commands.IntakeToHopper; import edu.wpi.first.wpilibj.command.Command; +import edu.wpi.first.wpilibj.smartdashboard.SmartDashboard; import frc.robot.Constants; import frc.robot.Robot; +import frc.robot.commands.IntakeToHopper.MoveManipulator; public class IrHopper extends Command { public IrHopper() { @@ -27,7 +29,8 @@ protected void initialize() { // Called repeatedly when this Command is scheduled to run @Override protected void execute() { - Robot.hopper.setHopper(Constants.HOPPER_LOADING_HORIZONTAL_OUTPUT, Constants.HOPPER_VERTICAL_OUTPUT); + Robot.hopper.setHopper(Constants.HOPPER_LOADING_HORIZONTAL_OUTPUT, Constants.HOPPER_VERTICAL_OUTPUT); + SmartDashboard.putBoolean("Ir Hopper Running", true); } // Make this return true when this Command no longer needs to run execute() @@ -41,6 +44,7 @@ protected boolean isFinished() { @Override protected void end() { Robot.hopper.setHopper(0, 0); + SmartDashboard.putBoolean("Ir Hopper Running", false); } // Called when another command which requires one or more of the same @@ -48,4 +52,5 @@ protected void end() { @Override protected void interrupted() { } + } diff --git a/src/main/java/frc/robot/commands/IntakeToHopper/ManipulatorToIrHopper.java b/src/main/java/frc/robot/commands/IntakeToHopper/ManipulatorToIrHopper.java new file mode 100644 index 0000000..2b8568a --- /dev/null +++ b/src/main/java/frc/robot/commands/IntakeToHopper/ManipulatorToIrHopper.java @@ -0,0 +1,14 @@ +package frc.robot.commands.IntakeToHopper; + +import edu.wpi.first.wpilibj.command.CommandGroup; +// import frc.robot.Robot; +// import frc.robot.commands.IntakeToHopper.*; +import frc.robot.commands.StopHopper; + +public class ManipulatorToIrHopper extends CommandGroup{ + public ManipulatorToIrHopper(){ + addParallel(new MoveManipulator()); + addParallel(new IrHopper()); + addSequential(new StopHopper()); + } +} \ No newline at end of file diff --git a/src/main/java/frc/robot/commands/Shooter/LongShot.java b/src/main/java/frc/robot/commands/Shooter/LongShot.java index 3ff7cb4..3030f28 100644 --- a/src/main/java/frc/robot/commands/Shooter/LongShot.java +++ b/src/main/java/frc/robot/commands/Shooter/LongShot.java @@ -32,6 +32,7 @@ protected void execute() { Robot.shooter.setShooterPID(-2791); } + // Make this return true when this Command no longer needs to run execute() @Override protected boolean isFinished() { diff --git a/src/main/java/frc/robot/subsystems/Hopper.java b/src/main/java/frc/robot/subsystems/Hopper.java index 7f7f6ad..c0791e3 100644 --- a/src/main/java/frc/robot/subsystems/Hopper.java +++ b/src/main/java/frc/robot/subsystems/Hopper.java @@ -52,6 +52,10 @@ public boolean isRetracted() { return !hopper_stopper.get(); } + public void setExtended() { + hopper_stopper.set(false); + } + public void setRetracted(boolean retract) { hopper_stopper.set(retract); } diff --git a/src/main/java/frc/robot/subsystems/Shooter.java b/src/main/java/frc/robot/subsystems/Shooter.java index dd406ba..3d32f51 100644 --- a/src/main/java/frc/robot/subsystems/Shooter.java +++ b/src/main/java/frc/robot/subsystems/Shooter.java @@ -135,7 +135,7 @@ public boolean checkWheelSpeed_Long() { public void debug() { SmartDashboard.putNumber("Shooter Neo Velocity -", getShooterVelocity()); SmartDashboard.putNumber("Shooter Neo CPR -", getShooter()); - SmartDashboard.putBoolean("Hood Position", getHood1()); + SmartDashboard.putBoolean("Hood Position Down", !getHood1()); SmartDashboard.putNumber("Voltage", getShooterVoltage()); SmartDashboard.putNumber("Calculated Velcoity", getShooterVelocity2()); } From 7883ec65309d746412a30d9a7777e9e14d4408e5 Mon Sep 17 00:00:00 2001 From: frcteam2791 Date: Sun, 1 Mar 2020 13:23:46 -0800 Subject: [PATCH 28/68] Tuned intake/hopper speeds and PID for wall shot Hopper is better at holding 5 but there is still a jam case when spacing isn't controlled properly. Wall shot was oscillating/taking a bit of time to spin up--new pid constants found to add possibility for a second pid controller --- src/main/java/frc/robot/Constants.java | 19 +++++++---- src/main/java/frc/robot/OI.java | 34 +++++++++++++------ src/main/java/frc/robot/Robot.java | 15 ++++---- .../commands/IntakeToHopper/IrHopper.java | 4 ++- .../java/frc/robot/subsystems/Hopper.java | 10 ++++-- .../java/frc/robot/subsystems/Shooter.java | 6 ++-- 6 files changed, 57 insertions(+), 31 deletions(-) diff --git a/src/main/java/frc/robot/Constants.java b/src/main/java/frc/robot/Constants.java index e8b1ceb..6ca3d1d 100644 --- a/src/main/java/frc/robot/Constants.java +++ b/src/main/java/frc/robot/Constants.java @@ -24,11 +24,13 @@ public final class Constants { public static final double kCamStraightSlow = 0.25; - public static final double ShooterkP = 0.002525; - public static final double ShooterkI = 0; - public static final double ShooterkD = 0.22; + public static final double ShooterTrenchkP = 0.002525; + public static final double ShooterTrenchkD = 0.22; + public static final double ShooterTrenchkFF = 0.0002; + public static final double ShooterWallkP = 0.001500; + public static final double ShooterWallkD = 0.1; + public static final double ShooterWallkF = 0.000180; public static final double ShooterkIz = 0; - public static final double ShooterkFF = 0.0002; public static final double ShooterMaxOutput = 1; public static final double ShooterMinOutput = -1; // max and min outputs that pidcontroller can send to the sparkmax public static final double kGravity = 32.1741; //acceleration due to gravity in ft/s/s @@ -64,16 +66,19 @@ public final class Constants { public static final double ELEVATOR_OUTPUT = -.05; - public static final double HOPPER_LOADING_HORIZONTAL_OUTPUT = .60; + public static final double HOPPER_LOADING_HORIZONTAL_OUTPUT = .62; public static final double HOPPER_WALL_HORIZONTAL_OUTPUT = 0.30; public static final double HOPPER_VERTICAL_OUTPUT = .35; + + + public static final double HOPPER_LOADING_VERTICAL_OUTPUT = .07; - public static final double REVERSE_HOPPER = -.20; + public static final double REVERSE_HOPPER = -.40; public static final double SHOOTER_OUTPUT = -.8; @@ -90,7 +95,7 @@ public final class Constants { public static final double MANUAL_POWER = .2; - public static final double INTAKE_MOTORSPEED = 0.15; //Temp value please test it out and do stuff yes + public static final double INTAKE_MOTORSPEED = 0.135; //Temp value please test it out and do stuff yes public static final double SHOOTER_VELOCITY = 100; //Temporary value diff --git a/src/main/java/frc/robot/OI.java b/src/main/java/frc/robot/OI.java index 322dfec..7da7ed1 100644 --- a/src/main/java/frc/robot/OI.java +++ b/src/main/java/frc/robot/OI.java @@ -73,8 +73,21 @@ public OI() { operatorDPadLeft.whenPressed(new LongShotHood()); operatorDPadRight.whenPressed(new WallShotHood()); - operatorDPadDown.whenPressed(new ReverseHopper()); - operatorDPadDown.whenReleased(new StopHopper()); + new Trigger(){ + @Override + public boolean get() { + // TODO Auto-generated method stub + return operatorStick.getRawAxis(1) > 0.8; + } + }.whenActive(new ReverseHopper()); + + new Trigger(){ + @Override + public boolean get() { + // TODO Auto-generated method stub + return operatorStick.getRawAxis(1) > 0.8; + } + }.whenInactive(new StopHopper()); // operatorA.whenPressed(new MoveHopperLong()); // operatorA.whenReleased(new StopHopper()); @@ -122,22 +135,23 @@ public boolean get() { driverA.whenPressed(new InstantCommand(() -> { Robot.Cam_switch.select(CameraSwitch.kcamera2);; })); - // driverA.whileHeld(new ManipulatorToIrHopper()); - // driverA.whenReleased(new StopManipulator()); - // // driverA.whenReleased(new StopHopper()); + + // driverA.whileHeld(new ManipulatorToIrHopper()); + // driverA.whenReleased(new StopManipulator()); + // driverA.whenReleased(new StopHopper()); driverDPadRight.whileHeld(new DrivetrainAlignToGoal()); - driverDPadLeft.whenPressed(new MoveManipulator()); - driverDPadLeft.whenReleased(new StopManipulator() - ); + // driverDPadLeft.whenPressed(new MoveManipulator()); + // driverDPadLeft.whenReleased(new StopManipulator()); // driverDPadRight.whenPressed(new ExtendPanelMech()); // driverDPadRight.whenReleased(new DefaultPanelMech()); + driverDPadDown.whenPressed(new ReleasePin(false, false)); //driverDPadDown.whenPressed(new SetPanelMech()); - // driverX.whenPressed(new ReleasePin(true, false)); - // driverA.whenPressed(new ReleasePin(false, false)); + driverX.whenPressed(new ReleasePin(true, true)); + //driverA.whenPressed(new ReleasePin(false, false)); driverY.whileHeld(new WinchClimb(true)); driverY.whenReleased(new StopWinchClimb()); driverB.whileHeld(new WinchClimb(false)); diff --git a/src/main/java/frc/robot/Robot.java b/src/main/java/frc/robot/Robot.java index 7f9fb73..9a074cf 100644 --- a/src/main/java/frc/robot/Robot.java +++ b/src/main/java/frc/robot/Robot.java @@ -128,9 +128,9 @@ public void teleopInit() { System.out.println("This is init"); - SmartDashboard.putNumber("Shooter kP", Constants.ShooterkP); - SmartDashboard.putNumber("Shooter kF", Constants.ShooterkFF); - SmartDashboard.putNumber("Shooter kD", Constants.ShooterkD); + SmartDashboard.putNumber("Shooter kP", Constants.ShooterTrenchkP); + SmartDashboard.putNumber("Shooter kF", Constants.ShooterTrenchkFF); + SmartDashboard.putNumber("Shooter kD", Constants.ShooterTrenchkD); SmartDashboard.putNumber("Shooter setpoint", 0); manipulator.setRetracted(); @@ -153,8 +153,6 @@ public void teleopPeriodic() { // 0.5 power is the sweet spot for wall, 0.8 for current at angle of 39 degrees Scheduler.getInstance().run(); - SmartDashboard.putNumber("Shooter velocity", shooter.getShooterVelocity()); - // double kp = SmartDashboard.getNumber("Shooter kP", 0); // double kf = SmartDashboard.getNumber("Shooter kF", 0); @@ -164,8 +162,11 @@ public void teleopPeriodic() { // shooter.shooter_leader.getPIDController().setFF(kf); // shooter.shooter_leader.getPIDController().setD(kd); - double setpoint = SmartDashboard.getNumber("Shooter setpoint", 0); - // shooter.setShooterPID(setpoint); + // double setpoint = SmartDashboard.getNumber("Shooter setpoint", 0); + // if (setpoint==0) + // shooter.setShooter(0); + // else + // shooter.setShooterPID(setpoint); } @Override public void testPeriodic() { diff --git a/src/main/java/frc/robot/commands/IntakeToHopper/IrHopper.java b/src/main/java/frc/robot/commands/IntakeToHopper/IrHopper.java index c3dc6e3..8ec9a87 100644 --- a/src/main/java/frc/robot/commands/IntakeToHopper/IrHopper.java +++ b/src/main/java/frc/robot/commands/IntakeToHopper/IrHopper.java @@ -29,7 +29,8 @@ protected void initialize() { // Called repeatedly when this Command is scheduled to run @Override protected void execute() { - Robot.hopper.setHopper(Constants.HOPPER_LOADING_HORIZONTAL_OUTPUT, Constants.HOPPER_VERTICAL_OUTPUT); + // Robot.hopper.setHopper(Constants.HOPPER_LOADING_HORIZONTAL_OUTPUT, Constants.HOPPER_VERTICAL_OUTPUT); + Robot.hopper.loadingWithIR(); SmartDashboard.putBoolean("Ir Hopper Running", true); } @@ -37,6 +38,7 @@ protected void execute() { @Override protected boolean isFinished() { + // return !Robot.hopper.isBall() || Robot.hopper.isUpperSensorTripped(); return !Robot.hopper.isBall(); } diff --git a/src/main/java/frc/robot/subsystems/Hopper.java b/src/main/java/frc/robot/subsystems/Hopper.java index c0791e3..7f17195 100644 --- a/src/main/java/frc/robot/subsystems/Hopper.java +++ b/src/main/java/frc/robot/subsystems/Hopper.java @@ -10,6 +10,7 @@ import com.ctre.phoenix.motorcontrol.ControlMode; import com.revrobotics.CANSparkMax; +import com.revrobotics.CANSparkMax.IdleMode; import com.revrobotics.CANSparkMaxLowLevel.MotorType; import frc.robot.Constants; @@ -36,6 +37,9 @@ public Hopper(){ hopper_stopper = new Solenoid(RobotMap.kPCM, RobotMap.HOPPER_SOLENOID); entrySensor = new IrSensor(RobotMap.kPDP); upperSensor = new IrSensor(2); + + hopper_horizontal.setIdleMode(IdleMode.kBrake); + hopper_vertical.setIdleMode(IdleMode.kBrake); hopper_horizontal.setSmartCurrentLimit(20); hopper_vertical.setSmartCurrentLimit(20); @@ -86,10 +90,10 @@ public boolean isBall(){ } public boolean isUpperSensorTripped() { - return 1750 <= upperSensor.getValue(); + return 745 <= upperSensor.getValue(); } - public void poopBall(){ + public void loadingWithIR(){ if(Constants.BALL_VALUE < getIRSensor()){ if (isUpperSensorTripped()) { setHopper( @@ -98,7 +102,7 @@ public void poopBall(){ } else { setHopper( Constants.HOPPER_LOADING_HORIZONTAL_OUTPUT, - Constants.HOPPER_VERTICAL_OUTPUT); + Constants.HOPPER_LOADING_VERTICAL_OUTPUT); } } else{ setHopper(0, 0); diff --git a/src/main/java/frc/robot/subsystems/Shooter.java b/src/main/java/frc/robot/subsystems/Shooter.java index 3d32f51..4654994 100644 --- a/src/main/java/frc/robot/subsystems/Shooter.java +++ b/src/main/java/frc/robot/subsystems/Shooter.java @@ -39,9 +39,9 @@ public Shooter(){ shooter_follower.follow(shooter_leader, true); hood_1 = new Solenoid(RobotMap.kPCM, RobotMap.HOOD_SOLENOID); - shooter_leader.getPIDController().setP(Constants.ShooterkP); - shooter_leader.getPIDController().setFF(Constants.ShooterkFF); - shooter_leader.getPIDController().setD(Constants.ShooterkD); + shooter_leader.getPIDController().setP(Constants.ShooterTrenchkP); + shooter_leader.getPIDController().setFF(Constants.ShooterTrenchkFF); + shooter_leader.getPIDController().setD(Constants.ShooterTrenchkD); shooter_leader.getPIDController().setOutputRange(-1, 1); shooter_leader.enableVoltageCompensation(12.4); From ae61597e7f3b66dbbed20470cc3f7ace73657831 Mon Sep 17 00:00:00 2001 From: frcteam2791 Date: Sun, 1 Mar 2020 16:32:24 -0500 Subject: [PATCH 29/68] Reduced buttons (added commands) Yet to be tested --- src/main/java/frc/robot/OI.java | 6 +-- .../commands/IntakeToHopper/IrHopper.java | 7 --- .../IntakeToHopper/ManipulatorToIrHopper.java | 4 +- .../{ => IntakeToHopper}/MoveHopperWall.java | 2 +- .../IntakeToHopper/MoveManipulator.java | 4 +- .../OpenPistonsAndMoveHopper.java | 51 +++++++++++++++++++ 6 files changed, 60 insertions(+), 14 deletions(-) rename src/main/java/frc/robot/commands/{ => IntakeToHopper}/MoveHopperWall.java (97%) create mode 100644 src/main/java/frc/robot/commands/IntakeToHopper/OpenPistonsAndMoveHopper.java diff --git a/src/main/java/frc/robot/OI.java b/src/main/java/frc/robot/OI.java index 322dfec..05c2e29 100644 --- a/src/main/java/frc/robot/OI.java +++ b/src/main/java/frc/robot/OI.java @@ -85,9 +85,9 @@ public OI() { Robot.hopper.hopper_stopper.set(true); })); - operatorB.whenPressed(new InstantCommand(() -> { - Robot.hopper.hopper_stopper.set(false); - })); + operatorB.whileHeld(new OpenPistonsAndMoveHopper()); + + operatorB.whenReleased(new StopHopper()); operatorY.whileHeld(new MoveHopperWall()); operatorY.whenReleased(new StopHopper()); diff --git a/src/main/java/frc/robot/commands/IntakeToHopper/IrHopper.java b/src/main/java/frc/robot/commands/IntakeToHopper/IrHopper.java index c3dc6e3..a2533b7 100644 --- a/src/main/java/frc/robot/commands/IntakeToHopper/IrHopper.java +++ b/src/main/java/frc/robot/commands/IntakeToHopper/IrHopper.java @@ -1,10 +1,3 @@ -/*----------------------------------------------------------------------------*/ -/* Copyright (c) 2018 FIRST. All Rights Reserved. */ -/* Open Source Software - may be modified and shared by FRC teams. The code */ -/* must be accompanied by the FIRST BSD license file in the root directory of */ -/* the project. */ -/*----------------------------------------------------------------------------*/ - package frc.robot.commands.IntakeToHopper; import edu.wpi.first.wpilibj.command.Command; diff --git a/src/main/java/frc/robot/commands/IntakeToHopper/ManipulatorToIrHopper.java b/src/main/java/frc/robot/commands/IntakeToHopper/ManipulatorToIrHopper.java index 2b8568a..df9bb10 100644 --- a/src/main/java/frc/robot/commands/IntakeToHopper/ManipulatorToIrHopper.java +++ b/src/main/java/frc/robot/commands/IntakeToHopper/ManipulatorToIrHopper.java @@ -7,8 +7,8 @@ public class ManipulatorToIrHopper extends CommandGroup{ public ManipulatorToIrHopper(){ - addParallel(new MoveManipulator()); - addParallel(new IrHopper()); + addSequential(new MoveManipulator()); + addSequential(new IrHopper()); addSequential(new StopHopper()); } } \ No newline at end of file diff --git a/src/main/java/frc/robot/commands/MoveHopperWall.java b/src/main/java/frc/robot/commands/IntakeToHopper/MoveHopperWall.java similarity index 97% rename from src/main/java/frc/robot/commands/MoveHopperWall.java rename to src/main/java/frc/robot/commands/IntakeToHopper/MoveHopperWall.java index 017969a..f9bc688 100644 --- a/src/main/java/frc/robot/commands/MoveHopperWall.java +++ b/src/main/java/frc/robot/commands/IntakeToHopper/MoveHopperWall.java @@ -5,7 +5,7 @@ /* the project. */ /*----------------------------------------------------------------------------*/ -package frc.robot.commands; +package frc.robot.commands.IntakeToHopper; import edu.wpi.first.wpilibj.command.Command; import frc.robot.Constants; diff --git a/src/main/java/frc/robot/commands/IntakeToHopper/MoveManipulator.java b/src/main/java/frc/robot/commands/IntakeToHopper/MoveManipulator.java index 496f586..7cbd196 100644 --- a/src/main/java/frc/robot/commands/IntakeToHopper/MoveManipulator.java +++ b/src/main/java/frc/robot/commands/IntakeToHopper/MoveManipulator.java @@ -8,6 +8,7 @@ public class MoveManipulator extends Command { public MoveManipulator() { super("MoveManipulator"); requires(Robot.manipulator); + requires(Robot.hopper); //Use requires() here to declare subsystem dependencies //eg. requires(chassis); } @@ -23,12 +24,13 @@ protected void initialize() { protected void execute() { Robot.manipulator.setExtended(); Robot.manipulator.setManipulator(Constants.INTAKE_MOTORSPEED); + Robot.hopper.poopBall(); } //Make this return true when this Command no longer needs to run execute() @Override protected boolean isFinished() { - return true; + return !Robot.hopper.isBall(); } //Called once after isFinished returns true diff --git a/src/main/java/frc/robot/commands/IntakeToHopper/OpenPistonsAndMoveHopper.java b/src/main/java/frc/robot/commands/IntakeToHopper/OpenPistonsAndMoveHopper.java new file mode 100644 index 0000000..bddbe82 --- /dev/null +++ b/src/main/java/frc/robot/commands/IntakeToHopper/OpenPistonsAndMoveHopper.java @@ -0,0 +1,51 @@ +/*----------------------------------------------------------------------------*/ +/* Copyright (c) 2018 FIRST. All Rights Reserved. */ +/* Open Source Software - may be modified and shared by FRC teams. The code */ +/* must be accompanied by the FIRST BSD license file in the root directory of */ +/* the project. */ +/*----------------------------------------------------------------------------*/ + +package frc.robot.commands.IntakeToHopper; + +import edu.wpi.first.wpilibj.command.Command; +import frc.robot.Constants; +import frc.robot.Robot; + +public class OpenPistonsAndMoveHopper extends Command { + public OpenPistonsAndMoveHopper() { + super("OpenPistonsAndMoveHopper"); + requires(Robot.hopper); + // Use requires() here to declare subsystem dependencies + // eg. requires(chassis); + } + + // Called just before this Command runs the first time + @Override + protected void initialize() { + Robot.hopper.setRetracted(false); + } + + // Called repeatedly when this Command is scheduled to run + @Override + protected void execute() { + Robot.hopper.setHopper(Constants.HOPPER_WALL_HORIZONTAL_OUTPUT, Constants.HOPPER_VERTICAL_OUTPUT); + } + + // Make this return true when this Command no longer needs to run execute() + @Override + protected boolean isFinished() { + return true; + } + + // Called once after isFinished returns true + @Override + protected void end() { + // Robot.hopper.setHopper(0, 0); + } + + // Called when another command which requires one or more of the same + // subsystems is scheduled to run + @Override + protected void interrupted() { + } +} From e6786637cc4721b88559d8677ec3ef9a0cec86e9 Mon Sep 17 00:00:00 2001 From: allison-kunin Date: Sun, 1 Mar 2020 17:50:57 -0500 Subject: [PATCH 30/68] added some extend methods and timer added extend methods to some subsystems added a timer to the hopper piston extension started the toggle for setPanelMech --- .../frc/robot/Autons/ShooterGroupWall.java | 2 +- src/main/java/frc/robot/Autons/Stop.java | 2 +- src/main/java/frc/robot/OI.java | 19 +++---- .../robot/commands/Climb/StopWinchClimb.java | 2 +- .../frc/robot/commands/Climb/WinchClimb.java | 2 +- .../frc/robot/commands/DefaultExtension.java | 49 ------------------- .../frc/robot/commands/DefaultPanelMech.java | 2 +- .../frc/robot/commands/ExtendPanelMech.java | 2 +- .../IntakeToHopper/MoveManipulator.java | 4 +- .../OpenPistonsAndMoveHopper.java | 13 +++-- .../commands/Shooter/CloseHopperPiston.java | 2 +- .../commands/Shooter/OpenHopperPiston.java | 2 +- .../java/frc/robot/subsystems/Climber.java | 13 +++-- .../java/frc/robot/subsystems/Hopper.java | 6 +-- .../java/frc/robot/subsystems/PanelMech.java | 8 ++- 15 files changed, 46 insertions(+), 82 deletions(-) delete mode 100644 src/main/java/frc/robot/commands/DefaultExtension.java diff --git a/src/main/java/frc/robot/Autons/ShooterGroupWall.java b/src/main/java/frc/robot/Autons/ShooterGroupWall.java index 07567f9..2f7f472 100644 --- a/src/main/java/frc/robot/Autons/ShooterGroupWall.java +++ b/src/main/java/frc/robot/Autons/ShooterGroupWall.java @@ -2,7 +2,7 @@ import edu.wpi.first.wpilibj.command.CommandGroup; import frc.robot.Robot; -import frc.robot.commands.MoveHopperWall; +import frc.robot.commands.IntakeToHopper.MoveHopperWall; import frc.robot.commands.Shooter.OpenHopperPiston; import frc.robot.commands.Shooter.WallShot; import frc.robot.commands.Shooter.WallShotHood; diff --git a/src/main/java/frc/robot/Autons/Stop.java b/src/main/java/frc/robot/Autons/Stop.java index 4b3df3c..914a1bf 100644 --- a/src/main/java/frc/robot/Autons/Stop.java +++ b/src/main/java/frc/robot/Autons/Stop.java @@ -2,7 +2,7 @@ import edu.wpi.first.wpilibj.command.CommandGroup; import frc.robot.Robot; -import frc.robot.commands.MoveHopperWall; +import frc.robot.commands.IntakeToHopper.MoveHopperWall; import frc.robot.commands.StopHopper; import frc.robot.commands.Shooter.CloseHopperPiston; import frc.robot.commands.Shooter.OpenHopperPiston; diff --git a/src/main/java/frc/robot/OI.java b/src/main/java/frc/robot/OI.java index 86c5ef5..a3b2c9e 100644 --- a/src/main/java/frc/robot/OI.java +++ b/src/main/java/frc/robot/OI.java @@ -99,7 +99,6 @@ public boolean get() { })); operatorB.whileHeld(new OpenPistonsAndMoveHopper()); - operatorB.whenReleased(new StopHopper()); operatorY.whileHeld(new MoveHopperWall()); @@ -112,16 +111,12 @@ public boolean get() { operatorRB.whenPressed(new InstantCommand(() -> { Robot.Cam_switch.select(CameraSwitch.kcamera1);; })); - // operatorRB.whenPressed(new setCameraOne()); - // operatorRB.whenReleased(new StopShooter()); operatorLB.whenPressed(new LongShot()); operatorLB.whenPressed(new InstantCommand(() -> { Robot.Cam_switch.select(CameraSwitch.kcamera1);; })); - // operatorLB.whenPressed(new setCameraOne()); - // operatorLB.whenReleased(new StopShooter()); - // operatorStart.whenPressed(new StopShooter()); + new Trigger(){ @Override public boolean get() { @@ -141,14 +136,14 @@ public boolean get() { // driverA.whenReleased(new StopHopper()); driverDPadRight.whileHeld(new DrivetrainAlignToGoal()); - // driverDPadLeft.whenPressed(new MoveManipulator()); - // driverDPadLeft.whenReleased(new StopManipulator()); - // driverDPadRight.whenPressed(new ExtendPanelMech()); - // driverDPadRight.whenReleased(new DefaultPanelMech()); - driverDPadDown.whenPressed(new ReleasePin(false, false)); + driverDPadLeft.whenPressed(new ExtendPanelMech()); + driverDPadLeft.whenReleased(new DefaultPanelMech()); - //driverDPadDown.whenPressed(new SetPanelMech()); + driverDPadDown.whenPressed(new InstantCommand(() -> { + Robot.climber.setRetracted();; + })); + //driverDPadUp.whenPressed(new SetPanelMech()); driverX.whenPressed(new ReleasePin(true, true)); //driverA.whenPressed(new ReleasePin(false, false)); diff --git a/src/main/java/frc/robot/commands/Climb/StopWinchClimb.java b/src/main/java/frc/robot/commands/Climb/StopWinchClimb.java index 63f8a59..eb238f9 100644 --- a/src/main/java/frc/robot/commands/Climb/StopWinchClimb.java +++ b/src/main/java/frc/robot/commands/Climb/StopWinchClimb.java @@ -26,7 +26,7 @@ protected void initialize() { @Override protected void execute() { Robot.climber.setWinchOutput(0); - Robot.climber.setPinExtender(false); + Robot.climber.setRetracted(); } // Make this return true when this Command no longer needs to run execute() diff --git a/src/main/java/frc/robot/commands/Climb/WinchClimb.java b/src/main/java/frc/robot/commands/Climb/WinchClimb.java index d1cf6a6..7d1040b 100644 --- a/src/main/java/frc/robot/commands/Climb/WinchClimb.java +++ b/src/main/java/frc/robot/commands/Climb/WinchClimb.java @@ -32,7 +32,7 @@ protected void initialize() { // Called repeatedly when this Command is scheduled to run @Override protected void execute() { - Robot.climber.setPinExtender(true); + Robot.climber.setExtended(); if (waitTimer.get() > 0.25) { if (direction){ Robot.climber.setWinchOutput(-1); diff --git a/src/main/java/frc/robot/commands/DefaultExtension.java b/src/main/java/frc/robot/commands/DefaultExtension.java deleted file mode 100644 index b3b3c1b..0000000 --- a/src/main/java/frc/robot/commands/DefaultExtension.java +++ /dev/null @@ -1,49 +0,0 @@ -/*----------------------------------------------------------------------------*/ -/* Copyright (c) 2018 FIRST. All Rights Reserved. */ -/* Open Source Software - may be modified and shared by FRC teams. The code */ -/* must be accompanied by the FIRST BSD license file in the root directory of */ -/* the project. */ -/*----------------------------------------------------------------------------*/ - -package frc.robot.commands; -import frc.robot.Robot; -import edu.wpi.first.wpilibj.command.Command; - -public class DefaultExtension extends Command { - public DefaultExtension() { - super("DefaultExtension"); - - requires(Robot.panelMech); - // Use requires() here to declare subsystem dependencies - // eg. requires(chassis); - } - - // Called just before this Command runs the first time - @Override - protected void initialize() { - } - - // Called repeatedly when this Command is scheduled to run - @Override - protected void execute() { - Robot.panelMech.extendPanelMech(false); - - } - - // Make this return true when this Command no longer needs to run execute() - @Override - protected boolean isFinished() { - return false; - } - - // Called once after isFinished returns true - @Override - protected void end() { - } - - // Called when another command which requires one or more of the same - // subsystems is scheduled to run - @Override - protected void interrupted() { - } -} diff --git a/src/main/java/frc/robot/commands/DefaultPanelMech.java b/src/main/java/frc/robot/commands/DefaultPanelMech.java index 6b402a5..1617396 100644 --- a/src/main/java/frc/robot/commands/DefaultPanelMech.java +++ b/src/main/java/frc/robot/commands/DefaultPanelMech.java @@ -24,7 +24,7 @@ protected void initialize() { // Called repeatedly when this Command is scheduled to run @Override protected void execute() { - Robot.panelMech.extendPanelMech(false); + Robot.panelMech.retractPanelMech(); } // Make this return true when this Command no longer needs to run execute() diff --git a/src/main/java/frc/robot/commands/ExtendPanelMech.java b/src/main/java/frc/robot/commands/ExtendPanelMech.java index 3cc42fd..d3de432 100644 --- a/src/main/java/frc/robot/commands/ExtendPanelMech.java +++ b/src/main/java/frc/robot/commands/ExtendPanelMech.java @@ -26,7 +26,7 @@ protected void initialize() { // Called repeatedly when this Command is scheduled to run @Override protected void execute() { - Robot.panelMech.extendPanelMech(true); + Robot.panelMech.extendPanelMech(); } diff --git a/src/main/java/frc/robot/commands/IntakeToHopper/MoveManipulator.java b/src/main/java/frc/robot/commands/IntakeToHopper/MoveManipulator.java index 7cbd196..1a742e4 100644 --- a/src/main/java/frc/robot/commands/IntakeToHopper/MoveManipulator.java +++ b/src/main/java/frc/robot/commands/IntakeToHopper/MoveManipulator.java @@ -24,13 +24,13 @@ protected void initialize() { protected void execute() { Robot.manipulator.setExtended(); Robot.manipulator.setManipulator(Constants.INTAKE_MOTORSPEED); - Robot.hopper.poopBall(); + } //Make this return true when this Command no longer needs to run execute() @Override protected boolean isFinished() { - return !Robot.hopper.isBall(); + return true; } //Called once after isFinished returns true diff --git a/src/main/java/frc/robot/commands/IntakeToHopper/OpenPistonsAndMoveHopper.java b/src/main/java/frc/robot/commands/IntakeToHopper/OpenPistonsAndMoveHopper.java index bddbe82..647cc82 100644 --- a/src/main/java/frc/robot/commands/IntakeToHopper/OpenPistonsAndMoveHopper.java +++ b/src/main/java/frc/robot/commands/IntakeToHopper/OpenPistonsAndMoveHopper.java @@ -7,14 +7,17 @@ package frc.robot.commands.IntakeToHopper; +import edu.wpi.first.wpilibj.Timer; import edu.wpi.first.wpilibj.command.Command; import frc.robot.Constants; import frc.robot.Robot; public class OpenPistonsAndMoveHopper extends Command { + Timer timeForHopper; public OpenPistonsAndMoveHopper() { super("OpenPistonsAndMoveHopper"); requires(Robot.hopper); + timeForHopper = new Timer(); // Use requires() here to declare subsystem dependencies // eg. requires(chassis); } @@ -22,25 +25,29 @@ public OpenPistonsAndMoveHopper() { // Called just before this Command runs the first time @Override protected void initialize() { - Robot.hopper.setRetracted(false); + timeForHopper.start(); + Robot.hopper.setExtended(); + } // Called repeatedly when this Command is scheduled to run @Override protected void execute() { Robot.hopper.setHopper(Constants.HOPPER_WALL_HORIZONTAL_OUTPUT, Constants.HOPPER_VERTICAL_OUTPUT); + } // Make this return true when this Command no longer needs to run execute() @Override protected boolean isFinished() { - return true; + return false; } // Called once after isFinished returns true @Override protected void end() { - // Robot.hopper.setHopper(0, 0); + Robot.hopper.setHopper(0, 0); + Robot.hopper.setRetracted(); } // Called when another command which requires one or more of the same diff --git a/src/main/java/frc/robot/commands/Shooter/CloseHopperPiston.java b/src/main/java/frc/robot/commands/Shooter/CloseHopperPiston.java index 5e361c5..8d80278 100644 --- a/src/main/java/frc/robot/commands/Shooter/CloseHopperPiston.java +++ b/src/main/java/frc/robot/commands/Shooter/CloseHopperPiston.java @@ -20,7 +20,7 @@ protected void initialize(){ @Override protected void execute() { - Robot.hopper.setRetracted(false); + Robot.hopper.setRetracted(); } diff --git a/src/main/java/frc/robot/commands/Shooter/OpenHopperPiston.java b/src/main/java/frc/robot/commands/Shooter/OpenHopperPiston.java index cff08a5..71f0068 100644 --- a/src/main/java/frc/robot/commands/Shooter/OpenHopperPiston.java +++ b/src/main/java/frc/robot/commands/Shooter/OpenHopperPiston.java @@ -19,7 +19,7 @@ protected void initialize(){ @Override protected void execute() { - Robot.hopper.setRetracted(true); + Robot.hopper.setExtended(); } diff --git a/src/main/java/frc/robot/subsystems/Climber.java b/src/main/java/frc/robot/subsystems/Climber.java index 4318cf7..f27c3a5 100644 --- a/src/main/java/frc/robot/subsystems/Climber.java +++ b/src/main/java/frc/robot/subsystems/Climber.java @@ -53,9 +53,16 @@ public void initDefaultCommand() { // setDefaultCommand(new DefaultExtension()); } - - public void setPinExtender(boolean extended){ - Extender.set(extended); + public void setPinExtender(boolean extend){ + Extender.set(extend); + } + + public void setRetracted(){ + Extender.set(false); + } + + public void setExtended(){ + Extender.set(true); } public void setPinExtenderByButton(){ // if(driverY.get()){ diff --git a/src/main/java/frc/robot/subsystems/Hopper.java b/src/main/java/frc/robot/subsystems/Hopper.java index 7f17195..7576a76 100644 --- a/src/main/java/frc/robot/subsystems/Hopper.java +++ b/src/main/java/frc/robot/subsystems/Hopper.java @@ -57,11 +57,11 @@ public boolean isRetracted() { } public void setExtended() { - hopper_stopper.set(false); + hopper_stopper.set(true); } - public void setRetracted(boolean retract) { - hopper_stopper.set(retract); + public void setRetracted() { + hopper_stopper.set(false); } public boolean getRetracted() { diff --git a/src/main/java/frc/robot/subsystems/PanelMech.java b/src/main/java/frc/robot/subsystems/PanelMech.java index 44cec70..0e54cc0 100644 --- a/src/main/java/frc/robot/subsystems/PanelMech.java +++ b/src/main/java/frc/robot/subsystems/PanelMech.java @@ -31,8 +31,12 @@ public PanelMech(){ public void setPanelMech(final double velocity) { panelMech_motor.set(velocity); } - public void extendPanelMech(boolean extend) { - panelMech_soleinoid.set(extend); + public void extendPanelMech() { + panelMech_soleinoid.set(true); + } + + public void retractPanelMech(){ + panelMech_soleinoid.set(false); } @Override protected void initDefaultCommand() { From b7bef51752151322db8ca03464d199f303c691e8 Mon Sep 17 00:00:00 2001 From: allison-kunin Date: Sun, 1 Mar 2020 17:57:20 -0500 Subject: [PATCH 31/68] changed setPanelMech so it works hopefully --- .../java/frc/robot/commands/SetPanelMech.java | 91 +++++++++---------- .../java/frc/robot/commands/SetPanelmech.java | 91 +++++++++---------- 2 files changed, 84 insertions(+), 98 deletions(-) diff --git a/src/main/java/frc/robot/commands/SetPanelMech.java b/src/main/java/frc/robot/commands/SetPanelMech.java index 28d5a8c..5d84518 100644 --- a/src/main/java/frc/robot/commands/SetPanelMech.java +++ b/src/main/java/frc/robot/commands/SetPanelMech.java @@ -1,54 +1,47 @@ -/*----------------------------------------------------------------------------*/ -/* Copyright (c) 2018-2019 FIRST. All Rights Reserved. */ -/* Open Source Software - may be modified and shared by FRC teams. The code */ -/* must be accompanied by the FIRST BSD license file in the root directory of */ -/* the project. */ -/*----------------------------------------------------------------------------*/ - -// package frc.robot.commands; - -// import edu.wpi.first.wpilibj.command.Command; -// import frc.robot.Constants; -// import frc.robot.Robot; - -// public class SetPanelMech extends Command { -// public SetPanelMech() { -// super("SetPanelMech"); -// requires(Robot.panelMech); -// //Use requires() here to declare subsystem dependencies -// //eg. requires(chassis); -// } - -// //Called just before this Command runs the first time -// @Override -// protected void initialize() { +package frc.robot.commands; + +import edu.wpi.first.wpilibj.command.Command; +import frc.robot.Constants; +import frc.robot.Robot; + +public class SetPanelmech extends Command { + public SetPanelmech() { + super("SetPanelmech"); + requires(Robot.panelMech); + //Use requires() here to declare subsystem dependencies + //eg. requires(chassis); + } + + //Called just before this Command runs the first time + @Override + protected void initialize() { + } + - // //Called repeatedly when this Command is scheduled to run - // @Override - // protected void execute() { - // Robot.panelMech.setPanelMech(0); - // // Robot.panelMech.setManipulator(0); - // } - - // //Make this return true when this Command no longer needs to run execute() - // @Override - // protected boolean isFinished() { - // return false; - // } + @Override + protected void execute() { + Robot.panelMech.setPanelMech(Constants.PANEL_MECH_CREEP); + } + + //Make this return true when this Command no longer needs to run execute() + @Override + protected boolean isFinished() { + return false; + } //Called once after isFinished returns true -// @Override -// protected void end() { -// Robot.panelMech.setPanelMech(0); -// } - -// // //Called when another command which requires one or more of the same -// // //subsystems is scheduled to run - -// @Override -// protected void interrupted() { -// //Yes -// } -//} \ No newline at end of file + @Override + protected void end() { + Robot.panelMech.setPanelMech(0); + } + +// //Called when another command which requires one or more of the same +// //subsystems is scheduled to run + + @Override + protected void interrupted() { + //Yes + } +} \ No newline at end of file diff --git a/src/main/java/frc/robot/commands/SetPanelmech.java b/src/main/java/frc/robot/commands/SetPanelmech.java index 28d5a8c..5d84518 100644 --- a/src/main/java/frc/robot/commands/SetPanelmech.java +++ b/src/main/java/frc/robot/commands/SetPanelmech.java @@ -1,54 +1,47 @@ -/*----------------------------------------------------------------------------*/ -/* Copyright (c) 2018-2019 FIRST. All Rights Reserved. */ -/* Open Source Software - may be modified and shared by FRC teams. The code */ -/* must be accompanied by the FIRST BSD license file in the root directory of */ -/* the project. */ -/*----------------------------------------------------------------------------*/ - -// package frc.robot.commands; - -// import edu.wpi.first.wpilibj.command.Command; -// import frc.robot.Constants; -// import frc.robot.Robot; - -// public class SetPanelMech extends Command { -// public SetPanelMech() { -// super("SetPanelMech"); -// requires(Robot.panelMech); -// //Use requires() here to declare subsystem dependencies -// //eg. requires(chassis); -// } - -// //Called just before this Command runs the first time -// @Override -// protected void initialize() { +package frc.robot.commands; + +import edu.wpi.first.wpilibj.command.Command; +import frc.robot.Constants; +import frc.robot.Robot; + +public class SetPanelmech extends Command { + public SetPanelmech() { + super("SetPanelmech"); + requires(Robot.panelMech); + //Use requires() here to declare subsystem dependencies + //eg. requires(chassis); + } + + //Called just before this Command runs the first time + @Override + protected void initialize() { + } + - // //Called repeatedly when this Command is scheduled to run - // @Override - // protected void execute() { - // Robot.panelMech.setPanelMech(0); - // // Robot.panelMech.setManipulator(0); - // } - - // //Make this return true when this Command no longer needs to run execute() - // @Override - // protected boolean isFinished() { - // return false; - // } + @Override + protected void execute() { + Robot.panelMech.setPanelMech(Constants.PANEL_MECH_CREEP); + } + + //Make this return true when this Command no longer needs to run execute() + @Override + protected boolean isFinished() { + return false; + } //Called once after isFinished returns true -// @Override -// protected void end() { -// Robot.panelMech.setPanelMech(0); -// } - -// // //Called when another command which requires one or more of the same -// // //subsystems is scheduled to run - -// @Override -// protected void interrupted() { -// //Yes -// } -//} \ No newline at end of file + @Override + protected void end() { + Robot.panelMech.setPanelMech(0); + } + +// //Called when another command which requires one or more of the same +// //subsystems is scheduled to run + + @Override + protected void interrupted() { + //Yes + } +} \ No newline at end of file From 8f1a3544df957a481be6e9472d3407cd1f96e357 Mon Sep 17 00:00:00 2001 From: allison-kunin Date: Sun, 1 Mar 2020 18:00:01 -0500 Subject: [PATCH 32/68] changed set panel mech and put it in oi --- src/main/java/frc/robot/OI.java | 3 ++- src/main/java/frc/robot/commands/SetPanelMech.java | 2 +- src/main/java/frc/robot/commands/SetPanelmech.java | 2 +- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/main/java/frc/robot/OI.java b/src/main/java/frc/robot/OI.java index a3b2c9e..875e9da 100644 --- a/src/main/java/frc/robot/OI.java +++ b/src/main/java/frc/robot/OI.java @@ -143,7 +143,8 @@ public boolean get() { driverDPadDown.whenPressed(new InstantCommand(() -> { Robot.climber.setRetracted();; })); - //driverDPadUp.whenPressed(new SetPanelMech()); + + driverDPadUp.whileHeld(new SetPanelmech()); driverX.whenPressed(new ReleasePin(true, true)); //driverA.whenPressed(new ReleasePin(false, false)); diff --git a/src/main/java/frc/robot/commands/SetPanelMech.java b/src/main/java/frc/robot/commands/SetPanelMech.java index 5d84518..dffdf92 100644 --- a/src/main/java/frc/robot/commands/SetPanelMech.java +++ b/src/main/java/frc/robot/commands/SetPanelMech.java @@ -28,7 +28,7 @@ protected void execute() { //Make this return true when this Command no longer needs to run execute() @Override protected boolean isFinished() { - return false; + return true; } //Called once after isFinished returns true diff --git a/src/main/java/frc/robot/commands/SetPanelmech.java b/src/main/java/frc/robot/commands/SetPanelmech.java index 5d84518..dffdf92 100644 --- a/src/main/java/frc/robot/commands/SetPanelmech.java +++ b/src/main/java/frc/robot/commands/SetPanelmech.java @@ -28,7 +28,7 @@ protected void execute() { //Make this return true when this Command no longer needs to run execute() @Override protected boolean isFinished() { - return false; + return true; } //Called once after isFinished returns true From f2091049588fcfff9864ac3d6191274cf80e73af Mon Sep 17 00:00:00 2001 From: allison-kunin Date: Sun, 1 Mar 2020 19:18:34 -0500 Subject: [PATCH 33/68] cleaned up commands and folders a little --- .../ManipulatorToIrHopper.java | 6 +-- .../frc/robot/Autons/ShooterGroupLong.java | 10 +--- .../frc/robot/Autons/ShooterGroupWall.java | 4 -- src/main/java/frc/robot/Autons/Stop.java | 8 +-- src/main/java/frc/robot/OI.java | 1 + .../{ => IntakeToHopper}/MoveHopperLong.java | 2 +- .../{ => IntakeToHopper}/ReverseHopper.java | 2 +- .../{ => IntakeToHopper}/StopHopper.java | 2 +- .../{ => IntakeToHopper}/StopManipulator.java | 2 +- .../{ => PanelMech}/DefaultPanelMech.java | 2 +- .../{ => PanelMech}/ExtendPanelMech.java | 2 +- .../{ => PanelMech}/SetPanelmech.java | 2 +- .../java/frc/robot/commands/SetPanelMech.java | 47 ----------------- .../java/frc/robot/commands/StopElevator.java | 49 ------------------ .../java/frc/robot/commands/StopShooter.java | 49 ------------------ .../frc/robot/commands/SwitchCameras.java | 50 ------------------- 16 files changed, 13 insertions(+), 225 deletions(-) rename src/main/java/frc/robot/{commands/IntakeToHopper => Autons}/ManipulatorToIrHopper.java (64%) rename src/main/java/frc/robot/commands/{ => IntakeToHopper}/MoveHopperLong.java (97%) rename src/main/java/frc/robot/commands/{ => IntakeToHopper}/ReverseHopper.java (97%) rename src/main/java/frc/robot/commands/{ => IntakeToHopper}/StopHopper.java (97%) rename src/main/java/frc/robot/commands/{ => IntakeToHopper}/StopManipulator.java (96%) rename src/main/java/frc/robot/commands/{ => PanelMech}/DefaultPanelMech.java (97%) rename src/main/java/frc/robot/commands/{ => PanelMech}/ExtendPanelMech.java (97%) rename src/main/java/frc/robot/commands/{ => PanelMech}/SetPanelmech.java (96%) delete mode 100644 src/main/java/frc/robot/commands/SetPanelMech.java delete mode 100644 src/main/java/frc/robot/commands/StopElevator.java delete mode 100644 src/main/java/frc/robot/commands/StopShooter.java delete mode 100644 src/main/java/frc/robot/commands/SwitchCameras.java diff --git a/src/main/java/frc/robot/commands/IntakeToHopper/ManipulatorToIrHopper.java b/src/main/java/frc/robot/Autons/ManipulatorToIrHopper.java similarity index 64% rename from src/main/java/frc/robot/commands/IntakeToHopper/ManipulatorToIrHopper.java rename to src/main/java/frc/robot/Autons/ManipulatorToIrHopper.java index df9bb10..a84d806 100644 --- a/src/main/java/frc/robot/commands/IntakeToHopper/ManipulatorToIrHopper.java +++ b/src/main/java/frc/robot/Autons/ManipulatorToIrHopper.java @@ -1,9 +1,7 @@ -package frc.robot.commands.IntakeToHopper; +package frc.robot.Autons; import edu.wpi.first.wpilibj.command.CommandGroup; -// import frc.robot.Robot; -// import frc.robot.commands.IntakeToHopper.*; -import frc.robot.commands.StopHopper; +import frc.robot.commands.IntakeToHopper.*; public class ManipulatorToIrHopper extends CommandGroup{ public ManipulatorToIrHopper(){ diff --git a/src/main/java/frc/robot/Autons/ShooterGroupLong.java b/src/main/java/frc/robot/Autons/ShooterGroupLong.java index d5bf911..8196a47 100644 --- a/src/main/java/frc/robot/Autons/ShooterGroupLong.java +++ b/src/main/java/frc/robot/Autons/ShooterGroupLong.java @@ -1,24 +1,18 @@ package frc.robot.Autons; import edu.wpi.first.wpilibj.command.CommandGroup; -import frc.robot.Robot; -import frc.robot.commands.MoveHopperLong; +import frc.robot.commands.IntakeToHopper.*; import frc.robot.commands.Shooter.LongShot; import frc.robot.commands.Shooter.LongShotHood; import frc.robot.commands.Shooter.OpenHopperPiston; -//import frc.robot.commands.Shooter.CheckWheelSpeed; -//import frc.robot.commands.Shooter.RetractHood; -import frc.robot.subsystems.Shooter; public class ShooterGroupLong extends CommandGroup{ public ShooterGroupLong(){ addSequential(new LongShotHood()); - addSequential(new LongShot(), 5.0); + addSequential(new LongShot(), 2.0); addSequential(new OpenHopperPiston()); addSequential(new MoveHopperLong()); - //addSequential(new OpenHopperPiston()); - //addSequential(new MoveHopperLong()); } } \ No newline at end of file diff --git a/src/main/java/frc/robot/Autons/ShooterGroupWall.java b/src/main/java/frc/robot/Autons/ShooterGroupWall.java index 2f7f472..b36567f 100644 --- a/src/main/java/frc/robot/Autons/ShooterGroupWall.java +++ b/src/main/java/frc/robot/Autons/ShooterGroupWall.java @@ -1,14 +1,10 @@ package frc.robot.Autons; import edu.wpi.first.wpilibj.command.CommandGroup; -import frc.robot.Robot; import frc.robot.commands.IntakeToHopper.MoveHopperWall; import frc.robot.commands.Shooter.OpenHopperPiston; import frc.robot.commands.Shooter.WallShot; import frc.robot.commands.Shooter.WallShotHood; -//import frc.robot.commands.Shooter.CheckWheelSpeed; -//import frc.robot.commands.Shooter.RetractHood; -import frc.robot.subsystems.Shooter; public class ShooterGroupWall extends CommandGroup{ diff --git a/src/main/java/frc/robot/Autons/Stop.java b/src/main/java/frc/robot/Autons/Stop.java index 914a1bf..9db852c 100644 --- a/src/main/java/frc/robot/Autons/Stop.java +++ b/src/main/java/frc/robot/Autons/Stop.java @@ -1,15 +1,9 @@ package frc.robot.Autons; import edu.wpi.first.wpilibj.command.CommandGroup; -import frc.robot.Robot; -import frc.robot.commands.IntakeToHopper.MoveHopperWall; -import frc.robot.commands.StopHopper; +import frc.robot.commands.IntakeToHopper.StopHopper; import frc.robot.commands.Shooter.CloseHopperPiston; -import frc.robot.commands.Shooter.OpenHopperPiston; -//import frc.robot.commands.Shooter.CheckWheelSpeed; -//import frc.robot.commands.Shooter.RetractHood; import frc.robot.commands.Shooter.StopShooter; -import frc.robot.subsystems.Shooter; public class Stop extends CommandGroup { diff --git a/src/main/java/frc/robot/OI.java b/src/main/java/frc/robot/OI.java index 875e9da..fc37430 100644 --- a/src/main/java/frc/robot/OI.java +++ b/src/main/java/frc/robot/OI.java @@ -11,6 +11,7 @@ import frc.robot.commands.Shooter.*; import frc.robot.commands.Climb.*; import frc.robot.commands.IntakeToHopper.*; +import frc.robot.commands.PanelMech.*; import frc.robot.commands.*; import frc.robot.commands.Shooter.StopShooter; diff --git a/src/main/java/frc/robot/commands/MoveHopperLong.java b/src/main/java/frc/robot/commands/IntakeToHopper/MoveHopperLong.java similarity index 97% rename from src/main/java/frc/robot/commands/MoveHopperLong.java rename to src/main/java/frc/robot/commands/IntakeToHopper/MoveHopperLong.java index 95b988f..0833c0b 100644 --- a/src/main/java/frc/robot/commands/MoveHopperLong.java +++ b/src/main/java/frc/robot/commands/IntakeToHopper/MoveHopperLong.java @@ -5,7 +5,7 @@ /* the project. */ /*----------------------------------------------------------------------------*/ -package frc.robot.commands; +package frc.robot.commands.IntakeToHopper; import edu.wpi.first.wpilibj.command.Command; import frc.robot.Constants; diff --git a/src/main/java/frc/robot/commands/ReverseHopper.java b/src/main/java/frc/robot/commands/IntakeToHopper/ReverseHopper.java similarity index 97% rename from src/main/java/frc/robot/commands/ReverseHopper.java rename to src/main/java/frc/robot/commands/IntakeToHopper/ReverseHopper.java index acf3e1e..363c064 100644 --- a/src/main/java/frc/robot/commands/ReverseHopper.java +++ b/src/main/java/frc/robot/commands/IntakeToHopper/ReverseHopper.java @@ -5,7 +5,7 @@ /* the project. */ /*----------------------------------------------------------------------------*/ -package frc.robot.commands; +package frc.robot.commands.IntakeToHopper; import edu.wpi.first.wpilibj.command.Command; import frc.robot.Constants; diff --git a/src/main/java/frc/robot/commands/StopHopper.java b/src/main/java/frc/robot/commands/IntakeToHopper/StopHopper.java similarity index 97% rename from src/main/java/frc/robot/commands/StopHopper.java rename to src/main/java/frc/robot/commands/IntakeToHopper/StopHopper.java index b8dd1a8..135e944 100644 --- a/src/main/java/frc/robot/commands/StopHopper.java +++ b/src/main/java/frc/robot/commands/IntakeToHopper/StopHopper.java @@ -5,7 +5,7 @@ /* the project. */ /*----------------------------------------------------------------------------*/ -package frc.robot.commands; +package frc.robot.commands.IntakeToHopper; import edu.wpi.first.wpilibj.command.Command; import frc.robot.Robot; diff --git a/src/main/java/frc/robot/commands/StopManipulator.java b/src/main/java/frc/robot/commands/IntakeToHopper/StopManipulator.java similarity index 96% rename from src/main/java/frc/robot/commands/StopManipulator.java rename to src/main/java/frc/robot/commands/IntakeToHopper/StopManipulator.java index 3d767cf..5d5482b 100644 --- a/src/main/java/frc/robot/commands/StopManipulator.java +++ b/src/main/java/frc/robot/commands/IntakeToHopper/StopManipulator.java @@ -1,4 +1,4 @@ -package frc.robot.commands; +package frc.robot.commands.IntakeToHopper; import edu.wpi.first.wpilibj.command.Command; import frc.robot.Robot; diff --git a/src/main/java/frc/robot/commands/DefaultPanelMech.java b/src/main/java/frc/robot/commands/PanelMech/DefaultPanelMech.java similarity index 97% rename from src/main/java/frc/robot/commands/DefaultPanelMech.java rename to src/main/java/frc/robot/commands/PanelMech/DefaultPanelMech.java index 1617396..e81e8b3 100644 --- a/src/main/java/frc/robot/commands/DefaultPanelMech.java +++ b/src/main/java/frc/robot/commands/PanelMech/DefaultPanelMech.java @@ -5,7 +5,7 @@ /* the project. */ /*----------------------------------------------------------------------------*/ -package frc.robot.commands; +package frc.robot.commands.PanelMech; import edu.wpi.first.wpilibj.command.Command; import frc.robot.Robot; diff --git a/src/main/java/frc/robot/commands/ExtendPanelMech.java b/src/main/java/frc/robot/commands/PanelMech/ExtendPanelMech.java similarity index 97% rename from src/main/java/frc/robot/commands/ExtendPanelMech.java rename to src/main/java/frc/robot/commands/PanelMech/ExtendPanelMech.java index d3de432..066a82d 100644 --- a/src/main/java/frc/robot/commands/ExtendPanelMech.java +++ b/src/main/java/frc/robot/commands/PanelMech/ExtendPanelMech.java @@ -5,7 +5,7 @@ /* the project. */ /*----------------------------------------------------------------------------*/ -package frc.robot.commands; +package frc.robot.commands.PanelMech; import frc.robot.Robot; import edu.wpi.first.wpilibj.command.Command; diff --git a/src/main/java/frc/robot/commands/SetPanelmech.java b/src/main/java/frc/robot/commands/PanelMech/SetPanelmech.java similarity index 96% rename from src/main/java/frc/robot/commands/SetPanelmech.java rename to src/main/java/frc/robot/commands/PanelMech/SetPanelmech.java index dffdf92..3c9d2b0 100644 --- a/src/main/java/frc/robot/commands/SetPanelmech.java +++ b/src/main/java/frc/robot/commands/PanelMech/SetPanelmech.java @@ -1,4 +1,4 @@ -package frc.robot.commands; +package frc.robot.commands.PanelMech; import edu.wpi.first.wpilibj.command.Command; import frc.robot.Constants; diff --git a/src/main/java/frc/robot/commands/SetPanelMech.java b/src/main/java/frc/robot/commands/SetPanelMech.java deleted file mode 100644 index dffdf92..0000000 --- a/src/main/java/frc/robot/commands/SetPanelMech.java +++ /dev/null @@ -1,47 +0,0 @@ -package frc.robot.commands; - -import edu.wpi.first.wpilibj.command.Command; -import frc.robot.Constants; -import frc.robot.Robot; - -public class SetPanelmech extends Command { - public SetPanelmech() { - super("SetPanelmech"); - requires(Robot.panelMech); - //Use requires() here to declare subsystem dependencies - //eg. requires(chassis); - } - - //Called just before this Command runs the first time - @Override - protected void initialize() { - } - - - - //Called repeatedly when this Command is scheduled to run - @Override - protected void execute() { - Robot.panelMech.setPanelMech(Constants.PANEL_MECH_CREEP); - } - - //Make this return true when this Command no longer needs to run execute() - @Override - protected boolean isFinished() { - return true; - } - - //Called once after isFinished returns true - @Override - protected void end() { - Robot.panelMech.setPanelMech(0); - } - -// //Called when another command which requires one or more of the same -// //subsystems is scheduled to run - - @Override - protected void interrupted() { - //Yes - } -} \ No newline at end of file diff --git a/src/main/java/frc/robot/commands/StopElevator.java b/src/main/java/frc/robot/commands/StopElevator.java deleted file mode 100644 index b7581f1..0000000 --- a/src/main/java/frc/robot/commands/StopElevator.java +++ /dev/null @@ -1,49 +0,0 @@ -/*----------------------------------------------------------------------------*/ -/* Copyright (c) 2018 FIRST. All Rights Reserved. */ -/* Open Source Software - may be modified and shared by FRC teams. The code */ -/* must be accompanied by the FIRST BSD license file in the root directory of */ -/* the project. */ -/*----------------------------------------------------------------------------*/ - -package frc.robot.commands; - -import edu.wpi.first.wpilibj.command.Command; -import frc.robot.Robot; - -public class StopElevator extends Command { - public StopElevator() { - super("StopElevator"); - requires(Robot.elevator); - // Use requires() here to declare subsystem dependencies - // eg. requires(chassis); - } - - // Called just before this Command runs the first time - @Override - protected void initialize() { - } - - // Called repeatedly when this Command is scheduled to run - @Override - protected void execute() { - Robot.elevator.setElevator(0); - } - - // Make this return true when this Command no longer needs to run execute() - @Override - protected boolean isFinished() { - return false; - } - - // Called once after isFinished returns true - @Override - protected void end() { - Robot.elevator.setElevator(0); - } - - // Called when another command which requires one or more of the same - // subsystems is scheduled to run - @Override - protected void interrupted() { - } -} diff --git a/src/main/java/frc/robot/commands/StopShooter.java b/src/main/java/frc/robot/commands/StopShooter.java deleted file mode 100644 index 714ce9c..0000000 --- a/src/main/java/frc/robot/commands/StopShooter.java +++ /dev/null @@ -1,49 +0,0 @@ -/*----------------------------------------------------------------------------*/ -/* Copyright (c) 2018 FIRST. All Rights Reserved. */ -/* Open Source Software - may be modified and shared by FRC teams. The code */ -/* must be accompanied by the FIRST BSD license file in the root directory of */ -/* the project. */ -/*----------------------------------------------------------------------------*/ - -package frc.robot.commands; - -import edu.wpi.first.wpilibj.command.Command; -import frc.robot.Robot; - -public class StopShooter extends Command { - public StopShooter() { - super("StopShooter"); - requires(Robot.shooter); - // Use requires() here to declare subsystem dependencies - // eg. requires(chassis); - } - - // Called just before this Command runs the first time - @Override - protected void initialize() { - } - - // Called repeatedly when this Command is scheduled to run - @Override - protected void execute() { - Robot.shooter.setShooter(0); - } - - // Make this return true when this Command no longer needs to run execute() - @Override - protected boolean isFinished() { - return false; - } - - // Called once after isFinished returns true - @Override - protected void end() { - Robot.shooter.setShooter(0); - } - - // Called when another command which requires one or more of the same - // subsystems is scheduled to run - @Override - protected void interrupted() { - } -} diff --git a/src/main/java/frc/robot/commands/SwitchCameras.java b/src/main/java/frc/robot/commands/SwitchCameras.java deleted file mode 100644 index 2b6c270..0000000 --- a/src/main/java/frc/robot/commands/SwitchCameras.java +++ /dev/null @@ -1,50 +0,0 @@ -/*----------------------------------------------------------------------------*/ -/* Copyright (c) 2018 FIRST. All Rights Reserved. */ -/* Open Source Software - may be modified and shared by FRC teams. The code */ -/* must be accompanied by the FIRST BSD license file in the root directory of */ -/* the project. */ -/*----------------------------------------------------------------------------*/ - -package frc.robot.commands; - -import edu.wpi.first.wpilibj.command.Command; -import frc.robot.Constants; -import frc.robot.Robot; - -public class SwitchCameras extends Command { - public SwitchCameras() { - super("SwitchCameras"); - requires(Robot.drivetrain); - // Use requires() here to declare subsystem dependencies - // eg. requires(chassis); - } - - // Called just before this Command runs the first time - @Override - protected void initialize() { - } - - // Called repeatedly when this Command is scheduled to run - @Override - protected void execute() { - - } - - // Make this return true when this Command no longer needs to run execute() - @Override - protected boolean isFinished() { - return false; - } - - // Called once after isFinished returns true - @Override - protected void end() { - Robot.drivetrain.setMotors(0,0); - } - - // Called when another command which requires one or more of the same - // subsystems is scheduled to run - @Override - protected void interrupted() { - } -} From c63923378f6098676d39880944bb9b3e831ebe10 Mon Sep 17 00:00:00 2001 From: allison-kunin Date: Sun, 1 Mar 2020 20:22:14 -0500 Subject: [PATCH 34/68] used timer for hopper pistons --- .../commands/IntakeToHopper/OpenPistonsAndMoveHopper.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/main/java/frc/robot/commands/IntakeToHopper/OpenPistonsAndMoveHopper.java b/src/main/java/frc/robot/commands/IntakeToHopper/OpenPistonsAndMoveHopper.java index 647cc82..63a555f 100644 --- a/src/main/java/frc/robot/commands/IntakeToHopper/OpenPistonsAndMoveHopper.java +++ b/src/main/java/frc/robot/commands/IntakeToHopper/OpenPistonsAndMoveHopper.java @@ -33,8 +33,9 @@ protected void initialize() { // Called repeatedly when this Command is scheduled to run @Override protected void execute() { - Robot.hopper.setHopper(Constants.HOPPER_WALL_HORIZONTAL_OUTPUT, Constants.HOPPER_VERTICAL_OUTPUT); - + if(timeForHopper.get() > .25){ + Robot.hopper.setHopper(Constants.HOPPER_WALL_HORIZONTAL_OUTPUT, Constants.HOPPER_VERTICAL_OUTPUT); + } } // Make this return true when this Command no longer needs to run execute() From 2520d18e37e78c6157c393db96155176283c8f8c Mon Sep 17 00:00:00 2001 From: allison-kunin Date: Sun, 1 Mar 2020 20:22:59 -0500 Subject: [PATCH 35/68] changed command groups --- src/main/java/frc/robot/Autons/ManipulatorToIrHopper.java | 1 - 1 file changed, 1 deletion(-) diff --git a/src/main/java/frc/robot/Autons/ManipulatorToIrHopper.java b/src/main/java/frc/robot/Autons/ManipulatorToIrHopper.java index a84d806..42c5f39 100644 --- a/src/main/java/frc/robot/Autons/ManipulatorToIrHopper.java +++ b/src/main/java/frc/robot/Autons/ManipulatorToIrHopper.java @@ -7,6 +7,5 @@ public class ManipulatorToIrHopper extends CommandGroup{ public ManipulatorToIrHopper(){ addSequential(new MoveManipulator()); addSequential(new IrHopper()); - addSequential(new StopHopper()); } } \ No newline at end of file From 9da3d1df1a2b8f296cbd0214b63e76acd0f28d70 Mon Sep 17 00:00:00 2001 From: frcteam2791 Date: Sun, 1 Mar 2020 21:52:36 -0500 Subject: [PATCH 36/68] Added Shooter Sequences Put hood, hopper stopper, and firing hopper all on one button. Added Control panel camera and changed setCamera commands to work --- .../{Stop.java => StopShooterGroup.java} | 4 +- .../frc/robot/Autons/TrenchHoodAndFire.java | 17 +++++++ .../frc/robot/Autons/WallHoodAndFire.java | 17 +++++++ src/main/java/frc/robot/OI.java | 9 ++-- .../frc/robot/commands/Climb/ReleasePin.java | 7 ++- .../commands/PanelMech/ExtendPanelMech.java | 3 ++ .../java/frc/robot/commands/setCameraOne.java | 2 +- .../frc/robot/commands/setCameraThree.java | 48 +++++++++++++++++++ .../java/frc/robot/commands/setCameraTwo.java | 2 +- 9 files changed, 100 insertions(+), 9 deletions(-) rename src/main/java/frc/robot/Autons/{Stop.java => StopShooterGroup.java} (81%) create mode 100644 src/main/java/frc/robot/Autons/TrenchHoodAndFire.java create mode 100644 src/main/java/frc/robot/Autons/WallHoodAndFire.java create mode 100644 src/main/java/frc/robot/commands/setCameraThree.java diff --git a/src/main/java/frc/robot/Autons/Stop.java b/src/main/java/frc/robot/Autons/StopShooterGroup.java similarity index 81% rename from src/main/java/frc/robot/Autons/Stop.java rename to src/main/java/frc/robot/Autons/StopShooterGroup.java index 9db852c..d483b35 100644 --- a/src/main/java/frc/robot/Autons/Stop.java +++ b/src/main/java/frc/robot/Autons/StopShooterGroup.java @@ -5,9 +5,9 @@ import frc.robot.commands.Shooter.CloseHopperPiston; import frc.robot.commands.Shooter.StopShooter; -public class Stop extends CommandGroup { +public class StopShooterGroup extends CommandGroup { - public Stop() { + public StopShooterGroup() { addSequential(new StopShooter()); addSequential(new CloseHopperPiston()); addSequential(new StopHopper()); diff --git a/src/main/java/frc/robot/Autons/TrenchHoodAndFire.java b/src/main/java/frc/robot/Autons/TrenchHoodAndFire.java new file mode 100644 index 0000000..2ca8cba --- /dev/null +++ b/src/main/java/frc/robot/Autons/TrenchHoodAndFire.java @@ -0,0 +1,17 @@ +package frc.robot.Autons; + +import edu.wpi.first.wpilibj.command.CommandGroup; +import frc.robot.commands.IntakeToHopper.*; + +import frc.robot.commands.Shooter.LongShotHood; +import frc.robot.commands.Shooter.OpenHopperPiston; + +public class TrenchHoodAndFire extends CommandGroup{ + + public TrenchHoodAndFire(){ + addSequential(new LongShotHood(), 0.2); + addSequential(new OpenPistonsAndMoveHopper()); + // addSequential(new OpenHopperPiston()); + // addSequential(new MoveHopperLong()); + } +} \ No newline at end of file diff --git a/src/main/java/frc/robot/Autons/WallHoodAndFire.java b/src/main/java/frc/robot/Autons/WallHoodAndFire.java new file mode 100644 index 0000000..448c443 --- /dev/null +++ b/src/main/java/frc/robot/Autons/WallHoodAndFire.java @@ -0,0 +1,17 @@ +package frc.robot.Autons; + +import edu.wpi.first.wpilibj.command.CommandGroup; +import frc.robot.commands.IntakeToHopper.*; + +import frc.robot.commands.Shooter.WallShotHood; +import frc.robot.commands.Shooter.OpenHopperPiston; + +public class WallHoodAndFire extends CommandGroup{ + + public WallHoodAndFire(){ + addSequential(new WallShotHood(), 0.2); + addSequential(new OpenPistonsAndMoveHopper()); + // addSequential(new OpenHopperPiston()); + // addSequential(new MoveHopperLong()); + } +} \ No newline at end of file diff --git a/src/main/java/frc/robot/OI.java b/src/main/java/frc/robot/OI.java index fc37430..48f501c 100644 --- a/src/main/java/frc/robot/OI.java +++ b/src/main/java/frc/robot/OI.java @@ -7,7 +7,7 @@ import edu.wpi.first.wpilibj.command.InstantCommand; import frc.robot.Autons.ShooterGroupLong; import frc.robot.Autons.ShooterGroupWall; -import frc.robot.Autons.Stop; +import frc.robot.Autons.StopShooterGroup; import frc.robot.commands.Shooter.*; import frc.robot.commands.Climb.*; import frc.robot.commands.IntakeToHopper.*; @@ -61,15 +61,15 @@ public OI() { // driverRB.whenPressed(new ShooterGroupWall()); // driverRB.whileHeld(new WallShot()); - // driverRB.whenReleased(new Stop()); + // driverRB.whenReleased(new StopShooterGroup()); // driverLB.whenReleased(new StopShooterGroupLong()); // operatorDPadLeft.whenPressed(new ShooterGroupLong()); - // operatorDPadLeft.whenPressed(new Stop()); + // operatorDPadLeft.whenPressed(new StopShooterGroup()); // operatorDPadRight.whenPressed(new ShooterGroupWall()); - // operatorDPadRight.whenReleased(new Stop()); + // operatorDPadRight.whenReleased(new StopShooterGroup()); operatorDPadLeft.whenPressed(new LongShotHood()); operatorDPadRight.whenPressed(new WallShotHood()); @@ -139,6 +139,7 @@ public boolean get() { driverDPadRight.whileHeld(new DrivetrainAlignToGoal()); driverDPadLeft.whenPressed(new ExtendPanelMech()); + driverDPadLeft.whenPressed(new setCameraThree()); driverDPadLeft.whenReleased(new DefaultPanelMech()); driverDPadDown.whenPressed(new InstantCommand(() -> { diff --git a/src/main/java/frc/robot/commands/Climb/ReleasePin.java b/src/main/java/frc/robot/commands/Climb/ReleasePin.java index a074ee3..7444911 100644 --- a/src/main/java/frc/robot/commands/Climb/ReleasePin.java +++ b/src/main/java/frc/robot/commands/Climb/ReleasePin.java @@ -43,7 +43,12 @@ protected void execute() { } protected boolean isFinished() { - return intakeRetractTimer.get() > 0.1 && Robot.manipulator.getRetracted(); + if(lowerIntake){ + return intakeRetractTimer.get() > 0.1 && Robot.manipulator.getRetracted(); + } + else { + return true; + } } protected void end() { diff --git a/src/main/java/frc/robot/commands/PanelMech/ExtendPanelMech.java b/src/main/java/frc/robot/commands/PanelMech/ExtendPanelMech.java index 066a82d..f39ac97 100644 --- a/src/main/java/frc/robot/commands/PanelMech/ExtendPanelMech.java +++ b/src/main/java/frc/robot/commands/PanelMech/ExtendPanelMech.java @@ -6,7 +6,9 @@ /*----------------------------------------------------------------------------*/ package frc.robot.commands.PanelMech; + import frc.robot.Robot; +import frc.robot.util.Camera_Switch.CameraSwitch; import edu.wpi.first.wpilibj.command.Command; public class ExtendPanelMech extends Command { @@ -21,6 +23,7 @@ public ExtendPanelMech() { // Called just before this Command runs the first time @Override protected void initialize() { + // Robot.Cam_switch.select(CameraSwitch.kcamera1); } // Called repeatedly when this Command is scheduled to run diff --git a/src/main/java/frc/robot/commands/setCameraOne.java b/src/main/java/frc/robot/commands/setCameraOne.java index 6ebc0fe..a98c7a3 100644 --- a/src/main/java/frc/robot/commands/setCameraOne.java +++ b/src/main/java/frc/robot/commands/setCameraOne.java @@ -32,7 +32,7 @@ protected void execute() { // Make this return true when this Command no longer needs to run execute() @Override protected boolean isFinished() { - return false; + return true; } // Called once after isFinished returns true diff --git a/src/main/java/frc/robot/commands/setCameraThree.java b/src/main/java/frc/robot/commands/setCameraThree.java new file mode 100644 index 0000000..a0cff0b --- /dev/null +++ b/src/main/java/frc/robot/commands/setCameraThree.java @@ -0,0 +1,48 @@ +/*----------------------------------------------------------------------------*/ +/* Copyright (c) 2018 FIRST. All Rights Reserved. */ +/* Open Source Software - may be modified and shared by FRC teams. The code */ +/* must be accompanied by the FIRST BSD license file in the root directory of */ +/* the project. */ +/*----------------------------------------------------------------------------*/ + +package frc.robot.commands; + +import edu.wpi.first.wpilibj.command.Command; +import frc.robot.Robot; +//import frc.robot.subsystems.Camera; +import frc.robot.util.Camera_Switch.CameraSwitch; + +public class setCameraThree extends Command { + public setCameraThree() { + // Use requires() here to declare subsystem dependencies + // eg. requires(chassis); + } + + // Called just before this Command runs the first time + @Override + protected void initialize() { + } + + // Called repeatedly when this Command is scheduled to run + @Override + protected void execute() { + Robot.Cam_switch.select(CameraSwitch.kcamera3); + } + + // Make this return true when this Command no longer needs to run execute() + @Override + protected boolean isFinished() { + return true; + } + + // Called once after isFinished returns true + @Override + protected void end() { + } + + // Called when another command which requires one or more of the same + // subsystems is scheduled to run + @Override + protected void interrupted() { + } +} diff --git a/src/main/java/frc/robot/commands/setCameraTwo.java b/src/main/java/frc/robot/commands/setCameraTwo.java index 02f9afb..078b2ad 100644 --- a/src/main/java/frc/robot/commands/setCameraTwo.java +++ b/src/main/java/frc/robot/commands/setCameraTwo.java @@ -32,7 +32,7 @@ protected void execute() { // Make this return true when this Command no longer needs to run execute() @Override protected boolean isFinished() { - return false; + return true; } // Called once after isFinished returns true From fcbdb5301ef9987538b30c8814246b85d23bf359 Mon Sep 17 00:00:00 2001 From: frcteam2791 Date: Mon, 2 Mar 2020 14:33:38 -0800 Subject: [PATCH 37/68] Added Merged Commands Tested at Tech Park Monday Tested last night's commit commands and have working hood/stoppers/hopper firing and intake/hopper running --- .../frc/robot/Autons/StopShooterGroup.java | 2 + src/main/java/frc/robot/OI.java | 45 ++++++++++++------- .../commands/PanelMech/ExtendPanelMech.java | 5 ++- .../commands/Shooter/CloseHopperPiston.java | 1 - .../util/Camera_Switch/CameraSwitch.java | 2 +- 5 files changed, 36 insertions(+), 19 deletions(-) diff --git a/src/main/java/frc/robot/Autons/StopShooterGroup.java b/src/main/java/frc/robot/Autons/StopShooterGroup.java index d483b35..95f6d41 100644 --- a/src/main/java/frc/robot/Autons/StopShooterGroup.java +++ b/src/main/java/frc/robot/Autons/StopShooterGroup.java @@ -4,10 +4,12 @@ import frc.robot.commands.IntakeToHopper.StopHopper; import frc.robot.commands.Shooter.CloseHopperPiston; import frc.robot.commands.Shooter.StopShooter; +import frc.robot.commands.Shooter.WallShotHood; public class StopShooterGroup extends CommandGroup { public StopShooterGroup() { + addSequential(new WallShotHood()); addSequential(new StopShooter()); addSequential(new CloseHopperPiston()); addSequential(new StopHopper()); diff --git a/src/main/java/frc/robot/OI.java b/src/main/java/frc/robot/OI.java index 48f501c..ff259ee 100644 --- a/src/main/java/frc/robot/OI.java +++ b/src/main/java/frc/robot/OI.java @@ -5,9 +5,12 @@ import edu.wpi.first.wpilibj.buttons.JoystickButton; import edu.wpi.first.wpilibj.buttons.Trigger; import edu.wpi.first.wpilibj.command.InstantCommand; +import frc.robot.Autons.ManipulatorToIrHopper; import frc.robot.Autons.ShooterGroupLong; import frc.robot.Autons.ShooterGroupWall; import frc.robot.Autons.StopShooterGroup; +import frc.robot.Autons.TrenchHoodAndFire; +import frc.robot.Autons.WallHoodAndFire; import frc.robot.commands.Shooter.*; import frc.robot.commands.Climb.*; import frc.robot.commands.IntakeToHopper.*; @@ -99,8 +102,10 @@ public boolean get() { Robot.hopper.hopper_stopper.set(true); })); - operatorB.whileHeld(new OpenPistonsAndMoveHopper()); - operatorB.whenReleased(new StopHopper()); + // operatorB.whileHeld(new OpenPistonsAndMoveHopper()); + // operatorB.whenReleased(new StopHopper()); + operatorB.whileHeld(new WallHoodAndFire()); + operatorB.whenReleased(new StopShooterGroup()); operatorY.whileHeld(new MoveHopperWall()); operatorY.whenReleased(new StopHopper()); @@ -128,32 +133,40 @@ public boolean get() { driverA.whenPressed(new MoveManipulator()); //moves wheels as well so don't be surprised driverA.whenReleased(new StopManipulator()); + driverA.whenPressed(new InstantCommand(() -> { + Robot.hopper.setRetracted();; + })); driverA.whenPressed(new InstantCommand(() -> { Robot.Cam_switch.select(CameraSwitch.kcamera2);; })); - // driverA.whileHeld(new ManipulatorToIrHopper()); - // driverA.whenReleased(new StopManipulator()); - // driverA.whenReleased(new StopHopper()); + // driverA.whileHeld(new ManipulatorToIrHopper()); + // driverA.whenPressed(new InstantCommand(() -> { + // Robot.Cam_switch.select(CameraSwitch.kcamera2);; + // })); + // driverA.whenReleased(new StopManipulator()); + // driverA.whenReleased(new StopHopper()); driverDPadRight.whileHeld(new DrivetrainAlignToGoal()); - driverDPadLeft.whenPressed(new ExtendPanelMech()); - driverDPadLeft.whenPressed(new setCameraThree()); - driverDPadLeft.whenReleased(new DefaultPanelMech()); + // driverDPadLeft.whenPressed(new ExtendPanelMech()); + // //driverDPadLeft.whenPressed(new setCameraThree()); + // driverDPadLeft.whenReleased(new DefaultPanelMech()); - driverDPadDown.whenPressed(new InstantCommand(() -> { - Robot.climber.setRetracted();; - })); + // driverDPadDown.whenPressed(new InstantCommand(() -> { + // Robot.climber.setRetracted();; + // })); driverDPadUp.whileHeld(new SetPanelmech()); - driverX.whenPressed(new ReleasePin(true, true)); - //driverA.whenPressed(new ReleasePin(false, false)); - driverY.whileHeld(new WinchClimb(true)); + driverStart.whenPressed(new ReleasePin(true, true)); + // driverA.whenPressed(new ReleasePin(false, false)); + driverX.whileHeld(new WinchClimb(true)); + driverX.whenReleased(new StopWinchClimb()); + driverY.whileHeld(new WinchClimb(false)); driverY.whenReleased(new StopWinchClimb()); - driverB.whileHeld(new WinchClimb(false)); - driverB.whenReleased(new StopWinchClimb()); + driverB.whileHeld(new TrenchHoodAndFire()); + driverB.whenReleased(new StopShooterGroup()); } private void initButtons(){ diff --git a/src/main/java/frc/robot/commands/PanelMech/ExtendPanelMech.java b/src/main/java/frc/robot/commands/PanelMech/ExtendPanelMech.java index f39ac97..cb26d7e 100644 --- a/src/main/java/frc/robot/commands/PanelMech/ExtendPanelMech.java +++ b/src/main/java/frc/robot/commands/PanelMech/ExtendPanelMech.java @@ -9,6 +9,7 @@ import frc.robot.Robot; import frc.robot.util.Camera_Switch.CameraSwitch; +import edu.wpi.first.wpilibj.Relay; import edu.wpi.first.wpilibj.command.Command; public class ExtendPanelMech extends Command { @@ -23,12 +24,14 @@ public ExtendPanelMech() { // Called just before this Command runs the first time @Override protected void initialize() { - // Robot.Cam_switch.select(CameraSwitch.kcamera1); + Robot.Cam_switch.setDirection(Relay.Direction.kBoth); + } // Called repeatedly when this Command is scheduled to run @Override protected void execute() { + Robot.Cam_switch.select(CameraSwitch.kcamera1); Robot.panelMech.extendPanelMech(); } diff --git a/src/main/java/frc/robot/commands/Shooter/CloseHopperPiston.java b/src/main/java/frc/robot/commands/Shooter/CloseHopperPiston.java index 8d80278..71f63bb 100644 --- a/src/main/java/frc/robot/commands/Shooter/CloseHopperPiston.java +++ b/src/main/java/frc/robot/commands/Shooter/CloseHopperPiston.java @@ -21,7 +21,6 @@ protected void initialize(){ @Override protected void execute() { Robot.hopper.setRetracted(); - } @Override diff --git a/src/main/java/frc/robot/util/Camera_Switch/CameraSwitch.java b/src/main/java/frc/robot/util/Camera_Switch/CameraSwitch.java index 89a421c..e05d542 100644 --- a/src/main/java/frc/robot/util/Camera_Switch/CameraSwitch.java +++ b/src/main/java/frc/robot/util/Camera_Switch/CameraSwitch.java @@ -39,7 +39,7 @@ public class CameraSwitch implements RelayPortDevice{ public Relay camrelay2; public DigitalOutput DO; -public Victor pwm; + private int cameraState; public CameraSwitch(int port1, int port2){ From 4bfb637bb3f04556b510a3704d4e276c26992558 Mon Sep 17 00:00:00 2001 From: Tim Oh - Team2791 Date: Mon, 2 Mar 2020 17:34:47 -0500 Subject: [PATCH 38/68] Test commands for driving Manually moving climber and manipulator on a 3rd controller personally for Atharv --- src/main/java/frc/robot/OI.java | 15 ++++++ .../commands/tempTest/testExtendClimber.java | 47 +++++++++++++++++++ .../commands/tempTest/testManipulator.java | 45 ++++++++++++++++++ .../commands/tempTest/testRetractClimber.java | 44 +++++++++++++++++ .../tempTest/testStopManipulator.java | 46 ++++++++++++++++++ 5 files changed, 197 insertions(+) create mode 100644 src/main/java/frc/robot/commands/tempTest/testExtendClimber.java create mode 100644 src/main/java/frc/robot/commands/tempTest/testManipulator.java create mode 100644 src/main/java/frc/robot/commands/tempTest/testRetractClimber.java create mode 100644 src/main/java/frc/robot/commands/tempTest/testStopManipulator.java diff --git a/src/main/java/frc/robot/OI.java b/src/main/java/frc/robot/OI.java index 48f501c..6b8b886 100644 --- a/src/main/java/frc/robot/OI.java +++ b/src/main/java/frc/robot/OI.java @@ -15,6 +15,7 @@ import frc.robot.commands.*; import frc.robot.commands.Shooter.StopShooter; +import frc.robot.commands.tempTest.*; import frc.robot.commands.Climb.*; // import frc.robot.commands.auto.SetLimit; import frc.robot.controller.AnalogButton; @@ -38,6 +39,7 @@ public class OI { public static Joystick driverStick; public static Joystick operatorStick; + public static Joystick pitStick; private Button driveButton; private Button driverLB, driverRB; private Button driverStart, driverBack; @@ -51,9 +53,11 @@ public class OI { private Button driverRX; protected Button operatorLeftJoystickUsed, operatorRightJoystickUsed, operatorDPadDown, operatorDPadLeft, operatorDPadRight; private Button operatorA, operatorB, operatorX, operatorY; + private Button pitA, pitB, pitX, pitY; public OI() { driverStick = new Joystick(0); operatorStick = new Joystick(1); + pitStick = new Joystick(3); initButtons(); initUsed(); @@ -154,6 +158,12 @@ public boolean get() { driverY.whenReleased(new StopWinchClimb()); driverB.whileHeld(new WinchClimb(false)); driverB.whenReleased(new StopWinchClimb()); + + //Atharv's temporary demands + pitA.whenPressed(new testManipulator()); //Extends Manipulator + pitB.whenPressed(new testStopManipulator()); //Retracts Manipulator + pitX.whenPressed(new testExtendClimber()); //Extends Climber + pitY.whenPressed(new testRetractClimber()); //Retracts Climber } private void initButtons(){ @@ -201,6 +211,11 @@ private void initButtons(){ System.out.println("Error Init With Buttons"); error.printStackTrace(); } +//TEMPORARY PIT CONTROLS// + pitA = new JoystickButton(pitStick, 1); + pitB = new JoystickButton(pitStick, 2); + pitX = new JoystickButton(pitStick, 3); + pitY = new JoystickButton(pitStick, 4); } private void initUsed(){ diff --git a/src/main/java/frc/robot/commands/tempTest/testExtendClimber.java b/src/main/java/frc/robot/commands/tempTest/testExtendClimber.java new file mode 100644 index 0000000..cd502f3 --- /dev/null +++ b/src/main/java/frc/robot/commands/tempTest/testExtendClimber.java @@ -0,0 +1,47 @@ +package frc.robot.commands.tempTest; + +import edu.wpi.first.wpilibj.command.Command; +import frc.robot.Constants; +import frc.robot.Robot; + +public class testExtendClimber extends Command { + public testExtendClimber() { + super("testExtendClimber"); + requires(Robot.manipulator); + requires(Robot.hopper); + //Use requires() here to declare subsystem dependencies + //eg. requires(chassis); + } + + //Called just before this Command runs the first time + @Override + protected void initialize() { + + } + + //Called repeatedly when this Command is scheduled to run + @Override + protected void execute() { + Robot.climber.setExtended(); + + } + + //Make this return true when this Command no longer needs to run execute() + @Override + protected boolean isFinished() { + return true; + } + + //Called once after isFinished returns true + @Override + protected void end() { + } + + //Called when another command which requires one or more of the same + //subsystems is scheduled to run + + @Override + protected void interrupted() { + //Yes + } +} diff --git a/src/main/java/frc/robot/commands/tempTest/testManipulator.java b/src/main/java/frc/robot/commands/tempTest/testManipulator.java new file mode 100644 index 0000000..44cb65b --- /dev/null +++ b/src/main/java/frc/robot/commands/tempTest/testManipulator.java @@ -0,0 +1,45 @@ +package frc.robot.commands.tempTest; + +import edu.wpi.first.wpilibj.command.Command; +import frc.robot.Constants; +import frc.robot.Robot; + +public class testManipulator extends Command { + public testManipulator() { + super("testManipulator"); + requires(Robot.manipulator); + } + + //Called just before this Command runs the first time + @Override + protected void initialize() { + + } + + //Called repeatedly when this Command is scheduled to run + @Override + protected void execute() { + Robot.manipulator.setExtended(); + + } + + //Make this return true when this Command no longer needs to run execute() + @Override + protected boolean isFinished() { + return true; + } + + //Called once after isFinished returns true + @Override + protected void end() { + // Robot.manipulator.setManipulator(0); + } + + //Called when another command which requires one or more of the same + //subsystems is scheduled to run + + @Override + protected void interrupted() { + //Yes + } +} diff --git a/src/main/java/frc/robot/commands/tempTest/testRetractClimber.java b/src/main/java/frc/robot/commands/tempTest/testRetractClimber.java new file mode 100644 index 0000000..ad486c7 --- /dev/null +++ b/src/main/java/frc/robot/commands/tempTest/testRetractClimber.java @@ -0,0 +1,44 @@ +package frc.robot.commands.tempTest; + +import edu.wpi.first.wpilibj.command.Command; +import frc.robot.Constants; +import frc.robot.Robot; + +public class testRetractClimber extends Command { + public testRetractClimber() { + super("testRetractClimber"); + requires(Robot.climber); + } + + //Called just before this Command runs the first time + @Override + protected void initialize() { + + } + + //Called repeatedly when this Command is scheduled to run + @Override + protected void execute() { + Robot.climber.setRetracted(); + + } + + //Make this return true when this Command no longer needs to run execute() + @Override + protected boolean isFinished() { + return true; + } + + //Called once after isFinished returns true + @Override + protected void end() { + } + + //Called when another command which requires one or more of the same + //subsystems is scheduled to run + + @Override + protected void interrupted() { + //Yes + } +} diff --git a/src/main/java/frc/robot/commands/tempTest/testStopManipulator.java b/src/main/java/frc/robot/commands/tempTest/testStopManipulator.java new file mode 100644 index 0000000..2bdce40 --- /dev/null +++ b/src/main/java/frc/robot/commands/tempTest/testStopManipulator.java @@ -0,0 +1,46 @@ +package frc.robot.commands.tempTest; + +import edu.wpi.first.wpilibj.command.Command; +import frc.robot.Constants; +import frc.robot.Robot; + +public class testStopManipulator extends Command { + public testStopManipulator() { + super("testStopManipulator"); + requires(Robot.manipulator); + //Use requires() here to declare subsystem dependencies + //eg. requires(chassis); + } + + //Called just before this Command runs the first time + @Override + protected void initialize() { + + } + + //Called repeatedly when this Command is scheduled to run + @Override + protected void execute() { + Robot.manipulator.setRetracted(); + } + + //Make this return true when this Command no longer needs to run execute() + @Override + protected boolean isFinished() { + return true; + } + + //Called once after isFinished returns true + @Override + protected void end() { + // Robot.manipulator.setManipulator(0); + } + + //Called when another command which requires one or more of the same + //subsystems is scheduled to run + + @Override + protected void interrupted() { + //Yes + } +} From ceb0c9fcf37ee0047efb9beda9febe9073ed7437 Mon Sep 17 00:00:00 2001 From: Tim Oh - Team2791 Date: Mon, 2 Mar 2020 17:38:04 -0500 Subject: [PATCH 39/68] Hopper Stoppers added to Intake/Hopper Button --- .../java/frc/robot/Autons/ManipulatorToIrHopper.java | 2 ++ src/main/java/frc/robot/OI.java | 11 ----------- .../frc/robot/commands/Shooter/OpenHopperPiston.java | 1 - 3 files changed, 2 insertions(+), 12 deletions(-) diff --git a/src/main/java/frc/robot/Autons/ManipulatorToIrHopper.java b/src/main/java/frc/robot/Autons/ManipulatorToIrHopper.java index 42c5f39..8b7f5c8 100644 --- a/src/main/java/frc/robot/Autons/ManipulatorToIrHopper.java +++ b/src/main/java/frc/robot/Autons/ManipulatorToIrHopper.java @@ -2,10 +2,12 @@ import edu.wpi.first.wpilibj.command.CommandGroup; import frc.robot.commands.IntakeToHopper.*; +import frc.robot.commands.Shooter.OpenHopperPiston; public class ManipulatorToIrHopper extends CommandGroup{ public ManipulatorToIrHopper(){ addSequential(new MoveManipulator()); addSequential(new IrHopper()); + addSequential(new OpenHopperPiston()); } } \ No newline at end of file diff --git a/src/main/java/frc/robot/OI.java b/src/main/java/frc/robot/OI.java index 6b8b886..4f17e00 100644 --- a/src/main/java/frc/robot/OI.java +++ b/src/main/java/frc/robot/OI.java @@ -23,18 +23,7 @@ import frc.robot.controller.MultiButton; import frc.robot.util.Camera_Switch.CameraSwitch; -// import frc.robot.Autons.ShooterGroupLong; -// import frc.robot.Autons.StopShooterGroupLong; -// import frc.robot.Autons.ShooterGroupWall; -// import frc.robot.Autons.StopShooterGroupWall; -//import frc.robot.subsystems.Camera; - -// import frc.robot.commands.Lifter.ExtendBothLifters; import frc.robot.util.Util; -// import frc.robot.commands.CargoManipulator.ScoreInRocketCalculated; -// import frc.robot.commands.CargoManipulator.ScoreInRocketDropper; -// import frc.robot.commands.auto.AutoSetLifterPots; -//here lies robot RIP public class OI { public static Joystick driverStick; diff --git a/src/main/java/frc/robot/commands/Shooter/OpenHopperPiston.java b/src/main/java/frc/robot/commands/Shooter/OpenHopperPiston.java index 71f0068..6e7fe8e 100644 --- a/src/main/java/frc/robot/commands/Shooter/OpenHopperPiston.java +++ b/src/main/java/frc/robot/commands/Shooter/OpenHopperPiston.java @@ -20,7 +20,6 @@ protected void initialize(){ @Override protected void execute() { Robot.hopper.setExtended(); - } @Override From 0e738cbcdfb54f33465a6169d73900b174a288d5 Mon Sep 17 00:00:00 2001 From: frcteam2791 Date: Mon, 2 Mar 2020 18:23:44 -0500 Subject: [PATCH 40/68] changed setpanelmech() to a toggle kind of --- .../commands/PanelMech/SetPanelmech.java | 35 ++++++++++++++----- 1 file changed, 26 insertions(+), 9 deletions(-) diff --git a/src/main/java/frc/robot/commands/PanelMech/SetPanelmech.java b/src/main/java/frc/robot/commands/PanelMech/SetPanelmech.java index 3c9d2b0..c5a8ac2 100644 --- a/src/main/java/frc/robot/commands/PanelMech/SetPanelmech.java +++ b/src/main/java/frc/robot/commands/PanelMech/SetPanelmech.java @@ -5,16 +5,21 @@ import frc.robot.Robot; public class SetPanelmech extends Command { + double count = 1; public SetPanelmech() { - super("SetPanelmech"); - requires(Robot.panelMech); - //Use requires() here to declare subsystem dependencies - //eg. requires(chassis); + super("SetPanelmech"); + requires(Robot.panelMech); + } //Called just before this Command runs the first time @Override protected void initialize() { + count++; + if(count > 2){ + count = 0; + } + Robot.panelMech.extendPanelMech(); } @@ -22,26 +27,38 @@ protected void initialize() { //Called repeatedly when this Command is scheduled to run @Override protected void execute() { - Robot.panelMech.setPanelMech(Constants.PANEL_MECH_CREEP); + if(count == 1){ + Robot.panelMech.setPanelMech(Constants.PANEL_MECH_FAST); + } + else if(count == 2){ + Robot.panelMech.setPanelMech(Constants.PANEL_MECH_CREEP); + } + else{ + Robot.panelMech.setPanelMech(0); + } } //Make this return true when this Command no longer needs to run execute() @Override protected boolean isFinished() { - return true; + if(count == 0){ + return true; + } + return false; } //Called once after isFinished returns true @Override protected void end() { Robot.panelMech.setPanelMech(0); + Robot.panelMech.retractPanelMech(); } -// //Called when another command which requires one or more of the same -// //subsystems is scheduled to run + //Called when another command which requires one or more of the same + //subsystems is scheduled to run @Override protected void interrupted() { - //Yes + } } \ No newline at end of file From d15f5ec0c8500e17ed93db0dbb37ba4557896ce0 Mon Sep 17 00:00:00 2001 From: frcteam2791 Date: Mon, 2 Mar 2020 16:49:39 -0800 Subject: [PATCH 41/68] Tech Park Tuning Fixed stop shooter group to stop hopper too. Tried faster hopper output and commented old speed --- .../frc/robot/Autons/StopShooterGroup.java | 2 +- src/main/java/frc/robot/Constants.java | 4 +- src/main/java/frc/robot/OI.java | 45 +++++++++++++------ 3 files changed, 34 insertions(+), 17 deletions(-) diff --git a/src/main/java/frc/robot/Autons/StopShooterGroup.java b/src/main/java/frc/robot/Autons/StopShooterGroup.java index 95f6d41..a09e646 100644 --- a/src/main/java/frc/robot/Autons/StopShooterGroup.java +++ b/src/main/java/frc/robot/Autons/StopShooterGroup.java @@ -10,7 +10,7 @@ public class StopShooterGroup extends CommandGroup { public StopShooterGroup() { addSequential(new WallShotHood()); - addSequential(new StopShooter()); + // addSequential(new StopShooter()); addSequential(new CloseHopperPiston()); addSequential(new StopHopper()); } diff --git a/src/main/java/frc/robot/Constants.java b/src/main/java/frc/robot/Constants.java index 6ca3d1d..6e101d7 100644 --- a/src/main/java/frc/robot/Constants.java +++ b/src/main/java/frc/robot/Constants.java @@ -69,10 +69,10 @@ public final class Constants { public static final double HOPPER_LOADING_HORIZONTAL_OUTPUT = .62; - public static final double HOPPER_WALL_HORIZONTAL_OUTPUT = 0.30; + public static final double HOPPER_WALL_HORIZONTAL_OUTPUT = 0.86; // 0.30; 0.70; - public static final double HOPPER_VERTICAL_OUTPUT = .35; + public static final double HOPPER_VERTICAL_OUTPUT = 1.0; // .35; 0.80; public static final double HOPPER_LOADING_VERTICAL_OUTPUT = .07; diff --git a/src/main/java/frc/robot/OI.java b/src/main/java/frc/robot/OI.java index ff259ee..a34f8dd 100644 --- a/src/main/java/frc/robot/OI.java +++ b/src/main/java/frc/robot/OI.java @@ -129,23 +129,40 @@ public boolean get() { // TODO Auto-generated method stub return operatorStick.getRawAxis(3) > 0.25; } + }.whenActive(new WallHoodAndFire()); + + new Trigger(){ + @Override + public boolean get() { + // TODO Auto-generated method stub + return operatorStick.getRawAxis(3) > 0.25; + } + }.whenInactive(new StopShooterGroup()); + + new Trigger(){ + @Override + public boolean get() { + // TODO Auto-generated method stub + return operatorStick.getRawAxis(2) > 0.25; + } }.whenActive(new StopShooter()); + // driverA.whenPressed(new MoveManipulator()); //moves wheels as well so don't be surprised + // driverA.whenReleased(new StopManipulator()); + + // driverA.whenPressed(new InstantCommand(() -> { + // Robot.Cam_switch.select(CameraSwitch.kcamera2);; + // })); - driverA.whenPressed(new MoveManipulator()); //moves wheels as well so don't be surprised - driverA.whenReleased(new StopManipulator()); + driverA.whileHeld(new ManipulatorToIrHopper()); driverA.whenPressed(new InstantCommand(() -> { - Robot.hopper.setRetracted();; - })); + Robot.Cam_switch.select(CameraSwitch.kcamera2);; + })); driverA.whenPressed(new InstantCommand(() -> { - Robot.Cam_switch.select(CameraSwitch.kcamera2);; + Robot.hopper.setRetracted();; })); + driverA.whenReleased(new StopManipulator()); + driverA.whenReleased(new StopHopper()); - // driverA.whileHeld(new ManipulatorToIrHopper()); - // driverA.whenPressed(new InstantCommand(() -> { - // Robot.Cam_switch.select(CameraSwitch.kcamera2);; - // })); - // driverA.whenReleased(new StopManipulator()); - // driverA.whenReleased(new StopHopper()); driverDPadRight.whileHeld(new DrivetrainAlignToGoal()); @@ -153,9 +170,9 @@ public boolean get() { // //driverDPadLeft.whenPressed(new setCameraThree()); // driverDPadLeft.whenReleased(new DefaultPanelMech()); - // driverDPadDown.whenPressed(new InstantCommand(() -> { - // Robot.climber.setRetracted();; - // })); + driverDPadDown.whenPressed(new InstantCommand(() -> { + Robot.climber.setRetracted();; + })); driverDPadUp.whileHeld(new SetPanelmech()); From 60751b50013ebb579472120ce257d138f4cabe8e Mon Sep 17 00:00:00 2001 From: frcteam2791 Date: Mon, 2 Mar 2020 20:11:38 -0500 Subject: [PATCH 42/68] changed panel mech button in oi --- src/main/java/frc/robot/OI.java | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/main/java/frc/robot/OI.java b/src/main/java/frc/robot/OI.java index 62a5c1a..19eb8b8 100644 --- a/src/main/java/frc/robot/OI.java +++ b/src/main/java/frc/robot/OI.java @@ -97,8 +97,7 @@ public boolean get() { // operatorB.whileHeld(new OpenPistonsAndMoveHopper()); // operatorB.whenReleased(new StopHopper()); - operatorB.whileHeld(new WallHoodAndFire()); - operatorB.whenReleased(new StopShooterGroup()); + operatorB.whileHeld(new SetPanelmech()); operatorY.whileHeld(new MoveHopperWall()); operatorY.whenReleased(new StopHopper()); @@ -167,7 +166,6 @@ public boolean get() { Robot.climber.setRetracted();; })); - driverDPadUp.whileHeld(new SetPanelmech()); driverStart.whenPressed(new ReleasePin(true, true)); // driverA.whenPressed(new ReleasePin(false, false)); From 62912b8b3b83a0aeaf87feb8c5f4d853bfe124ce Mon Sep 17 00:00:00 2001 From: xprt656 Date: Tue, 3 Mar 2020 00:09:39 -0500 Subject: [PATCH 43/68] Added Hopper Counter and Jam commands Jam indicator added and Unjam command added along with counter for the number of balls intaken (all need to be tested) --- src/main/java/frc/robot/Constants.java | 7 +- .../IntakeToHopper/FixHopperSpacing.java | 64 +++++++++++++++++++ .../commands/IntakeToHopper/IrHopper.java | 4 ++ .../commands/IntakeToHopper/UnjamHopper.java | 50 +++++++++++++++ .../java/frc/robot/subsystems/Hopper.java | 8 +++ 5 files changed, 130 insertions(+), 3 deletions(-) create mode 100644 src/main/java/frc/robot/commands/IntakeToHopper/FixHopperSpacing.java create mode 100644 src/main/java/frc/robot/commands/IntakeToHopper/UnjamHopper.java diff --git a/src/main/java/frc/robot/Constants.java b/src/main/java/frc/robot/Constants.java index 6e101d7..b6b86c9 100644 --- a/src/main/java/frc/robot/Constants.java +++ b/src/main/java/frc/robot/Constants.java @@ -39,7 +39,8 @@ public final class Constants { public static final double kDrag = 1; public static final double kMagnus = 1; - + public static final double jamCurrent = 20; + public static final double fixSpaceTime = 0.2; public static final double DrivekP = 0.025; public static final double DrivekI = 0; @@ -63,8 +64,8 @@ public final class Constants { public static final double DEADZONE = 0.4; - public static final double ELEVATOR_OUTPUT = -.05; - + public static final double ELEVATOR_OUTPUT = -.05; + public static final double HOPPER_LOADING_HORIZONTAL_OUTPUT = .62; diff --git a/src/main/java/frc/robot/commands/IntakeToHopper/FixHopperSpacing.java b/src/main/java/frc/robot/commands/IntakeToHopper/FixHopperSpacing.java new file mode 100644 index 0000000..a2ea059 --- /dev/null +++ b/src/main/java/frc/robot/commands/IntakeToHopper/FixHopperSpacing.java @@ -0,0 +1,64 @@ +/*----------------------------------------------------------------------------*/ +/* Copyright (c) 2018 FIRST. All Rights Reserved. */ +/* Open Source Software - may be modified and shared by FRC teams. The code */ +/* must be accompanied by the FIRST BSD license file in the root directory of */ +/* the project. */ +/*----------------------------------------------------------------------------*/ + +package frc.robot.commands.IntakeToHopper; + +import java.util.concurrent.DelayQueue; + +import edu.wpi.first.wpilibj.Timer; +import edu.wpi.first.wpilibj.command.Command; +import frc.robot.Constants; +import frc.robot.Robot; + +public class FixHopperSpacing extends Command { + Timer timeToFixSpace; + public FixHopperSpacing() { + super("FixHopperSpacing"); + requires(Robot.hopper); + // Use requires() here to declare subsystem dependencies + // eg. requires(chassis); + } + + // Called just before this Command runs the first time + @Override + protected void initialize() { + } + + // Called repeatedly when this Command is scheduled to run + @Override + protected void execute() { + if(!Robot.hopper.isUpperSensorTripped()){ + Robot.hopper.setHopper(Constants.HOPPER_LOADING_HORIZONTAL_OUTPUT, Constants.HOPPER_LOADING_VERTICAL_OUTPUT); + } + else if(Robot.hopper.isUpperSensorTripped()){ + Robot.hopper.setHopper(Constants.HOPPER_LOADING_HORIZONTAL_OUTPUT, 0); + Timer.delay(Constants.fixSpaceTime); + Robot.hopper.setHopper(-Constants.HOPPER_LONG_HORIZONTAL_OUTPUT, -Constants.HOPPER_VERTICAL_OUTPUT); + } + //Pulls balls as far up as possible + //only runs the horizontal belt (not the vertical) for some time to decrease the space between balls 2 and 3 + //pulls balls back to first ir sensor + } + + // Make this return true when this Command no longer needs to run execute() + @Override + protected boolean isFinished() { + return Robot.hopper.isBall(); + } + + // Called once after isFinished returns true + @Override + protected void end() { + Robot.hopper.setHopper(0, 0); + } + + // Called when another command which requires one or more of the same + // subsystems is scheduled to run + @Override + protected void interrupted() { + } +} diff --git a/src/main/java/frc/robot/commands/IntakeToHopper/IrHopper.java b/src/main/java/frc/robot/commands/IntakeToHopper/IrHopper.java index ad24d42..c2efcbc 100644 --- a/src/main/java/frc/robot/commands/IntakeToHopper/IrHopper.java +++ b/src/main/java/frc/robot/commands/IntakeToHopper/IrHopper.java @@ -7,6 +7,8 @@ import frc.robot.commands.IntakeToHopper.MoveManipulator; public class IrHopper extends Command { + public int count; + public IrHopper() { super("IrHopper"); requires(Robot.hopper); @@ -17,6 +19,7 @@ public IrHopper() { // Called just before this Command runs the first time @Override protected void initialize() { + count = 0; } // Called repeatedly when this Command is scheduled to run @@ -38,6 +41,7 @@ protected boolean isFinished() { // Called once after isFinished returns true @Override protected void end() { + count++; Robot.hopper.setHopper(0, 0); SmartDashboard.putBoolean("Ir Hopper Running", false); } diff --git a/src/main/java/frc/robot/commands/IntakeToHopper/UnjamHopper.java b/src/main/java/frc/robot/commands/IntakeToHopper/UnjamHopper.java new file mode 100644 index 0000000..11f691f --- /dev/null +++ b/src/main/java/frc/robot/commands/IntakeToHopper/UnjamHopper.java @@ -0,0 +1,50 @@ +/*----------------------------------------------------------------------------*/ +/* Copyright (c) 2018 FIRST. All Rights Reserved. */ +/* Open Source Software - may be modified and shared by FRC teams. The code */ +/* must be accompanied by the FIRST BSD license file in the root directory of */ +/* the project. */ +/*----------------------------------------------------------------------------*/ + +package frc.robot.commands.IntakeToHopper; + +import edu.wpi.first.wpilibj.command.Command; +import frc.robot.Constants; +import frc.robot.Robot; + +public class UnjamHopper extends Command { + public UnjamHopper() { + super("UnjamHopper"); + requires(Robot.hopper); + // Use requires() here to declare subsystem dependencies + // eg. requires(chassis); + } + + // Called just before this Command runs the first time + @Override + protected void initialize() { + } + + // Called repeatedly when this Command is scheduled to run + @Override + protected void execute() { + Robot.hopper.setHopper(-Constants.HOPPER_LOADING_HORIZONTAL_OUTPUT, -Constants.HOPPER_LOADING_VERTICAL_OUTPUT); + } + + // Make this return true when this Command no longer needs to run execute() + @Override + protected boolean isFinished() { + return !Robot.hopper.checkJammed() || Robot.hopper.isBall(); + } + + // Called once after isFinished returns true + @Override + protected void end() { + Robot.hopper.setHopper(0, 0); + } + + // Called when another command which requires one or more of the same + // subsystems is scheduled to run + @Override + protected void interrupted() { + } +} diff --git a/src/main/java/frc/robot/subsystems/Hopper.java b/src/main/java/frc/robot/subsystems/Hopper.java index 7576a76..e403aba 100644 --- a/src/main/java/frc/robot/subsystems/Hopper.java +++ b/src/main/java/frc/robot/subsystems/Hopper.java @@ -80,6 +80,13 @@ public double getVerticalCurrent() { return hopper_vertical.getOutputCurrent(); } + public boolean checkJammed(){ + if(getHorizontalCurrent()>Constants.jamCurrent) + return true; + else + return false; + } + public boolean isBall(){ if(Constants.BALL_VALUE < getIRSensor()){ return true; @@ -117,6 +124,7 @@ public void debug(){ SmartDashboard.putNumber("Vertical Current", getVerticalCurrent()); SmartDashboard.putBoolean("Hopper Stopper Out", isRetracted()); SmartDashboard.putNumber("Upper IR Value", upperSensor.getValue()); + SmartDashboard.putBoolean("Jammed", checkJammed()); } @Override protected void initDefaultCommand() { From 42a7a95907276a8ee5e0063350ebc546d952acb3 Mon Sep 17 00:00:00 2001 From: frcteam2791 Date: Tue, 3 Mar 2020 12:11:36 -0500 Subject: [PATCH 44/68] changed set panel mech command and changed it in oi --- src/main/java/frc/robot/OI.java | 2 +- .../java/frc/robot/commands/PanelMech/SetPanelmech.java | 7 +------ 2 files changed, 2 insertions(+), 7 deletions(-) diff --git a/src/main/java/frc/robot/OI.java b/src/main/java/frc/robot/OI.java index 19eb8b8..1542401 100644 --- a/src/main/java/frc/robot/OI.java +++ b/src/main/java/frc/robot/OI.java @@ -97,7 +97,7 @@ public boolean get() { // operatorB.whileHeld(new OpenPistonsAndMoveHopper()); // operatorB.whenReleased(new StopHopper()); - operatorB.whileHeld(new SetPanelmech()); + operatorB.whenPressed(new SetPanelmech()); operatorY.whileHeld(new MoveHopperWall()); operatorY.whenReleased(new StopHopper()); diff --git a/src/main/java/frc/robot/commands/PanelMech/SetPanelmech.java b/src/main/java/frc/robot/commands/PanelMech/SetPanelmech.java index c5a8ac2..5a34033 100644 --- a/src/main/java/frc/robot/commands/PanelMech/SetPanelmech.java +++ b/src/main/java/frc/robot/commands/PanelMech/SetPanelmech.java @@ -19,7 +19,6 @@ protected void initialize() { if(count > 2){ count = 0; } - Robot.panelMech.extendPanelMech(); } @@ -41,17 +40,13 @@ else if(count == 2){ //Make this return true when this Command no longer needs to run execute() @Override protected boolean isFinished() { - if(count == 0){ - return true; - } return false; } //Called once after isFinished returns true @Override protected void end() { - Robot.panelMech.setPanelMech(0); - Robot.panelMech.retractPanelMech(); + } //Called when another command which requires one or more of the same From 07cba745fc7d74c4ee7217c41d76a9702ada3bcf Mon Sep 17 00:00:00 2001 From: frcteam2791 Date: Tue, 3 Mar 2020 11:53:17 -0800 Subject: [PATCH 45/68] Added Camera Switch to Pit Controller --- src/main/java/frc/robot/Constants.java | 2 +- src/main/java/frc/robot/Robot.java | 33 +++++++++++++++----------- 2 files changed, 20 insertions(+), 15 deletions(-) diff --git a/src/main/java/frc/robot/Constants.java b/src/main/java/frc/robot/Constants.java index 6e101d7..51ce5f1 100644 --- a/src/main/java/frc/robot/Constants.java +++ b/src/main/java/frc/robot/Constants.java @@ -72,7 +72,7 @@ public final class Constants { public static final double HOPPER_WALL_HORIZONTAL_OUTPUT = 0.86; // 0.30; 0.70; - public static final double HOPPER_VERTICAL_OUTPUT = 1.0; // .35; 0.80; + public static final double HOPPER_VERTICAL_OUTPUT = 1.0; // .35; 0.80;[\] public static final double HOPPER_LOADING_VERTICAL_OUTPUT = .07; diff --git a/src/main/java/frc/robot/Robot.java b/src/main/java/frc/robot/Robot.java index 9a074cf..cca05e4 100644 --- a/src/main/java/frc/robot/Robot.java +++ b/src/main/java/frc/robot/Robot.java @@ -27,7 +27,7 @@ public class Robot extends TimedRobot { long loopCounter = 0; - public static Joystick operatorStick; + public static Joystick pitStick; public static OI oi; public static Drivetrain drivetrain; public static PowerDistributionPanel pdp; @@ -42,7 +42,7 @@ public class Robot extends TimedRobot { public static PanelMech panelMech; public static CameraServer Cam; public static CameraSwitch Cam_switch; - private Button operatorA, operatorB; + private Button pitA, pitB, pitX; public static Climber climber; @@ -64,9 +64,10 @@ public void robotInit() { compressor = new Compressor(RobotMap.kPCM); compressor.start(); Cam.startAutomaticCapture(0); - operatorStick = new Joystick(1); - operatorA = new JoystickButton(operatorStick, 1); - operatorB = new JoystickButton(operatorStick, 2); + pitStick = new Joystick(3); + pitA = new JoystickButton(pitStick, 1); + pitB = new JoystickButton(pitStick, 2); + pitX = new JoystickButton(pitStick, 3); SmartDashboard.putBoolean("Drivetrain Align Complete", false); @@ -83,15 +84,19 @@ public void robotPeriodic() { hopper.debug(); climber.debug(); shooter.debug(); - // if(operatorA.get() == true) { - // Cam_switch.select(CameraSwitch.kcamera1); - // } - // else if (operatorB.get() == true) { - // Cam_switch.select(CameraSwitch.kcamera2); - // } - // else { - // Cam_switch.select(CameraSwitch.kcamera3); - // } + + if(pitA.get() == true) { + Cam_switch.select(CameraSwitch.kcamera1); + } + else if(pitB.get() == true) { + Cam_switch.select(CameraSwitch.kcamera2); + } + else if(pitX.get() == true){ + Cam_switch.select(CameraSwitch.kcamera3); + } + else { + Cam_switch.select(CameraSwitch.kcamera4); + } } @Override From 9c9330a4d5f15db0b909c73a79c76e603275ed19 Mon Sep 17 00:00:00 2001 From: frcteam2791 Date: Tue, 3 Mar 2020 12:09:13 -0800 Subject: [PATCH 46/68] Changed Pit Camera Buttons to not Conflict Changed pit camera buttons to dpad so they don't conflict with the climb --- src/main/java/frc/robot/Robot.java | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/src/main/java/frc/robot/Robot.java b/src/main/java/frc/robot/Robot.java index cca05e4..4b3d3a4 100644 --- a/src/main/java/frc/robot/Robot.java +++ b/src/main/java/frc/robot/Robot.java @@ -8,6 +8,7 @@ import edu.wpi.first.wpilibj.command.Scheduler; import edu.wpi.first.wpilibj.smartdashboard.SmartDashboard; import frc.robot.commands.setCameraOne; +import frc.robot.controller.DPadButton; import frc.robot.subsystems.*; import frc.robot.util.LedMode; import frc.robot.util.Camera_Switch.CameraSwitch; @@ -42,7 +43,7 @@ public class Robot extends TimedRobot { public static PanelMech panelMech; public static CameraServer Cam; public static CameraSwitch Cam_switch; - private Button pitA, pitB, pitX; + private Button pitDPadDown, pitDPadRight, pitDPadLeft, pitDPadUp; public static Climber climber; @@ -65,11 +66,11 @@ public void robotInit() { compressor.start(); Cam.startAutomaticCapture(0); pitStick = new Joystick(3); - pitA = new JoystickButton(pitStick, 1); - pitB = new JoystickButton(pitStick, 2); - pitX = new JoystickButton(pitStick, 3); - - + pitDPadDown = new DPadButton(pitStick, DPadButton.kDPadDown); + pitDPadLeft = new DPadButton(pitStick, DPadButton.kDPadLeft); + pitDPadUp = new DPadButton(pitStick, DPadButton.kDPadUp); + pitDPadRight = new DPadButton(pitStick, DPadButton.kDPadRight); + SmartDashboard.putBoolean("Drivetrain Align Complete", false); } @@ -85,13 +86,13 @@ public void robotPeriodic() { climber.debug(); shooter.debug(); - if(pitA.get() == true) { + if(pitDPadUp.get() == true) { Cam_switch.select(CameraSwitch.kcamera1); } - else if(pitB.get() == true) { + else if(pitDPadRight.get() == true) { Cam_switch.select(CameraSwitch.kcamera2); } - else if(pitX.get() == true){ + else if(pitDPadDown.get() == true){ Cam_switch.select(CameraSwitch.kcamera3); } else { From 2910c4a5bd352be32fad183fee7ca2895eb42701 Mon Sep 17 00:00:00 2001 From: frcteam2791 Date: Tue, 3 Mar 2020 19:01:53 -0500 Subject: [PATCH 47/68] added limit switch added a limit switch using a counter object for hopper --- .../robot/Autons/ManipulatorToIrHopper.java | 2 +- .../frc/robot/Autons/ShooterGroupLong.java | 18 ------- .../frc/robot/Autons/ShooterGroupWall.java | 17 ------- src/main/java/frc/robot/Constants.java | 6 ++- src/main/java/frc/robot/OI.java | 43 +++-------------- src/main/java/frc/robot/Robot.java | 15 ++---- .../commands/IntakeToHopper/IrHopper.java | 22 +++++++-- ...etPanelmech.java => SetPanelMechFast.java} | 23 +++------ .../commands/PanelMech/SetPanelMechSlow.java | 48 +++++++++++++++++++ .../java/frc/robot/subsystems/Hopper.java | 21 ++++++-- .../frc/robot/subsystems/Manipulator.java | 1 + 11 files changed, 108 insertions(+), 108 deletions(-) delete mode 100644 src/main/java/frc/robot/Autons/ShooterGroupLong.java delete mode 100644 src/main/java/frc/robot/Autons/ShooterGroupWall.java rename src/main/java/frc/robot/commands/PanelMech/{SetPanelmech.java => SetPanelMechFast.java} (64%) create mode 100644 src/main/java/frc/robot/commands/PanelMech/SetPanelMechSlow.java diff --git a/src/main/java/frc/robot/Autons/ManipulatorToIrHopper.java b/src/main/java/frc/robot/Autons/ManipulatorToIrHopper.java index 8b7f5c8..7c870e2 100644 --- a/src/main/java/frc/robot/Autons/ManipulatorToIrHopper.java +++ b/src/main/java/frc/robot/Autons/ManipulatorToIrHopper.java @@ -8,6 +8,6 @@ public class ManipulatorToIrHopper extends CommandGroup{ public ManipulatorToIrHopper(){ addSequential(new MoveManipulator()); addSequential(new IrHopper()); - addSequential(new OpenHopperPiston()); + //addSequential(new OpenHopperPiston()); } } \ No newline at end of file diff --git a/src/main/java/frc/robot/Autons/ShooterGroupLong.java b/src/main/java/frc/robot/Autons/ShooterGroupLong.java deleted file mode 100644 index 8196a47..0000000 --- a/src/main/java/frc/robot/Autons/ShooterGroupLong.java +++ /dev/null @@ -1,18 +0,0 @@ -package frc.robot.Autons; - -import edu.wpi.first.wpilibj.command.CommandGroup; -import frc.robot.commands.IntakeToHopper.*; - -import frc.robot.commands.Shooter.LongShot; -import frc.robot.commands.Shooter.LongShotHood; -import frc.robot.commands.Shooter.OpenHopperPiston; - -public class ShooterGroupLong extends CommandGroup{ - - public ShooterGroupLong(){ - addSequential(new LongShotHood()); - addSequential(new LongShot(), 2.0); - addSequential(new OpenHopperPiston()); - addSequential(new MoveHopperLong()); - } -} \ No newline at end of file diff --git a/src/main/java/frc/robot/Autons/ShooterGroupWall.java b/src/main/java/frc/robot/Autons/ShooterGroupWall.java deleted file mode 100644 index b36567f..0000000 --- a/src/main/java/frc/robot/Autons/ShooterGroupWall.java +++ /dev/null @@ -1,17 +0,0 @@ -package frc.robot.Autons; - -import edu.wpi.first.wpilibj.command.CommandGroup; -import frc.robot.commands.IntakeToHopper.MoveHopperWall; -import frc.robot.commands.Shooter.OpenHopperPiston; -import frc.robot.commands.Shooter.WallShot; -import frc.robot.commands.Shooter.WallShotHood; - -public class ShooterGroupWall extends CommandGroup{ - - public ShooterGroupWall(){ - addSequential(new WallShotHood()); - addSequential(new WallShot()); - addSequential(new OpenHopperPiston()); - addSequential(new MoveHopperWall()); - } -} \ No newline at end of file diff --git a/src/main/java/frc/robot/Constants.java b/src/main/java/frc/robot/Constants.java index 04ae5e6..21c731c 100644 --- a/src/main/java/frc/robot/Constants.java +++ b/src/main/java/frc/robot/Constants.java @@ -1,5 +1,6 @@ package frc.robot; +import edu.wpi.first.wpilibj.Timer; public final class Constants { public static final boolean debugMode = false; @@ -96,7 +97,7 @@ public final class Constants { public static final double MANUAL_POWER = .2; - public static final double INTAKE_MOTORSPEED = 0.135; //Temp value please test it out and do stuff yes + public static final double INTAKE_MOTORSPEED = 0.8; //Temp value please test it out and do stuff yes public static final double SHOOTER_VELOCITY = 100; //Temporary value @@ -137,4 +138,7 @@ public final class Constants { public static final double HOPPER_LONG_HORIZONTAL_OUTPUT = 0.25; + + public static final double kHopperTimer = 0.2; + } \ No newline at end of file diff --git a/src/main/java/frc/robot/OI.java b/src/main/java/frc/robot/OI.java index 1542401..b33e76b 100644 --- a/src/main/java/frc/robot/OI.java +++ b/src/main/java/frc/robot/OI.java @@ -6,8 +6,6 @@ import edu.wpi.first.wpilibj.buttons.Trigger; import edu.wpi.first.wpilibj.command.InstantCommand; import frc.robot.Autons.ManipulatorToIrHopper; -import frc.robot.Autons.ShooterGroupLong; -import frc.robot.Autons.ShooterGroupWall; import frc.robot.Autons.StopShooterGroup; import frc.robot.Autons.TrenchHoodAndFire; import frc.robot.Autons.WallHoodAndFire; @@ -20,7 +18,6 @@ import frc.robot.commands.Shooter.StopShooter; import frc.robot.commands.tempTest.*; import frc.robot.commands.Climb.*; -// import frc.robot.commands.auto.SetLimit; import frc.robot.controller.AnalogButton; import frc.robot.controller.DPadButton; import frc.robot.controller.MultiButton; @@ -53,19 +50,7 @@ public OI() { initButtons(); initUsed(); - driveButton.whileHeld(new DriveWithJoystick(driverStick, 0.1)); // TODO CHANGE DEADZONE VALUE IT MIGHT NOT BE THE SAME - - // driverRB.whenPressed(new ShooterGroupWall()); - // driverRB.whileHeld(new WallShot()); - // driverRB.whenReleased(new StopShooterGroup()); - - - // driverLB.whenReleased(new StopShooterGroupLong()); - // operatorDPadLeft.whenPressed(new ShooterGroupLong()); - // operatorDPadLeft.whenPressed(new StopShooterGroup()); - - // operatorDPadRight.whenPressed(new ShooterGroupWall()); - // operatorDPadRight.whenReleased(new StopShooterGroup()); + driveButton.whileHeld(new DriveWithJoystick(driverStick, 0.1)); // TODO CHANGE DEADZONE VALUE IT MIGHT NOT BE THE SAME operatorDPadLeft.whenPressed(new LongShotHood()); operatorDPadRight.whenPressed(new WallShotHood()); @@ -85,19 +70,13 @@ public boolean get() { return operatorStick.getRawAxis(1) > 0.8; } }.whenInactive(new StopHopper()); - // operatorA.whenPressed(new MoveHopperLong()); - // operatorA.whenReleased(new StopHopper()); - - // operatorB.whenPressed(new LongShotHood()); - // operatorB.whenReleased(new WallShotHood()); operatorA.whenPressed(new InstantCommand(() -> { Robot.hopper.hopper_stopper.set(true); })); - // operatorB.whileHeld(new OpenPistonsAndMoveHopper()); - // operatorB.whenReleased(new StopHopper()); - operatorB.whenPressed(new SetPanelmech()); + operatorB.whileHeld(new SetPanelMechSlow()); + operatorA.whileHeld(new SetPanelMechFast()); operatorY.whileHeld(new MoveHopperWall()); operatorY.whenReleased(new StopHopper()); @@ -138,12 +117,6 @@ public boolean get() { return operatorStick.getRawAxis(2) > 0.25; } }.whenActive(new StopShooter()); - // driverA.whenPressed(new MoveManipulator()); //moves wheels as well so don't be surprised - // driverA.whenReleased(new StopManipulator()); - - // driverA.whenPressed(new InstantCommand(() -> { - // Robot.Cam_switch.select(CameraSwitch.kcamera2);; - // })); driverA.whileHeld(new ManipulatorToIrHopper()); driverA.whenPressed(new InstantCommand(() -> { @@ -151,26 +124,24 @@ public boolean get() { })); driverA.whenPressed(new InstantCommand(() -> { Robot.hopper.setRetracted();; + })); driverA.whenReleased(new StopManipulator()); driverA.whenReleased(new StopHopper()); + //driverA.whileHeld(new IrHopper()); driverDPadRight.whileHeld(new DrivetrainAlignToGoal()); - // driverDPadLeft.whenPressed(new ExtendPanelMech()); - // //driverDPadLeft.whenPressed(new setCameraThree()); - // driverDPadLeft.whenReleased(new DefaultPanelMech()); - driverDPadDown.whenPressed(new InstantCommand(() -> { Robot.climber.setRetracted();; })); - driverStart.whenPressed(new ReleasePin(true, true)); - // driverA.whenPressed(new ReleasePin(false, false)); + driverX.whileHeld(new WinchClimb(true)); driverX.whenReleased(new StopWinchClimb()); + driverY.whileHeld(new WinchClimb(false)); driverY.whenReleased(new StopWinchClimb()); diff --git a/src/main/java/frc/robot/Robot.java b/src/main/java/frc/robot/Robot.java index 4b3d3a4..3571ccd 100644 --- a/src/main/java/frc/robot/Robot.java +++ b/src/main/java/frc/robot/Robot.java @@ -85,6 +85,7 @@ public void robotPeriodic() { hopper.debug(); climber.debug(); shooter.debug(); + manipulator.debug(); if(pitDPadUp.get() == true) { Cam_switch.select(CameraSwitch.kcamera1); @@ -118,7 +119,7 @@ public void disabledPeriodic() { manipulator.setRetracted(); shooter.setShooter(0); //add emergency stops for panelMech - // Robot.drivetrain.resetGyro(); + // autoCommand.start(); } @@ -146,17 +147,7 @@ public void teleopInit() { @Override public void teleopPeriodic() { - // Robot.elevator.setElevator(-.1); - // Robot.hopper.setHopper(-1); - // Robot.shooter.setShooter(-1); - // Robot.drivetrain.setMotors(-1); - - // Robot.drivetrain.setMotors(-.0000001); - // Robot.drivetrain.setRightTalon(-1); - // Robot.drivetrain.setLeftNeo(-1); - // Robot.drivetrain.setLeftTalon(.7); - // Robot.drivetrain.setRightNeo(1); - // 0.5 power is the sweet spot for wall, 0.8 for current at angle of 39 degrees + Scheduler.getInstance().run(); diff --git a/src/main/java/frc/robot/commands/IntakeToHopper/IrHopper.java b/src/main/java/frc/robot/commands/IntakeToHopper/IrHopper.java index c2efcbc..ba8acd9 100644 --- a/src/main/java/frc/robot/commands/IntakeToHopper/IrHopper.java +++ b/src/main/java/frc/robot/commands/IntakeToHopper/IrHopper.java @@ -5,10 +5,11 @@ import frc.robot.Constants; import frc.robot.Robot; import frc.robot.commands.IntakeToHopper.MoveManipulator; +import edu.wpi.first.wpilibj.Timer; public class IrHopper extends Command { public int count; - + public Timer timer= new Timer(); public IrHopper() { super("IrHopper"); requires(Robot.hopper); @@ -25,9 +26,17 @@ protected void initialize() { // Called repeatedly when this Command is scheduled to run @Override protected void execute() { - // Robot.hopper.setHopper(Constants.HOPPER_LOADING_HORIZONTAL_OUTPUT, Constants.HOPPER_VERTICAL_OUTPUT); Robot.hopper.loadingWithIR(); SmartDashboard.putBoolean("Ir Hopper Running", true); + if(Robot.hopper.limitSwitch.get()){ + timer.start(); + Robot.hopper.setHopper(Constants.HOPPER_LOADING_HORIZONTAL_OUTPUT, Constants.HOPPER_LOADING_VERTICAL_OUTPUT); + } + if (timer.get()>=Constants.kHopperTimer){ + timer.stop(); + Robot.hopper.setHopper(0,0); + } + } // Make this return true when this Command no longer needs to run execute() @@ -35,7 +44,13 @@ protected void execute() { protected boolean isFinished() { // return !Robot.hopper.isBall() || Robot.hopper.isUpperSensorTripped(); - return !Robot.hopper.isBall(); + if (Robot.hopper.isHopperFull()==true){ + return true; + } + else{ + return false; + } + } // Called once after isFinished returns true @@ -44,6 +59,7 @@ protected void end() { count++; Robot.hopper.setHopper(0, 0); SmartDashboard.putBoolean("Ir Hopper Running", false); + Robot.hopper.counter.reset(); } // Called when another command which requires one or more of the same diff --git a/src/main/java/frc/robot/commands/PanelMech/SetPanelmech.java b/src/main/java/frc/robot/commands/PanelMech/SetPanelMechFast.java similarity index 64% rename from src/main/java/frc/robot/commands/PanelMech/SetPanelmech.java rename to src/main/java/frc/robot/commands/PanelMech/SetPanelMechFast.java index 5a34033..85c8a9e 100644 --- a/src/main/java/frc/robot/commands/PanelMech/SetPanelmech.java +++ b/src/main/java/frc/robot/commands/PanelMech/SetPanelMechFast.java @@ -4,10 +4,10 @@ import frc.robot.Constants; import frc.robot.Robot; -public class SetPanelmech extends Command { +public class SetPanelMechFast extends Command { double count = 1; - public SetPanelmech() { - super("SetPanelmech"); + public SetPanelMechFast() { + super("SetPanelMechFast"); requires(Robot.panelMech); } @@ -15,10 +15,7 @@ public SetPanelmech() { //Called just before this Command runs the first time @Override protected void initialize() { - count++; - if(count > 2){ - count = 0; - } + } @@ -26,21 +23,13 @@ protected void initialize() { //Called repeatedly when this Command is scheduled to run @Override protected void execute() { - if(count == 1){ - Robot.panelMech.setPanelMech(Constants.PANEL_MECH_FAST); - } - else if(count == 2){ - Robot.panelMech.setPanelMech(Constants.PANEL_MECH_CREEP); - } - else{ - Robot.panelMech.setPanelMech(0); - } + Robot.panelMech.setPanelMech(Constants.PANEL_MECH_FAST); } //Make this return true when this Command no longer needs to run execute() @Override protected boolean isFinished() { - return false; + return true; } //Called once after isFinished returns true diff --git a/src/main/java/frc/robot/commands/PanelMech/SetPanelMechSlow.java b/src/main/java/frc/robot/commands/PanelMech/SetPanelMechSlow.java new file mode 100644 index 0000000..c30c1cc --- /dev/null +++ b/src/main/java/frc/robot/commands/PanelMech/SetPanelMechSlow.java @@ -0,0 +1,48 @@ +package frc.robot.commands.PanelMech; + +import edu.wpi.first.wpilibj.command.Command; +import frc.robot.Constants; +import frc.robot.Robot; + +public class SetPanelMechSlow extends Command { + double count = 1; + public SetPanelMechSlow() { + super("SetPanelMechSlow"); + requires(Robot.panelMech); + + } + + //Called just before this Command runs the first time + @Override + protected void initialize() { + + } + + + + //Called repeatedly when this Command is scheduled to run + @Override + protected void execute() { + Robot.panelMech.setPanelMech(Constants.PANEL_MECH_CREEP); + } + + //Make this return true when this Command no longer needs to run execute() + @Override + protected boolean isFinished() { + return true; + } + + //Called once after isFinished returns true + @Override + protected void end() { + + } + + //Called when another command which requires one or more of the same + //subsystems is scheduled to run + + @Override + protected void interrupted() { + + } +} \ No newline at end of file diff --git a/src/main/java/frc/robot/subsystems/Hopper.java b/src/main/java/frc/robot/subsystems/Hopper.java index e403aba..05c3c8b 100644 --- a/src/main/java/frc/robot/subsystems/Hopper.java +++ b/src/main/java/frc/robot/subsystems/Hopper.java @@ -19,7 +19,8 @@ import edu.wpi.first.wpilibj.smartdashboard.SmartDashboard; import frc.robot.RobotMap; import frc.robot.util.IrSensor; - +import edu.wpi.first.wpilibj.Counter; +import edu.wpi.first.wpilibj.DigitalInput;; /** * Add your docs here. */ @@ -29,8 +30,9 @@ public class Hopper extends Subsystem { public CANSparkMax hopper_vertical; public Solenoid hopper_stopper; public IrSensor entrySensor, upperSensor; + public DigitalInput limitSwitch = new DigitalInput(9); + public Counter counter= new Counter(limitSwitch); - public Hopper(){ hopper_horizontal = new CANSparkMax(RobotMap.HORIZONTAL_HOPPER, MotorType.kBrushless); hopper_vertical = new CANSparkMax(RobotMap.VERTICAL_HOPPER, MotorType.kBrushless); @@ -43,6 +45,8 @@ public Hopper(){ hopper_horizontal.setSmartCurrentLimit(20); hopper_vertical.setSmartCurrentLimit(20); + + counter.clearDownSource(); } public void setHopper(final double output, final double vOutput){ @@ -95,7 +99,9 @@ public boolean isBall(){ return false; } } - + public boolean isSwitchSet() { + return counter.get() > 0; + } public boolean isUpperSensorTripped() { return 745 <= upperSensor.getValue(); } @@ -116,6 +122,13 @@ public void loadingWithIR(){ } } + public boolean isHopperFull(){ + if (counter.get()==5){ + return true; + } + return false; + } + public void debug(){ //SmartDashboard.putNumber("Hopper Voltage - ", getHopperVoltage()); SmartDashboard.putNumber("Entry IR Value", entrySensor.getValue()); @@ -125,6 +138,8 @@ public void debug(){ SmartDashboard.putBoolean("Hopper Stopper Out", isRetracted()); SmartDashboard.putNumber("Upper IR Value", upperSensor.getValue()); SmartDashboard.putBoolean("Jammed", checkJammed()); + SmartDashboard.putNumber("Counter Value", counter.get()); + SmartDashboard.putBoolean("Limit Switch", limitSwitch.get()); } @Override protected void initDefaultCommand() { diff --git a/src/main/java/frc/robot/subsystems/Manipulator.java b/src/main/java/frc/robot/subsystems/Manipulator.java index b3b3002..b476af7 100644 --- a/src/main/java/frc/robot/subsystems/Manipulator.java +++ b/src/main/java/frc/robot/subsystems/Manipulator.java @@ -44,5 +44,6 @@ public boolean getRetracted() { public void debug() { SmartDashboard.putBoolean("Manipulator Extender Solenoid", extender.get()); + SmartDashboard.putNumber("Manipulator current", manipulator_neo.getOutputCurrent()); } } \ No newline at end of file From 078f197d9d04e314686d94a60e82e181301a524a Mon Sep 17 00:00:00 2001 From: frcteam2791 Date: Wed, 4 Mar 2020 14:55:20 -0500 Subject: [PATCH 48/68] Fixed hooper/intake --- .../java/frc/robot/commands/IntakeToHopper/IrHopper.java | 7 ++++--- .../frc/robot/commands/IntakeToHopper/MoveManipulator.java | 1 - 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/main/java/frc/robot/commands/IntakeToHopper/IrHopper.java b/src/main/java/frc/robot/commands/IntakeToHopper/IrHopper.java index ba8acd9..e0a1cc2 100644 --- a/src/main/java/frc/robot/commands/IntakeToHopper/IrHopper.java +++ b/src/main/java/frc/robot/commands/IntakeToHopper/IrHopper.java @@ -26,13 +26,14 @@ protected void initialize() { // Called repeatedly when this Command is scheduled to run @Override protected void execute() { - Robot.hopper.loadingWithIR(); + //Robot.hopper.loadingWithIR(); SmartDashboard.putBoolean("Ir Hopper Running", true); if(Robot.hopper.limitSwitch.get()){ timer.start(); - Robot.hopper.setHopper(Constants.HOPPER_LOADING_HORIZONTAL_OUTPUT, Constants.HOPPER_LOADING_VERTICAL_OUTPUT); + Robot.hopper.setHopper(Constants.HOPPER_LOADING_HORIZONTAL_OUTPUT, + Constants.HOPPER_LOADING_VERTICAL_OUTPUT); } - if (timer.get()>=Constants.kHopperTimer){ + else if (timer.get()>=Constants.kHopperTimer){ timer.stop(); Robot.hopper.setHopper(0,0); } diff --git a/src/main/java/frc/robot/commands/IntakeToHopper/MoveManipulator.java b/src/main/java/frc/robot/commands/IntakeToHopper/MoveManipulator.java index 1a742e4..653bf8c 100644 --- a/src/main/java/frc/robot/commands/IntakeToHopper/MoveManipulator.java +++ b/src/main/java/frc/robot/commands/IntakeToHopper/MoveManipulator.java @@ -8,7 +8,6 @@ public class MoveManipulator extends Command { public MoveManipulator() { super("MoveManipulator"); requires(Robot.manipulator); - requires(Robot.hopper); //Use requires() here to declare subsystem dependencies //eg. requires(chassis); } From b179a69fbe16014afb333f1cf502e3b5bedb125a Mon Sep 17 00:00:00 2001 From: frcteam2791 Date: Wed, 4 Mar 2020 18:05:02 -0500 Subject: [PATCH 49/68] laptop swap push --- .../Autons/ManipulatorToLimitHopper.java | 13 ++++ src/main/java/frc/robot/Constants.java | 8 +- src/main/java/frc/robot/OI.java | 8 +- src/main/java/frc/robot/Robot.java | 5 +- .../commands/IntakeToHopper/IrHopper.java | 25 +----- .../commands/IntakeToHopper/LimitSwitch.java | 76 +++++++++++++++++++ .../IntakeToHopper/MoveManipulator.java | 4 +- .../commands/PanelMech/SetPanelMechFast.java | 2 +- .../commands/PanelMech/SetPanelMechSlow.java | 2 +- 9 files changed, 109 insertions(+), 34 deletions(-) create mode 100644 src/main/java/frc/robot/Autons/ManipulatorToLimitHopper.java create mode 100644 src/main/java/frc/robot/commands/IntakeToHopper/LimitSwitch.java diff --git a/src/main/java/frc/robot/Autons/ManipulatorToLimitHopper.java b/src/main/java/frc/robot/Autons/ManipulatorToLimitHopper.java new file mode 100644 index 0000000..5c3b246 --- /dev/null +++ b/src/main/java/frc/robot/Autons/ManipulatorToLimitHopper.java @@ -0,0 +1,13 @@ +package frc.robot.Autons; + +import edu.wpi.first.wpilibj.command.CommandGroup; +import frc.robot.commands.IntakeToHopper.*; +import frc.robot.commands.Shooter.OpenHopperPiston; + +public class ManipulatorToLimitHopper extends CommandGroup{ + public ManipulatorToLimitHopper(){ + addSequential(new MoveManipulator()); + addSequential(new LimitSwitch()); + //addSequential(new OpenHopperPiston()); + } +} \ No newline at end of file diff --git a/src/main/java/frc/robot/Constants.java b/src/main/java/frc/robot/Constants.java index 21c731c..6f08641 100644 --- a/src/main/java/frc/robot/Constants.java +++ b/src/main/java/frc/robot/Constants.java @@ -68,7 +68,7 @@ public final class Constants { public static final double ELEVATOR_OUTPUT = -.05; - public static final double HOPPER_LOADING_HORIZONTAL_OUTPUT = .62; + public static final double HOPPER_LOADING_HORIZONTAL_OUTPUT = .5; public static final double HOPPER_WALL_HORIZONTAL_OUTPUT = 0.86; // 0.30; 0.70; @@ -77,7 +77,7 @@ public final class Constants { public static final double HOPPER_VERTICAL_OUTPUT = 1.0; // .35; 0.80;[\] - public static final double HOPPER_LOADING_VERTICAL_OUTPUT = .07; + public static final double HOPPER_LOADING_VERTICAL_OUTPUT = .15; public static final double REVERSE_HOPPER = -.40; @@ -97,7 +97,7 @@ public final class Constants { public static final double MANUAL_POWER = .2; - public static final double INTAKE_MOTORSPEED = 0.8; //Temp value please test it out and do stuff yes + public static final double INTAKE_MOTORSPEED = 0.37; //Temp value please test it out and do stuff yes public static final double SHOOTER_VELOCITY = 100; //Temporary value @@ -139,6 +139,6 @@ public final class Constants { public static final double HOPPER_LONG_HORIZONTAL_OUTPUT = 0.25; - public static final double kHopperTimer = 0.2; + public static final double kHopperTimer = 0.12; } \ No newline at end of file diff --git a/src/main/java/frc/robot/OI.java b/src/main/java/frc/robot/OI.java index b33e76b..49b58cb 100644 --- a/src/main/java/frc/robot/OI.java +++ b/src/main/java/frc/robot/OI.java @@ -6,6 +6,7 @@ import edu.wpi.first.wpilibj.buttons.Trigger; import edu.wpi.first.wpilibj.command.InstantCommand; import frc.robot.Autons.ManipulatorToIrHopper; +import frc.robot.Autons.ManipulatorToLimitHopper; import frc.robot.Autons.StopShooterGroup; import frc.robot.Autons.TrenchHoodAndFire; import frc.robot.Autons.WallHoodAndFire; @@ -77,6 +78,7 @@ public boolean get() { operatorB.whileHeld(new SetPanelMechSlow()); operatorA.whileHeld(new SetPanelMechFast()); + operatorY.whileHeld(new MoveHopperWall()); operatorY.whenReleased(new StopHopper()); @@ -118,7 +120,7 @@ public boolean get() { } }.whenActive(new StopShooter()); - driverA.whileHeld(new ManipulatorToIrHopper()); + driverA.whenPressed(new ManipulatorToLimitHopper()); driverA.whenPressed(new InstantCommand(() -> { Robot.Cam_switch.select(CameraSwitch.kcamera2);; })); @@ -128,8 +130,8 @@ public boolean get() { })); driverA.whenReleased(new StopManipulator()); driverA.whenReleased(new StopHopper()); - //driverA.whileHeld(new IrHopper()); - + driverA.whileHeld(new LimitSwitch()); + driverDPadRight.whileHeld(new DrivetrainAlignToGoal()); diff --git a/src/main/java/frc/robot/Robot.java b/src/main/java/frc/robot/Robot.java index 3571ccd..a415898 100644 --- a/src/main/java/frc/robot/Robot.java +++ b/src/main/java/frc/robot/Robot.java @@ -145,12 +145,13 @@ public void teleopInit() { Robot.shooter.setHood1(false); } + @Override public void teleopPeriodic() { Scheduler.getInstance().run(); - - + + // double kp = SmartDashboard.getNumber("Shooter kP", 0); // double kf = SmartDashboard.getNumber("Shooter kF", 0); // double kd = SmartDashboard.getNumber("Shooter kD", 0); diff --git a/src/main/java/frc/robot/commands/IntakeToHopper/IrHopper.java b/src/main/java/frc/robot/commands/IntakeToHopper/IrHopper.java index e0a1cc2..1e7b3a7 100644 --- a/src/main/java/frc/robot/commands/IntakeToHopper/IrHopper.java +++ b/src/main/java/frc/robot/commands/IntakeToHopper/IrHopper.java @@ -9,7 +9,6 @@ public class IrHopper extends Command { public int count; - public Timer timer= new Timer(); public IrHopper() { super("IrHopper"); requires(Robot.hopper); @@ -26,31 +25,16 @@ protected void initialize() { // Called repeatedly when this Command is scheduled to run @Override protected void execute() { - //Robot.hopper.loadingWithIR(); - SmartDashboard.putBoolean("Ir Hopper Running", true); - if(Robot.hopper.limitSwitch.get()){ - timer.start(); - Robot.hopper.setHopper(Constants.HOPPER_LOADING_HORIZONTAL_OUTPUT, - Constants.HOPPER_LOADING_VERTICAL_OUTPUT); - } - else if (timer.get()>=Constants.kHopperTimer){ - timer.stop(); - Robot.hopper.setHopper(0,0); - } - + Robot.hopper.loadingWithIR(); + } // Make this return true when this Command no longer needs to run execute() @Override protected boolean isFinished() { - // return !Robot.hopper.isBall() || Robot.hopper.isUpperSensorTripped(); - if (Robot.hopper.isHopperFull()==true){ - return true; - } - else{ - return false; - } + return !Robot.hopper.isBall() || Robot.hopper.isUpperSensorTripped(); + } @@ -60,7 +44,6 @@ protected void end() { count++; Robot.hopper.setHopper(0, 0); SmartDashboard.putBoolean("Ir Hopper Running", false); - Robot.hopper.counter.reset(); } // Called when another command which requires one or more of the same diff --git a/src/main/java/frc/robot/commands/IntakeToHopper/LimitSwitch.java b/src/main/java/frc/robot/commands/IntakeToHopper/LimitSwitch.java new file mode 100644 index 0000000..8a643de --- /dev/null +++ b/src/main/java/frc/robot/commands/IntakeToHopper/LimitSwitch.java @@ -0,0 +1,76 @@ +package frc.robot.commands.IntakeToHopper; + +import edu.wpi.first.wpilibj.command.Command; +import edu.wpi.first.wpilibj.smartdashboard.SmartDashboard; +import frc.robot.Constants; +import frc.robot.Robot; +import frc.robot.commands.IntakeToHopper.MoveManipulator; +import edu.wpi.first.wpilibj.Timer; + +public class LimitSwitch extends Command { + public int count; + private boolean timerStart = false; + public Timer timer= new Timer(); + public LimitSwitch() { + super("LimitSwitch"); + requires(Robot.hopper); + + } + + // Called just before this Command runs the first time + @Override + protected void initialize() { + // count = 0; + } + + // Called repeatedly when this Command is scheduled to run + @Override + protected void execute() { + + SmartDashboard.putBoolean("Ir Hopper Running", true); + if(!Robot.hopper.limitSwitch.get()){ + timer.start(); + Robot.hopper.setHopper(Constants.HOPPER_LOADING_HORIZONTAL_OUTPUT, + Constants.HOPPER_LOADING_VERTICAL_OUTPUT); + timerStart = true; + } + if(timerStart){ + if (timer.get()>=Constants.kHopperTimer){ + timer.stop(); + timer.reset(); + Robot.hopper.setHopper(0,0); + } + } + + } + + // Make this return true when this Command no longer needs to run execute() + @Override + + protected boolean isFinished() { + // if (Robot.hopper.isHopperFull()==true){ + // return true; + // } + // else{ + // return false; + // } + return false; + + } + + // Called once after isFinished returns true + @Override + protected void end() { + // count++; + Robot.hopper.setHopper(0, 0); + SmartDashboard.putBoolean("Ir Hopper Running", false); + // Robot.hopper.counter.reset(); + } + + // Called when another command which requires one or more of the same + // subsystems is scheduled to run + @Override + protected void interrupted() { + } + +} diff --git a/src/main/java/frc/robot/commands/IntakeToHopper/MoveManipulator.java b/src/main/java/frc/robot/commands/IntakeToHopper/MoveManipulator.java index 653bf8c..4b3c593 100644 --- a/src/main/java/frc/robot/commands/IntakeToHopper/MoveManipulator.java +++ b/src/main/java/frc/robot/commands/IntakeToHopper/MoveManipulator.java @@ -15,13 +15,13 @@ public MoveManipulator() { //Called just before this Command runs the first time @Override protected void initialize() { - + Robot.manipulator.setExtended(); } //Called repeatedly when this Command is scheduled to run @Override protected void execute() { - Robot.manipulator.setExtended(); + // Robot.manipulator.setExtended(); Robot.manipulator.setManipulator(Constants.INTAKE_MOTORSPEED); } diff --git a/src/main/java/frc/robot/commands/PanelMech/SetPanelMechFast.java b/src/main/java/frc/robot/commands/PanelMech/SetPanelMechFast.java index 85c8a9e..f991870 100644 --- a/src/main/java/frc/robot/commands/PanelMech/SetPanelMechFast.java +++ b/src/main/java/frc/robot/commands/PanelMech/SetPanelMechFast.java @@ -35,7 +35,7 @@ protected boolean isFinished() { //Called once after isFinished returns true @Override protected void end() { - + Robot.panelMech.setPanelMech(0); } //Called when another command which requires one or more of the same diff --git a/src/main/java/frc/robot/commands/PanelMech/SetPanelMechSlow.java b/src/main/java/frc/robot/commands/PanelMech/SetPanelMechSlow.java index c30c1cc..f5a3d7c 100644 --- a/src/main/java/frc/robot/commands/PanelMech/SetPanelMechSlow.java +++ b/src/main/java/frc/robot/commands/PanelMech/SetPanelMechSlow.java @@ -35,7 +35,7 @@ protected boolean isFinished() { //Called once after isFinished returns true @Override protected void end() { - + Robot.panelMech.setPanelMech(0); } //Called when another command which requires one or more of the same From 7ee5482447a515757bb6f8e7b56bfea1951d21cb Mon Sep 17 00:00:00 2001 From: frcteam2791 Date: Wed, 4 Mar 2020 17:03:00 -0800 Subject: [PATCH 50/68] Updated Constants Limit Switch constants tuned but reverted back to IR. Panel Mech updated but never tested. Tech park 3/4 --- src/main/java/frc/robot/Constants.java | 6 +-- src/main/java/frc/robot/OI.java | 24 ++++++---- src/main/java/frc/robot/Robot.java | 2 +- .../commands/IntakeToHopper/IrHopper.java | 4 +- .../commands/PanelMech/StopPanelMech.java | 48 +++++++++++++++++++ .../frc/robot/commands/RamseteCommand.java | 5 ++ 6 files changed, 73 insertions(+), 16 deletions(-) create mode 100644 src/main/java/frc/robot/commands/PanelMech/StopPanelMech.java create mode 100644 src/main/java/frc/robot/commands/RamseteCommand.java diff --git a/src/main/java/frc/robot/Constants.java b/src/main/java/frc/robot/Constants.java index 6f08641..179ee74 100644 --- a/src/main/java/frc/robot/Constants.java +++ b/src/main/java/frc/robot/Constants.java @@ -68,7 +68,7 @@ public final class Constants { public static final double ELEVATOR_OUTPUT = -.05; - public static final double HOPPER_LOADING_HORIZONTAL_OUTPUT = .5; + public static final double HOPPER_LOADING_HORIZONTAL_OUTPUT = .62; //.5 for limit public static final double HOPPER_WALL_HORIZONTAL_OUTPUT = 0.86; // 0.30; 0.70; @@ -77,7 +77,7 @@ public final class Constants { public static final double HOPPER_VERTICAL_OUTPUT = 1.0; // .35; 0.80;[\] - public static final double HOPPER_LOADING_VERTICAL_OUTPUT = .15; + public static final double HOPPER_LOADING_VERTICAL_OUTPUT = .07; //0.15 for limit public static final double REVERSE_HOPPER = -.40; @@ -97,7 +97,7 @@ public final class Constants { public static final double MANUAL_POWER = .2; - public static final double INTAKE_MOTORSPEED = 0.37; //Temp value please test it out and do stuff yes + public static final double INTAKE_MOTORSPEED = 0.28; // .135 old speed: Temp value please test it out and do stuff yes public static final double SHOOTER_VELOCITY = 100; //Temporary value diff --git a/src/main/java/frc/robot/OI.java b/src/main/java/frc/robot/OI.java index 49b58cb..b69fcf3 100644 --- a/src/main/java/frc/robot/OI.java +++ b/src/main/java/frc/robot/OI.java @@ -77,8 +77,14 @@ public boolean get() { })); operatorB.whileHeld(new SetPanelMechSlow()); + operatorB.whenPressed(new ExtendPanelMech()); + operatorB.whenReleased(new DefaultPanelMech()); + operatorB.whenReleased(new StopPanelMech()); + operatorA.whileHeld(new SetPanelMechFast()); - + operatorA.whenPressed(new ExtendPanelMech()); + operatorA.whenReleased(new StopPanelMech()); + operatorA.whenReleased(new DefaultPanelMech()); operatorY.whileHeld(new MoveHopperWall()); operatorY.whenReleased(new StopHopper()); @@ -87,15 +93,12 @@ public boolean get() { operatorX.whenReleased(new StopHopper()); operatorRB.whenPressed(new WallShot()); - operatorRB.whenPressed(new InstantCommand(() -> { - Robot.Cam_switch.select(CameraSwitch.kcamera1);; - })); + // // operatorRB.whenPressed(new InstantCommand(() -> { + // Robot.Cam_switch.select(CameraSwitch.kcamera1);; + // })); operatorLB.whenPressed(new LongShot()); - operatorLB.whenPressed(new InstantCommand(() -> { - Robot.Cam_switch.select(CameraSwitch.kcamera1);; - })); - + new Trigger(){ @Override public boolean get() { @@ -120,7 +123,9 @@ public boolean get() { } }.whenActive(new StopShooter()); - driverA.whenPressed(new ManipulatorToLimitHopper()); + // driverA.whenPressed(new ManipulatorToLimitHopper()); + driverA.whileHeld(new ManipulatorToIrHopper()); + driverA.whenPressed(new InstantCommand(() -> { Robot.Cam_switch.select(CameraSwitch.kcamera2);; })); @@ -130,7 +135,6 @@ public boolean get() { })); driverA.whenReleased(new StopManipulator()); driverA.whenReleased(new StopHopper()); - driverA.whileHeld(new LimitSwitch()); driverDPadRight.whileHeld(new DrivetrainAlignToGoal()); diff --git a/src/main/java/frc/robot/Robot.java b/src/main/java/frc/robot/Robot.java index a415898..d8643be 100644 --- a/src/main/java/frc/robot/Robot.java +++ b/src/main/java/frc/robot/Robot.java @@ -96,7 +96,7 @@ else if(pitDPadRight.get() == true) { else if(pitDPadDown.get() == true){ Cam_switch.select(CameraSwitch.kcamera3); } - else { + else if(pitDPadLeft.get()) { Cam_switch.select(CameraSwitch.kcamera4); } } diff --git a/src/main/java/frc/robot/commands/IntakeToHopper/IrHopper.java b/src/main/java/frc/robot/commands/IntakeToHopper/IrHopper.java index 1e7b3a7..eb05054 100644 --- a/src/main/java/frc/robot/commands/IntakeToHopper/IrHopper.java +++ b/src/main/java/frc/robot/commands/IntakeToHopper/IrHopper.java @@ -19,7 +19,7 @@ public IrHopper() { // Called just before this Command runs the first time @Override protected void initialize() { - count = 0; + // count = 0; } // Called repeatedly when this Command is scheduled to run @@ -41,7 +41,7 @@ protected boolean isFinished() { // Called once after isFinished returns true @Override protected void end() { - count++; + // count++; Robot.hopper.setHopper(0, 0); SmartDashboard.putBoolean("Ir Hopper Running", false); } diff --git a/src/main/java/frc/robot/commands/PanelMech/StopPanelMech.java b/src/main/java/frc/robot/commands/PanelMech/StopPanelMech.java new file mode 100644 index 0000000..6168b08 --- /dev/null +++ b/src/main/java/frc/robot/commands/PanelMech/StopPanelMech.java @@ -0,0 +1,48 @@ +package frc.robot.commands.PanelMech; + +import edu.wpi.first.wpilibj.command.Command; +import frc.robot.Constants; +import frc.robot.Robot; + +public class StopPanelMech extends Command { + double count = 1; + public StopPanelMech() { + super("StopPanelMech"); + requires(Robot.panelMech); + + } + + //Called just before this Command runs the first time + @Override + protected void initialize() { + + } + + + + //Called repeatedly when this Command is scheduled to run + @Override + protected void execute() { + Robot.panelMech.setPanelMech(0); + } + + //Make this return true when this Command no longer needs to run execute() + @Override + protected boolean isFinished() { + return true; + } + + //Called once after isFinished returns true + @Override + protected void end() { + Robot.panelMech.setPanelMech(0); + } + + //Called when another command which requires one or more of the same + //subsystems is scheduled to run + + @Override + protected void interrupted() { + + } +} \ No newline at end of file diff --git a/src/main/java/frc/robot/commands/RamseteCommand.java b/src/main/java/frc/robot/commands/RamseteCommand.java new file mode 100644 index 0000000..4ea4866 --- /dev/null +++ b/src/main/java/frc/robot/commands/RamseteCommand.java @@ -0,0 +1,5 @@ +package frc.robot.commands; + +public class RamseteCommand { + +} From 1eb82a271e8a0d6dda071b8523a7c1d8583c11f5 Mon Sep 17 00:00:00 2001 From: Chris Lane Date: Thu, 5 Mar 2020 11:58:39 -0500 Subject: [PATCH 51/68] cleaned up some small stuff --- src/main/java/frc/robot/OI.java | 9 +++++++-- .../commands/IntakeToHopper/IrHopper.java | 6 ++---- src/main/java/frc/robot/subsystems/Hopper.java | 6 ++++-- .../robot/util/Camera_Switch/CameraSwitch.java | 18 ++++++++++-------- 4 files changed, 23 insertions(+), 16 deletions(-) diff --git a/src/main/java/frc/robot/OI.java b/src/main/java/frc/robot/OI.java index b69fcf3..32410d5 100644 --- a/src/main/java/frc/robot/OI.java +++ b/src/main/java/frc/robot/OI.java @@ -44,10 +44,15 @@ public class OI { protected Button operatorLeftJoystickUsed, operatorRightJoystickUsed, operatorDPadDown, operatorDPadLeft, operatorDPadRight; private Button operatorA, operatorB, operatorX, operatorY; private Button pitA, pitB, pitX, pitY; + + public OI() { + + driverStick = new Joystick(0); operatorStick = new Joystick(1); pitStick = new Joystick(3); + initButtons(); initUsed(); @@ -74,7 +79,7 @@ public boolean get() { operatorA.whenPressed(new InstantCommand(() -> { Robot.hopper.hopper_stopper.set(true); - })); + })) ; operatorB.whileHeld(new SetPanelMechSlow()); operatorB.whenPressed(new ExtendPanelMech()); @@ -86,7 +91,7 @@ public boolean get() { operatorA.whenReleased(new StopPanelMech()); operatorA.whenReleased(new DefaultPanelMech()); - operatorY.whileHeld(new MoveHopperWall()); + operatorY.whileHeld(new MoveHopperWall());//moves hopper at constant speeds operatorY.whenReleased(new StopHopper()); operatorX.whileHeld(new IrHopper()); diff --git a/src/main/java/frc/robot/commands/IntakeToHopper/IrHopper.java b/src/main/java/frc/robot/commands/IntakeToHopper/IrHopper.java index eb05054..ad507bf 100644 --- a/src/main/java/frc/robot/commands/IntakeToHopper/IrHopper.java +++ b/src/main/java/frc/robot/commands/IntakeToHopper/IrHopper.java @@ -2,10 +2,8 @@ import edu.wpi.first.wpilibj.command.Command; import edu.wpi.first.wpilibj.smartdashboard.SmartDashboard; -import frc.robot.Constants; import frc.robot.Robot; -import frc.robot.commands.IntakeToHopper.MoveManipulator; -import edu.wpi.first.wpilibj.Timer; + public class IrHopper extends Command { public int count; @@ -13,7 +11,7 @@ public IrHopper() { super("IrHopper"); requires(Robot.hopper); // Use requires() here to declare subsystem dependencies - // eg. requires(chassis); + } // Called just before this Command runs the first time diff --git a/src/main/java/frc/robot/subsystems/Hopper.java b/src/main/java/frc/robot/subsystems/Hopper.java index 05c3c8b..fd0b924 100644 --- a/src/main/java/frc/robot/subsystems/Hopper.java +++ b/src/main/java/frc/robot/subsystems/Hopper.java @@ -7,7 +7,6 @@ package frc.robot.subsystems; -import com.ctre.phoenix.motorcontrol.ControlMode; import com.revrobotics.CANSparkMax; import com.revrobotics.CANSparkMax.IdleMode; @@ -108,6 +107,7 @@ public boolean isUpperSensorTripped() { public void loadingWithIR(){ if(Constants.BALL_VALUE < getIRSensor()){ + if (isUpperSensorTripped()) { setHopper( Constants.HOPPER_LOADING_HORIZONTAL_OUTPUT, @@ -117,7 +117,9 @@ public void loadingWithIR(){ Constants.HOPPER_LOADING_HORIZONTAL_OUTPUT, Constants.HOPPER_LOADING_VERTICAL_OUTPUT); } - } else{ + } + + else{ setHopper(0, 0); } } diff --git a/src/main/java/frc/robot/util/Camera_Switch/CameraSwitch.java b/src/main/java/frc/robot/util/Camera_Switch/CameraSwitch.java index e05d542..d3fff64 100644 --- a/src/main/java/frc/robot/util/Camera_Switch/CameraSwitch.java +++ b/src/main/java/frc/robot/util/Camera_Switch/CameraSwitch.java @@ -23,8 +23,8 @@ import edu.wpi.first.wpilibj.Relay; import edu.wpi.first.wpilibj.Relay.Value; import edu.wpi.first.wpilibj.smartdashboard.SmartDashboard; -import edu.wpi.first.wpilibj.DigitalOutput; -import edu.wpi.first.wpilibj.Victor; + + public class CameraSwitch implements RelayPortDevice{ @@ -37,7 +37,7 @@ public class CameraSwitch implements RelayPortDevice{ public static Relay camrelay1; public Relay camrelay2; - public DigitalOutput DO; + private int cameraState; @@ -53,25 +53,27 @@ public void select(int camSelected){ constants for cameras are- "kcamera(camera#)" (these can be changed in the switch statment) This switch has four possible ports. */ cameraState = camSelected; + switch (camSelected) { case kcamera1 : camrelay1.set(Value.kReverse); - camrelay2.set(Value.kOff); + camrelay2.set(Value.kOff); break; case kcamera2 : - camrelay1.set(Value.kForward); - camrelay2.set(Value.kOff); + camrelay1.set(Value.kForward); + camrelay2.set(Value.kOff); break; case kcamera3 : - camrelay2.set(Value.kReverse); + camrelay2.set(Value.kReverse); camrelay1.set(Value.kOff); case kcamera4 : camrelay2.set(Value.kForward); - camrelay1.set(Value.kOff); + camrelay1.set(Value.kOff); break; default: camrelay1.set(Value.kReverse); + camrelay2.set(Value.kOff); System.err.print("Camera not properly selected, setting to case 1,Camera1"); break; }//This switch statement is what actually writes to the relay port From 62fbea24ce2813d8b62645f6e18da82f29331780 Mon Sep 17 00:00:00 2001 From: frcteam2791 Date: Thu, 5 Mar 2020 16:16:26 -0800 Subject: [PATCH 52/68] Updated shooter and hopper speeds. --- src/main/java/frc/robot/Constants.java | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/main/java/frc/robot/Constants.java b/src/main/java/frc/robot/Constants.java index 179ee74..aca100d 100644 --- a/src/main/java/frc/robot/Constants.java +++ b/src/main/java/frc/robot/Constants.java @@ -68,16 +68,17 @@ public final class Constants { public static final double ELEVATOR_OUTPUT = -.05; - public static final double HOPPER_LOADING_HORIZONTAL_OUTPUT = .62; //.5 for limit + public static final double HOPPER_LOADING_HORIZONTAL_OUTPUT = .82; //.5 for limit - public static final double HOPPER_WALL_HORIZONTAL_OUTPUT = 0.86; // 0.30; 0.70; + public static final double HOPPER_WALL_HORIZONTAL_OUTPUT = 0.60; // 0.30; 0.70; + //FIX 0.86 public static final double HOPPER_VERTICAL_OUTPUT = 1.0; // .35; 0.80;[\] - public static final double HOPPER_LOADING_VERTICAL_OUTPUT = .07; //0.15 for limit + public static final double HOPPER_LOADING_VERTICAL_OUTPUT = .1; //0.15 for limit public static final double REVERSE_HOPPER = -.40; @@ -112,7 +113,7 @@ public final class Constants { public static final double TURN_FACTOR = 0.7; - public static final int BALL_VALUE = 2425; + public static final int BALL_VALUE = 2350; From 65e9b3ef4bbb9ce1da6061eb159a3489856e92be Mon Sep 17 00:00:00 2001 From: xprt656 Date: Thu, 5 Mar 2020 23:22:33 -0500 Subject: [PATCH 53/68] Drivetrain Pid Controller Added pid controller for drivetrain to drive straight back into trench TODO: Tune pid, tune distance to drive, add command group to intake ball, align, and shoot --- src/main/java/frc/robot/Constants.java | 8 ++- .../frc/robot/PID_Autos/FourBallTrench.java | 65 +++++++++++++++++++ .../robot/commands/DrivetrainAlignToGoal.java | 2 +- .../java/frc/robot/subsystems/Drivetrain.java | 15 ++++- 4 files changed, 85 insertions(+), 5 deletions(-) create mode 100644 src/main/java/frc/robot/PID_Autos/FourBallTrench.java diff --git a/src/main/java/frc/robot/Constants.java b/src/main/java/frc/robot/Constants.java index 179ee74..6c2dea4 100644 --- a/src/main/java/frc/robot/Constants.java +++ b/src/main/java/frc/robot/Constants.java @@ -23,6 +23,7 @@ public final class Constants { public static final double kCamStraightSuperFast = 0.75; public static final double kCamStraightMedium = 0.45; public static final double kCamStraightSlow = 0.25; + public static final double wheelDiameterInches = 5; public static final double ShooterTrenchkP = 0.002525; @@ -43,7 +44,7 @@ public final class Constants { public static final double jamCurrent = 20; public static final double fixSpaceTime = 0.2; - public static final double DrivekP = 0.025; + public static final double DrivekP = 0.000025; public static final double DrivekI = 0; public static final double DrivekD = 0; public static final double DriveIz = 0; @@ -52,7 +53,7 @@ public final class Constants { public static final double DriveMinOutput = -1; public static final double DrivemaxRPM = 4500; - public static final double LimelightkP = 0.35; + public static final double LimelightkP = 0.025; public static final double LimelightkI = 0.0; public static final double LimelightkD = 0.0; @@ -141,4 +142,7 @@ public final class Constants { public static final double kHopperTimer = 0.12; + + public static final double TrenchBallOneDist = 7; + } \ No newline at end of file diff --git a/src/main/java/frc/robot/PID_Autos/FourBallTrench.java b/src/main/java/frc/robot/PID_Autos/FourBallTrench.java new file mode 100644 index 0000000..f34f4c6 --- /dev/null +++ b/src/main/java/frc/robot/PID_Autos/FourBallTrench.java @@ -0,0 +1,65 @@ +/*----------------------------------------------------------------------------*/ +/* Copyright (c) 2018 FIRST. All Rights Reserved. */ +/* Open Source Software - may be modified and shared by FRC teams. The code */ +/* must be accompanied by the FIRST BSD license file in the root directory of */ +/* the project. */ +/*----------------------------------------------------------------------------*/ + +package frc.robot.PID_Autos; + +import edu.wpi.first.wpilibj.command.Command; +import edu.wpi.first.wpilibj.controller.PIDController; +import edu.wpi.first.wpilibj.smartdashboard.SmartDashboard; +import frc.robot.Constants; +import frc.robot.Robot; + + +public class FourBallTrench extends Command { + + PIDController pid; + double setpoint; + + public FourBallTrench() { + // Use requires() here to declare subsystem dependencies + // eg. requires(chassis); + requires(Robot.drivetrain); + pid = new PIDController(Constants.DrivekP, Constants.DrivekI, Constants.DrivekD); + } + + // Called just before this Command runs the first time + @Override + protected void initialize() { + setpoint = Constants.TrenchBallOneDist; + setpoint += Robot.drivetrain.getAverageDistance(); + pid.setSetpoint(setpoint); + pid.setTolerance(0.3); + } + + // Called repeatedly when this Command is scheduled to run + @Override + protected void execute() { + double output = pid.calculate(Robot.drivetrain.getAverageDistance()); + Robot.drivetrain.setMotors(output, output); + SmartDashboard.putBoolean("Drivetrain Distance Complete", false); + } + + // Make this return true when this Command no longer needs to run execute() + @Override + protected boolean isFinished() { + return pid.atSetpoint(); + } + + // Called once after isFinished returns true + @Override + protected void end() { + // Robot.limelight.setCamMode(CamMode.DRIVER_CAM); + SmartDashboard.putBoolean("Drivetrain Distance Complete", true); + Robot.drivetrain.setMotors(0, 0); + } + + // Called when another command which requires one or more of the same + // subsystems is scheduled to run + @Override + protected void interrupted() { + } +} diff --git a/src/main/java/frc/robot/commands/DrivetrainAlignToGoal.java b/src/main/java/frc/robot/commands/DrivetrainAlignToGoal.java index 471a48a..863103c 100644 --- a/src/main/java/frc/robot/commands/DrivetrainAlignToGoal.java +++ b/src/main/java/frc/robot/commands/DrivetrainAlignToGoal.java @@ -24,7 +24,7 @@ public DrivetrainAlignToGoal() { // eg. requires(chassis); requires(Robot.drivetrain); requires(Robot.limelight); - pid = new PIDController(Constants.DrivekP, Constants.DrivekI, Constants.DrivekD); + pid = new PIDController(Constants.LimelightkP, Constants.LimelightkI, Constants.LimelightkD); } // Called just before this Command runs the first time diff --git a/src/main/java/frc/robot/subsystems/Drivetrain.java b/src/main/java/frc/robot/subsystems/Drivetrain.java index 0ae00d5..e52ba47 100644 --- a/src/main/java/frc/robot/subsystems/Drivetrain.java +++ b/src/main/java/frc/robot/subsystems/Drivetrain.java @@ -12,8 +12,7 @@ import frc.robot.Constants; import frc.robot.RobotMap; - - +import frc.robot.util.Util; import frc.robot.util.Camera_Switch.*; public class Drivetrain extends Subsystem { @@ -103,6 +102,18 @@ public double getRightCPR(){ return m_leftAlternateEncoder.getCountsPerRevolution(); } + public double getAverageDistance(){ + return Util.average(getDistanceLeft(), getDistanceRight()); + } + + public double getDistanceLeft(){ + return Math.PI*Constants.wheelDiameterInches*getLeftCPR()/12; // returns distance in feet + } + + public double getDistanceRight(){ + return Math.PI*Constants.wheelDiameterInches*getLeftCPR()/12; // returns distance in feet + } + public void setBrakeMode(boolean isbrake) { IdleMode mode = isbrake ? IdleMode.kBrake : IdleMode.kCoast; leftLeader.setIdleMode(mode); From b47d6f5ec2a45826192a5fe9723a073d7d6c343b Mon Sep 17 00:00:00 2001 From: Chris Lane Date: Fri, 6 Mar 2020 12:18:16 -0500 Subject: [PATCH 54/68] Update CameraSwitch.java made camrelay2 static --- .../java/frc/robot/util/Camera_Switch/CameraSwitch.java | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/main/java/frc/robot/util/Camera_Switch/CameraSwitch.java b/src/main/java/frc/robot/util/Camera_Switch/CameraSwitch.java index d3fff64..affc97e 100644 --- a/src/main/java/frc/robot/util/Camera_Switch/CameraSwitch.java +++ b/src/main/java/frc/robot/util/Camera_Switch/CameraSwitch.java @@ -36,8 +36,8 @@ public class CameraSwitch implements RelayPortDevice{ public static Relay camrelay1; - public Relay camrelay2; - + public static Relay camrelay2; + private int cameraState; @@ -53,7 +53,6 @@ public void select(int camSelected){ constants for cameras are- "kcamera(camera#)" (these can be changed in the switch statment) This switch has four possible ports. */ cameraState = camSelected; - switch (camSelected) { case kcamera1 : camrelay1.set(Value.kReverse); @@ -62,7 +61,7 @@ public void select(int camSelected){ case kcamera2 : camrelay1.set(Value.kForward); camrelay2.set(Value.kOff); - + break; case kcamera3 : camrelay2.set(Value.kReverse); From 49f8822430e553eb876c45e5768daccc4f37912a Mon Sep 17 00:00:00 2001 From: frcteam2791 Date: Fri, 6 Mar 2020 16:13:06 -0800 Subject: [PATCH 55/68] Tech Park Update + Control Panel Control Panel working. Beam break sensors replaced IR and hopper/intake (new) retuned. Changed shooter/voltage compensation --- .../Autons/ManipulatorToLimitHopper.java | 2 +- .../frc/robot/Autons/TrenchHoodAndFire.java | 2 +- src/main/java/frc/robot/Constants.java | 13 +- src/main/java/frc/robot/OI.java | 20 +-- .../robot/commands/DrivetrainAlignToGoal.java | 4 +- .../commands/IntakeToHopper/BeamBreak.java | 76 +++++++++++ .../commands/IntakeToHopper/LimitSwitch.java | 129 +++++++++--------- .../commands/PanelMech/SetPanelMechFast.java | 4 +- .../commands/PanelMech/SetPanelMechSlow.java | 4 +- .../robot/commands/Shooter/WallShotHood.java | 9 +- .../java/frc/robot/subsystems/Hopper.java | 6 +- .../java/frc/robot/subsystems/Shooter.java | 2 +- 12 files changed, 179 insertions(+), 92 deletions(-) create mode 100644 src/main/java/frc/robot/commands/IntakeToHopper/BeamBreak.java diff --git a/src/main/java/frc/robot/Autons/ManipulatorToLimitHopper.java b/src/main/java/frc/robot/Autons/ManipulatorToLimitHopper.java index 5c3b246..dc11541 100644 --- a/src/main/java/frc/robot/Autons/ManipulatorToLimitHopper.java +++ b/src/main/java/frc/robot/Autons/ManipulatorToLimitHopper.java @@ -7,7 +7,7 @@ public class ManipulatorToLimitHopper extends CommandGroup{ public ManipulatorToLimitHopper(){ addSequential(new MoveManipulator()); - addSequential(new LimitSwitch()); + addSequential(new BeamBreak()); //addSequential(new OpenHopperPiston()); } } \ No newline at end of file diff --git a/src/main/java/frc/robot/Autons/TrenchHoodAndFire.java b/src/main/java/frc/robot/Autons/TrenchHoodAndFire.java index 2ca8cba..aaf39b8 100644 --- a/src/main/java/frc/robot/Autons/TrenchHoodAndFire.java +++ b/src/main/java/frc/robot/Autons/TrenchHoodAndFire.java @@ -9,7 +9,7 @@ public class TrenchHoodAndFire extends CommandGroup{ public TrenchHoodAndFire(){ - addSequential(new LongShotHood(), 0.2); + addSequential(new LongShotHood(), 0.21); addSequential(new OpenPistonsAndMoveHopper()); // addSequential(new OpenHopperPiston()); // addSequential(new MoveHopperLong()); diff --git a/src/main/java/frc/robot/Constants.java b/src/main/java/frc/robot/Constants.java index aca100d..a9a330c 100644 --- a/src/main/java/frc/robot/Constants.java +++ b/src/main/java/frc/robot/Constants.java @@ -68,17 +68,17 @@ public final class Constants { public static final double ELEVATOR_OUTPUT = -.05; - public static final double HOPPER_LOADING_HORIZONTAL_OUTPUT = .82; //.5 for limit + public static final double HOPPER_LOADING_HORIZONTAL_OUTPUT = 0.85;//.82; //.5 for limit - public static final double HOPPER_WALL_HORIZONTAL_OUTPUT = 0.60; // 0.30; 0.70; + public static final double HOPPER_WALL_HORIZONTAL_OUTPUT = 0.60; // 0.30; 0.70; //FIX 0.86 public static final double HOPPER_VERTICAL_OUTPUT = 1.0; // .35; 0.80;[\] - public static final double HOPPER_LOADING_VERTICAL_OUTPUT = .1; //0.15 for limit + public static final double HOPPER_LOADING_VERTICAL_OUTPUT = .15; //0.15 for limit public static final double REVERSE_HOPPER = -.40; @@ -98,7 +98,7 @@ public final class Constants { public static final double MANUAL_POWER = .2; - public static final double INTAKE_MOTORSPEED = 0.28; // .135 old speed: Temp value please test it out and do stuff yes + public static final double INTAKE_MOTORSPEED = 0.18; // .135 old speed: Temp value please test it out and do stuff yes public static final double SHOOTER_VELOCITY = 100; //Temporary value @@ -140,6 +140,9 @@ public final class Constants { public static final double HOPPER_LONG_HORIZONTAL_OUTPUT = 0.25; - public static final double kHopperTimer = 0.12; + public static final double kHopperTimer = 0.037;//0.12; + + + public static final double LimelightSetpoint = -1; } \ No newline at end of file diff --git a/src/main/java/frc/robot/OI.java b/src/main/java/frc/robot/OI.java index 32410d5..9529338 100644 --- a/src/main/java/frc/robot/OI.java +++ b/src/main/java/frc/robot/OI.java @@ -77,24 +77,28 @@ public boolean get() { } }.whenInactive(new StopHopper()); - operatorA.whenPressed(new InstantCommand(() -> { - Robot.hopper.hopper_stopper.set(true); - })) ; + // operatorA.whenPressed(new InstantCommand(() -> { //PLEASE CHANGE THIS BUTTON BC IT IS THE SAME AS PANEL MECH STUFF!!! + // Robot.hopper.hopper_stopper.set(true); + // })) ; operatorB.whileHeld(new SetPanelMechSlow()); - operatorB.whenPressed(new ExtendPanelMech()); + // operatorB.whenPressed(new ExtendPanelMech()); operatorB.whenReleased(new DefaultPanelMech()); operatorB.whenReleased(new StopPanelMech()); operatorA.whileHeld(new SetPanelMechFast()); - operatorA.whenPressed(new ExtendPanelMech()); + // operatorA.whenPressed(new ExtendPanelMech()); operatorA.whenReleased(new StopPanelMech()); operatorA.whenReleased(new DefaultPanelMech()); operatorY.whileHeld(new MoveHopperWall());//moves hopper at constant speeds operatorY.whenReleased(new StopHopper()); - operatorX.whileHeld(new IrHopper()); + operatorX.whileHeld(new BeamBreak()); + operatorX.whenPressed(new InstantCommand(() -> { + Robot.hopper.setRetracted();; + + })); operatorX.whenReleased(new StopHopper()); operatorRB.whenPressed(new WallShot()); @@ -128,8 +132,8 @@ public boolean get() { } }.whenActive(new StopShooter()); - // driverA.whenPressed(new ManipulatorToLimitHopper()); - driverA.whileHeld(new ManipulatorToIrHopper()); + driverA.whenPressed(new ManipulatorToLimitHopper()); + // driverA.whileHeld(new ManipulatorToLimitHopper()); driverA.whenPressed(new InstantCommand(() -> { Robot.Cam_switch.select(CameraSwitch.kcamera2);; diff --git a/src/main/java/frc/robot/commands/DrivetrainAlignToGoal.java b/src/main/java/frc/robot/commands/DrivetrainAlignToGoal.java index 471a48a..397ced7 100644 --- a/src/main/java/frc/robot/commands/DrivetrainAlignToGoal.java +++ b/src/main/java/frc/robot/commands/DrivetrainAlignToGoal.java @@ -32,8 +32,8 @@ public DrivetrainAlignToGoal() { protected void initialize() { Robot.limelight.setCamMode(CamMode.VISION_CAM); Robot.limelight.setLedMode(LedMode.PIPELINE); - pid.setSetpoint(0.0); - pid.setTolerance(0.3); + pid.setSetpoint(Constants.LimelightSetpoint); + pid.setTolerance(0.1); //0.3 old } // Called repeatedly when this Command is scheduled to run diff --git a/src/main/java/frc/robot/commands/IntakeToHopper/BeamBreak.java b/src/main/java/frc/robot/commands/IntakeToHopper/BeamBreak.java new file mode 100644 index 0000000..89955ef --- /dev/null +++ b/src/main/java/frc/robot/commands/IntakeToHopper/BeamBreak.java @@ -0,0 +1,76 @@ +package frc.robot.commands.IntakeToHopper; + +import edu.wpi.first.wpilibj.command.Command; +import edu.wpi.first.wpilibj.smartdashboard.SmartDashboard; +import frc.robot.Constants; +import frc.robot.Robot; +import frc.robot.commands.IntakeToHopper.MoveManipulator; +import edu.wpi.first.wpilibj.Timer; + +public class BeamBreak extends Command { + public int count; + private boolean timerStart = false; + public Timer timer= new Timer(); + public BeamBreak() { + super("BeamBreak"); + requires(Robot.hopper); + + } + + // Called just before this Command runs the first time + @Override + protected void initialize() { + // count = 0; + } + + // Called repeatedly when this Command is scheduled to run + @Override + protected void execute() { + + SmartDashboard.putBoolean("Beam Break Hopper Running", true); + if(!Robot.hopper.beamBreak.get()){ + timer.start(); + Robot.hopper.setHopper(Constants.HOPPER_LOADING_HORIZONTAL_OUTPUT, + Constants.HOPPER_LOADING_VERTICAL_OUTPUT); + timerStart = true; + } + if(timerStart){ + if (timer.get()>=Constants.kHopperTimer){ + timer.stop(); + timer.reset(); + Robot.hopper.setHopper(0,0); + } + } + + } + + // Make this return true when this Command no longer needs to run execute() + @Override + + protected boolean isFinished() { + // if (Robot.hopper.isHopperFull()==true){ + // return true; + // } + // else{ + // return false; + // } + return false; + + } + + // Called once after isFinished returns true + @Override + protected void end() { + // count++; + Robot.hopper.setHopper(0, 0); + SmartDashboard.putBoolean("Ir Hopper Running", false); + // Robot.hopper.counter.reset(); + } + + // Called when another command which requires one or more of the same + // subsystems is scheduled to run + @Override + protected void interrupted() { + } + +} diff --git a/src/main/java/frc/robot/commands/IntakeToHopper/LimitSwitch.java b/src/main/java/frc/robot/commands/IntakeToHopper/LimitSwitch.java index 8a643de..61ed8a1 100644 --- a/src/main/java/frc/robot/commands/IntakeToHopper/LimitSwitch.java +++ b/src/main/java/frc/robot/commands/IntakeToHopper/LimitSwitch.java @@ -1,76 +1,79 @@ -package frc.robot.commands.IntakeToHopper; +// limit switch swapped with Beam Break sensor -import edu.wpi.first.wpilibj.command.Command; -import edu.wpi.first.wpilibj.smartdashboard.SmartDashboard; -import frc.robot.Constants; -import frc.robot.Robot; -import frc.robot.commands.IntakeToHopper.MoveManipulator; -import edu.wpi.first.wpilibj.Timer; -public class LimitSwitch extends Command { - public int count; - private boolean timerStart = false; - public Timer timer= new Timer(); - public LimitSwitch() { - super("LimitSwitch"); - requires(Robot.hopper); +// package frc.robot.commands.IntakeToHopper; + +// import edu.wpi.first.wpilibj.command.Command; +// import edu.wpi.first.wpilibj.smartdashboard.SmartDashboard; +// import frc.robot.Constants; +// import frc.robot.Robot; +// import frc.robot.commands.IntakeToHopper.MoveManipulator; +// import edu.wpi.first.wpilibj.Timer; + +// public class LimitSwitch extends Command { +// public int count; +// private boolean timerStart = false; +// public Timer timer= new Timer(); +// public LimitSwitch() { +// super("LimitSwitch"); +// requires(Robot.hopper); - } +// } - // Called just before this Command runs the first time - @Override - protected void initialize() { - // count = 0; - } +// // Called just before this Command runs the first time +// @Override +// protected void initialize() { +// // count = 0; +// } - // Called repeatedly when this Command is scheduled to run - @Override - protected void execute() { +// // Called repeatedly when this Command is scheduled to run +// @Override +// protected void execute() { - SmartDashboard.putBoolean("Ir Hopper Running", true); - if(!Robot.hopper.limitSwitch.get()){ - timer.start(); - Robot.hopper.setHopper(Constants.HOPPER_LOADING_HORIZONTAL_OUTPUT, - Constants.HOPPER_LOADING_VERTICAL_OUTPUT); - timerStart = true; - } - if(timerStart){ - if (timer.get()>=Constants.kHopperTimer){ - timer.stop(); - timer.reset(); - Robot.hopper.setHopper(0,0); - } - } +// SmartDashboard.putBoolean("Limit Switch Hopper Running", true); +// if(!Robot.hopper.limitSwitch.get()){ +// timer.start(); +// Robot.hopper.setHopper(Constants.HOPPER_LOADING_HORIZONTAL_OUTPUT, +// Constants.HOPPER_LOADING_VERTICAL_OUTPUT); +// timerStart = true; +// } +// if(timerStart){ +// if (timer.get()>=Constants.kHopperTimer){ +// timer.stop(); +// timer.reset(); +// Robot.hopper.setHopper(0,0); +// } +// } - } +// } - // Make this return true when this Command no longer needs to run execute() - @Override +// // Make this return true when this Command no longer needs to run execute() +// @Override - protected boolean isFinished() { - // if (Robot.hopper.isHopperFull()==true){ - // return true; - // } - // else{ - // return false; - // } - return false; +// protected boolean isFinished() { +// // if (Robot.hopper.isHopperFull()==true){ +// // return true; +// // } +// // else{ +// // return false; +// // } +// return false; - } +// } - // Called once after isFinished returns true - @Override - protected void end() { - // count++; - Robot.hopper.setHopper(0, 0); - SmartDashboard.putBoolean("Ir Hopper Running", false); - // Robot.hopper.counter.reset(); - } +// // Called once after isFinished returns true +// @Override +// protected void end() { +// // count++; +// Robot.hopper.setHopper(0, 0); +// SmartDashboard.putBoolean("Ir Hopper Running", false); +// // Robot.hopper.counter.reset(); +// } - // Called when another command which requires one or more of the same - // subsystems is scheduled to run - @Override - protected void interrupted() { - } +// // Called when another command which requires one or more of the same +// // subsystems is scheduled to run +// @Override +// protected void interrupted() { +// } -} +// } diff --git a/src/main/java/frc/robot/commands/PanelMech/SetPanelMechFast.java b/src/main/java/frc/robot/commands/PanelMech/SetPanelMechFast.java index f991870..2191f1b 100644 --- a/src/main/java/frc/robot/commands/PanelMech/SetPanelMechFast.java +++ b/src/main/java/frc/robot/commands/PanelMech/SetPanelMechFast.java @@ -15,7 +15,7 @@ public SetPanelMechFast() { //Called just before this Command runs the first time @Override protected void initialize() { - + Robot.panelMech.extendPanelMech(); } @@ -35,7 +35,7 @@ protected boolean isFinished() { //Called once after isFinished returns true @Override protected void end() { - Robot.panelMech.setPanelMech(0); + // Robot.panelMech.setPanelMech(0); } //Called when another command which requires one or more of the same diff --git a/src/main/java/frc/robot/commands/PanelMech/SetPanelMechSlow.java b/src/main/java/frc/robot/commands/PanelMech/SetPanelMechSlow.java index f5a3d7c..3c42a58 100644 --- a/src/main/java/frc/robot/commands/PanelMech/SetPanelMechSlow.java +++ b/src/main/java/frc/robot/commands/PanelMech/SetPanelMechSlow.java @@ -15,7 +15,7 @@ public SetPanelMechSlow() { //Called just before this Command runs the first time @Override protected void initialize() { - + Robot.panelMech.extendPanelMech(); } @@ -35,7 +35,7 @@ protected boolean isFinished() { //Called once after isFinished returns true @Override protected void end() { - Robot.panelMech.setPanelMech(0); + // Robot.panelMech.setPanelMech(0); } //Called when another command which requires one or more of the same diff --git a/src/main/java/frc/robot/commands/Shooter/WallShotHood.java b/src/main/java/frc/robot/commands/Shooter/WallShotHood.java index 10120b3..7cfdd1e 100644 --- a/src/main/java/frc/robot/commands/Shooter/WallShotHood.java +++ b/src/main/java/frc/robot/commands/Shooter/WallShotHood.java @@ -35,10 +35,11 @@ protected void execute() { // Make this return true when this Command no longer needs to run execute() @Override protected boolean isFinished() { - if(Robot.shooter.getHood1()) { - return true; - } - return false; + // if(Robot.shooter.getHood1()) { + // return true; + // } + // return false; + return true; } // Called once after isFinished returns true diff --git a/src/main/java/frc/robot/subsystems/Hopper.java b/src/main/java/frc/robot/subsystems/Hopper.java index fd0b924..136b19c 100644 --- a/src/main/java/frc/robot/subsystems/Hopper.java +++ b/src/main/java/frc/robot/subsystems/Hopper.java @@ -29,8 +29,8 @@ public class Hopper extends Subsystem { public CANSparkMax hopper_vertical; public Solenoid hopper_stopper; public IrSensor entrySensor, upperSensor; - public DigitalInput limitSwitch = new DigitalInput(9); - public Counter counter= new Counter(limitSwitch); + public DigitalInput beamBreak = new DigitalInput(9);//Switched from Limit switch to bream break + public Counter counter= new Counter(beamBreak); public Hopper(){ hopper_horizontal = new CANSparkMax(RobotMap.HORIZONTAL_HOPPER, MotorType.kBrushless); @@ -141,7 +141,7 @@ public void debug(){ SmartDashboard.putNumber("Upper IR Value", upperSensor.getValue()); SmartDashboard.putBoolean("Jammed", checkJammed()); SmartDashboard.putNumber("Counter Value", counter.get()); - SmartDashboard.putBoolean("Limit Switch", limitSwitch.get()); + SmartDashboard.putBoolean("Beam Break", beamBreak.get()); //Switched from Limit switch to bream break } @Override protected void initDefaultCommand() { diff --git a/src/main/java/frc/robot/subsystems/Shooter.java b/src/main/java/frc/robot/subsystems/Shooter.java index 4654994..1a392bd 100644 --- a/src/main/java/frc/robot/subsystems/Shooter.java +++ b/src/main/java/frc/robot/subsystems/Shooter.java @@ -44,7 +44,7 @@ public Shooter(){ shooter_leader.getPIDController().setD(Constants.ShooterTrenchkD); shooter_leader.getPIDController().setOutputRange(-1, 1); - shooter_leader.enableVoltageCompensation(12.4); + shooter_leader.enableVoltageCompensation(11.9); } public double idealVelocity(double angle, double dist, double height){ double gravityInches = Constants.kGravity*12; From 479439af887d4cf7d3271299d43a32b329bb00be Mon Sep 17 00:00:00 2001 From: frcteam2791 Date: Sat, 7 Mar 2020 09:03:03 -0500 Subject: [PATCH 56/68] Added Reverse Intake and Hopper Reverse intake command added. Reverse Hopper until it reaches the mouth of the hopper added. --- src/main/java/frc/robot/OI.java | 2 +- .../IntakeToHopper/ReverseHopper.java | 7 --- .../IntakeToHopper/ReverseIntake.java | 48 +++++++++++++++++++ .../IntakeToHopper/ReverseUntilBeamBreak.java | 46 ++++++++++++++++++ 4 files changed, 95 insertions(+), 8 deletions(-) create mode 100644 src/main/java/frc/robot/commands/IntakeToHopper/ReverseIntake.java create mode 100644 src/main/java/frc/robot/commands/IntakeToHopper/ReverseUntilBeamBreak.java diff --git a/src/main/java/frc/robot/OI.java b/src/main/java/frc/robot/OI.java index 32410d5..f014f0a 100644 --- a/src/main/java/frc/robot/OI.java +++ b/src/main/java/frc/robot/OI.java @@ -67,7 +67,7 @@ public boolean get() { // TODO Auto-generated method stub return operatorStick.getRawAxis(1) > 0.8; } - }.whenActive(new ReverseHopper()); + }.whenActive(new ReverseHopper()); //or try ReverseUntilBeamBreak new Trigger(){ @Override diff --git a/src/main/java/frc/robot/commands/IntakeToHopper/ReverseHopper.java b/src/main/java/frc/robot/commands/IntakeToHopper/ReverseHopper.java index 363c064..0f0450c 100644 --- a/src/main/java/frc/robot/commands/IntakeToHopper/ReverseHopper.java +++ b/src/main/java/frc/robot/commands/IntakeToHopper/ReverseHopper.java @@ -1,10 +1,3 @@ -/*----------------------------------------------------------------------------*/ -/* Copyright (c) 2018 FIRST. All Rights Reserved. */ -/* Open Source Software - may be modified and shared by FRC teams. The code */ -/* must be accompanied by the FIRST BSD license file in the root directory of */ -/* the project. */ -/*----------------------------------------------------------------------------*/ - package frc.robot.commands.IntakeToHopper; import edu.wpi.first.wpilibj.command.Command; diff --git a/src/main/java/frc/robot/commands/IntakeToHopper/ReverseIntake.java b/src/main/java/frc/robot/commands/IntakeToHopper/ReverseIntake.java new file mode 100644 index 0000000..ef15770 --- /dev/null +++ b/src/main/java/frc/robot/commands/IntakeToHopper/ReverseIntake.java @@ -0,0 +1,48 @@ +package frc.robot.commands.IntakeToHopper; + +import edu.wpi.first.wpilibj.command.Command; +import frc.robot.Constants; +import frc.robot.Robot; + +public class ReverseIntake extends Command { + public ReverseIntake() { + super("ReverseIntake"); + requires(Robot.manipulator); + //Use requires() here to declare subsystem dependencies + //eg. requires(chassis); + } + + //Called just before this Command runs the first time + @Override + protected void initialize() { + //Robot.manipulator.setExtended(); + } + + //Called repeatedly when this Command is scheduled to run + @Override + protected void execute() { + // Robot.manipulator.setExtended(); + Robot.manipulator.setManipulator(-Constants.INTAKE_MOTORSPEED); + + } + + //Make this return true when this Command no longer needs to run execute() + @Override + protected boolean isFinished() { + return true; + } + + //Called once after isFinished returns true + @Override + protected void end() { + // Robot.manipulator.setManipulator(0); + } + + //Called when another command which requires one or more of the same + //subsystems is scheduled to run + + @Override + protected void interrupted() { + //Yes + } +} diff --git a/src/main/java/frc/robot/commands/IntakeToHopper/ReverseUntilBeamBreak.java b/src/main/java/frc/robot/commands/IntakeToHopper/ReverseUntilBeamBreak.java new file mode 100644 index 0000000..d25dea5 --- /dev/null +++ b/src/main/java/frc/robot/commands/IntakeToHopper/ReverseUntilBeamBreak.java @@ -0,0 +1,46 @@ +package frc.robot.commands.IntakeToHopper; + +import edu.wpi.first.wpilibj.command.Command; +import frc.robot.Constants; +import frc.robot.Robot; + +public class ReverseUntilBeamBreak extends Command { + public ReverseUntilBeamBreak() { + super("ReverseUntilBeamBreak"); + requires(Robot.hopper); + // Use requires() here to declare subsystem dependencies + // eg. requires(chassis); + } + + // Called just before this Command runs the first time + @Override + protected void initialize() { + } + + // Called repeatedly when this Command is scheduled to run + @Override + protected void execute() { + if(!Robot.hopper.limitSwitch.get()){ + Robot.hopper.setHopper(0, 0); + } + else{ + Robot.hopper.setHopper(Constants.REVERSE_HOPPER, Constants.REVERSE_HOPPER); + } + } + + // Make this return true when this Command no longer needs to run execute() + @Override + protected boolean isFinished() { + return true; + } + + // Called once after isFinished returns true + @Override + protected void end() { + // Robot.hopper.setHopper(0, 0); + } + + @Override + protected void interrupted() { + } +} \ No newline at end of file From 8bd9bbf2feed0f4e349ef7b947e6e7730dc0d29a Mon Sep 17 00:00:00 2001 From: frcteam2791 Date: Sun, 8 Mar 2020 10:10:36 -0400 Subject: [PATCH 57/68] Allisons changes --- .../AutonomousMode/AUTOGetBallAndShoot.java | 19 ++++++ .../robot/AutonomousMode/tempTwoCycle.java | 21 ++++++ src/main/java/frc/robot/Constants.java | 6 ++ .../AutoCommands}/FourBallTrench.java | 9 +-- .../commands/AutoCommands/ReturnPosition.java | 67 +++++++++++++++++++ .../commands/AutoCommands/SaveOffset.java | 25 +++++++ .../ReverseHopperAtVoltage.java | 56 ++++++++++++++++ .../IntakeToHopper/ReverseUntilBeamBreak.java | 5 +- 8 files changed, 197 insertions(+), 11 deletions(-) create mode 100644 src/main/java/frc/robot/AutonomousMode/AUTOGetBallAndShoot.java create mode 100644 src/main/java/frc/robot/AutonomousMode/tempTwoCycle.java rename src/main/java/frc/robot/{PID_Autos => commands/AutoCommands}/FourBallTrench.java (76%) create mode 100644 src/main/java/frc/robot/commands/AutoCommands/ReturnPosition.java create mode 100644 src/main/java/frc/robot/commands/AutoCommands/SaveOffset.java create mode 100644 src/main/java/frc/robot/commands/IntakeToHopper/ReverseHopperAtVoltage.java diff --git a/src/main/java/frc/robot/AutonomousMode/AUTOGetBallAndShoot.java b/src/main/java/frc/robot/AutonomousMode/AUTOGetBallAndShoot.java new file mode 100644 index 0000000..06c65e5 --- /dev/null +++ b/src/main/java/frc/robot/AutonomousMode/AUTOGetBallAndShoot.java @@ -0,0 +1,19 @@ +package frc.robot.AutonomousMode; + +import edu.wpi.first.wpilibj.command.CommandGroup; +import frc.robot.Autons.TrenchHoodAndFire; +import frc.robot.commands.AutoCommands.*; +import frc.robot.commands.DrivetrainAlignToGoal; +import frc.robot.commands.IntakeToHopper.*; + +public class AUTOGetBallAndShoot extends CommandGroup{ + public AUTOGetBallAndShoot(){ + addSequential(new MoveManipulator()); + addParallel(new FourBallTrench(), 5.0); + addParallel(new BeamBreak()); + addSequential(new StopManipulator()); + addSequential(new StopHopper()); + addSequential(new DrivetrainAlignToGoal()); + addSequential(new TrenchHoodAndFire()); + } +} \ No newline at end of file diff --git a/src/main/java/frc/robot/AutonomousMode/tempTwoCycle.java b/src/main/java/frc/robot/AutonomousMode/tempTwoCycle.java new file mode 100644 index 0000000..f43e618 --- /dev/null +++ b/src/main/java/frc/robot/AutonomousMode/tempTwoCycle.java @@ -0,0 +1,21 @@ +package frc.robot.AutonomousMode; + +import edu.wpi.first.wpilibj.command.CommandGroup; +import frc.robot.Autons.TrenchHoodAndFire; +import frc.robot.commands.AutoCommands.*; +import frc.robot.commands.DrivetrainAlignToGoal; +import frc.robot.commands.IntakeToHopper.*; + +public class tempTwoCycle extends CommandGroup{ + public tempTwoCycle(){ + addSequential(new MoveManipulator()); + addParallel(new FourBallTrench(), 5.0); + addParallel(new BeamBreak()); + addSequential(new StopManipulator()); + addSequential(new StopHopper()); + addSequential(new SaveOffset()); + addSequential(new DrivetrainAlignToGoal()); + addSequential(new TrenchHoodAndFire()); + addSequential(new ReturnPosition()); + } +} \ No newline at end of file diff --git a/src/main/java/frc/robot/Constants.java b/src/main/java/frc/robot/Constants.java index 4522b86..5f93ce4 100644 --- a/src/main/java/frc/robot/Constants.java +++ b/src/main/java/frc/robot/Constants.java @@ -149,4 +149,10 @@ public final class Constants { public static final double TrenchBallOneDist = 7; + + public static double reverseTime = 1.0; + + + public static double tempOffset; + } \ No newline at end of file diff --git a/src/main/java/frc/robot/PID_Autos/FourBallTrench.java b/src/main/java/frc/robot/commands/AutoCommands/FourBallTrench.java similarity index 76% rename from src/main/java/frc/robot/PID_Autos/FourBallTrench.java rename to src/main/java/frc/robot/commands/AutoCommands/FourBallTrench.java index f34f4c6..122fcb8 100644 --- a/src/main/java/frc/robot/PID_Autos/FourBallTrench.java +++ b/src/main/java/frc/robot/commands/AutoCommands/FourBallTrench.java @@ -1,11 +1,4 @@ -/*----------------------------------------------------------------------------*/ -/* Copyright (c) 2018 FIRST. All Rights Reserved. */ -/* Open Source Software - may be modified and shared by FRC teams. The code */ -/* must be accompanied by the FIRST BSD license file in the root directory of */ -/* the project. */ -/*----------------------------------------------------------------------------*/ - -package frc.robot.PID_Autos; +package frc.robot.commands.AutoCommands; import edu.wpi.first.wpilibj.command.Command; import edu.wpi.first.wpilibj.controller.PIDController; diff --git a/src/main/java/frc/robot/commands/AutoCommands/ReturnPosition.java b/src/main/java/frc/robot/commands/AutoCommands/ReturnPosition.java new file mode 100644 index 0000000..d281d4e --- /dev/null +++ b/src/main/java/frc/robot/commands/AutoCommands/ReturnPosition.java @@ -0,0 +1,67 @@ +/*----------------------------------------------------------------------------*/ +/* Copyright (c) 2018 FIRST. All Rights Reserved. */ +/* Open Source Software - may be modified and shared by FRC teams. The code */ +/* must be accompanied by the FIRST BSD license file in the root directory of */ +/* the project. */ +/*----------------------------------------------------------------------------*/ + +package frc.robot.commands.AutoCommands; + +import edu.wpi.first.wpilibj.command.Command; +import edu.wpi.first.wpilibj.controller.PIDController; +import edu.wpi.first.wpilibj.smartdashboard.SmartDashboard; +import frc.robot.Constants; +import frc.robot.Robot; +import frc.robot.subsystems.Limelight.CamMode; +import frc.robot.subsystems.Limelight.LedMode; + +import frc.robot.commands.AutoCommands.SaveOffset; + +public class ReturnPosition extends Command { + + PIDController pid; + + public ReturnPosition() { + // Use requires() here to declare subsystem dependencies + // eg. requires(chassis); + requires(Robot.drivetrain); + requires(Robot.limelight); + pid = new PIDController(Constants.LimelightkP, Constants.LimelightkI, Constants.LimelightkD); + } + + // Called just before this Command runs the first time + @Override + protected void initialize() { + Robot.limelight.setCamMode(CamMode.VISION_CAM); + Robot.limelight.setLedMode(LedMode.PIPELINE); + pid.setSetpoint(Constants.tempOffset); + pid.setTolerance(0.1); //0.3 old + } + + // Called repeatedly when this Command is scheduled to run + @Override + protected void execute() { + double output = pid.calculate(Robot.limelight.getHorizontalOffset()); + Robot.drivetrain.setMotors(-output, output); + SmartDashboard.putBoolean("Drivetrain Align Complete", false); + } + + @Override + protected boolean isFinished() { + return pid.atSetpoint(); + } + + // Called once after isFinished returns true + @Override + protected void end() { + // Robot.limelight.setCamMode(CamMode.DRIVER_CAM); + SmartDashboard.putBoolean("Drivetrain Align Complete", true); + Robot.drivetrain.setMotors(0, 0); + } + + // Called when another command which requires one or more of the same + // subsystems is scheduled to run + @Override + protected void interrupted() { + } +} diff --git a/src/main/java/frc/robot/commands/AutoCommands/SaveOffset.java b/src/main/java/frc/robot/commands/AutoCommands/SaveOffset.java new file mode 100644 index 0000000..c1220e1 --- /dev/null +++ b/src/main/java/frc/robot/commands/AutoCommands/SaveOffset.java @@ -0,0 +1,25 @@ +package frc.robot.commands.AutoCommands; + +import edu.wpi.first.wpilibj.command.Command; +import frc.robot.Constants; +import frc.robot.Robot; + +public class SaveOffset extends Command { + //public double tempOffset; + + public SaveOffset() { + super("SaveOffset"); + requires(Robot.limelight); + } + + public void execute() { + Constants.tempOffset = Robot.limelight.getHorizontalOffset(); + } + + public void end() { + } + + public boolean isFinished() { + return true; + } +} \ No newline at end of file diff --git a/src/main/java/frc/robot/commands/IntakeToHopper/ReverseHopperAtVoltage.java b/src/main/java/frc/robot/commands/IntakeToHopper/ReverseHopperAtVoltage.java new file mode 100644 index 0000000..7b0408b --- /dev/null +++ b/src/main/java/frc/robot/commands/IntakeToHopper/ReverseHopperAtVoltage.java @@ -0,0 +1,56 @@ +package frc.robot.commands.IntakeToHopper; + +import edu.wpi.first.wpilibj.DriverStation; +import edu.wpi.first.wpilibj.Timer; +import edu.wpi.first.wpilibj.command.Command; +import frc.robot.Constants; +import frc.robot.Robot; + +public class ReverseHopperAtVoltage extends Command { + Timer reverseTime; + private boolean reverse = false; + public ReverseHopperAtVoltage() { + super("ReverseHopperAtVoltage"); + requires(Robot.hopper); + reverseTime = new Timer(); + } + + // Called just before this Command runs the first time + @Override + protected void initialize() { + + } + + // Called repeatedly when this Command is scheduled to run + @Override + protected void execute() { + if(Robot.hopper.getHorizontalCurrent() > Constants.jamCurrent){ + reverseTime.start(); + reverse = true; + } + if(reverse && reverseTime.get() < Constants.reverseTime){ + Robot.hopper.setHopper(Constants.REVERSE_HOPPER, Constants.REVERSE_HOPPER); + } + else{ + Robot.hopper.setHopper(0, 0); + reverseTime.stop(); + reverseTime.reset(); + } + } + + // Make this return true when this Command no longer needs to run execute() + @Override + protected boolean isFinished() { + return !reverse; + } + + // Called once after isFinished returns true + @Override + protected void end() { + // Robot.hopper.setHopper(0, 0); + } + + @Override + protected void interrupted() { + } +} \ No newline at end of file diff --git a/src/main/java/frc/robot/commands/IntakeToHopper/ReverseUntilBeamBreak.java b/src/main/java/frc/robot/commands/IntakeToHopper/ReverseUntilBeamBreak.java index d25dea5..00b7a67 100644 --- a/src/main/java/frc/robot/commands/IntakeToHopper/ReverseUntilBeamBreak.java +++ b/src/main/java/frc/robot/commands/IntakeToHopper/ReverseUntilBeamBreak.java @@ -8,8 +8,7 @@ public class ReverseUntilBeamBreak extends Command { public ReverseUntilBeamBreak() { super("ReverseUntilBeamBreak"); requires(Robot.hopper); - // Use requires() here to declare subsystem dependencies - // eg. requires(chassis); + } // Called just before this Command runs the first time @@ -20,7 +19,7 @@ protected void initialize() { // Called repeatedly when this Command is scheduled to run @Override protected void execute() { - if(!Robot.hopper.limitSwitch.get()){ + if(!Robot.hopper.beamBreak.get()){ Robot.hopper.setHopper(0, 0); } else{ From c11244dd47fc5a6984a3c508722104521e0cfc95 Mon Sep 17 00:00:00 2001 From: frcteam2791 Date: Sun, 8 Mar 2020 07:46:26 -0700 Subject: [PATCH 58/68] Limelight and SmartDashboard Layouts Moved all pipelines off local --- .../GoodTPMORNINGMARCH7 (1).vpr | 58 ++++++++ .../GoodTPMORNINGMARCH7 (2).vpr | 58 ++++++++ .../GoodTPMORNINGMARCH7 (3).vpr | 58 ++++++++ Limelight Pipelines/GoodTPMORNINGMARCH7.vpr | 58 ++++++++ Limelight Pipelines/Pipeline_Name (1).vpr | 58 ++++++++ Limelight Pipelines/Pipeline_Name (10).vpr | 58 ++++++++ Limelight Pipelines/Pipeline_Name (11).vpr | 58 ++++++++ Limelight Pipelines/Pipeline_Name (12).vpr | 58 ++++++++ Limelight Pipelines/Pipeline_Name (13).vpr | 58 ++++++++ Limelight Pipelines/Pipeline_Name (14).vpr | 58 ++++++++ Limelight Pipelines/Pipeline_Name (15).vpr | 58 ++++++++ Limelight Pipelines/Pipeline_Name (2).vpr | 58 ++++++++ Limelight Pipelines/Pipeline_Name (3).vpr | 58 ++++++++ Limelight Pipelines/Pipeline_Name (4).vpr | 58 ++++++++ Limelight Pipelines/Pipeline_Name (5).vpr | 58 ++++++++ Limelight Pipelines/Pipeline_Name (6).vpr | 58 ++++++++ Limelight Pipelines/Pipeline_Name (7).vpr | 58 ++++++++ ...Pipeline_Name (8) - Copy - Copy - Copy.vpr | 58 ++++++++ .../Pipeline_Name (8) - Copy - Copy.vpr | 56 ++++++++ .../Pipeline_Name (8) - Copy.vpr | 58 ++++++++ Limelight Pipelines/Pipeline_Name (8).vpr | 58 ++++++++ Limelight Pipelines/Pipeline_Name (9).vpr | 58 ++++++++ Limelight Pipelines/Pipeline_Name.vpr | 58 ++++++++ SmartDashboard Layout/save.xml | 124 ++++++++++++++++++ 24 files changed, 1456 insertions(+) create mode 100644 Limelight Pipelines/GoodTPMORNINGMARCH7 (1).vpr create mode 100644 Limelight Pipelines/GoodTPMORNINGMARCH7 (2).vpr create mode 100644 Limelight Pipelines/GoodTPMORNINGMARCH7 (3).vpr create mode 100644 Limelight Pipelines/GoodTPMORNINGMARCH7.vpr create mode 100644 Limelight Pipelines/Pipeline_Name (1).vpr create mode 100644 Limelight Pipelines/Pipeline_Name (10).vpr create mode 100644 Limelight Pipelines/Pipeline_Name (11).vpr create mode 100644 Limelight Pipelines/Pipeline_Name (12).vpr create mode 100644 Limelight Pipelines/Pipeline_Name (13).vpr create mode 100644 Limelight Pipelines/Pipeline_Name (14).vpr create mode 100644 Limelight Pipelines/Pipeline_Name (15).vpr create mode 100644 Limelight Pipelines/Pipeline_Name (2).vpr create mode 100644 Limelight Pipelines/Pipeline_Name (3).vpr create mode 100644 Limelight Pipelines/Pipeline_Name (4).vpr create mode 100644 Limelight Pipelines/Pipeline_Name (5).vpr create mode 100644 Limelight Pipelines/Pipeline_Name (6).vpr create mode 100644 Limelight Pipelines/Pipeline_Name (7).vpr create mode 100644 Limelight Pipelines/Pipeline_Name (8) - Copy - Copy - Copy.vpr create mode 100644 Limelight Pipelines/Pipeline_Name (8) - Copy - Copy.vpr create mode 100644 Limelight Pipelines/Pipeline_Name (8) - Copy.vpr create mode 100644 Limelight Pipelines/Pipeline_Name (8).vpr create mode 100644 Limelight Pipelines/Pipeline_Name (9).vpr create mode 100644 Limelight Pipelines/Pipeline_Name.vpr create mode 100644 SmartDashboard Layout/save.xml diff --git a/Limelight Pipelines/GoodTPMORNINGMARCH7 (1).vpr b/Limelight Pipelines/GoodTPMORNINGMARCH7 (1).vpr new file mode 100644 index 0000000..66df1e5 --- /dev/null +++ b/Limelight Pipelines/GoodTPMORNINGMARCH7 (1).vpr @@ -0,0 +1,58 @@ +area_max:0.5393580481000001 +area_min:0.2097273616 +area_similarity:66 +aspect_max:20 +aspect_min:0.0000010124999999999998 +black_level:1 +blue_balance:1536 +calibration_type:0 +contour_grouping:0 +contour_sort_final:6 +convexity_max:64.5 +convexity_min:23.1 +corner_approx:2 +cross_a_a:1 +cross_a_x:0 +cross_a_y:0 +cross_b_a:1 +cross_b_x:0 +cross_b_y:0 +desc:GoodTPMORNINGMARCH7 +desired_contour_region:0 +dilation_steps:1 +direction_filter:0 +dual_close_sort_origin:0 +erosion_steps:0 +exposure:10 +force_convex:1 +hue_max:144 +hue_min:58 +image_flip:0 +image_source:0 +img_to_show:0 +intersection_filter:0 +pipeline_led_enabled:1 +pipeline_led_power:100 +pipeline_res:0 +pipeline_type:0 +red_balance:500 +roi_x:0 +roi_y:0 +sat_max:255 +sat_min:100 +send_corners:0 +send_raw_contours:0 +solve3d:0 +solve3d_algo:0 +solve3d_bindtarget:1 +solve3d_conf:0.990000 +solve3d_error:8 +solve3d_guess:0 +solve3d_iterations:50 +solve3d_precies:1 +solve3d_precise:0 +solve3d_zoffset:0 +val_max:254 +val_min:132 +y_max:1.000000 +y_min:-1.000000 diff --git a/Limelight Pipelines/GoodTPMORNINGMARCH7 (2).vpr b/Limelight Pipelines/GoodTPMORNINGMARCH7 (2).vpr new file mode 100644 index 0000000..fd27c61 --- /dev/null +++ b/Limelight Pipelines/GoodTPMORNINGMARCH7 (2).vpr @@ -0,0 +1,58 @@ +area_max:0.5393580481000001 +area_min:0.2097273616 +area_similarity:66 +aspect_max:20 +aspect_min:0.0000010124999999999998 +black_level:1 +blue_balance:1536 +calibration_type:0 +contour_grouping:0 +contour_sort_final:6 +convexity_max:64.5 +convexity_min:23.1 +corner_approx:2 +cross_a_a:1 +cross_a_x:0 +cross_a_y:0 +cross_b_a:1 +cross_b_x:0 +cross_b_y:0 +desc:GoodTPMORNINGMARCH7 +desired_contour_region:0 +dilation_steps:1 +direction_filter:0 +dual_close_sort_origin:0 +erosion_steps:0 +exposure:8 +force_convex:1 +hue_max:144 +hue_min:58 +image_flip:0 +image_source:0 +img_to_show:0 +intersection_filter:0 +pipeline_led_enabled:1 +pipeline_led_power:100 +pipeline_res:0 +pipeline_type:0 +red_balance:500 +roi_x:0 +roi_y:0 +sat_max:255 +sat_min:100 +send_corners:0 +send_raw_contours:0 +solve3d:0 +solve3d_algo:0 +solve3d_bindtarget:1 +solve3d_conf:0.990000 +solve3d_error:8 +solve3d_guess:0 +solve3d_iterations:50 +solve3d_precies:1 +solve3d_precise:0 +solve3d_zoffset:0 +val_max:254 +val_min:132 +y_max:1.000000 +y_min:-1.000000 diff --git a/Limelight Pipelines/GoodTPMORNINGMARCH7 (3).vpr b/Limelight Pipelines/GoodTPMORNINGMARCH7 (3).vpr new file mode 100644 index 0000000..8d255b1 --- /dev/null +++ b/Limelight Pipelines/GoodTPMORNINGMARCH7 (3).vpr @@ -0,0 +1,58 @@ +area_max:0.5393580481000001 +area_min:0.2097273616 +area_similarity:66 +aspect_max:20 +aspect_min:0.0000010124999999999998 +black_level:1 +blue_balance:1536 +calibration_type:0 +contour_grouping:0 +contour_sort_final:6 +convexity_max:64.5 +convexity_min:23.1 +corner_approx:2 +cross_a_a:1 +cross_a_x:0 +cross_a_y:0 +cross_b_a:1 +cross_b_x:0 +cross_b_y:0 +desc:GoodTPMORNINGMARCH7 +desired_contour_region:0 +dilation_steps:1 +direction_filter:0 +dual_close_sort_origin:0 +erosion_steps:0 +exposure:6 +force_convex:1 +hue_max:144 +hue_min:58 +image_flip:0 +image_source:0 +img_to_show:0 +intersection_filter:0 +pipeline_led_enabled:1 +pipeline_led_power:100 +pipeline_res:0 +pipeline_type:0 +red_balance:500 +roi_x:0 +roi_y:0 +sat_max:255 +sat_min:100 +send_corners:0 +send_raw_contours:0 +solve3d:0 +solve3d_algo:0 +solve3d_bindtarget:1 +solve3d_conf:0.990000 +solve3d_error:8 +solve3d_guess:0 +solve3d_iterations:50 +solve3d_precies:1 +solve3d_precise:0 +solve3d_zoffset:0 +val_max:254 +val_min:132 +y_max:1.000000 +y_min:-1.000000 diff --git a/Limelight Pipelines/GoodTPMORNINGMARCH7.vpr b/Limelight Pipelines/GoodTPMORNINGMARCH7.vpr new file mode 100644 index 0000000..fd27c61 --- /dev/null +++ b/Limelight Pipelines/GoodTPMORNINGMARCH7.vpr @@ -0,0 +1,58 @@ +area_max:0.5393580481000001 +area_min:0.2097273616 +area_similarity:66 +aspect_max:20 +aspect_min:0.0000010124999999999998 +black_level:1 +blue_balance:1536 +calibration_type:0 +contour_grouping:0 +contour_sort_final:6 +convexity_max:64.5 +convexity_min:23.1 +corner_approx:2 +cross_a_a:1 +cross_a_x:0 +cross_a_y:0 +cross_b_a:1 +cross_b_x:0 +cross_b_y:0 +desc:GoodTPMORNINGMARCH7 +desired_contour_region:0 +dilation_steps:1 +direction_filter:0 +dual_close_sort_origin:0 +erosion_steps:0 +exposure:8 +force_convex:1 +hue_max:144 +hue_min:58 +image_flip:0 +image_source:0 +img_to_show:0 +intersection_filter:0 +pipeline_led_enabled:1 +pipeline_led_power:100 +pipeline_res:0 +pipeline_type:0 +red_balance:500 +roi_x:0 +roi_y:0 +sat_max:255 +sat_min:100 +send_corners:0 +send_raw_contours:0 +solve3d:0 +solve3d_algo:0 +solve3d_bindtarget:1 +solve3d_conf:0.990000 +solve3d_error:8 +solve3d_guess:0 +solve3d_iterations:50 +solve3d_precies:1 +solve3d_precise:0 +solve3d_zoffset:0 +val_max:254 +val_min:132 +y_max:1.000000 +y_min:-1.000000 diff --git a/Limelight Pipelines/Pipeline_Name (1).vpr b/Limelight Pipelines/Pipeline_Name (1).vpr new file mode 100644 index 0000000..b132ff4 --- /dev/null +++ b/Limelight Pipelines/Pipeline_Name (1).vpr @@ -0,0 +1,58 @@ +area_max:100 +area_min:0.0244140625 +area_similarity:0 +aspect_max:20 +aspect_min:0.0000010124999999999998 +black_level:0 +blue_balance:1944 +calibration_type:0 +contour_grouping:0 +contour_sort_final:6 +convexity_max:43 +convexity_min:10 +corner_approx:2 +cross_a_a:1 +cross_a_x:0 +cross_a_y:0 +cross_b_a:1 +cross_b_x:0 +cross_b_y:0 +desc:Pipeline_Name +desired_contour_region:0 +dilation_steps:1 +direction_filter:0 +dual_close_sort_origin:0 +erosion_steps:0 +exposure:28 +force_convex:1 +hue_max:147 +hue_min:60 +image_flip:0 +image_source:0 +img_to_show:1 +intersection_filter:0 +pipeline_led_enabled:1 +pipeline_led_power:100 +pipeline_res:0 +pipeline_type:0 +red_balance:1130 +roi_x:0 +roi_y:0 +sat_max:255 +sat_min:95 +send_corners:0 +send_raw_contours:0 +solve3d:0 +solve3d_algo:0 +solve3d_bindtarget:1 +solve3d_conf:0.990000 +solve3d_error:8 +solve3d_guess:0 +solve3d_iterations:50 +solve3d_precies:1 +solve3d_precise:0 +solve3d_zoffset:0 +val_max:254 +val_min:163 +y_max:1.000000 +y_min:-1.000000 diff --git a/Limelight Pipelines/Pipeline_Name (10).vpr b/Limelight Pipelines/Pipeline_Name (10).vpr new file mode 100644 index 0000000..19abfbc --- /dev/null +++ b/Limelight Pipelines/Pipeline_Name (10).vpr @@ -0,0 +1,58 @@ +area_max:2.853430424100001 +area_min:0.005996953600000002 +area_similarity:0 +aspect_max:20 +aspect_min:0 +black_level:24 +blue_balance:1361 +calibration_type:0 +contour_grouping:0 +contour_sort_final:0 +convexity_max:100 +convexity_min:10 +corner_approx:2 +cross_a_a:1 +cross_a_x:-0.07 +cross_a_y:0 +cross_b_a:1 +cross_b_x:0 +cross_b_y:0 +desc:Pipeline_Name +desired_contour_region:0 +dilation_steps:1 +direction_filter:0 +dual_close_sort_origin:0 +erosion_steps:0 +exposure:41 +force_convex:1 +hue_max:65 +hue_min:55 +image_flip:0 +image_source:0 +img_to_show:0 +intersection_filter:0 +pipeline_led_enabled:1 +pipeline_led_power:100 +pipeline_res:0 +pipeline_type:0 +red_balance:2104 +roi_x:0 +roi_y:0 +sat_max:255 +sat_min:240 +send_corners:0 +send_raw_contours:0 +solve3d:0 +solve3d_algo:0 +solve3d_bindtarget:1 +solve3d_conf:0.990000 +solve3d_error:8 +solve3d_guess:0 +solve3d_iterations:50 +solve3d_precies:1 +solve3d_precise:0 +solve3d_zoffset:0 +val_max:58 +val_min:28 +y_max:1.000000 +y_min:-1.000000 diff --git a/Limelight Pipelines/Pipeline_Name (11).vpr b/Limelight Pipelines/Pipeline_Name (11).vpr new file mode 100644 index 0000000..ad6ee61 --- /dev/null +++ b/Limelight Pipelines/Pipeline_Name (11).vpr @@ -0,0 +1,58 @@ +area_max:100 +area_min:0.0244140625 +area_similarity:0 +aspect_max:20 +aspect_min:0.0000010124999999999998 +black_level:0 +blue_balance:1396 +calibration_type:0 +contour_grouping:0 +contour_sort_final:6 +convexity_max:43 +convexity_min:10 +corner_approx:2 +cross_a_a:1 +cross_a_x:0 +cross_a_y:0 +cross_b_a:1 +cross_b_x:0 +cross_b_y:0 +desc:Pipeline_Name +desired_contour_region:0 +dilation_steps:0 +direction_filter:0 +dual_close_sort_origin:0 +erosion_steps:0 +exposure:2 +force_convex:1 +hue_max:67 +hue_min:57 +image_flip:0 +image_source:0 +img_to_show:0 +intersection_filter:0 +pipeline_led_enabled:1 +pipeline_led_power:100 +pipeline_res:0 +pipeline_type:0 +red_balance:2500 +roi_x:0 +roi_y:0 +sat_max:255 +sat_min:60 +send_corners:0 +send_raw_contours:0 +solve3d:0 +solve3d_algo:0 +solve3d_bindtarget:1 +solve3d_conf:0.990000 +solve3d_error:8 +solve3d_guess:0 +solve3d_iterations:50 +solve3d_precies:1 +solve3d_precise:0 +solve3d_zoffset:0 +val_max:255 +val_min:35 +y_max:1.000000 +y_min:-1.000000 diff --git a/Limelight Pipelines/Pipeline_Name (12).vpr b/Limelight Pipelines/Pipeline_Name (12).vpr new file mode 100644 index 0000000..cb8c2ee --- /dev/null +++ b/Limelight Pipelines/Pipeline_Name (12).vpr @@ -0,0 +1,58 @@ +area_max:74.80520100000001 +area_min:1.0355301121 +area_similarity:32 +aspect_max:20 +aspect_min:0.0000010124999999999998 +black_level:0 +blue_balance:1396 +calibration_type:0 +contour_grouping:0 +contour_sort_final:2 +convexity_max:50.7 +convexity_min:27.6 +corner_approx:3.6 +cross_a_a:0.000000 +cross_a_x:0.000000 +cross_a_y:0 +cross_b_a:1 +cross_b_x:0 +cross_b_y:0 +desc:Pipeline_Name +desired_contour_region:1 +dilation_steps:0 +direction_filter:2 +dual_close_sort_origin:0 +erosion_steps:0 +exposure:63 +force_convex:1 +hue_max:33 +hue_min:23 +image_flip:0 +image_source:0 +img_to_show:0 +intersection_filter:0 +pipeline_led_enabled:1 +pipeline_led_power:100 +pipeline_res:0 +pipeline_type:0 +red_balance:2326 +roi_x:0 +roi_y:0 +sat_max:255 +sat_min:240 +send_corners:0 +send_raw_contours:0 +solve3d:0 +solve3d_algo:0 +solve3d_bindtarget:1 +solve3d_conf:0.990000 +solve3d_error:8 +solve3d_guess:0 +solve3d_iterations:50 +solve3d_precies:1 +solve3d_precise:0 +solve3d_zoffset:0 +val_max:255 +val_min:201 +y_max:1.000000 +y_min:-1.000000 diff --git a/Limelight Pipelines/Pipeline_Name (13).vpr b/Limelight Pipelines/Pipeline_Name (13).vpr new file mode 100644 index 0000000..319ce2a --- /dev/null +++ b/Limelight Pipelines/Pipeline_Name (13).vpr @@ -0,0 +1,58 @@ +area_max:5.9072816401 +area_min:0.1330863361 +area_similarity:66 +aspect_max:20 +aspect_min:0.0000010124999999999998 +black_level:1 +blue_balance:1536 +calibration_type:0 +contour_grouping:0 +contour_sort_final:6 +convexity_max:64.5 +convexity_min:23.1 +corner_approx:2 +cross_a_a:1 +cross_a_x:0 +cross_a_y:0 +cross_b_a:1 +cross_b_x:0 +cross_b_y:0 +desc:Pipeline_Name +desired_contour_region:0 +dilation_steps:1 +direction_filter:0 +dual_close_sort_origin:0 +erosion_steps:0 +exposure:12 +force_convex:1 +hue_max:144 +hue_min:59 +image_flip:0 +image_source:0 +img_to_show:0 +intersection_filter:0 +pipeline_led_enabled:1 +pipeline_led_power:100 +pipeline_res:0 +pipeline_type:0 +red_balance:500 +roi_x:0 +roi_y:0 +sat_max:255 +sat_min:100 +send_corners:0 +send_raw_contours:0 +solve3d:0 +solve3d_algo:0 +solve3d_bindtarget:1 +solve3d_conf:0.990000 +solve3d_error:8 +solve3d_guess:0 +solve3d_iterations:50 +solve3d_precies:1 +solve3d_precise:0 +solve3d_zoffset:0 +val_max:254 +val_min:84 +y_max:1.000000 +y_min:-1.000000 diff --git a/Limelight Pipelines/Pipeline_Name (14).vpr b/Limelight Pipelines/Pipeline_Name (14).vpr new file mode 100644 index 0000000..5f662c7 --- /dev/null +++ b/Limelight Pipelines/Pipeline_Name (14).vpr @@ -0,0 +1,58 @@ +area_max:25.843904016099994 +area_min:0.0244140625 +area_similarity:66 +aspect_max:20 +aspect_min:0.0000010124999999999998 +black_level:1 +blue_balance:1536 +calibration_type:0 +contour_grouping:0 +contour_sort_final:6 +convexity_max:64.5 +convexity_min:23.1 +corner_approx:2 +cross_a_a:1 +cross_a_x:0 +cross_a_y:0 +cross_b_a:1 +cross_b_x:0 +cross_b_y:0 +desc:Pipeline_Name +desired_contour_region:0 +dilation_steps:1 +direction_filter:0 +dual_close_sort_origin:0 +erosion_steps:0 +exposure:12 +force_convex:1 +hue_max:144 +hue_min:60 +image_flip:0 +image_source:0 +img_to_show:0 +intersection_filter:0 +pipeline_led_enabled:1 +pipeline_led_power:100 +pipeline_res:0 +pipeline_type:0 +red_balance:500 +roi_x:0 +roi_y:0 +sat_max:255 +sat_min:100 +send_corners:0 +send_raw_contours:0 +solve3d:0 +solve3d_algo:0 +solve3d_bindtarget:1 +solve3d_conf:0.990000 +solve3d_error:8 +solve3d_guess:0 +solve3d_iterations:50 +solve3d_precies:1 +solve3d_precise:0 +solve3d_zoffset:0 +val_max:254 +val_min:132 +y_max:1.000000 +y_min:-1.000000 diff --git a/Limelight Pipelines/Pipeline_Name (15).vpr b/Limelight Pipelines/Pipeline_Name (15).vpr new file mode 100644 index 0000000..16a44ce --- /dev/null +++ b/Limelight Pipelines/Pipeline_Name (15).vpr @@ -0,0 +1,58 @@ +area_max:12.199721696099997 +area_min:0.8999178496 +area_similarity:66 +aspect_max:20 +aspect_min:0.0000010124999999999998 +black_level:0 +blue_balance:1555 +calibration_type:0 +contour_grouping:0 +contour_sort_final:6 +convexity_max:64.5 +convexity_min:23.1 +corner_approx:2 +cross_a_a:1 +cross_a_x:0 +cross_a_y:0 +cross_b_a:1 +cross_b_x:0 +cross_b_y:0 +desc:Pipeline_Name +desired_contour_region:0 +dilation_steps:1 +direction_filter:0 +dual_close_sort_origin:0 +erosion_steps:0 +exposure:2 +force_convex:1 +hue_max:144 +hue_min:60 +image_flip:0 +image_source:0 +img_to_show:0 +intersection_filter:0 +pipeline_led_enabled:1 +pipeline_led_power:100 +pipeline_res:0 +pipeline_type:0 +red_balance:500 +roi_x:0 +roi_y:0 +sat_max:255 +sat_min:100 +send_corners:0 +send_raw_contours:0 +solve3d:0 +solve3d_algo:0 +solve3d_bindtarget:1 +solve3d_conf:0.990000 +solve3d_error:8 +solve3d_guess:0 +solve3d_iterations:50 +solve3d_precies:1 +solve3d_precise:0 +solve3d_zoffset:0 +val_max:254 +val_min:132 +y_max:1.000000 +y_min:-1.000000 diff --git a/Limelight Pipelines/Pipeline_Name (2).vpr b/Limelight Pipelines/Pipeline_Name (2).vpr new file mode 100644 index 0000000..3c21d14 --- /dev/null +++ b/Limelight Pipelines/Pipeline_Name (2).vpr @@ -0,0 +1,58 @@ +area_max:100 +area_min:0.0244140625 +area_similarity:0 +aspect_max:20 +aspect_min:0.0000010124999999999998 +black_level:0 +blue_balance:1944 +calibration_type:0 +contour_grouping:0 +contour_sort_final:6 +convexity_max:43 +convexity_min:10 +corner_approx:2 +cross_a_a:1 +cross_a_x:0 +cross_a_y:0 +cross_b_a:1 +cross_b_x:0 +cross_b_y:0 +desc:Pipeline_Name +desired_contour_region:0 +dilation_steps:1 +direction_filter:0 +dual_close_sort_origin:0 +erosion_steps:0 +exposure:28 +force_convex:1 +hue_max:147 +hue_min:60 +image_flip:0 +image_source:0 +img_to_show:0 +intersection_filter:0 +pipeline_led_enabled:1 +pipeline_led_power:100 +pipeline_res:0 +pipeline_type:0 +red_balance:1130 +roi_x:0 +roi_y:0 +sat_max:255 +sat_min:95 +send_corners:0 +send_raw_contours:0 +solve3d:0 +solve3d_algo:0 +solve3d_bindtarget:1 +solve3d_conf:0.990000 +solve3d_error:8 +solve3d_guess:0 +solve3d_iterations:50 +solve3d_precies:1 +solve3d_precise:0 +solve3d_zoffset:0 +val_max:254 +val_min:163 +y_max:1.000000 +y_min:-1.000000 diff --git a/Limelight Pipelines/Pipeline_Name (3).vpr b/Limelight Pipelines/Pipeline_Name (3).vpr new file mode 100644 index 0000000..a7490c2 --- /dev/null +++ b/Limelight Pipelines/Pipeline_Name (3).vpr @@ -0,0 +1,58 @@ +area_max:100 +area_min:0.0244140625 +area_similarity:66 +aspect_max:20 +aspect_min:0.0000010124999999999998 +black_level:0 +blue_balance:1944 +calibration_type:0 +contour_grouping:0 +contour_sort_final:6 +convexity_max:43 +convexity_min:10 +corner_approx:2 +cross_a_a:1 +cross_a_x:0 +cross_a_y:0 +cross_b_a:1 +cross_b_x:0 +cross_b_y:0 +desc:Pipeline_Name +desired_contour_region:0 +dilation_steps:1 +direction_filter:0 +dual_close_sort_origin:0 +erosion_steps:0 +exposure:28 +force_convex:1 +hue_max:147 +hue_min:60 +image_flip:0 +image_source:0 +img_to_show:0 +intersection_filter:0 +pipeline_led_enabled:1 +pipeline_led_power:100 +pipeline_res:0 +pipeline_type:0 +red_balance:1130 +roi_x:0 +roi_y:0 +sat_max:255 +sat_min:95 +send_corners:0 +send_raw_contours:0 +solve3d:0 +solve3d_algo:0 +solve3d_bindtarget:1 +solve3d_conf:0.990000 +solve3d_error:8 +solve3d_guess:0 +solve3d_iterations:50 +solve3d_precies:1 +solve3d_precise:0 +solve3d_zoffset:0 +val_max:254 +val_min:163 +y_max:1.000000 +y_min:-1.000000 diff --git a/Limelight Pipelines/Pipeline_Name (4).vpr b/Limelight Pipelines/Pipeline_Name (4).vpr new file mode 100644 index 0000000..223c668 --- /dev/null +++ b/Limelight Pipelines/Pipeline_Name (4).vpr @@ -0,0 +1,58 @@ +area_max:100 +area_min:0.0244140625 +area_similarity:66 +aspect_max:20 +aspect_min:0.0000010124999999999998 +black_level:0 +blue_balance:1944 +calibration_type:0 +contour_grouping:0 +contour_sort_final:6 +convexity_max:64.5 +convexity_min:23.1 +corner_approx:2 +cross_a_a:1 +cross_a_x:0 +cross_a_y:0 +cross_b_a:1 +cross_b_x:0 +cross_b_y:0 +desc:Pipeline_Name +desired_contour_region:0 +dilation_steps:1 +direction_filter:0 +dual_close_sort_origin:0 +erosion_steps:0 +exposure:28 +force_convex:1 +hue_max:147 +hue_min:60 +image_flip:0 +image_source:0 +img_to_show:0 +intersection_filter:0 +pipeline_led_enabled:1 +pipeline_led_power:100 +pipeline_res:0 +pipeline_type:0 +red_balance:1130 +roi_x:0 +roi_y:0 +sat_max:255 +sat_min:100 +send_corners:0 +send_raw_contours:0 +solve3d:0 +solve3d_algo:0 +solve3d_bindtarget:1 +solve3d_conf:0.990000 +solve3d_error:8 +solve3d_guess:0 +solve3d_iterations:50 +solve3d_precies:1 +solve3d_precise:0 +solve3d_zoffset:0 +val_max:254 +val_min:132 +y_max:1.000000 +y_min:-1.000000 diff --git a/Limelight Pipelines/Pipeline_Name (5).vpr b/Limelight Pipelines/Pipeline_Name (5).vpr new file mode 100644 index 0000000..a72fcc1 --- /dev/null +++ b/Limelight Pipelines/Pipeline_Name (5).vpr @@ -0,0 +1,58 @@ +area_max:25.843904016099994 +area_min:0.0244140625 +area_similarity:66 +aspect_max:20 +aspect_min:0.0000010124999999999998 +black_level:0 +blue_balance:1944 +calibration_type:0 +contour_grouping:0 +contour_sort_final:6 +convexity_max:64.5 +convexity_min:23.1 +corner_approx:2 +cross_a_a:1 +cross_a_x:0 +cross_a_y:0 +cross_b_a:1 +cross_b_x:0 +cross_b_y:0 +desc:Pipeline_Name +desired_contour_region:0 +dilation_steps:1 +direction_filter:0 +dual_close_sort_origin:0 +erosion_steps:0 +exposure:28 +force_convex:1 +hue_max:147 +hue_min:60 +image_flip:0 +image_source:0 +img_to_show:0 +intersection_filter:0 +pipeline_led_enabled:1 +pipeline_led_power:100 +pipeline_res:0 +pipeline_type:0 +red_balance:1130 +roi_x:0 +roi_y:0 +sat_max:255 +sat_min:100 +send_corners:0 +send_raw_contours:0 +solve3d:0 +solve3d_algo:0 +solve3d_bindtarget:1 +solve3d_conf:0.990000 +solve3d_error:8 +solve3d_guess:0 +solve3d_iterations:50 +solve3d_precies:1 +solve3d_precise:0 +solve3d_zoffset:0 +val_max:254 +val_min:132 +y_max:1.000000 +y_min:-1.000000 diff --git a/Limelight Pipelines/Pipeline_Name (6).vpr b/Limelight Pipelines/Pipeline_Name (6).vpr new file mode 100644 index 0000000..5f662c7 --- /dev/null +++ b/Limelight Pipelines/Pipeline_Name (6).vpr @@ -0,0 +1,58 @@ +area_max:25.843904016099994 +area_min:0.0244140625 +area_similarity:66 +aspect_max:20 +aspect_min:0.0000010124999999999998 +black_level:1 +blue_balance:1536 +calibration_type:0 +contour_grouping:0 +contour_sort_final:6 +convexity_max:64.5 +convexity_min:23.1 +corner_approx:2 +cross_a_a:1 +cross_a_x:0 +cross_a_y:0 +cross_b_a:1 +cross_b_x:0 +cross_b_y:0 +desc:Pipeline_Name +desired_contour_region:0 +dilation_steps:1 +direction_filter:0 +dual_close_sort_origin:0 +erosion_steps:0 +exposure:12 +force_convex:1 +hue_max:144 +hue_min:60 +image_flip:0 +image_source:0 +img_to_show:0 +intersection_filter:0 +pipeline_led_enabled:1 +pipeline_led_power:100 +pipeline_res:0 +pipeline_type:0 +red_balance:500 +roi_x:0 +roi_y:0 +sat_max:255 +sat_min:100 +send_corners:0 +send_raw_contours:0 +solve3d:0 +solve3d_algo:0 +solve3d_bindtarget:1 +solve3d_conf:0.990000 +solve3d_error:8 +solve3d_guess:0 +solve3d_iterations:50 +solve3d_precies:1 +solve3d_precise:0 +solve3d_zoffset:0 +val_max:254 +val_min:132 +y_max:1.000000 +y_min:-1.000000 diff --git a/Limelight Pipelines/Pipeline_Name (7).vpr b/Limelight Pipelines/Pipeline_Name (7).vpr new file mode 100644 index 0000000..72ff7fb --- /dev/null +++ b/Limelight Pipelines/Pipeline_Name (7).vpr @@ -0,0 +1,58 @@ +area_max:25.843904016099994 +area_min:0.0244140625 +area_similarity:83 +aspect_max:20 +aspect_min:2e-7 +black_level:3 +blue_balance:1536 +calibration_type:0 +contour_grouping:1 +contour_sort_final:6 +convexity_max:87 +convexity_min:41.9 +corner_approx:5.8 +cross_a_a:1 +cross_a_x:0 +cross_a_y:0 +cross_b_a:1 +cross_b_x:0 +cross_b_y:0 +desc:Pipeline_Name +desired_contour_region:1 +dilation_steps:1 +direction_filter:0 +dual_close_sort_origin:0 +erosion_steps:0 +exposure:24 +force_convex:1 +hue_max:65 +hue_min:55 +image_flip:0 +image_source:0 +img_to_show:0 +intersection_filter:0 +pipeline_led_enabled:1 +pipeline_led_power:100 +pipeline_res:0 +pipeline_type:0 +red_balance:500 +roi_x:0 +roi_y:0 +sat_max:255 +sat_min:240 +send_corners:0 +send_raw_contours:0 +solve3d:0 +solve3d_algo:0 +solve3d_bindtarget:1 +solve3d_conf:0.990000 +solve3d_error:8 +solve3d_guess:0 +solve3d_iterations:50 +solve3d_precies:1 +solve3d_precise:0 +solve3d_zoffset:0 +val_max:221 +val_min:191 +y_max:1.000000 +y_min:-1.000000 diff --git a/Limelight Pipelines/Pipeline_Name (8) - Copy - Copy - Copy.vpr b/Limelight Pipelines/Pipeline_Name (8) - Copy - Copy - Copy.vpr new file mode 100644 index 0000000..cc3521c --- /dev/null +++ b/Limelight Pipelines/Pipeline_Name (8) - Copy - Copy - Copy.vpr @@ -0,0 +1,58 @@ +area_max:100 +area_min:0.0244140625 +area_similarity:0 +aspect_max:20 +aspect_min:0.0000010124999999999998 +black_level:0 +blue_balance:1944 +calibration_type:0 +contour_grouping:0 +contour_sort_final:6 +convexity_max:43 +convexity_min:10 +corner_approx:2 +cross_a_a:1 +cross_a_x:0 +cross_a_y:0 +cross_b_a:1 +cross_b_x:0 +cross_b_y:0 +desc:Pipeline_Name +desired_contour_region:0 +dilation_steps:1 +direction_filter:0 +dual_close_sort_origin:0 +erosion_steps:0 +exposure:2 +force_convex:1 +hue_max:147 +hue_min:60 +image_flip:0 +image_source:0 +img_to_show:0 +intersection_filter:0 +pipeline_led_enabled:1 +pipeline_led_power:100 +pipeline_res:0 +pipeline_type:0 +red_balance:1130 +roi_x:0 +roi_y:0 +sat_max:255 +sat_min:95 +send_corners:0 +send_raw_contours:0 +solve3d:0 +solve3d_algo:0 +solve3d_bindtarget:1 +solve3d_conf:0.990000 +solve3d_error:8 +solve3d_guess:0 +solve3d_iterations:50 +solve3d_precies:1 +solve3d_precise:0 +solve3d_zoffset:0 +val_max:254 +val_min:163 +y_max:1.000000 +y_min:-1.000000 \ No newline at end of file diff --git a/Limelight Pipelines/Pipeline_Name (8) - Copy - Copy.vpr b/Limelight Pipelines/Pipeline_Name (8) - Copy - Copy.vpr new file mode 100644 index 0000000..262f302 --- /dev/null +++ b/Limelight Pipelines/Pipeline_Name (8) - Copy - Copy.vpr @@ -0,0 +1,56 @@ +area_max:100 +area_min:0.07233948159999996 +area_similarity:10 +aspect_max:15.285387012499996 +aspect_min:0 +black_level:0 +blue_balance:1975 +calibration_type:0 +contour_grouping:0 +contour_sort_final:0 +convexity_max:60 +convexity_min:0 +corner_approx:2 +cross_a_a:1 +cross_a_x:0 +cross_a_y:0 +cross_b_a:1 +cross_b_x:0 +cross_b_y:0 +desc:PowerPortCalibrated +desired_contour_region:0 +dilation_steps:0 +direction_filter:0 +dual_close_sort_origin:0 +erosion_steps:0 +exposure:2 +force_convex:1 +hue_max:98 +hue_min:59 +image_flip:0 +image_source:0 +img_to_show:1 +intersection_filter:0 +pipeline_led_enabled:1 +pipeline_led_power:100 +pipeline_res:0 +pipeline_type:0 +red_balance:1200 +sat_max:255 +sat_min:94 +send_corners:0 +send_raw_contours:0 +solve3d:0 +solve3d_algo:0 +solve3d_bindtarget:1 +solve3d_conf:0.990000 +solve3d_error:8 +solve3d_guess:0 +solve3d_iterations:50 +solve3d_precies:1 +solve3d_precise:0 +solve3d_zoffset:0 +val_max:255 +val_min:90 +y_max:1.000000 +y_min:-1.000000 \ No newline at end of file diff --git a/Limelight Pipelines/Pipeline_Name (8) - Copy.vpr b/Limelight Pipelines/Pipeline_Name (8) - Copy.vpr new file mode 100644 index 0000000..6685e36 --- /dev/null +++ b/Limelight Pipelines/Pipeline_Name (8) - Copy.vpr @@ -0,0 +1,58 @@ +area_max:100 +area_min:0.0163047361 +area_similarity:0 +aspect_max:20.000000 +aspect_min:0.000000 +black_level:17 +blue_balance:1526 +calibration_type:0 +contour_grouping:0 +contour_sort_final:0 +convexity_max:100 +convexity_min:10 +corner_approx:2 +cross_a_a:1 +cross_a_x:-0.07 +cross_a_y:0 +cross_b_a:1 +cross_b_x:0 +cross_b_y:0 +desc:Pipeline_Name +desired_contour_region:1 +dilation_steps:1 +direction_filter:0 +dual_close_sort_origin:0 +erosion_steps:0 +exposure:2 +force_convex:1 +hue_max:83 +hue_min:38 +image_flip:0 +image_source:0 +img_to_show:0 +intersection_filter:0 +pipeline_led_enabled:1 +pipeline_led_power:100 +pipeline_res:0 +pipeline_type:0 +red_balance:1323 +roi_x:0 +roi_y:0 +sat_max:255 +sat_min:124 +send_corners:0 +send_raw_contours:0 +solve3d:0 +solve3d_algo:0 +solve3d_bindtarget:1 +solve3d_conf:0.990000 +solve3d_error:8 +solve3d_guess:0 +solve3d_iterations:50 +solve3d_precies:1 +solve3d_precise:0 +solve3d_zoffset:0 +val_max:250 +val_min:114 +y_max:1.000000 +y_min:-1.000000 \ No newline at end of file diff --git a/Limelight Pipelines/Pipeline_Name (8).vpr b/Limelight Pipelines/Pipeline_Name (8).vpr new file mode 100644 index 0000000..06ebbd1 --- /dev/null +++ b/Limelight Pipelines/Pipeline_Name (8).vpr @@ -0,0 +1,58 @@ +area_max:25.843904016099994 +area_min:0.0244140625 +area_similarity:83 +aspect_max:20 +aspect_min:2e-7 +black_level:3 +blue_balance:1536 +calibration_type:0 +contour_grouping:1 +contour_sort_final:6 +convexity_max:87 +convexity_min:41.9 +corner_approx:5.8 +cross_a_a:1 +cross_a_x:0 +cross_a_y:0 +cross_b_a:1 +cross_b_x:0 +cross_b_y:0 +desc:Pipeline_Name +desired_contour_region:1 +dilation_steps:1 +direction_filter:0 +dual_close_sort_origin:0 +erosion_steps:0 +exposure:24 +force_convex:1 +hue_max:61 +hue_min:41 +image_flip:0 +image_source:0 +img_to_show:0 +intersection_filter:0 +pipeline_led_enabled:1 +pipeline_led_power:100 +pipeline_res:0 +pipeline_type:0 +red_balance:500 +roi_x:0 +roi_y:0 +sat_max:255 +sat_min:240 +send_corners:0 +send_raw_contours:0 +solve3d:0 +solve3d_algo:0 +solve3d_bindtarget:1 +solve3d_conf:0.990000 +solve3d_error:8 +solve3d_guess:0 +solve3d_iterations:50 +solve3d_precies:1 +solve3d_precise:0 +solve3d_zoffset:0 +val_max:221 +val_min:191 +y_max:1.000000 +y_min:-1.000000 diff --git a/Limelight Pipelines/Pipeline_Name (9).vpr b/Limelight Pipelines/Pipeline_Name (9).vpr new file mode 100644 index 0000000..f990528 --- /dev/null +++ b/Limelight Pipelines/Pipeline_Name (9).vpr @@ -0,0 +1,58 @@ +area_max:2.853430424100001 +area_min:0.005996953600000002 +area_similarity:0 +aspect_max:20 +aspect_min:0 +black_level:17 +blue_balance:1972 +calibration_type:0 +contour_grouping:0 +contour_sort_final:0 +convexity_max:100 +convexity_min:10 +corner_approx:2 +cross_a_a:1 +cross_a_x:-0.07 +cross_a_y:0 +cross_b_a:1 +cross_b_x:0 +cross_b_y:0 +desc:Pipeline_Name +desired_contour_region:0 +dilation_steps:1 +direction_filter:0 +dual_close_sort_origin:0 +erosion_steps:0 +exposure:33 +force_convex:1 +hue_max:65 +hue_min:55 +image_flip:0 +image_source:0 +img_to_show:0 +intersection_filter:0 +pipeline_led_enabled:1 +pipeline_led_power:100 +pipeline_res:0 +pipeline_type:0 +red_balance:1830 +roi_x:0 +roi_y:0 +sat_max:255 +sat_min:240 +send_corners:0 +send_raw_contours:0 +solve3d:0 +solve3d_algo:0 +solve3d_bindtarget:1 +solve3d_conf:0.990000 +solve3d_error:8 +solve3d_guess:0 +solve3d_iterations:50 +solve3d_precies:1 +solve3d_precise:0 +solve3d_zoffset:0 +val_max:58 +val_min:28 +y_max:1.000000 +y_min:-1.000000 diff --git a/Limelight Pipelines/Pipeline_Name.vpr b/Limelight Pipelines/Pipeline_Name.vpr new file mode 100644 index 0000000..c688629 --- /dev/null +++ b/Limelight Pipelines/Pipeline_Name.vpr @@ -0,0 +1,58 @@ +area_max:4.921342928100001 +area_min:0 +area_similarity:13 +aspect_max:20 +aspect_min:0 +black_level:0 +blue_balance:1876 +calibration_type:0 +contour_grouping:0 +contour_sort_final:2 +convexity_max:45.2 +convexity_min:0 +corner_approx:2 +cross_a_a:1 +cross_a_x:0 +cross_a_y:0 +cross_b_a:1 +cross_b_x:0 +cross_b_y:0 +desc:Pipeline_Name +desired_contour_region:0 +dilation_steps:1 +direction_filter:0 +dual_close_sort_origin:0 +erosion_steps:0 +exposure:13 +force_convex:1 +hue_max:148 +hue_min:61 +image_flip:0 +image_source:0 +img_to_show:1 +intersection_filter:0 +pipeline_led_enabled:1 +pipeline_led_power:100 +pipeline_res:0 +pipeline_type:0 +red_balance:927 +roi_x:0 +roi_y:0 +sat_max:254 +sat_min:114 +send_corners:0 +send_raw_contours:0 +solve3d:0 +solve3d_algo:0 +solve3d_bindtarget:1 +solve3d_conf:0.990000 +solve3d_error:8 +solve3d_guess:0 +solve3d_iterations:50 +solve3d_precies:1 +solve3d_precise:0 +solve3d_zoffset:0 +val_max:255 +val_min:113 +y_max:1.000000 +y_min:-1.000000 diff --git a/SmartDashboard Layout/save.xml b/SmartDashboard Layout/save.xml new file mode 100644 index 0000000..154bd4b --- /dev/null +++ b/SmartDashboard Layout/save.xml @@ -0,0 +1,124 @@ + + + + + + + + + 226 + 109 + + + + + + + + + + + + + 199 + 63 + + + + 162 + 67 + + + + + + + 354 + 317 + + + + + 325 + 125 + + + + + + + + + + 427 + 323 + + + + + + + + + + + + + + 187 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file From f9005d2db7f6867a3d447590f68b1ad23ab30a93 Mon Sep 17 00:00:00 2001 From: frcteam2791 Date: Sun, 8 Mar 2020 07:47:42 -0700 Subject: [PATCH 59/68] Second Beam Break Hopper --- .../Autons/ManipulatorToLimitHopper.java | 2 +- src/main/java/frc/robot/Constants.java | 2 +- .../commands/IntakeToHopper/BeamBreak.java | 2 +- .../commands/IntakeToHopper/TwoBeamBreak.java | 91 +++++++++++++++++++ .../java/frc/robot/subsystems/Hopper.java | 7 +- 5 files changed, 98 insertions(+), 6 deletions(-) create mode 100644 src/main/java/frc/robot/commands/IntakeToHopper/TwoBeamBreak.java diff --git a/src/main/java/frc/robot/Autons/ManipulatorToLimitHopper.java b/src/main/java/frc/robot/Autons/ManipulatorToLimitHopper.java index dc11541..1a387ce 100644 --- a/src/main/java/frc/robot/Autons/ManipulatorToLimitHopper.java +++ b/src/main/java/frc/robot/Autons/ManipulatorToLimitHopper.java @@ -7,7 +7,7 @@ public class ManipulatorToLimitHopper extends CommandGroup{ public ManipulatorToLimitHopper(){ addSequential(new MoveManipulator()); - addSequential(new BeamBreak()); + addSequential(new TwoBeamBreak()); //addSequential(new OpenHopperPiston()); } } \ No newline at end of file diff --git a/src/main/java/frc/robot/Constants.java b/src/main/java/frc/robot/Constants.java index 4522b86..ae7bdbc 100644 --- a/src/main/java/frc/robot/Constants.java +++ b/src/main/java/frc/robot/Constants.java @@ -141,7 +141,7 @@ public final class Constants { public static final double HOPPER_LONG_HORIZONTAL_OUTPUT = 0.25; - public static final double kHopperTimer = 0.037;//0.12; + public static final double kHopperTimer = 0.06;//0.037;//0.12; public static final double LimelightSetpoint = -1; diff --git a/src/main/java/frc/robot/commands/IntakeToHopper/BeamBreak.java b/src/main/java/frc/robot/commands/IntakeToHopper/BeamBreak.java index 89955ef..d61e473 100644 --- a/src/main/java/frc/robot/commands/IntakeToHopper/BeamBreak.java +++ b/src/main/java/frc/robot/commands/IntakeToHopper/BeamBreak.java @@ -28,7 +28,7 @@ protected void initialize() { protected void execute() { SmartDashboard.putBoolean("Beam Break Hopper Running", true); - if(!Robot.hopper.beamBreak.get()){ + if(!Robot.hopper.beamBreak1.get()){ timer.start(); Robot.hopper.setHopper(Constants.HOPPER_LOADING_HORIZONTAL_OUTPUT, Constants.HOPPER_LOADING_VERTICAL_OUTPUT); diff --git a/src/main/java/frc/robot/commands/IntakeToHopper/TwoBeamBreak.java b/src/main/java/frc/robot/commands/IntakeToHopper/TwoBeamBreak.java new file mode 100644 index 0000000..bcc6294 --- /dev/null +++ b/src/main/java/frc/robot/commands/IntakeToHopper/TwoBeamBreak.java @@ -0,0 +1,91 @@ +package frc.robot.commands.IntakeToHopper; + +import edu.wpi.first.wpilibj.command.Command; +import edu.wpi.first.wpilibj.smartdashboard.SmartDashboard; +import frc.robot.Constants; +import frc.robot.Robot; +import frc.robot.commands.IntakeToHopper.MoveManipulator; +import edu.wpi.first.wpilibj.Timer; + +public class TwoBeamBreak extends Command { + public int count; + private boolean timerStart = false; + private boolean firstBall = false; + private boolean on1 = false; + private boolean off1 = false; + private boolean on2 = false; + private boolean beenthrough = false; + // public Timer timer= new Timer(); + public TwoBeamBreak() { + super("TwoBeamBreak"); + requires(Robot.hopper); + + } + + // Called just before this Command runs the first time + @Override + protected void initialize() { + // count = 0; + } + + // Called repeatedly when this Command is scheduled to run + @Override + protected void execute() { + SmartDashboard.putBoolean("Beam Break Hopper Running", true); + if(!Robot.hopper.beamBreak1.get()){ + // timer.start(); + Robot.hopper.setHopper(Constants.HOPPER_LOADING_HORIZONTAL_OUTPUT, + Constants.HOPPER_LOADING_VERTICAL_OUTPUT); + on1 = true; + // timerStart = true; + } + on1 = !Robot.hopper.beamBreak2.get(); + if(Robot.hopper.beamBreak2.get() || beenthrough){ + beenthrough = true; + if(!Robot.hopper.beamBreak2.get() && on1){ + Robot.hopper.setHopper(0,0); + on1 = false; + beenthrough = false; + } + } + // if(timerStart){ + // if (timer.get()>=Constants.kHopperTimer){ + // timer.stop(); + // timer.reset(); + // Robot.hopper.setHopper(0,0); + // } + // } + } + + + + // Make this return true when this Command no longer needs to run execute() + @Override + + protected boolean isFinished() { + // if (Robot.hopper.isHopperFull()==true){ + // return true; + // } + // else{ + // return false; + // } + return false; + + } + + // Called once after isFinished returns true + @Override + protected void end() { + // count++; + Robot.hopper.setHopper(0, 0); + // SmartDashboard.putBoolean("Ir Hopper Running", false); + // Robot.hopper.counter.reset(); + } + + // Called when another command which requires one or more of the same + // subsystems is scheduled to run + @Override + protected void interrupted() { + } + +} diff --git a/src/main/java/frc/robot/subsystems/Hopper.java b/src/main/java/frc/robot/subsystems/Hopper.java index 136b19c..1e60c99 100644 --- a/src/main/java/frc/robot/subsystems/Hopper.java +++ b/src/main/java/frc/robot/subsystems/Hopper.java @@ -29,8 +29,9 @@ public class Hopper extends Subsystem { public CANSparkMax hopper_vertical; public Solenoid hopper_stopper; public IrSensor entrySensor, upperSensor; - public DigitalInput beamBreak = new DigitalInput(9);//Switched from Limit switch to bream break - public Counter counter= new Counter(beamBreak); + public DigitalInput beamBreak1 = new DigitalInput(9);//Switched from Limit switch to bream break + public DigitalInput beamBreak2 = new DigitalInput(8); + public Counter counter= new Counter(beamBreak1); public Hopper(){ hopper_horizontal = new CANSparkMax(RobotMap.HORIZONTAL_HOPPER, MotorType.kBrushless); @@ -141,7 +142,7 @@ public void debug(){ SmartDashboard.putNumber("Upper IR Value", upperSensor.getValue()); SmartDashboard.putBoolean("Jammed", checkJammed()); SmartDashboard.putNumber("Counter Value", counter.get()); - SmartDashboard.putBoolean("Beam Break", beamBreak.get()); //Switched from Limit switch to bream break + SmartDashboard.putBoolean("Beam Break", beamBreak1.get()); //Switched from Limit switch to bream break } @Override protected void initDefaultCommand() { From bdbb22341c32dc8c553ca371aa40056098cbdb6d Mon Sep 17 00:00:00 2001 From: frcteam2791 Date: Sun, 8 Mar 2020 09:03:19 -0700 Subject: [PATCH 60/68] Messed With 2 beam and tempoprarily reverted to 1 beam --- .../Autons/ManipulatorToLimitHopper.java | 2 +- src/main/java/frc/robot/Constants.java | 5 +- .../IntakeToHopper/ReverseUntilBeamBreak.java | 2 +- .../commands/IntakeToHopper/TwoBeamBreak.java | 75 +++++++++++++------ 4 files changed, 58 insertions(+), 26 deletions(-) diff --git a/src/main/java/frc/robot/Autons/ManipulatorToLimitHopper.java b/src/main/java/frc/robot/Autons/ManipulatorToLimitHopper.java index 1a387ce..dc11541 100644 --- a/src/main/java/frc/robot/Autons/ManipulatorToLimitHopper.java +++ b/src/main/java/frc/robot/Autons/ManipulatorToLimitHopper.java @@ -7,7 +7,7 @@ public class ManipulatorToLimitHopper extends CommandGroup{ public ManipulatorToLimitHopper(){ addSequential(new MoveManipulator()); - addSequential(new TwoBeamBreak()); + addSequential(new BeamBreak()); //addSequential(new OpenHopperPiston()); } } \ No newline at end of file diff --git a/src/main/java/frc/robot/Constants.java b/src/main/java/frc/robot/Constants.java index 5558fef..5ee5964 100644 --- a/src/main/java/frc/robot/Constants.java +++ b/src/main/java/frc/robot/Constants.java @@ -69,7 +69,7 @@ public final class Constants { public static final double ELEVATOR_OUTPUT = -.05; - public static final double HOPPER_LOADING_HORIZONTAL_OUTPUT = 0.85;//.82; //.5 for limit + public static final double HOPPER_LOADING_HORIZONTAL_OUTPUT = 0.82;//.82; //.5 for limit public static final double HOPPER_WALL_HORIZONTAL_OUTPUT = 0.60; // 0.30; 0.70; @@ -150,6 +150,9 @@ public final class Constants { public static final double TrenchBallOneDist = 7; + public static final double kHopperTimerBeams = 0.02; + + public static double reverseTime = 1.0; diff --git a/src/main/java/frc/robot/commands/IntakeToHopper/ReverseUntilBeamBreak.java b/src/main/java/frc/robot/commands/IntakeToHopper/ReverseUntilBeamBreak.java index 00b7a67..273dc51 100644 --- a/src/main/java/frc/robot/commands/IntakeToHopper/ReverseUntilBeamBreak.java +++ b/src/main/java/frc/robot/commands/IntakeToHopper/ReverseUntilBeamBreak.java @@ -19,7 +19,7 @@ protected void initialize() { // Called repeatedly when this Command is scheduled to run @Override protected void execute() { - if(!Robot.hopper.beamBreak.get()){ + if(!Robot.hopper.beamBreak1.get()){ Robot.hopper.setHopper(0, 0); } else{ diff --git a/src/main/java/frc/robot/commands/IntakeToHopper/TwoBeamBreak.java b/src/main/java/frc/robot/commands/IntakeToHopper/TwoBeamBreak.java index bcc6294..e9d7d1a 100644 --- a/src/main/java/frc/robot/commands/IntakeToHopper/TwoBeamBreak.java +++ b/src/main/java/frc/robot/commands/IntakeToHopper/TwoBeamBreak.java @@ -15,7 +15,8 @@ public class TwoBeamBreak extends Command { private boolean off1 = false; private boolean on2 = false; private boolean beenthrough = false; - // public Timer timer= new Timer(); + private boolean trippitybop = true; + public Timer timer= new Timer(); public TwoBeamBreak() { super("TwoBeamBreak"); requires(Robot.hopper); @@ -26,35 +27,63 @@ public TwoBeamBreak() { @Override protected void initialize() { // count = 0; + SmartDashboard.putBoolean("Timer Running", false); + SmartDashboard.putBoolean("Started", false); + SmartDashboard.putBoolean("Beam Break", !Robot.hopper.beamBreak1.get()); + SmartDashboard.putBoolean("Upper Sensor", Robot.hopper.isUpperSensorTripped()); } // Called repeatedly when this Command is scheduled to run @Override protected void execute() { SmartDashboard.putBoolean("Beam Break Hopper Running", true); - if(!Robot.hopper.beamBreak1.get()){ - // timer.start(); - Robot.hopper.setHopper(Constants.HOPPER_LOADING_HORIZONTAL_OUTPUT, - Constants.HOPPER_LOADING_VERTICAL_OUTPUT); - on1 = true; - // timerStart = true; - } - on1 = !Robot.hopper.beamBreak2.get(); - if(Robot.hopper.beamBreak2.get() || beenthrough){ - beenthrough = true; - if(!Robot.hopper.beamBreak2.get() && on1){ - Robot.hopper.setHopper(0,0); - on1 = false; - beenthrough = false; + if(!Robot.hopper.isUpperSensorTripped()){ + if(!Robot.hopper.beamBreak1.get()){ + // timer.start(); + Robot.hopper.setHopper(Constants.HOPPER_LOADING_HORIZONTAL_OUTPUT, + Constants.HOPPER_LOADING_VERTICAL_OUTPUT); + on1 = true; + // timerStart = true; + } + on1 = !Robot.hopper.beamBreak2.get(); + + if(Robot.hopper.beamBreak2.get() || beenthrough){ + beenthrough = true; + if(!Robot.hopper.beamBreak2.get() && on1){ + Robot.hopper.setHopper(0,0); + on1 = false; + beenthrough = false; + } + + // if(timerStart){ + // if (timer.get()>=Constants.kHopperTimer){ + // timer.stop(); + // timer.reset(); + // Robot.hopper.setHopper(0,0); + // } + // } + } } - } - // if(timerStart){ - // if (timer.get()>=Constants.kHopperTimer){ - // timer.stop(); - // timer.reset(); - // Robot.hopper.setHopper(0,0); - // } - // } + else { + SmartDashboard.putBoolean("Started", true); + SmartDashboard.putBoolean("Beam Break", !Robot.hopper.beamBreak1.get()); + SmartDashboard.putBoolean("Upper Sensor", Robot.hopper.isUpperSensorTripped()); + if((!Robot.hopper.beamBreak1.get()&&Robot.hopper.isUpperSensorTripped())&&trippitybop){ + // if (Robot.hopper.isUpperSensorTripped(){//||trippitybop){ + timer.start(); + // trippitybop = true; + Robot.hopper.setHopper(Constants.HOPPER_LOADING_HORIZONTAL_OUTPUT, Constants.HOPPER_LOADING_VERTICAL_OUTPUT); + SmartDashboard.putBoolean("Timer Running", true); + if(timer.get()>=0){ + Robot.hopper.setHopper(0,0); + trippitybop = false; + SmartDashboard.putBoolean("Timer Running", false); + } + // } + + } + } + } From f471dc8bb44371b85215a594ae9df6fe58b4f1b8 Mon Sep 17 00:00:00 2001 From: frcteam2791 Date: Sun, 8 Mar 2020 13:51:03 -0400 Subject: [PATCH 61/68] Fixed PID --- src/main/java/frc/robot/subsystems/Shooter.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/main/java/frc/robot/subsystems/Shooter.java b/src/main/java/frc/robot/subsystems/Shooter.java index 1a392bd..61274d6 100644 --- a/src/main/java/frc/robot/subsystems/Shooter.java +++ b/src/main/java/frc/robot/subsystems/Shooter.java @@ -43,8 +43,10 @@ public Shooter(){ shooter_leader.getPIDController().setFF(Constants.ShooterTrenchkFF); shooter_leader.getPIDController().setD(Constants.ShooterTrenchkD); shooter_leader.getPIDController().setOutputRange(-1, 1); + shooter_leader.setSmartCurrentLimit(75); shooter_leader.enableVoltageCompensation(11.9); + SmartDashboard.putNumber("Shooter Current", 0); } public double idealVelocity(double angle, double dist, double height){ double gravityInches = Constants.kGravity*12; @@ -138,5 +140,6 @@ public void debug() { SmartDashboard.putBoolean("Hood Position Down", !getHood1()); SmartDashboard.putNumber("Voltage", getShooterVoltage()); SmartDashboard.putNumber("Calculated Velcoity", getShooterVelocity2()); + SmartDashboard.putNumber("Shooter Current", shooter_leader.getOutputCurrent()); } } From 0ce8b2c82302da5d8202a509239880a97e24fe23 Mon Sep 17 00:00:00 2001 From: frcteam2791 Date: Tue, 10 Mar 2020 15:51:37 -0400 Subject: [PATCH 62/68] made an auto method in drivetrain --- SmartDashboard Layout/save.xml | 126 +++++++++++++++++- src/main/java/frc/robot/Constants.java | 12 +- src/main/java/frc/robot/OI.java | 1 + src/main/java/frc/robot/Robot.java | 44 ++++-- .../commands/AutoCommands/FourBallTrench.java | 1 + .../frc/robot/commands/Shooter/LongShot.java | 1 + .../java/frc/robot/subsystems/Drivetrain.java | 65 ++++++++- 7 files changed, 228 insertions(+), 22 deletions(-) diff --git a/SmartDashboard Layout/save.xml b/SmartDashboard Layout/save.xml index 154bd4b..7f4e7a6 100644 --- a/SmartDashboard Layout/save.xml +++ b/SmartDashboard Layout/save.xml @@ -1,5 +1,8 @@ + + + @@ -110,15 +113,134 @@ - + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + + + + + + + + + + + + + + + + + + 20 + 341 + + + + 194 + 341 + + + + 20 + 341 + + + + 155 + 341 + + + + 23 + 122 + + + + 20 + 341 + + + + 23 + 122 + + + + 20 + 341 + + + + 23 + 132 + + + + 23 + 122 + + + + 23 + 122 + + + + 23 + 122 + + + + 20 + 341 + + + + 20 + 341 + + + + 20 + 341 + + + 353 + 649 \ No newline at end of file diff --git a/src/main/java/frc/robot/Constants.java b/src/main/java/frc/robot/Constants.java index 5ee5964..878b601 100644 --- a/src/main/java/frc/robot/Constants.java +++ b/src/main/java/frc/robot/Constants.java @@ -26,7 +26,7 @@ public final class Constants { public static final double wheelDiameterInches = 5; - public static final double ShooterTrenchkP = 0.002525; + public static final double ShooterTrenchkP = 0.002535; //.002535 good for comp //was .002525 public static final double ShooterTrenchkD = 0.22; public static final double ShooterTrenchkFF = 0.0002; public static final double ShooterWallkP = 0.001500; @@ -117,7 +117,9 @@ public final class Constants { public static final int BALL_VALUE = 2350; - + //TODO: MAKE CONSTANTS FOR SHOOTER PID SPEEDS FOR WALL AND + //TODO: LONG SHOT SO THEY ARE NOT IN THE COMMANDS AND ARE EASIER + //TODO: CHANGED FOR LATER USE AND REPURPOSE!!!!!!!!!!! //climber public static final double CLIMBER_CREEP = 0.25; @@ -138,7 +140,9 @@ public final class Constants { public static final double PANEL_MECH_FAST = 0.45; - public static final double HOPPER_LONG_HORIZONTAL_OUTPUT = 0.25; + public static final double HOPPER_LONG_HORIZONTAL_OUTPUT = 0.25; + public static final double HOPPER_AUTO_HORIZONTAL = 0.4; + public static final double HOPPER_AUTO_VERTICAL = 0.9; public static final double kHopperTimer = 0.06;//0.037;//0.12; @@ -147,7 +151,7 @@ public final class Constants { public static final double LimelightSetpoint = -1; - public static final double TrenchBallOneDist = 7; + public static final double TrenchBallOneDist = 7; //was 7 public static final double kHopperTimerBeams = 0.02; diff --git a/src/main/java/frc/robot/OI.java b/src/main/java/frc/robot/OI.java index 7211b2b..76dc7b8 100644 --- a/src/main/java/frc/robot/OI.java +++ b/src/main/java/frc/robot/OI.java @@ -125,6 +125,7 @@ public boolean get() { }.whenInactive(new StopShooterGroup()); new Trigger(){ + @Override public boolean get() { // TODO Auto-generated method stub diff --git a/src/main/java/frc/robot/Robot.java b/src/main/java/frc/robot/Robot.java index d8643be..1076050 100644 --- a/src/main/java/frc/robot/Robot.java +++ b/src/main/java/frc/robot/Robot.java @@ -8,11 +8,13 @@ import edu.wpi.first.wpilibj.command.Scheduler; import edu.wpi.first.wpilibj.smartdashboard.SmartDashboard; import frc.robot.commands.setCameraOne; +import frc.robot.commands.AutoCommands.FourBallTrench; import frc.robot.controller.DPadButton; import frc.robot.subsystems.*; import frc.robot.util.LedMode; import frc.robot.util.Camera_Switch.CameraSwitch; import frc.robot.OI.*; +import edu.wpi.first.wpilibj.DriverStation; import edu.wpi.first.wpilibj.Compressor; import edu.wpi.first.wpilibj.Joystick; @@ -28,6 +30,9 @@ public class Robot extends TimedRobot { long loopCounter = 0; + //m_ds = DriverStation.getInstance; + + public static Joystick pitStick; public static OI oi; public static Drivetrain drivetrain; @@ -123,9 +128,20 @@ public void disabledPeriodic() { // autoCommand.start(); } + @Override + public void autonomousInit(){ + // if(m_ds.isAutonomous()){ + // new FourBallTrench(); + // } + drivetrain.driveTime.start(); + } + @Override public void autonomousPeriodic() { Scheduler.getInstance().run(); + drivetrain.BackupAndShoot(); + + } @Override @@ -142,7 +158,7 @@ public void teleopInit() { manipulator.setRetracted(); Robot.hopper.hopper_stopper.set(true); - Robot.shooter.setHood1(false); + Robot.shooter.setHood1(true); } @@ -152,19 +168,19 @@ public void teleopPeriodic() { Scheduler.getInstance().run(); - // double kp = SmartDashboard.getNumber("Shooter kP", 0); - // double kf = SmartDashboard.getNumber("Shooter kF", 0); - // double kd = SmartDashboard.getNumber("Shooter kD", 0); - - // shooter.shooter_leader.getPIDController().setP(kp); - // shooter.shooter_leader.getPIDController().setFF(kf); - // shooter.shooter_leader.getPIDController().setD(kd); - - // double setpoint = SmartDashboard.getNumber("Shooter setpoint", 0); - // if (setpoint==0) - // shooter.setShooter(0); - // else - // shooter.setShooterPID(setpoint); + double kp = SmartDashboard.getNumber("Shooter kP", Constants.DrivekP); + double kf = SmartDashboard.getNumber("Shooter kF", Constants.DrivekFF); + double kd = SmartDashboard.getNumber("Shooter kD", Constants.DrivekD); + + shooter.shooter_leader.getPIDController().setP(kp); + shooter.shooter_leader.getPIDController().setFF(kf); + shooter.shooter_leader.getPIDController().setD(kd); + + double setpoint = SmartDashboard.getNumber("Shooter setpoint", 0); + if (setpoint==0) + shooter.setShooter(0); + else + shooter.setShooterPID(setpoint); } @Override public void testPeriodic() { diff --git a/src/main/java/frc/robot/commands/AutoCommands/FourBallTrench.java b/src/main/java/frc/robot/commands/AutoCommands/FourBallTrench.java index 122fcb8..d4f302e 100644 --- a/src/main/java/frc/robot/commands/AutoCommands/FourBallTrench.java +++ b/src/main/java/frc/robot/commands/AutoCommands/FourBallTrench.java @@ -34,6 +34,7 @@ protected void execute() { double output = pid.calculate(Robot.drivetrain.getAverageDistance()); Robot.drivetrain.setMotors(output, output); SmartDashboard.putBoolean("Drivetrain Distance Complete", false); + SmartDashboard.putNumber("Drivetrain Auto Output", output); } // Make this return true when this Command no longer needs to run execute() diff --git a/src/main/java/frc/robot/commands/Shooter/LongShot.java b/src/main/java/frc/robot/commands/Shooter/LongShot.java index 3030f28..9e1551b 100644 --- a/src/main/java/frc/robot/commands/Shooter/LongShot.java +++ b/src/main/java/frc/robot/commands/Shooter/LongShot.java @@ -30,6 +30,7 @@ protected void initialize() { @Override protected void execute() { Robot.shooter.setShooterPID(-2791); + //-3100 good for comp bot } diff --git a/src/main/java/frc/robot/subsystems/Drivetrain.java b/src/main/java/frc/robot/subsystems/Drivetrain.java index e52ba47..ffb1af2 100644 --- a/src/main/java/frc/robot/subsystems/Drivetrain.java +++ b/src/main/java/frc/robot/subsystems/Drivetrain.java @@ -7,10 +7,12 @@ import com.revrobotics.CANEncoder; import com.revrobotics.AlternateEncoderType; +import edu.wpi.first.wpilibj.Timer; import edu.wpi.first.wpilibj.command.Subsystem; import edu.wpi.first.wpilibj.smartdashboard.SmartDashboard; import frc.robot.Constants; +import frc.robot.Robot; import frc.robot.RobotMap; import frc.robot.util.Util; import frc.robot.util.Camera_Switch.*; @@ -25,6 +27,8 @@ public class Drivetrain extends Subsystem { private static final AlternateEncoderType kAltEncType = AlternateEncoderType.kQuadrature; private CANEncoder m_leftAlternateEncoder; private CANEncoder m_rightAlternateEncoder; + + public Timer driveTime; @@ -62,6 +66,7 @@ public Drivetrain() { rightFollowers[i].follow(rightLeader); } + driveTime = new Timer(); setBrakeMode(true); } @@ -107,11 +112,11 @@ public double getAverageDistance(){ } public double getDistanceLeft(){ - return Math.PI*Constants.wheelDiameterInches*getLeftCPR()/12; // returns distance in feet + return Math.PI*Constants.wheelDiameterInches*(getLeftCPR()/1024)/12; // returns distance in feet } public double getDistanceRight(){ - return Math.PI*Constants.wheelDiameterInches*getLeftCPR()/12; // returns distance in feet + return Math.PI*Constants.wheelDiameterInches*(getLeftCPR()/1024)/12; // returns distance in feet } public void setBrakeMode(boolean isbrake) { @@ -133,6 +138,61 @@ public void stopCompletely() { } + public void BackupAndShoot(){ + //driveTime.start(); + if(driveTime.get() < 1.85){ + setMotors(-0.5,-0.5); + Robot.shooter.setShooterPID(-3200); + } + if (driveTime.get() >= 1.85){ + Robot.shooter.setShooterPID(-3200); + Robot.shooter.setHood1(true); + Robot.hopper.setExtended(); + setMotors(0, 0); + if(driveTime.get() > 6.45){ + Robot.hopper.setHopper(Constants.HOPPER_AUTO_HORIZONTAL, Constants.HOPPER_AUTO_VERTICAL); + } + } + } + public void BackAndShoot2(){ + //driveTime.start(); + if(driveTime.get() < 1.5){ + setMotors(-0.5,-0.5); + Robot.shooter.setShooterPID(-2900); + } + if (driveTime.get() >= 1.5){ + Robot.shooter.setShooterPID(-2900); + Robot.shooter.setHood1(true); + Robot.hopper.setExtended(); + setMotors(0, 0); + if(driveTime.get() > 6.3){ + Robot.hopper.setHopper(Constants.HOPPER_AUTO_HORIZONTAL, Constants.HOPPER_AUTO_VERTICAL); + } + + } + + + + + } + public void BackAndShoot3(){ + //driveTime.start(); + if(driveTime.get() < 1.5){ + setMotors(-0.5,-0.5); + Robot.shooter.setShooterPID(-2900); + } + if (driveTime.get() >= 1.5){ + Robot.shooter.setShooterPID(-2900); + Robot.shooter.setHood1(true); + Robot.hopper.setExtended(); + setMotors(0, 0); + if(driveTime.get() > 6.3){ + Robot.hopper.setHopper(Constants.HOPPER_AUTO_HORIZONTAL, Constants.HOPPER_AUTO_VERTICAL); + } + } + } + + public void debug() { SmartDashboard.putNumber("Get Left Velocity", getLeftMotor()); SmartDashboard.putNumber("Get Right Velocity", getRightMotor()); @@ -140,6 +200,7 @@ public void debug() { SmartDashboard.putNumber("Get Left Position", getLeftPosition()); SmartDashboard.putNumber("Get Right CPR", getRightCPR()); SmartDashboard.putNumber("Get Left CPR", getLeftCPR()); + SmartDashboard.putNumber("Drivetimer", driveTime.get()); } } \ No newline at end of file From f33384eb70b68f1eefe55853fb2649720ef0eb4a Mon Sep 17 00:00:00 2001 From: xprt656 Date: Tue, 10 Mar 2020 18:23:07 -0400 Subject: [PATCH 63/68] Added Double Ir Hopper Code and Maybe the fifth ball Added double ir hopper code that should fit 4 with good spacing and stop when full as well as code for a fifth ball --times and functionaility need to be tested --- .../IntakeToHopper/DoubleBeamBreakHopper.java | 76 +++++++++++++++++++ .../commands/IntakeToHopper/FifthBall.java | 76 +++++++++++++++++++ 2 files changed, 152 insertions(+) create mode 100644 src/main/java/frc/robot/commands/IntakeToHopper/DoubleBeamBreakHopper.java create mode 100644 src/main/java/frc/robot/commands/IntakeToHopper/FifthBall.java diff --git a/src/main/java/frc/robot/commands/IntakeToHopper/DoubleBeamBreakHopper.java b/src/main/java/frc/robot/commands/IntakeToHopper/DoubleBeamBreakHopper.java new file mode 100644 index 0000000..a8c8a34 --- /dev/null +++ b/src/main/java/frc/robot/commands/IntakeToHopper/DoubleBeamBreakHopper.java @@ -0,0 +1,76 @@ +package frc.robot.commands.IntakeToHopper; + +import edu.wpi.first.wpilibj.command.Command; +import edu.wpi.first.wpilibj.smartdashboard.SmartDashboard; +import frc.robot.Constants; +import frc.robot.Robot; +import frc.robot.commands.IntakeToHopper.MoveManipulator; +import edu.wpi.first.wpilibj.Timer; + +public class DoubleBeamBreakHopper extends Command { + public int count; + private boolean timerStart = false; + public Timer timer = new Timer(); + public DoubleBeamBreakHopper() { + super("DoubleBeamBreakHopper"); + requires(Robot.hopper); + + } + + // Called just before this Command runs the first time + @Override + protected void initialize() { + // count = 0; + } + + // Called repeatedly when this Command is scheduled to run + @Override + protected void execute() { + + SmartDashboard.putBoolean("Beam Break Hopper Running", true); + if(!Robot.hopper.beamBreak1.get()){ + timer.start(); + Robot.hopper.setHopper(Constants.HOPPER_LOADING_HORIZONTAL_OUTPUT, + Constants.HOPPER_LOADING_VERTICAL_OUTPUT); + timerStart = true; + } + if(timerStart){ + if (timer.get()>=Constants.kHopperTimer){ + timer.stop(); + timer.reset(); + Robot.hopper.setHopper(0,0); + } + } + + } + + // Make this return true when this Command no longer needs to run execute() + @Override + + protected boolean isFinished() { + // if (Robot.hopper.isHopperFull()==true){ + // return true; + // } + // else{ + // return false; + // } + return Robot.hopper.isUpperSensorTripped(); + + } + + // Called once after isFinished returns true + @Override + protected void end() { + // count++; + Robot.hopper.setHopper(0, 0); + SmartDashboard.putBoolean("Ir Hopper Running", false); + // Robot.hopper.counter.reset(); + } + + // Called when another command which requires one or more of the same + // subsystems is scheduled to run + @Override + protected void interrupted() { + } + +} diff --git a/src/main/java/frc/robot/commands/IntakeToHopper/FifthBall.java b/src/main/java/frc/robot/commands/IntakeToHopper/FifthBall.java new file mode 100644 index 0000000..95c9260 --- /dev/null +++ b/src/main/java/frc/robot/commands/IntakeToHopper/FifthBall.java @@ -0,0 +1,76 @@ +package frc.robot.commands.IntakeToHopper; + +import edu.wpi.first.wpilibj.command.Command; +import edu.wpi.first.wpilibj.smartdashboard.SmartDashboard; +import frc.robot.Constants; +import frc.robot.Robot; +import frc.robot.commands.IntakeToHopper.MoveManipulator; +import edu.wpi.first.wpilibj.Timer; + +public class FifthBall extends Command { + public Timer timer = new Timer(); + public boolean HopperSet = false; + private boolean timerStart = true; + public FifthBall() { + super("FifthBall"); + requires(Robot.hopper); + + } + + // Called just before this Command runs the first time + @Override + protected void initialize() { + + } + + // Called repeatedly when this Command is scheduled to run + @Override + protected void execute() { + if(Robot.hopper.beamBreak1.get()){ + HopperSet = true; + } + + SmartDashboard.putBoolean("Beam Break Hopper Running", true); + if (HopperSet && !Robot.hopper.beamBreak1.get()){ + if(timerStart){ + timer.start(); + timerStart = false; + } + Robot.hopper.setHopper(Constants.HOPPER_LOADING_HORIZONTAL_OUTPUT, Constants.HOPPER_LOADING_VERTICAL_OUTPUT); + } + + if(timer.get()>=Constants.kHopperTimerBeams){ + Robot.hopper.setHopper(0,0); + } + + } + + // Make this return true when this Command no longer needs to run execute() + @Override + + protected boolean isFinished() { + // if (Robot.hopper.isHopperFull()==true){ + // return true; + // } + // else{ + // return false; + // } + return false; + } + + // Called once after isFinished returns true + @Override + protected void end() { + // count++; + Robot.hopper.setHopper(0, 0); + SmartDashboard.putBoolean("Ir Hopper Running", false); + // Robot.hopper.counter.reset(); + } + + // Called when another command which requires one or more of the same + // subsystems is scheduled to run + @Override + protected void interrupted() { + } + +} From 011313ce17deead16ddb696fe410bd8559272909 Mon Sep 17 00:00:00 2001 From: xprt656 Date: Tue, 10 Mar 2020 18:33:18 -0400 Subject: [PATCH 64/68] Fixed Double Beam Break Hopper to use Two Sensors --- .../IntakeToHopper/DoubleBeamBreakHopper.java | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) diff --git a/src/main/java/frc/robot/commands/IntakeToHopper/DoubleBeamBreakHopper.java b/src/main/java/frc/robot/commands/IntakeToHopper/DoubleBeamBreakHopper.java index a8c8a34..e8e5f1d 100644 --- a/src/main/java/frc/robot/commands/IntakeToHopper/DoubleBeamBreakHopper.java +++ b/src/main/java/frc/robot/commands/IntakeToHopper/DoubleBeamBreakHopper.java @@ -8,19 +8,15 @@ import edu.wpi.first.wpilibj.Timer; public class DoubleBeamBreakHopper extends Command { - public int count; - private boolean timerStart = false; - public Timer timer = new Timer(); + public boolean firstBeamBroken = false; public DoubleBeamBreakHopper() { super("DoubleBeamBreakHopper"); requires(Robot.hopper); - } // Called just before this Command runs the first time @Override protected void initialize() { - // count = 0; } // Called repeatedly when this Command is scheduled to run @@ -29,17 +25,13 @@ protected void execute() { SmartDashboard.putBoolean("Beam Break Hopper Running", true); if(!Robot.hopper.beamBreak1.get()){ - timer.start(); Robot.hopper.setHopper(Constants.HOPPER_LOADING_HORIZONTAL_OUTPUT, Constants.HOPPER_LOADING_VERTICAL_OUTPUT); - timerStart = true; + firstBeamBroken = true; } - if(timerStart){ - if (timer.get()>=Constants.kHopperTimer){ - timer.stop(); - timer.reset(); + if(!Robot.hopper.beamBreak2.get() && firstBeamBroken){ Robot.hopper.setHopper(0,0); - } + firstBeamBroken = false; } } From cf4f93b377d918e2715812fd8606af1a31bfb950 Mon Sep 17 00:00:00 2001 From: Chris Lane <54559326+chrisLane279@users.noreply.github.com> Date: Wed, 11 Mar 2020 07:23:14 -0400 Subject: [PATCH 65/68] Added another autonomus (I used math) --- build.gradle | 2 +- .../java/frc/robot/subsystems/Drivetrain.java | 24 +++++++++++++++++++ 2 files changed, 25 insertions(+), 1 deletion(-) diff --git a/build.gradle b/build.gradle index becc3d0..9eb9d8f 100644 --- a/build.gradle +++ b/build.gradle @@ -1,6 +1,6 @@ plugins { id "java" - id "edu.wpi.first.GradleRIO" version "2020.2.2" + id "edu.wpi.first.GradleRIO" version "2020.3.2" } sourceCompatibility = JavaVersion.VERSION_11 diff --git a/src/main/java/frc/robot/subsystems/Drivetrain.java b/src/main/java/frc/robot/subsystems/Drivetrain.java index ffb1af2..1f9ba0b 100644 --- a/src/main/java/frc/robot/subsystems/Drivetrain.java +++ b/src/main/java/frc/robot/subsystems/Drivetrain.java @@ -139,6 +139,7 @@ public void stopCompletely() { public void BackupAndShoot(){ + SmartDashboard.putString("AUTO_LOADED", "BackupAndShoot"); //driveTime.start(); if(driveTime.get() < 1.85){ setMotors(-0.5,-0.5); @@ -155,6 +156,7 @@ public void BackupAndShoot(){ } } public void BackAndShoot2(){ + SmartDashboard.putString("AUTO_LOADED", "BackAndShoot2"); //driveTime.start(); if(driveTime.get() < 1.5){ setMotors(-0.5,-0.5); @@ -176,6 +178,7 @@ public void BackAndShoot2(){ } public void BackAndShoot3(){ + SmartDashboard.putString("AUTO_LOADED", "BackAndShoot3"); //driveTime.start(); if(driveTime.get() < 1.5){ setMotors(-0.5,-0.5); @@ -193,6 +196,27 @@ public void BackAndShoot3(){ } + + public void driveBackAndShoot_angled(){ + SmartDashboard.putString("AUTO_LOADED", "DriveBackAndShoot_angled"); + if(driveTime.get() < 2.25){ + setMotors(-0.5,-0.5); + Robot.shooter.setShooterPID(-2900); + } + if (driveTime.get() >= 2.25){ + setMotors(0, 0); + Robot.shooter.setShooterPID(-2900); + Robot.shooter.setHood1(true); + Robot.hopper.setExtended(); + if(driveTime.get() > 6.3){ + Robot.hopper.setHopper(Constants.HOPPER_AUTO_HORIZONTAL, Constants.HOPPER_AUTO_VERTICAL); + } + + } + + } + + public void debug() { SmartDashboard.putNumber("Get Left Velocity", getLeftMotor()); SmartDashboard.putNumber("Get Right Velocity", getRightMotor()); From b8fb482695e33059eaa1e2c4bd673feeb1f6e36e Mon Sep 17 00:00:00 2001 From: Chris Lane <54559326+chrisLane279@users.noreply.github.com> Date: Wed, 11 Mar 2020 07:38:41 -0400 Subject: [PATCH 66/68] Stopped auto timer in teleop init --- src/main/java/frc/robot/Robot.java | 1 + 1 file changed, 1 insertion(+) diff --git a/src/main/java/frc/robot/Robot.java b/src/main/java/frc/robot/Robot.java index 1076050..4872f67 100644 --- a/src/main/java/frc/robot/Robot.java +++ b/src/main/java/frc/robot/Robot.java @@ -148,6 +148,7 @@ public void autonomousPeriodic() { public void teleopInit() { // autoCommand.cancel(); compressor.start(); + drivetrain.driveTime.stop(); System.out.println("This is init"); From 75c577c8363e3b237bfc5f039f3c585595030457 Mon Sep 17 00:00:00 2001 From: Chris Lane <54559326+chrisLane279@users.noreply.github.com> Date: Wed, 11 Mar 2020 12:25:54 -0400 Subject: [PATCH 67/68] Added comments for auto placement in pits --- src/main/java/frc/robot/Robot.java | 11 +++++++---- src/main/java/frc/robot/subsystems/Drivetrain.java | 1 + 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/src/main/java/frc/robot/Robot.java b/src/main/java/frc/robot/Robot.java index 4872f67..43d4116 100644 --- a/src/main/java/frc/robot/Robot.java +++ b/src/main/java/frc/robot/Robot.java @@ -130,17 +130,20 @@ public void disabledPeriodic() { @Override public void autonomousInit(){ - // if(m_ds.isAutonomous()){ - // new FourBallTrench(); - // } drivetrain.driveTime.start(); + + //LOAD COMMAND BASED AUTO HERE + + /*******************************/ } @Override public void autonomousPeriodic() { Scheduler.getInstance().run(); - drivetrain.BackupAndShoot(); + //LOAD ITERATIVE BASED AUTO HERE + drivetrain.BackupAndShoot(); + /*******************************/ } diff --git a/src/main/java/frc/robot/subsystems/Drivetrain.java b/src/main/java/frc/robot/subsystems/Drivetrain.java index 1f9ba0b..6c9ef68 100644 --- a/src/main/java/frc/robot/subsystems/Drivetrain.java +++ b/src/main/java/frc/robot/subsystems/Drivetrain.java @@ -199,6 +199,7 @@ public void BackAndShoot3(){ public void driveBackAndShoot_angled(){ SmartDashboard.putString("AUTO_LOADED", "DriveBackAndShoot_angled"); + if(driveTime.get() < 2.25){ setMotors(-0.5,-0.5); Robot.shooter.setShooterPID(-2900); From 526e0286c5bb273445e79152803fbe5bda94aa0a Mon Sep 17 00:00:00 2001 From: Chris Lane <54559326+chrisLane279@users.noreply.github.com> Date: Wed, 11 Mar 2020 12:32:21 -0400 Subject: [PATCH 68/68] removed a ton of unused imports --- src/main/java/frc/robot/Constants.java | 1 - src/main/java/frc/robot/Robot.java | 14 ++------------ src/main/java/frc/robot/RobotMap.java | 2 +- .../frc/robot/commands/DrivetrainBackwards.java | 1 - .../java/frc/robot/commands/StopDrivetrain.java | 1 - src/main/java/frc/robot/subsystems/Climber.java | 2 -- src/main/java/frc/robot/subsystems/Drivetrain.java | 2 +- src/main/java/frc/robot/subsystems/Elevator.java | 9 --------- src/main/java/frc/robot/subsystems/PanelMech.java | 9 +-------- 9 files changed, 5 insertions(+), 36 deletions(-) diff --git a/src/main/java/frc/robot/Constants.java b/src/main/java/frc/robot/Constants.java index 878b601..1d1ecc3 100644 --- a/src/main/java/frc/robot/Constants.java +++ b/src/main/java/frc/robot/Constants.java @@ -1,6 +1,5 @@ package frc.robot; -import edu.wpi.first.wpilibj.Timer; public final class Constants { public static final boolean debugMode = false; diff --git a/src/main/java/frc/robot/Robot.java b/src/main/java/frc/robot/Robot.java index 43d4116..35a18ba 100644 --- a/src/main/java/frc/robot/Robot.java +++ b/src/main/java/frc/robot/Robot.java @@ -2,27 +2,17 @@ import edu.wpi.first.wpilibj.PowerDistributionPanel; import edu.wpi.first.wpilibj.TimedRobot; -import edu.wpi.first.wpilibj.Relay.Value; import edu.wpi.first.wpilibj.buttons.Button; -import edu.wpi.first.wpilibj.buttons.JoystickButton; import edu.wpi.first.wpilibj.command.Scheduler; import edu.wpi.first.wpilibj.smartdashboard.SmartDashboard; -import frc.robot.commands.setCameraOne; -import frc.robot.commands.AutoCommands.FourBallTrench; import frc.robot.controller.DPadButton; import frc.robot.subsystems.*; -import frc.robot.util.LedMode; import frc.robot.util.Camera_Switch.CameraSwitch; -import frc.robot.OI.*; -import edu.wpi.first.wpilibj.DriverStation; - import edu.wpi.first.wpilibj.Compressor; import edu.wpi.first.wpilibj.Joystick; - import edu.wpi.first.cameraserver.CameraServer; - import frc.robot.subsystems.Climber; -import frc.robot.subsystems.*; + @@ -30,7 +20,7 @@ public class Robot extends TimedRobot { long loopCounter = 0; - //m_ds = DriverStation.getInstance; + public static Joystick pitStick; diff --git a/src/main/java/frc/robot/RobotMap.java b/src/main/java/frc/robot/RobotMap.java index e1d59db..bd8bb7f 100644 --- a/src/main/java/frc/robot/RobotMap.java +++ b/src/main/java/frc/robot/RobotMap.java @@ -7,7 +7,7 @@ package frc.robot; -import edu.wpi.first.wpilibj.DigitalOutput; + /** * The RobotMap is a mapping from the ports sensors and actuators are wired into diff --git a/src/main/java/frc/robot/commands/DrivetrainBackwards.java b/src/main/java/frc/robot/commands/DrivetrainBackwards.java index af099eb..cd50d33 100644 --- a/src/main/java/frc/robot/commands/DrivetrainBackwards.java +++ b/src/main/java/frc/robot/commands/DrivetrainBackwards.java @@ -2,7 +2,6 @@ import edu.wpi.first.wpilibj.Joystick; import edu.wpi.first.wpilibj.command.Command; -import frc.robot.Constants; import frc.robot.Robot; public class DrivetrainBackwards extends Command { diff --git a/src/main/java/frc/robot/commands/StopDrivetrain.java b/src/main/java/frc/robot/commands/StopDrivetrain.java index 4dfc545..f4d0066 100644 --- a/src/main/java/frc/robot/commands/StopDrivetrain.java +++ b/src/main/java/frc/robot/commands/StopDrivetrain.java @@ -8,7 +8,6 @@ package frc.robot.commands; import edu.wpi.first.wpilibj.command.Command; -import frc.robot.Constants; import frc.robot.Robot; public class StopDrivetrain extends Command { diff --git a/src/main/java/frc/robot/subsystems/Climber.java b/src/main/java/frc/robot/subsystems/Climber.java index f27c3a5..0f576b8 100644 --- a/src/main/java/frc/robot/subsystems/Climber.java +++ b/src/main/java/frc/robot/subsystems/Climber.java @@ -19,8 +19,6 @@ import edu.wpi.first.wpilibj.buttons.Button; import edu.wpi.first.wpilibj.GyroBase; import edu.wpi.first.wpilibj.Joystick; -import frc.robot.commands.*; -import edu.wpi.first.wpilibj.buttons.JoystickButton; public class Climber extends Subsystem { private CANSparkMax winch_Neo; diff --git a/src/main/java/frc/robot/subsystems/Drivetrain.java b/src/main/java/frc/robot/subsystems/Drivetrain.java index 6c9ef68..1bdbd8f 100644 --- a/src/main/java/frc/robot/subsystems/Drivetrain.java +++ b/src/main/java/frc/robot/subsystems/Drivetrain.java @@ -15,7 +15,7 @@ import frc.robot.Robot; import frc.robot.RobotMap; import frc.robot.util.Util; -import frc.robot.util.Camera_Switch.*; + public class Drivetrain extends Subsystem { diff --git a/src/main/java/frc/robot/subsystems/Elevator.java b/src/main/java/frc/robot/subsystems/Elevator.java index f882f0d..9d375e6 100644 --- a/src/main/java/frc/robot/subsystems/Elevator.java +++ b/src/main/java/frc/robot/subsystems/Elevator.java @@ -6,22 +6,13 @@ /*----------------------------------------------------------------------------*/ package frc.robot.subsystems; -import com.revrobotics.CANSparkMax; -import com.revrobotics.CANSparkMaxLowLevel.MotorType; import com.ctre.phoenix.motorcontrol.ControlMode; import com.ctre.phoenix.motorcontrol.can.TalonSRX; - - import edu.wpi.first.wpilibj.command.Subsystem; import edu.wpi.first.wpilibj.smartdashboard.SmartDashboard; - -import frc.robot.Constants; import frc.robot.RobotMap; -import frc.robot.util.Util; -import edu.wpi.first.wpilibj.command.Subsystem; - /** * Add your docs here. */ diff --git a/src/main/java/frc/robot/subsystems/PanelMech.java b/src/main/java/frc/robot/subsystems/PanelMech.java index 0e54cc0..d56cdc2 100644 --- a/src/main/java/frc/robot/subsystems/PanelMech.java +++ b/src/main/java/frc/robot/subsystems/PanelMech.java @@ -1,18 +1,11 @@ package frc.robot.subsystems; import com.revrobotics.CANSparkMax; import com.revrobotics.CANSparkMaxLowLevel.MotorType; -import com.ctre.phoenix.motorcontrol.ControlMode; -import com.ctre.phoenix.motorcontrol.can.TalonSRX; - import edu.wpi.first.wpilibj.Solenoid; import edu.wpi.first.wpilibj.command.Subsystem; -import edu.wpi.first.wpilibj.smartdashboard.SmartDashboard; - import frc.robot.Constants; import frc.robot.RobotMap; -// import frc.robot.commands.MoveShooter; -// import frc.robot.commands.MoveShooterPassive; -import frc.robot.util.Util; + /** * Add your docs here.