From a69a79a72ea76ada4a373138878f62054935542e Mon Sep 17 00:00:00 2001 From: Connor_H Date: Thu, 20 Feb 2020 09:20:28 -0500 Subject: [PATCH 1/5] Added CP Mech --- src/main/java/frc/robot/Constants.java | 6 +- src/main/java/frc/robot/OI.java | 3 + src/main/java/frc/robot/Robot.java | 1 + src/main/java/frc/robot/RobotMap.java | 4 +- .../frc/robot/commands/DefaultPanelMech.java | 50 ++++++++++++++ .../frc/robot/commands/ExtendPanelMech.java | 50 ++++++++++++++ .../java/frc/robot/commands/SetPanelMech.java | 65 +++++++++++++++++++ .../java/frc/robot/subsystems/PanelMech.java | 12 +++- 8 files changed, 186 insertions(+), 5 deletions(-) create mode 100644 src/main/java/frc/robot/commands/DefaultPanelMech.java create mode 100644 src/main/java/frc/robot/commands/ExtendPanelMech.java create mode 100644 src/main/java/frc/robot/commands/SetPanelMech.java diff --git a/src/main/java/frc/robot/Constants.java b/src/main/java/frc/robot/Constants.java index 7b4f412..17dfc0f 100644 --- a/src/main/java/frc/robot/Constants.java +++ b/src/main/java/frc/robot/Constants.java @@ -97,5 +97,9 @@ 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 = 2050; + + //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/OI.java b/src/main/java/frc/robot/OI.java index f392812..1ee6d0d 100644 --- a/src/main/java/frc/robot/OI.java +++ b/src/main/java/frc/robot/OI.java @@ -94,6 +94,9 @@ public OI() { driverX.whenReleased(new StopHopper()); driverB.whenPressed(new OpenHopperPiston()); driverB.whenReleased(new CloseHopperPiston()); + operatorA.toggleWhenPressed(new ExtendPanelMech()); + operatorB.whileHeld(new SetPanelMech()); + // driverRB.whenPressed(new ShooterGroupWall()); // driverRB.whenReleased(new StopShooterGroupWall()); // driverLB.whenPressed(new ShooterGroupLong()); diff --git a/src/main/java/frc/robot/Robot.java b/src/main/java/frc/robot/Robot.java index fda2b89..29c4394 100644 --- a/src/main/java/frc/robot/Robot.java +++ b/src/main/java/frc/robot/Robot.java @@ -29,6 +29,7 @@ public class Robot extends TimedRobot { // public static PanelMech panelMech; public static CameraServer Cam; public static CameraSwitch Cam_switch; + public static PanelMech panelMech; @Override public void robotInit() { diff --git a/src/main/java/frc/robot/RobotMap.java b/src/main/java/frc/robot/RobotMap.java index 63df49a..79956e5 100644 --- a/src/main/java/frc/robot/RobotMap.java +++ b/src/main/java/frc/robot/RobotMap.java @@ -95,5 +95,7 @@ public class RobotMap { public static final int MANIPULATOR_SOLENOID = 6; public static final int MANIPULATOR_NEO = 40; public static final int MECHNECK = 50; - +//PanelMech +public static final int PANEL_NEO=50; +public static final int PANEL_SOLENOID=2; } diff --git a/src/main/java/frc/robot/commands/DefaultPanelMech.java b/src/main/java/frc/robot/commands/DefaultPanelMech.java new file mode 100644 index 0000000..5c31068 --- /dev/null +++ b/src/main/java/frc/robot/commands/DefaultPanelMech.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 frc.robot.Robot; +import edu.wpi.first.wpilibj.command.Command; + + +public class DefaultPanelMech extends Command { + public DefaultPanelMech() { + super("DefaultPanelMech"); + + 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); + + } + + // 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() { + } +} \ No newline at end of file diff --git a/src/main/java/frc/robot/commands/ExtendPanelMech.java b/src/main/java/frc/robot/commands/ExtendPanelMech.java new file mode 100644 index 0000000..782dbf5 --- /dev/null +++ b/src/main/java/frc/robot/commands/ExtendPanelMech.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 frc.robot.Robot; +import edu.wpi.first.wpilibj.command.Command; + + +public class ExtendPanelMech extends Command { + public ExtendPanelMech() { + super("ExtendPanelMech"); + + 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); + + } + + // 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() { + } +} \ 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 new file mode 100644 index 0000000..de526b4 --- /dev/null +++ b/src/main/java/frc/robot/commands/SetPanelMech.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.commands; +import frc.robot.Robot; + +import edu.wpi.first.wpilibj.command.Command; +import frc.robot.Constants; + +public class SetPanelMech extends Command { + int x=1; + 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() { + x++; + if(x==3){ + x=1; + } + } + + // Called repeatedly when this Command is scheduled to run + @Override + protected void execute() { + if(x==1){ + Robot.panelMech.setPanelMech(Constants.PANEL_MECH_FAST); + } + else{ + 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() { + } + + // 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/PanelMech.java b/src/main/java/frc/robot/subsystems/PanelMech.java index 0179ab3..a73acf2 100644 --- a/src/main/java/frc/robot/subsystems/PanelMech.java +++ b/src/main/java/frc/robot/subsystems/PanelMech.java @@ -30,11 +30,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 +48,4 @@ protected void initDefaultCommand() { public void debug() { } -} +} \ No newline at end of file From 12e7d4c0eaafb74db469d78c15ebf364d1e54d59 Mon Sep 17 00:00:00 2001 From: Connor_H Date: Thu, 20 Feb 2020 09:48:44 -0500 Subject: [PATCH 2/5] fixed a couple cp thigs --- src/main/java/frc/robot/Constants.java | 1 + src/main/java/frc/robot/commands/DefaultPanelMech.java | 2 +- src/main/java/frc/robot/commands/ExtendPanelMech.java | 1 + src/main/java/frc/robot/commands/SetPanelMech.java | 9 ++++----- 4 files changed, 7 insertions(+), 6 deletions(-) diff --git a/src/main/java/frc/robot/Constants.java b/src/main/java/frc/robot/Constants.java index 17dfc0f..4bfdd04 100644 --- a/src/main/java/frc/robot/Constants.java +++ b/src/main/java/frc/robot/Constants.java @@ -102,4 +102,5 @@ 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 int PanelNum=1; } \ No newline at end of file diff --git a/src/main/java/frc/robot/commands/DefaultPanelMech.java b/src/main/java/frc/robot/commands/DefaultPanelMech.java index 5c31068..b814b4f 100644 --- a/src/main/java/frc/robot/commands/DefaultPanelMech.java +++ b/src/main/java/frc/robot/commands/DefaultPanelMech.java @@ -27,7 +27,7 @@ protected void initialize() { // Called repeatedly when this Command is scheduled to run @Override protected void execute() { - Robot.panelMech.extendPanelMech(true); + Robot.panelMech.extendPanelMech(false); } diff --git a/src/main/java/frc/robot/commands/ExtendPanelMech.java b/src/main/java/frc/robot/commands/ExtendPanelMech.java index 782dbf5..f6a7640 100644 --- a/src/main/java/frc/robot/commands/ExtendPanelMech.java +++ b/src/main/java/frc/robot/commands/ExtendPanelMech.java @@ -40,6 +40,7 @@ protected boolean isFinished() { // Called once after isFinished returns true @Override protected void end() { + Robot.panelMech.extendPanelMech(false); } // Called when another command which requires one or more of the same diff --git a/src/main/java/frc/robot/commands/SetPanelMech.java b/src/main/java/frc/robot/commands/SetPanelMech.java index de526b4..69fedc6 100644 --- a/src/main/java/frc/robot/commands/SetPanelMech.java +++ b/src/main/java/frc/robot/commands/SetPanelMech.java @@ -12,7 +12,6 @@ import frc.robot.Constants; public class SetPanelMech extends Command { - int x=1; public SetPanelMech() { super("SetPanelMech"); @@ -25,16 +24,16 @@ public SetPanelMech() { // Called just before this Command runs the first time @Override protected void initialize() { - x++; - if(x==3){ - x=1; + Constants.PanelNum++; + if(Constants.PanelNum==3){ + Constants.PanelNum=1; } } // Called repeatedly when this Command is scheduled to run @Override protected void execute() { - if(x==1){ + if(Constants.PanelNum==1){ Robot.panelMech.setPanelMech(Constants.PANEL_MECH_FAST); } else{ From c3ffd290f6f78426949d288fb8fe0053ecb0d159 Mon Sep 17 00:00:00 2001 From: fidgetspinnerkid <35818373+fidgetspinnerkid@users.noreply.github.com> Date: Thu, 20 Feb 2020 08:49:06 -0800 Subject: [PATCH 3/5] changed to fit errors --- src/main/java/frc/robot/OI.java | 77 ++++++++++--------- src/main/java/frc/robot/Robot.java | 2 + .../frc/robot/commands/DefaultPanelMech.java | 2 +- .../frc/robot/commands/ExtendPanelMech.java | 2 +- .../java/frc/robot/commands/SetPanelMech.java | 7 +- .../frc/robot/commands/StopPanelMech.java | 50 ++++++++++++ .../java/frc/robot/subsystems/PanelMech.java | 16 +++- .../util/Camera_Switch/CameraSwitch.java | 6 +- 8 files changed, 115 insertions(+), 47 deletions(-) create mode 100644 src/main/java/frc/robot/commands/StopPanelMech.java diff --git a/src/main/java/frc/robot/OI.java b/src/main/java/frc/robot/OI.java index 1ee6d0d..5d074d8 100644 --- a/src/main/java/frc/robot/OI.java +++ b/src/main/java/frc/robot/OI.java @@ -3,7 +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.Command; import frc.robot.commands.*; import frc.robot.commands.Shooter.StopShooter; import frc.robot.commands.Shooter.CloseHopperPiston; @@ -24,29 +24,29 @@ // import frc.robot.commands.CargoManipulator.ScoreInRocketCalculated; // import frc.robot.commands.CargoManipulator.ScoreInRocketDropper; // import frc.robot.commands.auto.AutoSetLifterPots; - // _____ - // | | - // | | | | - // |_____| - // ____ ___|_|___ ____ - // ()___) ()___) - // // /| |\ \\ - // // / | | \ \\ - // (___) |___________| (___) - // (___) (_______) (___) - // (___) (___) (___) - // (___) |_| (___) - // (___) ___/___\___ | | - // | | | | | | - // | | |___________| /___\ - // /___\ ||| ||| // \\ - // // \\ ||| ||| \\ // - // \\ // ||| ||| \\ // - // \\ // ()__) (__() - // /// \\\ - // /// \\\ - // _///___ ___\\\_ - // |_______| |_______| +// _____ +// | | +// | | | | +// |_____| +// ____ ___|_|___ ____ +// ()___) ()___) +// // /| |\ \\ +// // / | | \ \\ +// (___) |___________| (___) +// (___) (_______) (___) +// (___) (___) (___) +// (___) |_| (___) +// (___) ___/___\___ | | +// | | | | | | +// | | |___________| /___\ +// /___\ ||| ||| // \\ +// // \\ ||| ||| \\ // +// \\ // ||| ||| \\ // +// \\ // ()__) (__() +// /// \\\ +// /// \\\ +// _///___ ___\\\_ +// |_______| |_______| public class OI { public static Joystick driverStick; @@ -64,19 +64,22 @@ public class OI { private Button driverRX; protected Button operatorLeftJoystickUsed, operatorRightJoystickUsed, operatorDPadDown, operatorDPadLeft; private Button operatorA, operatorB, operatorX, operatorY; + public OI() { driverStick = new Joystick(0); operatorStick = new Joystick(1); initButtons(); 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)); + 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)); + // 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()); @@ -94,8 +97,10 @@ public OI() { driverX.whenReleased(new StopHopper()); driverB.whenPressed(new OpenHopperPiston()); driverB.whenReleased(new CloseHopperPiston()); - operatorA.toggleWhenPressed(new ExtendPanelMech()); - operatorB.whileHeld(new SetPanelMech()); + operatorA.whenPressed(new ExtendPanelMech()); + operatorA.whenReleased(new DefaultPanelMech()); + operatorB.whenPressed(new SetPanelMech()); + operatorB.whenReleased(new StopPanelMech()); // driverRB.whenPressed(new ShooterGroupWall()); // driverRB.whenReleased(new StopShooterGroupWall()); @@ -103,10 +108,10 @@ public OI() { // 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()); + // 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 29c4394..bd21e4f 100644 --- a/src/main/java/frc/robot/Robot.java +++ b/src/main/java/frc/robot/Robot.java @@ -82,6 +82,7 @@ public void teleopInit() { // autoCommand.cancel(); compressor.start(); System.out.println("This is init"); + } @@ -99,6 +100,7 @@ public void teleopPeriodic() { // 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 + Cam_switch.select(CameraSwitch.kcamera1); Scheduler.getInstance().run(); } @Override diff --git a/src/main/java/frc/robot/commands/DefaultPanelMech.java b/src/main/java/frc/robot/commands/DefaultPanelMech.java index b814b4f..2c362f1 100644 --- a/src/main/java/frc/robot/commands/DefaultPanelMech.java +++ b/src/main/java/frc/robot/commands/DefaultPanelMech.java @@ -14,7 +14,7 @@ public class DefaultPanelMech extends Command { public DefaultPanelMech() { super("DefaultPanelMech"); - requires(Robot.panelMech); + //requires(Robot.panelMech); // Use requires() here to declare subsystem dependencies // eg. requires(chassis); } diff --git a/src/main/java/frc/robot/commands/ExtendPanelMech.java b/src/main/java/frc/robot/commands/ExtendPanelMech.java index f6a7640..149f126 100644 --- a/src/main/java/frc/robot/commands/ExtendPanelMech.java +++ b/src/main/java/frc/robot/commands/ExtendPanelMech.java @@ -14,7 +14,7 @@ public class ExtendPanelMech extends Command { public ExtendPanelMech() { super("ExtendPanelMech"); - requires(Robot.panelMech); + //requires(Robot.panelMech); // Use requires() here to declare subsystem dependencies // eg. requires(chassis); } diff --git a/src/main/java/frc/robot/commands/SetPanelMech.java b/src/main/java/frc/robot/commands/SetPanelMech.java index 69fedc6..5ba81d1 100644 --- a/src/main/java/frc/robot/commands/SetPanelMech.java +++ b/src/main/java/frc/robot/commands/SetPanelMech.java @@ -15,7 +15,7 @@ public class SetPanelMech extends Command { public SetPanelMech() { super("SetPanelMech"); - requires(Robot.panelMech); + //requires(Robot.panelMech); // Use requires() here to declare subsystem dependencies // eg. requires(chassis); @@ -34,10 +34,10 @@ protected void initialize() { @Override protected void execute() { if(Constants.PanelNum==1){ - Robot.panelMech.setPanelMech(Constants.PANEL_MECH_FAST); + Robot.panelMech.setPanelMech(Constants.PANEL_MECH_FAST); } else{ - Robot.panelMech.setPanelMech(Constants.PANEL_MECH_CREEP); + Robot.panelMech.setPanelMech(Constants.PANEL_MECH_CREEP); } @@ -54,6 +54,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/StopPanelMech.java b/src/main/java/frc/robot/commands/StopPanelMech.java new file mode 100644 index 0000000..5a75c6f --- /dev/null +++ b/src/main/java/frc/robot/commands/StopPanelMech.java @@ -0,0 +1,50 @@ +package frc.robot.commands; +import frc.robot.Robot; + +import edu.wpi.first.wpilibj.command.Command; +import frc.robot.Constants; + +public class StopPanelMech extends Command { + public StopPanelMech() { + super("StopPanelMech"); + + //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); + + + } + + + + // 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() { + } +} \ 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 a73acf2..7e2a13f 100644 --- a/src/main/java/frc/robot/subsystems/PanelMech.java +++ b/src/main/java/frc/robot/subsystems/PanelMech.java @@ -26,22 +26,32 @@ */ public class PanelMech extends Subsystem { private CANSparkMax panelMech_motor; - private Solenoid panelMech_soleinoid; + private Solenoid panelMech_solenoid; //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); + panelMech_solenoid= 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); + panelMech_solenoid.set(extend); + } + @Override + + // public boolean getRetracted(){ + // return panelMech_solenoid.get(); + // } + protected void initDefaultCommand() { } 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..31c0266 100644 --- a/src/main/java/frc/robot/util/Camera_Switch/CameraSwitch.java +++ b/src/main/java/frc/robot/util/Camera_Switch/CameraSwitch.java @@ -54,12 +54,12 @@ public void select(int camSelected){ switch (camSelected) { case kcamera1 : - // camrelay1.set(Value.kReverse); - // camrelay.set(Value.kForward); + camrelay1.set(Value.kReverse); + //camrelay.set(Value.kForward); break; case kcamera2 : - // camrelay1.set(Value.kForward); + camrelay1.set(Value.kForward); break; case kcamera3 : From de6fe31d4eaa2da8d49627d1cfbe13b356273d3f Mon Sep 17 00:00:00 2001 From: fidgetspinnerkid <35818373+fidgetspinnerkid@users.noreply.github.com> Date: Thu, 20 Feb 2020 10:39:14 -0800 Subject: [PATCH 4/5] CP Stuff --- src/main/java/frc/robot/Constants.java | 3 ++- src/main/java/frc/robot/OI.java | 14 +++++------- src/main/java/frc/robot/Robot.java | 2 +- .../frc/robot/commands/DefaultPanelMech.java | 9 +------- .../frc/robot/commands/ExtendPanelMech.java | 20 ++++++++++------- .../java/frc/robot/commands/SetPanelMech.java | 16 +++++--------- .../frc/robot/commands/StopPanelMech.java | 2 +- .../java/frc/robot/subsystems/PanelMech.java | 22 ++++++------------- .../java/frc/robot/subsystems/Shooter.java | 10 ++++++++- 9 files changed, 45 insertions(+), 53 deletions(-) diff --git a/src/main/java/frc/robot/Constants.java b/src/main/java/frc/robot/Constants.java index 4bfdd04..cf61975 100644 --- a/src/main/java/frc/robot/Constants.java +++ b/src/main/java/frc/robot/Constants.java @@ -102,5 +102,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 int PanelNum=1; + public static int PanelNum=2; + public static int SpinNum=0; } \ 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 5d074d8..43aa144 100644 --- a/src/main/java/frc/robot/OI.java +++ b/src/main/java/frc/robot/OI.java @@ -97,10 +97,8 @@ public OI() { driverX.whenReleased(new StopHopper()); driverB.whenPressed(new OpenHopperPiston()); driverB.whenReleased(new CloseHopperPiston()); - operatorA.whenPressed(new ExtendPanelMech()); - operatorA.whenReleased(new DefaultPanelMech()); - operatorB.whenPressed(new SetPanelMech()); - operatorB.whenReleased(new StopPanelMech()); + operatorA.whileHeld(new ExtendPanelMech()); + operatorB.whileHeld(new SetPanelMech()); // driverRB.whenPressed(new ShooterGroupWall()); // driverRB.whenReleased(new StopShooterGroupWall()); @@ -108,10 +106,10 @@ public OI() { // 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()); + 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 bd21e4f..abd41bb 100644 --- a/src/main/java/frc/robot/Robot.java +++ b/src/main/java/frc/robot/Robot.java @@ -37,7 +37,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/commands/DefaultPanelMech.java b/src/main/java/frc/robot/commands/DefaultPanelMech.java index 2c362f1..39ed8e3 100644 --- a/src/main/java/frc/robot/commands/DefaultPanelMech.java +++ b/src/main/java/frc/robot/commands/DefaultPanelMech.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; import frc.robot.Robot; import edu.wpi.first.wpilibj.command.Command; @@ -14,7 +7,7 @@ public class DefaultPanelMech extends Command { public DefaultPanelMech() { super("DefaultPanelMech"); - //requires(Robot.panelMech); + requires(Robot.panelMech); // Use requires() here to declare subsystem dependencies // eg. requires(chassis); } diff --git a/src/main/java/frc/robot/commands/ExtendPanelMech.java b/src/main/java/frc/robot/commands/ExtendPanelMech.java index 149f126..5f425a3 100644 --- a/src/main/java/frc/robot/commands/ExtendPanelMech.java +++ b/src/main/java/frc/robot/commands/ExtendPanelMech.java @@ -1,20 +1,15 @@ -/*----------------------------------------------------------------------------*/ -/* 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; +import frc.robot.Constants; + public class ExtendPanelMech extends Command { public ExtendPanelMech() { super("ExtendPanelMech"); - //requires(Robot.panelMech); + requires(Robot.panelMech); // Use requires() here to declare subsystem dependencies // eg. requires(chassis); } @@ -22,14 +17,23 @@ public ExtendPanelMech() { // Called just before this Command runs the first time @Override protected void initialize() { + Constants.SpinNum++; + if(Constants.SpinNum==2){ + Constants.SpinNum=0; + } } // Called repeatedly when this Command is scheduled to run @Override protected void execute() { + if(Constants.SpinNum==0){ Robot.panelMech.extendPanelMech(true); } + else{ + Robot.panelMech.extendPanelMech(false); + } +} // Make this return true when this Command no longer needs to run execute() @Override diff --git a/src/main/java/frc/robot/commands/SetPanelMech.java b/src/main/java/frc/robot/commands/SetPanelMech.java index 5ba81d1..ce17995 100644 --- a/src/main/java/frc/robot/commands/SetPanelMech.java +++ b/src/main/java/frc/robot/commands/SetPanelMech.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; import frc.robot.Robot; @@ -15,7 +8,7 @@ public class SetPanelMech extends Command { public SetPanelMech() { super("SetPanelMech"); - //requires(Robot.panelMech); + requires(Robot.panelMech); // Use requires() here to declare subsystem dependencies // eg. requires(chassis); @@ -26,7 +19,7 @@ public SetPanelMech() { protected void initialize() { Constants.PanelNum++; if(Constants.PanelNum==3){ - Constants.PanelNum=1; + Constants.PanelNum=0; } } @@ -36,9 +29,12 @@ protected void execute() { if(Constants.PanelNum==1){ Robot.panelMech.setPanelMech(Constants.PANEL_MECH_FAST); } - else{ + else if(Constants.PanelNum==0){ Robot.panelMech.setPanelMech(Constants.PANEL_MECH_CREEP); } + else{ + Robot.panelMech.setPanelMech(0); + } } diff --git a/src/main/java/frc/robot/commands/StopPanelMech.java b/src/main/java/frc/robot/commands/StopPanelMech.java index 5a75c6f..5a7d3d7 100644 --- a/src/main/java/frc/robot/commands/StopPanelMech.java +++ b/src/main/java/frc/robot/commands/StopPanelMech.java @@ -8,7 +8,7 @@ public class StopPanelMech extends Command { public StopPanelMech() { super("StopPanelMech"); - //requires(Robot.panelMech); + requires(Robot.panelMech); // Use requires() here to declare subsystem dependencies // eg. requires(chassis); diff --git a/src/main/java/frc/robot/subsystems/PanelMech.java b/src/main/java/frc/robot/subsystems/PanelMech.java index 7e2a13f..d8bdc28 100644 --- a/src/main/java/frc/robot/subsystems/PanelMech.java +++ b/src/main/java/frc/robot/subsystems/PanelMech.java @@ -1,9 +1,3 @@ -/*----------------------------------------------------------------------------*/ -/* 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; @@ -36,6 +30,10 @@ public PanelMech(){ panelMech_solenoid= new Solenoid(RobotMap.kPCM, RobotMap.PANEL_SOLENOID); } + protected void initDefaultCommand() { + + } + public void setPanelMech(final double velocity) { panelMech_motor.set(velocity); @@ -46,16 +44,10 @@ public void extendPanelMech(boolean extend) { } - @Override - - // public boolean getRetracted(){ - // return panelMech_solenoid.get(); - // } - - protected void initDefaultCommand() { - + public boolean getRetracted(){ + return panelMech_solenoid.get(); } - + public void debug() { } } \ 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 e7d9c8a..b61bf3b 100644 --- a/src/main/java/frc/robot/subsystems/Shooter.java +++ b/src/main/java/frc/robot/subsystems/Shooter.java @@ -18,12 +18,14 @@ import frc.robot.Robot; import frc.robot.RobotMap; +import edu.wpi.first.wpilibj.Timer; + // import frc.robot.commands.MoveShooterPassive; /** * Add your docs here. */ public class Shooter extends Subsystem { - + private Timer currentMonitorTimer; private CANSparkMax shooter_leader; private CANSparkMax shooter_follower; private Solenoid hood_1; @@ -32,6 +34,12 @@ public class Shooter extends Subsystem { public Shooter(){ + SmartDashboard.putNumber("Shooter kP", 0.000050); + SmartDashboard.putNumber("Shooter kF", 0.000165); + SmartDashboard.putNumber("Shooter max output", 0); + SmartDashboard.putNumber("Shooter setpoint (RPM)", 0); + SmartDashboard.putNumber("Shooter accelerator RPM", 0); + currentMonitorTimer = new Timer(); shooter_leader = new CANSparkMax(RobotMap.kShooterLeft, MotorType.kBrushless); shooter_follower = new CANSparkMax(RobotMap.kShooterRight, MotorType.kBrushless); shooter_leader.setOpenLoopRampRate(Constants.kNeoRampTime); From 84731943113fa05a13d20dd7b30ff635cf3d027b Mon Sep 17 00:00:00 2001 From: fidgetspinnerkid <35818373+fidgetspinnerkid@users.noreply.github.com> Date: Thu, 20 Feb 2020 13:43:41 -0800 Subject: [PATCH 5/5] Added a few controls + Camera work --- src/main/java/frc/robot/Constants.java | 3 + src/main/java/frc/robot/OI.java | 26 ++++++-- src/main/java/frc/robot/Robot.java | 2 +- .../java/frc/robot/commands/IntakeOff.java | 46 ++++++++++++++ .../java/frc/robot/commands/IntakeOn.java | 44 ++++++++++++++ .../java/frc/robot/commands/SetPanelMech.java | 3 +- .../robot/commands/Shooter/ExtendHood.java | 44 ++++++++++++++ .../robot/commands/Shooter/RetractHood.java | 48 +++++++++++++++ .../java/frc/robot/commands/cycleCameras.java | 60 +++++++++++++++++++ .../frc/robot/commands/setCameraThree.java | 48 +++++++++++++++ .../util/Camera_Switch/CameraSwitch.java | 6 +- 11 files changed, 321 insertions(+), 9 deletions(-) create mode 100644 src/main/java/frc/robot/commands/IntakeOff.java create mode 100644 src/main/java/frc/robot/commands/IntakeOn.java create mode 100644 src/main/java/frc/robot/commands/Shooter/ExtendHood.java create mode 100644 src/main/java/frc/robot/commands/Shooter/RetractHood.java create mode 100644 src/main/java/frc/robot/commands/cycleCameras.java create mode 100644 src/main/java/frc/robot/commands/setCameraThree.java diff --git a/src/main/java/frc/robot/Constants.java b/src/main/java/frc/robot/Constants.java index cf61975..20409c9 100644 --- a/src/main/java/frc/robot/Constants.java +++ b/src/main/java/frc/robot/Constants.java @@ -104,4 +104,7 @@ public final class Constants { public static final double PANEL_MECH_FAST = 0.5; public static int PanelNum=2; public static int SpinNum=0; + + //cameras + public static int camnum=0; } \ 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 43aa144..55bb3f8 100644 --- a/src/main/java/frc/robot/OI.java +++ b/src/main/java/frc/robot/OI.java @@ -6,9 +6,17 @@ import edu.wpi.first.wpilibj.command.Command; import frc.robot.commands.*; import frc.robot.commands.Shooter.StopShooter; +import frc.robot.commands.Shooter.CheckHoodLong; import frc.robot.commands.Shooter.CloseHopperPiston; -import frc.robot.commands.Shooter.MoveShooterWall; import frc.robot.commands.Shooter.OpenHopperPiston; +import frc.robot.commands.Shooter.RetractHood; +import frc.robot.commands.Shooter.ExtendHood; +import frc.robot.commands.Shooter.MoveShooterWall; +import frc.robot.commands.Shooter.MoveShooterLong; +import frc.robot.commands.setCameraOne; +import frc.robot.commands.setCameraTwo; +import frc.robot.commands.setCameraThree; +import frc.robot.commands.Shooter.CheckHoodWall; // import frc.robot.commands.auto.SetLimit; import frc.robot.controller.AnalogButton; import frc.robot.controller.DPadButton; @@ -104,12 +112,18 @@ public OI() { // driverRB.whenReleased(new StopShooterGroupWall()); // driverLB.whenPressed(new ShooterGroupLong()); // driverLB.whenReleased(new StopShooterGroupLong()); - driverDPadLeft.whenPressed(new setCameraTwo()); - driverDPadLeft.whenReleased(new setCameraOne()); - driverDPadDown.whenPressed(new ReverseHopper()); + //driverDPadLeft.whileHeld(new cycleCameras()); + operatorRT.whileHeld(new setCameraTwo()); + operatorLT.whileHeld(new setCameraOne()); + operatorRB.whileHeld(new setCameraThree()); + operatorDPadDown.whenPressed(new RetractHood()); + operatorDPadLeft.whenPressed(new ExtendHood()); + driverDPadDown.whileHeld(new IntakeOn()); + driverDPadDown.whenReleased(new IntakeOff()); driverDPadDown.whenReleased(new StopHopper()); - driverDPadRight.whenPressed(new MoveShooterWall()); - driverDPadRight.whenReleased(new StopShooter()); + operatorX.whenPressed(new MoveShooterWall()); + operatorY.whenPressed(new MoveShooterLong()); + driverDPadRight.whenPressed(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 abd41bb..63f68b3 100644 --- a/src/main/java/frc/robot/Robot.java +++ b/src/main/java/frc/robot/Robot.java @@ -100,7 +100,7 @@ public void teleopPeriodic() { // 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 - Cam_switch.select(CameraSwitch.kcamera1); + //Cam_switch.select(CameraSwitch.kcamera1); Scheduler.getInstance().run(); } @Override diff --git a/src/main/java/frc/robot/commands/IntakeOff.java b/src/main/java/frc/robot/commands/IntakeOff.java new file mode 100644 index 0000000..84b7c2e --- /dev/null +++ b/src/main/java/frc/robot/commands/IntakeOff.java @@ -0,0 +1,46 @@ +/*----------------------------------------------------------------------------*/ +/* 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.Constants; +import edu.wpi.first.wpilibj.command.Command; +import frc.robot.Robot; + +public class IntakeOff extends Command { + public IntakeOff() { + // 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); + } + + // 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/IntakeOn.java b/src/main/java/frc/robot/commands/IntakeOn.java new file mode 100644 index 0000000..158e348 --- /dev/null +++ b/src/main/java/frc/robot/commands/IntakeOn.java @@ -0,0 +1,44 @@ +/*----------------------------------------------------------------------------*/ +/* 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; + +public class IntakeOn extends Command { + public IntakeOn() { + // 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() { + } + + // 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 ce17995..e509df1 100644 --- a/src/main/java/frc/robot/commands/SetPanelMech.java +++ b/src/main/java/frc/robot/commands/SetPanelMech.java @@ -3,6 +3,7 @@ import edu.wpi.first.wpilibj.command.Command; import frc.robot.Constants; +import frc.robot.util.Camera_Switch.CameraSwitch; public class SetPanelMech extends Command { public SetPanelMech() { @@ -34,7 +35,7 @@ else if(Constants.PanelNum==0){ } else{ Robot.panelMech.setPanelMech(0); - } + } } diff --git a/src/main/java/frc/robot/commands/Shooter/ExtendHood.java b/src/main/java/frc/robot/commands/Shooter/ExtendHood.java new file mode 100644 index 0000000..9b71aa1 --- /dev/null +++ b/src/main/java/frc/robot/commands/Shooter/ExtendHood.java @@ -0,0 +1,44 @@ +/*----------------------------------------------------------------------------*/ +/* 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; + +public class ExtendHood extends Command { + public ExtendHood() { + // 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() { + } + + // 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/RetractHood.java b/src/main/java/frc/robot/commands/Shooter/RetractHood.java new file mode 100644 index 0000000..dd707df --- /dev/null +++ b/src/main/java/frc/robot/commands/Shooter/RetractHood.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.Shooter; + +import edu.wpi.first.wpilibj.command.Command; +import frc.robot.Robot; + +public class RetractHood extends Command { + public RetractHood() { + super("RetractHood"); + 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.setHood1(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/cycleCameras.java b/src/main/java/frc/robot/commands/cycleCameras.java new file mode 100644 index 0000000..1ca6528 --- /dev/null +++ b/src/main/java/frc/robot/commands/cycleCameras.java @@ -0,0 +1,60 @@ +/*----------------------------------------------------------------------------*/ +/* 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.Constants; +// import edu.wpi.first.wpilibj.command.Command; +// import frc.robot.util.Camera_Switch.CameraSwitch; +// import frc.robot.Robot; + +// public class cycleCameras extends Command { +// public cycleCameras() { +// } + +// // Called just before this Command runs the first time +// @Override +// protected void initialize() { +// Constants.camnum++; +// if(Constants.camnum==3){ +// Constants.camnum=0; +// } +// } + +// // Called repeatedly when this Command is scheduled to run +// @Override +// protected void execute() { +// if(Constants.camnum==0){ +// Robot.Cam_switch.select(CameraSwitch.kcamera1); + +// } +// else if(Constants.camnum==1){ +// Robot.Cam_switch.select(CameraSwitch.kcamera2); + +// } +// else{ +// Robot.Cam_switch.select(CameraSwitch.kcamera3); + +// } +// } + +// // 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/setCameraThree.java b/src/main/java/frc/robot/commands/setCameraThree.java new file mode 100644 index 0000000..aa5f350 --- /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 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/util/Camera_Switch/CameraSwitch.java b/src/main/java/frc/robot/util/Camera_Switch/CameraSwitch.java index 31c0266..9d8d34a 100644 --- a/src/main/java/frc/robot/util/Camera_Switch/CameraSwitch.java +++ b/src/main/java/frc/robot/util/Camera_Switch/CameraSwitch.java @@ -55,22 +55,26 @@ public void select(int camSelected){ switch (camSelected) { case kcamera1 : camrelay1.set(Value.kReverse); + camrelay2.set(Value.kOff); //camrelay.set(Value.kForward); break; case kcamera2 : camrelay1.set(Value.kForward); + camrelay2.set(Value.kOff); break; case kcamera3 : + camrelay1.set(Value.kOff); camrelay2.set(Value.kReverse); // camrelay.set(Value.kOn); case kcamera4 : + camrelay1.set(Value.kOff); camrelay2.set(Value.kForward); // camrelay.set(Value.kOff); break; default: - camrelay1.set(Value.kReverse); + // 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