From 1ca642cd509727647d9a1ec9415cc5d38815c79c Mon Sep 17 00:00:00 2001 From: Stefan Hauge Date: Mon, 9 Mar 2020 18:19:56 -0500 Subject: [PATCH 1/9] Added interruption case --- src/main/java/frc/robot/commands/shooter_command.java | 1 + 1 file changed, 1 insertion(+) diff --git a/src/main/java/frc/robot/commands/shooter_command.java b/src/main/java/frc/robot/commands/shooter_command.java index 207107c..5c81dd3 100644 --- a/src/main/java/frc/robot/commands/shooter_command.java +++ b/src/main/java/frc/robot/commands/shooter_command.java @@ -74,5 +74,6 @@ protected void end() { // subsystems is scheduled to run @Override protected void interrupted() { + end(); } } From 11f3cd0f29d94bc970a1791ec0b1e1539d932f46 Mon Sep 17 00:00:00 2001 From: Levy8Me Date: Mon, 9 Mar 2020 19:26:24 -0500 Subject: [PATCH 2/9] finishing shooter --- src/main/java/frc/robot/Robot.java | 4 ++-- src/main/java/frc/robot/RobotMap.java | 8 ++++---- .../frc/robot/commands/intake_command.java | 16 +++++++++++++--- .../frc/robot/commands/shooter_command.java | 19 ++++++++++++------- .../robot/subsystems/shooter_subsystem.java | 12 +++++++++--- 5 files changed, 40 insertions(+), 19 deletions(-) diff --git a/src/main/java/frc/robot/Robot.java b/src/main/java/frc/robot/Robot.java index e9125ad..bebbddc 100644 --- a/src/main/java/frc/robot/Robot.java +++ b/src/main/java/frc/robot/Robot.java @@ -58,8 +58,8 @@ public Robot(){ */ @Override public void robotInit() { - index_subsystem = new index_subsystem(); - //shooter_subsystem = new shooter_subsystem(); + //index_subsystem = new index_subsystem(); + shooter_subsystem = new shooter_subsystem(); colorWheel_subsystem = new colorWheel_subsystem(); drive_subsystem = new drive_subsystem(); intake_subsystem = new intake_subsystem(); diff --git a/src/main/java/frc/robot/RobotMap.java b/src/main/java/frc/robot/RobotMap.java index 2c8ec0b..8a03446 100644 --- a/src/main/java/frc/robot/RobotMap.java +++ b/src/main/java/frc/robot/RobotMap.java @@ -32,8 +32,8 @@ public class RobotMap { //Intake Motor public static final int MOTOR_INTAKE = 6; //Shooter Motor - public static final int MOTOR_SHOOT_TOP = 2; - public static final int MOTOT_SHOOT_BOTTOM = 1; + public static final int MOTOR_SHOOT_TOP = 8; + public static final int MOTOT_SHOOT_BOTTOM = 9; //SOLENOID public static final int SOLENOID_IN = 0; public static final int SOLENOID_OUT = 1; @@ -65,8 +65,8 @@ public class RobotMap { public static final int LT = 0; public static final int RT = 1; //Bumpers - public static final int LB = 6; - public static final int RB = 5; + public static final int LB = 5; + public static final int RB = 6; //Encoders public static final int leftEncoderPort1 = 3; diff --git a/src/main/java/frc/robot/commands/intake_command.java b/src/main/java/frc/robot/commands/intake_command.java index b953690..ae8de6c 100644 --- a/src/main/java/frc/robot/commands/intake_command.java +++ b/src/main/java/frc/robot/commands/intake_command.java @@ -11,7 +11,8 @@ import frc.robot.Robot; public class intake_command extends Command { - double motorSpeed = 0.85; + double intakeSpeed = 0.85; + double shootSpeed = 0.2; public intake_command() { // Use requires() here to declare subsystem dependencies // eg. requires(chassis); @@ -26,10 +27,18 @@ protected void initialize() { @Override protected void execute() { if (Robot.m_oi.Intake_buttonA.get()){ - Robot.intake_subsystem.rollerSpeed(motorSpeed); + Robot.intake_subsystem.rollerSpeed(intakeSpeed); + Robot.shooter_subsystem.shootAnywayBoth(shootSpeed); } else{ - Robot.intake_subsystem.rollerSpeed(0); + end(); + } + if(Robot.m_oi.Intake_buttonB.get()){ + Robot.intake_subsystem.rollerSpeed(intakeSpeed); + Robot.shooter_subsystem.shootAnywayBoth(-shootSpeed); + } + else{ + end(); } } @@ -43,6 +52,7 @@ protected boolean isFinished() { @Override protected void end() { Robot.intake_subsystem.rollerSpeed(0); + Robot.shooter_subsystem.shootAnywayBoth(0); } // Called when another command which requires one or more of the same diff --git a/src/main/java/frc/robot/commands/shooter_command.java b/src/main/java/frc/robot/commands/shooter_command.java index 1ce8387..c8f947b 100644 --- a/src/main/java/frc/robot/commands/shooter_command.java +++ b/src/main/java/frc/robot/commands/shooter_command.java @@ -30,27 +30,31 @@ protected void initialize() { // Called repeatedly when this Command is scheduled to run @Override protected void execute() {//Different speeds are set based on what position the d-pad was pushed - if(Robot.m_oi.Intake_dPadLeft.get()){ + if(Robot.m_oi.Intake_leftButton.get()){ topSpeed = 3000; bottomSpeed = 1500; - topSpeedSet = topSpeed/maxRPM; - bottomSpeedSet = bottomSpeed/maxRPM; + topSpeedSet = 0.5; + bottomSpeedSet = 0.5; + System.out.println("Low spd"); } - else if(Robot.m_oi.Intake_dPadUp.get()){ + else if(Robot.m_oi.Intake_upButton.get()){ topSpeed = 3750; bottomSpeed = 3000; topSpeedSet = topSpeed/maxRPM; bottomSpeedSet = bottomSpeed/maxRPM; + System.out.println("Med spd"); } - else if(Robot.m_oi.Intake_dPadRight.get()){ + else if(Robot.m_oi.Intake_rightButton.get()){ topSpeed = 5000; bottomSpeed = 5000; topSpeedSet = topSpeed/maxRPM; bottomSpeedSet = bottomSpeed/maxRPM; + System.out.println("High spd"); } if(Robot.m_oi.Intake_RB.get()){ //Robot.shooter_subsystem.setShooterSpeeds(topSpeed, bottomSpeed); - Robot.shooter_subsystem.shootAnyway(topSpeedSet, bottomSpeedSet); + Robot.shooter_subsystem.shootAnywayTop(topSpeedSet); + Robot.shooter_subsystem.shootAnywayBottom(bottomSpeedSet); } else{ end(); @@ -67,7 +71,8 @@ protected boolean isFinished() { @Override protected void end() { Robot.shooter_subsystem.setShooterSpeeds(0, 0); - Robot.shooter_subsystem.shootAnyway(0, 0); + Robot.shooter_subsystem.shootAnywayTop(0); + Robot.shooter_subsystem.shootAnywayBottom(0); } // Called when another command which requires one or more of the same diff --git a/src/main/java/frc/robot/subsystems/shooter_subsystem.java b/src/main/java/frc/robot/subsystems/shooter_subsystem.java index 07291b5..67b64d4 100644 --- a/src/main/java/frc/robot/subsystems/shooter_subsystem.java +++ b/src/main/java/frc/robot/subsystems/shooter_subsystem.java @@ -42,14 +42,14 @@ public shooter_subsystem(){ bottomPID = bottomMotor.getPIDController(); //topPID.setReference(0, ControlType.kSmartMotion); //bottomPID.setReference(0, ControlType.kSmartMotion); - topPID.setP(kP); + /*topPID.setP(kP); topPID.setI(kI); topPID.setFF(kFF); topPID.setIZone(kIz); bottomPID.setP(kP); bottomPID.setI(kI); bottomPID.setFF(kFF); - bottomPID.setIZone(kIz); + bottomPID.setIZone(kIz);*/ } /** Sets the shooters speeds (in RPM) *@param topRPM the max RPM for the top of the shooter (between 5700RPM-1000RPM) @@ -70,8 +70,14 @@ public void setShooterSpeeds(double topRPM, double bottomRPM){ bottomMotor.stopMotor(); } } - public void shootAnyway(double topMotorSpeed, double bottomMotorSpeed){ + public void shootAnywayTop(double topMotorSpeed){ topMotor.set(topMotorSpeed); + } + public void shootAnywayBottom(double bottomMotorSpeed){ bottomMotor.set(bottomMotorSpeed); } + public void shootAnywayBoth(double speed){ + shootAnywayBottom(speed); + shootAnywayTop(speed); + } } From 120b564e57053b9a273cb3d4cd3e11e4eac9169d Mon Sep 17 00:00:00 2001 From: Levy8Me Date: Tue, 10 Mar 2020 18:29:35 -0500 Subject: [PATCH 3/9] touched up shooter --- src/main/java/frc/robot/OI.java | 1 + src/main/java/frc/robot/Robot.java | 2 +- src/main/java/frc/robot/RobotMap.java | 10 +++--- .../robot/commands/colorWheel_command.java | 2 +- .../frc/robot/commands/index_command.java | 6 ++-- .../frc/robot/commands/intake_command.java | 19 +++++------ .../frc/robot/commands/shooter_command.java | 32 +++++++++++++++---- .../frc/robot/subsystems/index_subsystem.java | 15 ++++----- .../robot/subsystems/shooter_subsystem.java | 20 ++++++++---- 9 files changed, 67 insertions(+), 40 deletions(-) diff --git a/src/main/java/frc/robot/OI.java b/src/main/java/frc/robot/OI.java index 363bfa3..0402192 100644 --- a/src/main/java/frc/robot/OI.java +++ b/src/main/java/frc/robot/OI.java @@ -10,6 +10,7 @@ import edu.wpi.first.wpilibj.Joystick; import edu.wpi.first.wpilibj.buttons.JoystickButton; import edu.wpi.first.wpilibj.buttons.POVButton; +import frc.robot.commands.shooter_command; /** * This class is the glue that binds the controls on the physical operator diff --git a/src/main/java/frc/robot/Robot.java b/src/main/java/frc/robot/Robot.java index bebbddc..3b5553a 100644 --- a/src/main/java/frc/robot/Robot.java +++ b/src/main/java/frc/robot/Robot.java @@ -61,7 +61,7 @@ public void robotInit() { //index_subsystem = new index_subsystem(); shooter_subsystem = new shooter_subsystem(); colorWheel_subsystem = new colorWheel_subsystem(); - drive_subsystem = new drive_subsystem(); + //drive_subsystem = new drive_subsystem(); intake_subsystem = new intake_subsystem(); m_oi = new OI(); m_oi.bind(); //bind the buttons to commands diff --git a/src/main/java/frc/robot/RobotMap.java b/src/main/java/frc/robot/RobotMap.java index 8a03446..5ada843 100644 --- a/src/main/java/frc/robot/RobotMap.java +++ b/src/main/java/frc/robot/RobotMap.java @@ -33,7 +33,7 @@ public class RobotMap { public static final int MOTOR_INTAKE = 6; //Shooter Motor public static final int MOTOR_SHOOT_TOP = 8; - public static final int MOTOT_SHOOT_BOTTOM = 9; + public static final int MOTOR_SHOOT_BOTTOM = 9; //SOLENOID public static final int SOLENOID_IN = 0; public static final int SOLENOID_OUT = 1; @@ -58,15 +58,15 @@ public class RobotMap { public static final int D_PAD_UP = 6; public static final int D_PAD_DOWN = 7; public static final int D_PAD_RIGHT = 8; - public static final int START_BUTTON = 9; - public static final int SELECT_BUTTON = 10; + public static final int START_BUTTON = 8; + public static final int SELECT_BUTTON = 7; //Triggers public static final int LT = 0; public static final int RT = 1; //Bumpers - public static final int LB = 5; - public static final int RB = 6; + public static final int LB = 6; + public static final int RB = 5; //Encoders public static final int leftEncoderPort1 = 3; diff --git a/src/main/java/frc/robot/commands/colorWheel_command.java b/src/main/java/frc/robot/commands/colorWheel_command.java index 8a27542..11178af 100644 --- a/src/main/java/frc/robot/commands/colorWheel_command.java +++ b/src/main/java/frc/robot/commands/colorWheel_command.java @@ -48,7 +48,7 @@ protected void initialize() { // Called repeatedly when this Command is scheduled to run @Override protected void execute() { - if (Robot.m_oi.Intake_buttonY.get() && yPressed == false) {//this is not needed if you call the command when the button is pressed + if (Robot.m_oi.Intake_startButton.get() && yPressed == false) {//this is not needed if you call the command when the button is pressed yPressed = true; initialColor = Robot.colorWheel_subsystem.getColor(); SmartDashboard.putString("FMScolor", initialColor); diff --git a/src/main/java/frc/robot/commands/index_command.java b/src/main/java/frc/robot/commands/index_command.java index 5419ecf..0e65790 100644 --- a/src/main/java/frc/robot/commands/index_command.java +++ b/src/main/java/frc/robot/commands/index_command.java @@ -33,13 +33,13 @@ protected void initialize() { // Called repeatedly when this Command is scheduled to run @Override protected void execute() { - if(Robot.m_oi.buttonB.get()){ + /*if(Robot.m_oi.buttonB.get()){ System.out.println("B"); Robot.index_subsystem.indexActivate(kForward); } else{ Robot.index_subsystem.indexActivate(kReverse); - } + }*/ // If the a button is pressed the boolean value is true which activates the pnuematics of the indexing system } @@ -52,7 +52,7 @@ protected boolean isFinished() { // Called once after isFinished returns true @Override protected void end() { - Robot.index_subsystem.indexActivate(kOff); + //Robot.index_subsystem.indexActivate(kOff); } // Called when another command which requires one or more of the same diff --git a/src/main/java/frc/robot/commands/intake_command.java b/src/main/java/frc/robot/commands/intake_command.java index ae8de6c..c7dda37 100644 --- a/src/main/java/frc/robot/commands/intake_command.java +++ b/src/main/java/frc/robot/commands/intake_command.java @@ -26,19 +26,20 @@ protected void initialize() { // Called repeatedly when this Command is scheduled to run @Override protected void execute() { - if (Robot.m_oi.Intake_buttonA.get()){ + if(Robot.m_oi.Intake_buttonX.get()){ Robot.intake_subsystem.rollerSpeed(intakeSpeed); - Robot.shooter_subsystem.shootAnywayBoth(shootSpeed); } - else{ - end(); + else if(Robot.m_oi.Intake_buttonY.get()){ + Robot.intake_subsystem.rollerSpeed(1.0); } - if(Robot.m_oi.Intake_buttonB.get()){ - Robot.intake_subsystem.rollerSpeed(intakeSpeed); - Robot.shooter_subsystem.shootAnywayBoth(-shootSpeed); + else if(Robot.m_oi.Intake_buttonB.get()){ + Robot.intake_subsystem.rollerSpeed(1.0); + } + else if(Robot.m_oi.Intake_selectButton.get()){ + Robot.intake_subsystem.rollerSpeed(-1.0); } else{ - end(); + Robot.intake_subsystem.rollerSpeed(0); } } @@ -52,7 +53,7 @@ protected boolean isFinished() { @Override protected void end() { Robot.intake_subsystem.rollerSpeed(0); - Robot.shooter_subsystem.shootAnywayBoth(0); + //Robot.shooter_subsystem.shootAnywayBoth(0); } // Called when another command which requires one or more of the same diff --git a/src/main/java/frc/robot/commands/shooter_command.java b/src/main/java/frc/robot/commands/shooter_command.java index c8f947b..211f3b4 100644 --- a/src/main/java/frc/robot/commands/shooter_command.java +++ b/src/main/java/frc/robot/commands/shooter_command.java @@ -8,6 +8,7 @@ package frc.robot.commands; import edu.wpi.first.wpilibj.command.Command; +import edu.wpi.first.wpilibj.smartdashboard.SmartDashboard; import frc.robot.Robot; public class shooter_command extends Command { @@ -15,7 +16,7 @@ public class shooter_command extends Command { double bottomSpeed; double bottomSpeedSet = 0.8; double topSpeedSet = 0.8; - double maxRPM = 5700; + //double maxRPM = 5700; public shooter_command() { requires(Robot.shooter_subsystem); // Use requires() here to declare subsystem dependencies @@ -30,7 +31,7 @@ protected void initialize() { // Called repeatedly when this Command is scheduled to run @Override protected void execute() {//Different speeds are set based on what position the d-pad was pushed - if(Robot.m_oi.Intake_leftButton.get()){ + /* if(Robot.m_oi.Intake_leftButton.get()){ topSpeed = 3000; bottomSpeed = 1500; topSpeedSet = 0.5; @@ -50,14 +51,32 @@ else if(Robot.m_oi.Intake_rightButton.get()){ topSpeedSet = topSpeed/maxRPM; bottomSpeedSet = bottomSpeed/maxRPM; System.out.println("High spd"); - } + }*/ + SmartDashboard.putNumber("Top RPM", Robot.shooter_subsystem.bottomEncoder.getVelocity()); + SmartDashboard.putNumber("Bottom RPM", Robot.shooter_subsystem.topEncoder.getVelocity()); if(Robot.m_oi.Intake_RB.get()){ //Robot.shooter_subsystem.setShooterSpeeds(topSpeed, bottomSpeed); - Robot.shooter_subsystem.shootAnywayTop(topSpeedSet); - Robot.shooter_subsystem.shootAnywayBottom(bottomSpeedSet); + Robot.shooter_subsystem.setShooterSpeeds(0,2000); + } + else if(Robot.m_oi.Intake_LB.get()){ + Robot.shooter_subsystem.setShooterSpeeds(2000,0); + } + else if(Robot.m_oi.Intake_LB.get() || Robot.m_oi.Intake_RB.get()){ + Robot.shooter_subsystem.setShooterSpeeds(2000,2000); + } + else if(Robot.m_oi.Intake_buttonA.get()){ + Robot.shooter_subsystem.setShooterSpeeds(3000,3000); + } + else if(Robot.m_oi.Intake_buttonY.get()){ + Robot.shooter_subsystem.shootAnywayTop(0.075); + Robot.shooter_subsystem.shootAnywayBottom(0.1); + } + else if(Robot.m_oi.Intake_buttonB.get()){ + Robot.shooter_subsystem.shootAnywayTop(-0.075); + Robot.shooter_subsystem.shootAnywayBottom(-0.1); } else{ - end(); + Robot.shooter_subsystem.shootAnywayBoth(0); } } @@ -79,5 +98,6 @@ protected void end() { // subsystems is scheduled to run @Override protected void interrupted() { + end(); } } diff --git a/src/main/java/frc/robot/subsystems/index_subsystem.java b/src/main/java/frc/robot/subsystems/index_subsystem.java index 08cc794..7258484 100644 --- a/src/main/java/frc/robot/subsystems/index_subsystem.java +++ b/src/main/java/frc/robot/subsystems/index_subsystem.java @@ -8,6 +8,7 @@ package frc.robot.subsystems; import edu.wpi.first.wpilibj.command.Subsystem; +import frc.robot.Robot; import frc.robot.RobotMap; import frc.robot.commands.index_command; import edu.wpi.first.wpilibj.Compressor; @@ -32,23 +33,21 @@ public void initDefaultCommand() { // setDefaultCommand(new MySpecialCommand()); } public index_subsystem(){ - airComp = new Compressor(10); + airComp = new Compressor(1); + airComp.setClosedLoopControl(true); airComp.clearAllPCMStickyFaults(); - airComp.stop(); - solenoid = new DoubleSolenoid(RobotMap.SOLENOID_IN, RobotMap.SOLENOID_OUT); - if(airComp.getPressureSwitchValue()){ + //solenoid = new DoubleSolenoid(RobotMap.SOLENOID_IN, RobotMap.SOLENOID_OUT); + System.out.println("Switch val: " + airComp.getPressureSwitchValue()); + if(Robot.m_oi.buttonY.get()){ airComp.start(); } - else{ - airComp.stop(); - } } /** Extends or retracts both pneumatic pistons based on 'active' * @param active if true pistons are extended if false they are retracted */ public void indexActivate(Value status){ - solenoid.set(status); + //solenoid.set(status); } } diff --git a/src/main/java/frc/robot/subsystems/shooter_subsystem.java b/src/main/java/frc/robot/subsystems/shooter_subsystem.java index 67b64d4..98eca61 100644 --- a/src/main/java/frc/robot/subsystems/shooter_subsystem.java +++ b/src/main/java/frc/robot/subsystems/shooter_subsystem.java @@ -6,6 +6,7 @@ /*----------------------------------------------------------------------------*/ package frc.robot.subsystems; +import com.revrobotics.CANEncoder; import com.revrobotics.CANPIDController; import com.revrobotics.CANSparkMax; import com.revrobotics.ControlType; @@ -21,7 +22,9 @@ public class shooter_subsystem extends Subsystem { // here. Call these from Commands. CANPIDController bottomPID; CANPIDController topPID; - CANSparkMax bottomMotor; + CANEncoder topEncoder; + public CANEncoder bottomEncoder; + public CANSparkMax bottomMotor; CANSparkMax topMotor; double kP = 0; double kI = 0; @@ -37,26 +40,29 @@ public void initDefaultCommand() { //Declaring PID and motors for shooter public shooter_subsystem(){ topMotor = new CANSparkMax(RobotMap.MOTOR_SHOOT_TOP, MotorType.kBrushless); - bottomMotor = new CANSparkMax(RobotMap.MOTOT_SHOOT_BOTTOM, MotorType.kBrushless); + bottomMotor = new CANSparkMax(RobotMap.MOTOR_SHOOT_BOTTOM, MotorType.kBrushless); + topMotor.setInverted(true); topPID = topMotor.getPIDController(); bottomPID = bottomMotor.getPIDController(); - //topPID.setReference(0, ControlType.kSmartMotion); - //bottomPID.setReference(0, ControlType.kSmartMotion); - /*topPID.setP(kP); + topEncoder = new CANEncoder(topMotor); + bottomEncoder = new CANEncoder(bottomMotor); + topPID.setReference(0, ControlType.kSmartMotion); + bottomPID.setReference(0, ControlType.kSmartMotion); + topPID.setP(kP); topPID.setI(kI); topPID.setFF(kFF); topPID.setIZone(kIz); bottomPID.setP(kP); bottomPID.setI(kI); bottomPID.setFF(kFF); - bottomPID.setIZone(kIz);*/ + bottomPID.setIZone(kIz); } /** Sets the shooters speeds (in RPM) *@param topRPM the max RPM for the top of the shooter (between 5700RPM-1000RPM) *@param bottomRPM the max RPM for the bottom of the shooter (between 5700RPM-1000RPM) */ public void setShooterSpeeds(double topRPM, double bottomRPM){ - if(topRPM < 5700 && bottomRPM < 5700 && topRPM > 1000 && bottomRPM > 1000){ + if(topRPM < 5700 && bottomRPM < 5700 && topRPM > 1000 && bottomRPM > 1000){ bottomPID.setSmartMotionMaxVelocity(bottomRPM, 0); topPID.setSmartMotionMaxVelocity(topRPM, 0); bottomPID.setSmartMotionMinOutputVelocity(bottomRPM-100, 0); From de69cd125e1ee8b045d9f7accae374375e428fe9 Mon Sep 17 00:00:00 2001 From: Levy8Me Date: Tue, 10 Mar 2020 18:31:54 -0500 Subject: [PATCH 4/9] added bottom smardashboard rpm --- src/main/java/frc/robot/commands/shooter_command.java | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/main/java/frc/robot/commands/shooter_command.java b/src/main/java/frc/robot/commands/shooter_command.java index 211f3b4..0901992 100644 --- a/src/main/java/frc/robot/commands/shooter_command.java +++ b/src/main/java/frc/robot/commands/shooter_command.java @@ -52,8 +52,7 @@ else if(Robot.m_oi.Intake_rightButton.get()){ bottomSpeedSet = bottomSpeed/maxRPM; System.out.println("High spd"); }*/ - SmartDashboard.putNumber("Top RPM", Robot.shooter_subsystem.bottomEncoder.getVelocity()); - SmartDashboard.putNumber("Bottom RPM", Robot.shooter_subsystem.topEncoder.getVelocity()); + SmartDashboard.putNumber("Bottom RPM", Robot.shooter_subsystem.bottomEncoder.getVelocity()); if(Robot.m_oi.Intake_RB.get()){ //Robot.shooter_subsystem.setShooterSpeeds(topSpeed, bottomSpeed); Robot.shooter_subsystem.setShooterSpeeds(0,2000); From 70efcf48b33aafdcaa58fa07a9530ba1e4058566 Mon Sep 17 00:00:00 2001 From: Levy8Me Date: Tue, 10 Mar 2020 18:39:34 -0500 Subject: [PATCH 5/9] touched up --- src/main/java/frc/robot/Robot.java | 5 ---- src/main/java/frc/robot/RobotMap.java | 5 ---- .../frc/robot/commands/intake_command.java | 7 +---- .../frc/robot/commands/shooter_command.java | 26 +++++++------------ 4 files changed, 10 insertions(+), 33 deletions(-) diff --git a/src/main/java/frc/robot/Robot.java b/src/main/java/frc/robot/Robot.java index 9d71dcd..3b5553a 100644 --- a/src/main/java/frc/robot/Robot.java +++ b/src/main/java/frc/robot/Robot.java @@ -60,13 +60,8 @@ public Robot(){ public void robotInit() { //index_subsystem = new index_subsystem(); shooter_subsystem = new shooter_subsystem(); -<<<<<<< HEAD colorWheel_subsystem = new colorWheel_subsystem(); //drive_subsystem = new drive_subsystem(); -======= - //colorWheel_subsystem = new colorWheel_subsystem(); - drive_subsystem = new drive_subsystem(); ->>>>>>> 1ca642cd509727647d9a1ec9415cc5d38815c79c intake_subsystem = new intake_subsystem(); m_oi = new OI(); m_oi.bind(); //bind the buttons to commands diff --git a/src/main/java/frc/robot/RobotMap.java b/src/main/java/frc/robot/RobotMap.java index 6d1dfe0..6b4bbc0 100644 --- a/src/main/java/frc/robot/RobotMap.java +++ b/src/main/java/frc/robot/RobotMap.java @@ -32,13 +32,8 @@ public class RobotMap { //Intake Motor public static final int MOTOR_INTAKE = 6; //Shooter Motor -<<<<<<< HEAD public static final int MOTOR_SHOOT_TOP = 8; public static final int MOTOR_SHOOT_BOTTOM = 9; -======= - public static final int MOTOR_SHOOT_TOP = 9; - public static final int MOTOT_SHOOT_BOTTOM = 8; ->>>>>>> 1ca642cd509727647d9a1ec9415cc5d38815c79c //SOLENOID public static final int SOLENOID_IN = 0; public static final int SOLENOID_OUT = 1; diff --git a/src/main/java/frc/robot/commands/intake_command.java b/src/main/java/frc/robot/commands/intake_command.java index 89c815d..6e45d02 100644 --- a/src/main/java/frc/robot/commands/intake_command.java +++ b/src/main/java/frc/robot/commands/intake_command.java @@ -11,12 +11,7 @@ import frc.robot.Robot; public class intake_command extends Command { -<<<<<<< HEAD double intakeSpeed = 0.85; - double shootSpeed = 0.2; -======= - double motorSpeed = 1.0; ->>>>>>> 1ca642cd509727647d9a1ec9415cc5d38815c79c public intake_command() { // Use requires() here to declare subsystem dependencies // eg. requires(chassis); @@ -43,7 +38,7 @@ else if(Robot.m_oi.Intake_selectButton.get()){ Robot.intake_subsystem.rollerSpeed(-1.0); } else if(Robot.m_oi.Intake_buttonB.get()){ - Robot.intake_subsystem.rollerSpeed(-motorSpeed); + Robot.intake_subsystem.rollerSpeed(-intakeSpeed); } else{ Robot.intake_subsystem.rollerSpeed(0); diff --git a/src/main/java/frc/robot/commands/shooter_command.java b/src/main/java/frc/robot/commands/shooter_command.java index cb493eb..c1c37ca 100644 --- a/src/main/java/frc/robot/commands/shooter_command.java +++ b/src/main/java/frc/robot/commands/shooter_command.java @@ -33,7 +33,6 @@ protected void initialize() { // Called repeatedly when this Command is scheduled to run @Override protected void execute() {//Different speeds are set based on what position the d-pad was pushed -<<<<<<< HEAD /* if(Robot.m_oi.Intake_leftButton.get()){ topSpeed = 3000; bottomSpeed = 1500; @@ -43,28 +42,13 @@ protected void execute() {//Different speeds are set based on what position the } else if(Robot.m_oi.Intake_upButton.get()){ topSpeed = 3750; -======= -/* if(Robot.m_oi.Intake_dPadLeft.get()){ - //topSpeed = 3000; - bottomSpeed = 1500; - // topSpeedSet = topSpeed/maxRPM; - bottomSpeedSet = bottomSpeed/maxRPM; - } - else if(Robot.m_oi.Intake_dPadUp.get()){ - //topSpeed = 3750; ->>>>>>> 1ca642cd509727647d9a1ec9415cc5d38815c79c bottomSpeed = 3000; //topSpeedSet = topSpeed/maxRPM; bottomSpeedSet = bottomSpeed/maxRPM; System.out.println("Med spd"); } -<<<<<<< HEAD else if(Robot.m_oi.Intake_rightButton.get()){ topSpeed = 5000; -======= - else if(Robot.m_oi.Intake_dPadRight.get()){ - // topSpeed = 5000; ->>>>>>> 1ca642cd509727647d9a1ec9415cc5d38815c79c bottomSpeed = 5000; // topSpeedSet = topSpeed/maxRPM; bottomSpeedSet = bottomSpeed/maxRPM; @@ -94,11 +78,19 @@ else if(Robot.m_oi.Intake_buttonB.get()){ else{ Robot.shooter_subsystem.shootAnywayBoth(0); } + } + @Override + protected boolean isFinished() { + return false; + } + @Override protected void end() { // Robot.shooter_subsystem.setShooterSpeeds(0, 0); - Robot.shooter_subsystem.shootAnyway(0); // add back 0 + Robot.shooter_subsystem.shootAnywayBoth(0); // add back 0 } + // Make this return true when this Command no longer needs to run execute() + // Called when another command which requires one or more of the same // subsystems is scheduled to run From 3421b79051b7564d494ca3f77c455dcdb7bd0e97 Mon Sep 17 00:00:00 2001 From: lewisgra000 Date: Tue, 10 Mar 2020 20:24:44 -0500 Subject: [PATCH 6/9] Got index working --- src/main/java/frc/robot/Robot.java | 3 +- .../frc/robot/commands/index_command.java | 14 ++++---- .../frc/robot/subsystems/index_subsystem.java | 35 ++++++++++++++----- 3 files changed, 36 insertions(+), 16 deletions(-) diff --git a/src/main/java/frc/robot/Robot.java b/src/main/java/frc/robot/Robot.java index 3b5553a..4ea8b75 100644 --- a/src/main/java/frc/robot/Robot.java +++ b/src/main/java/frc/robot/Robot.java @@ -58,7 +58,8 @@ public Robot(){ */ @Override public void robotInit() { - //index_subsystem = new index_subsystem(); + System.out.println("Made it"); + index_subsystem = new index_subsystem(); shooter_subsystem = new shooter_subsystem(); colorWheel_subsystem = new colorWheel_subsystem(); //drive_subsystem = new drive_subsystem(); diff --git a/src/main/java/frc/robot/commands/index_command.java b/src/main/java/frc/robot/commands/index_command.java index 0e65790..0980ddb 100644 --- a/src/main/java/frc/robot/commands/index_command.java +++ b/src/main/java/frc/robot/commands/index_command.java @@ -33,15 +33,15 @@ protected void initialize() { // Called repeatedly when this Command is scheduled to run @Override protected void execute() { - /*if(Robot.m_oi.buttonB.get()){ - System.out.println("B"); - Robot.index_subsystem.indexActivate(kForward); + if(Robot.m_oi.buttonB.get()){ + Robot.index_subsystem.indexActivate(kReverse); } else{ - Robot.index_subsystem.indexActivate(kReverse); - }*/ + Robot.index_subsystem.indexActivate(kForward); } // If the a button is pressed the boolean value is true which activates the pnuematics of the indexing system - } + Robot.index_subsystem.checkCompressor(); + } + // Make this return true when this Command no longer needs to run execute() @Override @@ -52,7 +52,7 @@ protected boolean isFinished() { // Called once after isFinished returns true @Override protected void end() { - //Robot.index_subsystem.indexActivate(kOff); + Robot.index_subsystem.indexActivate(kOff); } // Called when another command which requires one or more of the same diff --git a/src/main/java/frc/robot/subsystems/index_subsystem.java b/src/main/java/frc/robot/subsystems/index_subsystem.java index 7258484..090d08e 100644 --- a/src/main/java/frc/robot/subsystems/index_subsystem.java +++ b/src/main/java/frc/robot/subsystems/index_subsystem.java @@ -8,7 +8,6 @@ package frc.robot.subsystems; import edu.wpi.first.wpilibj.command.Subsystem; -import frc.robot.Robot; import frc.robot.RobotMap; import frc.robot.commands.index_command; import edu.wpi.first.wpilibj.Compressor; @@ -33,21 +32,41 @@ public void initDefaultCommand() { // setDefaultCommand(new MySpecialCommand()); } public index_subsystem(){ + System.out.println("Made it2"); airComp = new Compressor(1); - airComp.setClosedLoopControl(true); - airComp.clearAllPCMStickyFaults(); - //solenoid = new DoubleSolenoid(RobotMap.SOLENOID_IN, RobotMap.SOLENOID_OUT); - System.out.println("Switch val: " + airComp.getPressureSwitchValue()); - if(Robot.m_oi.buttonY.get()){ + //airComp.clearAllPCMStickyFaults(); + solenoid = new DoubleSolenoid(1, RobotMap.SOLENOID_IN, RobotMap.SOLENOID_OUT); + } + + /** Turns on or off the compressor + */ + public void checkCompressor(){ + System.out.println("Switch "+ airComp.getPressureSwitchValue()); + if(!airComp.getPressureSwitchValue()){ // remember to fix this so take away the ! airComp.start(); } + else{ + airComp.stop(); + } } - + + /** Extends or retracts both pneumatic pistons based on 'active' * @param active if true pistons are extended if false they are retracted */ public void indexActivate(Value status){ - //solenoid.set(status); + System.out.println("Status " + status); + solenoid.set(status); + // airComp = new Compressor(1); + // //airComp.clearAllPCMStickyFaults(); + // solenoid = new DoubleSolenoid(1, RobotMap.SOLENOID_IN, RobotMap.SOLENOID_OUT); + // System.out.println("Switch "+ airComp.getPressureSwitchValue()); + // if(airComp.getPressureSwitchValue()){ + // airComp.start(); + // } + // else{ + // airComp.stop(); + // } } } From 5838fff36001c0bf95c52b955df7381edb20139b Mon Sep 17 00:00:00 2001 From: lewisgra000 Date: Tue, 10 Mar 2020 20:41:27 -0500 Subject: [PATCH 7/9] cleaned up --- src/main/java/frc/robot/Robot.java | 2 +- src/main/java/frc/robot/commands/index_command.java | 6 +++--- .../java/frc/robot/subsystems/index_subsystem.java | 11 ----------- 3 files changed, 4 insertions(+), 15 deletions(-) diff --git a/src/main/java/frc/robot/Robot.java b/src/main/java/frc/robot/Robot.java index 4ea8b75..7cc28cf 100644 --- a/src/main/java/frc/robot/Robot.java +++ b/src/main/java/frc/robot/Robot.java @@ -61,7 +61,7 @@ public void robotInit() { System.out.println("Made it"); index_subsystem = new index_subsystem(); shooter_subsystem = new shooter_subsystem(); - colorWheel_subsystem = new colorWheel_subsystem(); + //colorWheel_subsystem = new colorWheel_subsystem(); //drive_subsystem = new drive_subsystem(); intake_subsystem = new intake_subsystem(); m_oi = new OI(); diff --git a/src/main/java/frc/robot/commands/index_command.java b/src/main/java/frc/robot/commands/index_command.java index 0980ddb..5876cc8 100644 --- a/src/main/java/frc/robot/commands/index_command.java +++ b/src/main/java/frc/robot/commands/index_command.java @@ -37,10 +37,10 @@ protected void execute() { Robot.index_subsystem.indexActivate(kReverse); } else{ - Robot.index_subsystem.indexActivate(kForward); } - // If the a button is pressed the boolean value is true which activates the pnuematics of the indexing system + Robot.index_subsystem.indexActivate(kForward); + }// If the a button is pressed the boolean value is true which activates the pnuematics of the indexing system Robot.index_subsystem.checkCompressor(); - } + } // Make this return true when this Command no longer needs to run execute() diff --git a/src/main/java/frc/robot/subsystems/index_subsystem.java b/src/main/java/frc/robot/subsystems/index_subsystem.java index 090d08e..8c160f0 100644 --- a/src/main/java/frc/robot/subsystems/index_subsystem.java +++ b/src/main/java/frc/robot/subsystems/index_subsystem.java @@ -32,7 +32,6 @@ public void initDefaultCommand() { // setDefaultCommand(new MySpecialCommand()); } public index_subsystem(){ - System.out.println("Made it2"); airComp = new Compressor(1); //airComp.clearAllPCMStickyFaults(); solenoid = new DoubleSolenoid(1, RobotMap.SOLENOID_IN, RobotMap.SOLENOID_OUT); @@ -57,16 +56,6 @@ public void checkCompressor(){ public void indexActivate(Value status){ System.out.println("Status " + status); solenoid.set(status); - // airComp = new Compressor(1); - // //airComp.clearAllPCMStickyFaults(); - // solenoid = new DoubleSolenoid(1, RobotMap.SOLENOID_IN, RobotMap.SOLENOID_OUT); - // System.out.println("Switch "+ airComp.getPressureSwitchValue()); - // if(airComp.getPressureSwitchValue()){ - // airComp.start(); - // } - // else{ - // airComp.stop(); - // } } } From 099f063068cd39f27d7807547933ff3d1e37f99c Mon Sep 17 00:00:00 2001 From: Levy8Me Date: Wed, 11 Mar 2020 07:58:13 -0500 Subject: [PATCH 8/9] cleaned up shooter (ready for adding PID if need) --- src/main/java/frc/robot/OI.java | 1 - src/main/java/frc/robot/Robot.java | 8 ++-- .../robot/commands/autonomousSelector.java | 10 ++-- .../robot/commands/colorWheel_command.java | 1 - .../frc/robot/commands/intake_command.java | 7 +-- .../frc/robot/commands/shooter_command.java | 46 +++++------------- .../robot/commands/turnRightGoStraight.java | 2 +- .../frc/robot/subsystems/index_subsystem.java | 1 - .../robot/subsystems/shooter_subsystem.java | 47 ++----------------- 9 files changed, 30 insertions(+), 93 deletions(-) diff --git a/src/main/java/frc/robot/OI.java b/src/main/java/frc/robot/OI.java index 0402192..363bfa3 100644 --- a/src/main/java/frc/robot/OI.java +++ b/src/main/java/frc/robot/OI.java @@ -10,7 +10,6 @@ import edu.wpi.first.wpilibj.Joystick; import edu.wpi.first.wpilibj.buttons.JoystickButton; import edu.wpi.first.wpilibj.buttons.POVButton; -import frc.robot.commands.shooter_command; /** * This class is the glue that binds the controls on the physical operator diff --git a/src/main/java/frc/robot/Robot.java b/src/main/java/frc/robot/Robot.java index 3b5553a..628bd1e 100644 --- a/src/main/java/frc/robot/Robot.java +++ b/src/main/java/frc/robot/Robot.java @@ -12,7 +12,7 @@ import edu.wpi.first.wpilibj.TimedRobot; import edu.wpi.first.wpilibj.CounterBase.EncodingType; import edu.wpi.first.wpilibj.command.Scheduler; -import edu.wpi.first.wpilibj.smartdashboard.SendableChooser; +//import edu.wpi.first.wpilibj.smartdashboard.SendableChooser; import frc.robot.subsystems.colorWheel_subsystem; import frc.robot.subsystems.drive_subsystem; import frc.robot.subsystems.index_subsystem; @@ -32,12 +32,10 @@ public class Robot extends TimedRobot { public static OI m_oi; public static AHRS navx; - private String m_autoSelected; - private final SendableChooser m_chooser = new SendableChooser<>(); + //private String m_autoSelected; + //private final SendableChooser m_chooser = new SendableChooser<>(); private static DateFormat dateFormat = new SimpleDateFormat("HH:mm:ss"); private static Date date = new Date(); - private static boolean indexInitalized; - private static boolean colorwheelInitalized; public static Encoder rightEncoder = new Encoder(RobotMap.leftEncoderPort1, RobotMap.leftEncoderPort2, false, EncodingType.k4X); public static Encoder leftEncoder = new Encoder(RobotMap.rightEncoderPort1, RobotMap.rightEncoderPort2, false, EncodingType.k4X); //declare subsystems diff --git a/src/main/java/frc/robot/commands/autonomousSelector.java b/src/main/java/frc/robot/commands/autonomousSelector.java index f58ca99..251bd5b 100644 --- a/src/main/java/frc/robot/commands/autonomousSelector.java +++ b/src/main/java/frc/robot/commands/autonomousSelector.java @@ -18,22 +18,24 @@ public autonomousSelector(double position, String priority) { Robot.WriteOut("Autonomous Selector Initialized"); if(position == 1){ Robot.WriteOut("Selected Postition 1"); - if(priority.equalsIgnoreCase("Mane1")){ + if(priority.equalsIgnoreCase("mane1")){ Robot.WriteOut("Selected Maneuver 1 on Position 1"); addSequential(new driveOverLine()); } - else if(priority.equalsIgnoreCase("Mane2")){ + else if(priority.equalsIgnoreCase("mane2")){ Robot.WriteOut("Selected Maneuver 2 on Position 1"); addSequential(new turnRightGoStraight()); } } else if(position == 2){ Robot.WriteOut("Selected Postition 2"); - if(priority.equalsIgnoreCase("Mane1")){ + if(priority.equalsIgnoreCase("mane1")){ Robot.WriteOut("Selected Maneuver 1 on Position 2"); + } - else if(priority.equalsIgnoreCase("Mane2")){ + else if(priority.equalsIgnoreCase("mane2")){ Robot.WriteOut("Selected Maneuver 2 on Position 2"); + } } } diff --git a/src/main/java/frc/robot/commands/colorWheel_command.java b/src/main/java/frc/robot/commands/colorWheel_command.java index 11178af..82bc89b 100644 --- a/src/main/java/frc/robot/commands/colorWheel_command.java +++ b/src/main/java/frc/robot/commands/colorWheel_command.java @@ -10,7 +10,6 @@ import edu.wpi.first.wpilibj.command.Command; import edu.wpi.first.wpilibj.smartdashboard.SmartDashboard; import frc.robot.Robot; -import frc.robot.RobotMap; import java.util.ArrayList; import edu.wpi.first.wpilibj.DriverStation; diff --git a/src/main/java/frc/robot/commands/intake_command.java b/src/main/java/frc/robot/commands/intake_command.java index 6e45d02..7d8d614 100644 --- a/src/main/java/frc/robot/commands/intake_command.java +++ b/src/main/java/frc/robot/commands/intake_command.java @@ -11,7 +11,6 @@ import frc.robot.Robot; public class intake_command extends Command { - double intakeSpeed = 0.85; public intake_command() { // Use requires() here to declare subsystem dependencies // eg. requires(chassis); @@ -26,19 +25,21 @@ protected void initialize() { @Override protected void execute() { if(Robot.m_oi.Intake_buttonX.get()){ - Robot.intake_subsystem.rollerSpeed(intakeSpeed); + Robot.intake_subsystem.rollerSpeed(1); } + //Setting intake full speed durring shooter operation (check shooter_subsystem with same buttons) else if(Robot.m_oi.Intake_buttonY.get()){ Robot.intake_subsystem.rollerSpeed(1.0); } else if(Robot.m_oi.Intake_buttonB.get()){ Robot.intake_subsystem.rollerSpeed(1.0); } + //"Normal" buttons for intake operation else if(Robot.m_oi.Intake_selectButton.get()){ Robot.intake_subsystem.rollerSpeed(-1.0); } else if(Robot.m_oi.Intake_buttonB.get()){ - Robot.intake_subsystem.rollerSpeed(-intakeSpeed); + Robot.intake_subsystem.rollerSpeed(-1); } else{ Robot.intake_subsystem.rollerSpeed(0); diff --git a/src/main/java/frc/robot/commands/shooter_command.java b/src/main/java/frc/robot/commands/shooter_command.java index c1c37ca..db5791b 100644 --- a/src/main/java/frc/robot/commands/shooter_command.java +++ b/src/main/java/frc/robot/commands/shooter_command.java @@ -32,51 +32,30 @@ protected void initialize() { // Called repeatedly when this Command is scheduled to run @Override - protected void execute() {//Different speeds are set based on what position the d-pad was pushed - /* if(Robot.m_oi.Intake_leftButton.get()){ - topSpeed = 3000; - bottomSpeed = 1500; - topSpeedSet = 0.5; - bottomSpeedSet = 0.5; - System.out.println("Low spd"); - } - else if(Robot.m_oi.Intake_upButton.get()){ - topSpeed = 3750; - bottomSpeed = 3000; - //topSpeedSet = topSpeed/maxRPM; - bottomSpeedSet = bottomSpeed/maxRPM; - System.out.println("Med spd"); - } - else if(Robot.m_oi.Intake_rightButton.get()){ - topSpeed = 5000; - bottomSpeed = 5000; - // topSpeedSet = topSpeed/maxRPM; - bottomSpeedSet = bottomSpeed/maxRPM; - }*/ - SmartDashboard.putNumber("Bottom RPM", Robot.shooter_subsystem.bottomEncoder.getVelocity()); + protected void execute() { + SmartDashboard.putNumber("Bottom RPM: ", Robot.shooter_subsystem.bottomEncoder.getVelocity()); + SmartDashboard.putNumber("Top RPM: ", Robot.shooter_subsystem.topEncoder.getVelocity()); if(Robot.m_oi.Intake_RB.get()){ - //Robot.shooter_subsystem.setShooterSpeeds(topSpeed, bottomSpeed); - Robot.shooter_subsystem.setShooterSpeeds(0,2000); + Robot.shooter_subsystem.shooterSet(0, 0.4); } else if(Robot.m_oi.Intake_LB.get()){ - Robot.shooter_subsystem.setShooterSpeeds(2000,0); + Robot.shooter_subsystem.shooterSet(0.4, 0); } else if(Robot.m_oi.Intake_LB.get() || Robot.m_oi.Intake_RB.get()){ - Robot.shooter_subsystem.setShooterSpeeds(2000,2000); + Robot.shooter_subsystem.shooterSet(0.4, 0.4); } else if(Robot.m_oi.Intake_buttonA.get()){ - Robot.shooter_subsystem.setShooterSpeeds(3000,3000); + Robot.shooter_subsystem.shooterSet(0.65, 0.65); } + //Partly keeping intake in check (check intake_command with same buttons) else if(Robot.m_oi.Intake_buttonY.get()){ - Robot.shooter_subsystem.shootAnywayTop(0.075); - Robot.shooter_subsystem.shootAnywayBottom(0.1); + Robot.shooter_subsystem.shooterSet(0.075, 0.1); } else if(Robot.m_oi.Intake_buttonB.get()){ - Robot.shooter_subsystem.shootAnywayTop(-0.075); - Robot.shooter_subsystem.shootAnywayBottom(-0.1); + Robot.shooter_subsystem.shooterSet(-0.075, -0.1); } else{ - Robot.shooter_subsystem.shootAnywayBoth(0); + Robot.shooter_subsystem.shooterSet(0, 0); } } @Override @@ -86,8 +65,7 @@ protected boolean isFinished() { @Override protected void end() { - // Robot.shooter_subsystem.setShooterSpeeds(0, 0); - Robot.shooter_subsystem.shootAnywayBoth(0); // add back 0 + Robot.shooter_subsystem.shooterSet(0, 0); // add back 0 } // Make this return true when this Command no longer needs to run execute() diff --git a/src/main/java/frc/robot/commands/turnRightGoStraight.java b/src/main/java/frc/robot/commands/turnRightGoStraight.java index 72776b2..776ce86 100644 --- a/src/main/java/frc/robot/commands/turnRightGoStraight.java +++ b/src/main/java/frc/robot/commands/turnRightGoStraight.java @@ -15,6 +15,6 @@ public class turnRightGoStraight extends CommandGroup { */ public turnRightGoStraight() { addSequential(new turnGyro_command(90, .5)); - addSequential(new driveStraight_command(0.5,100,-1)); + addSequential(new driveStraight_command(0.5, 100, -1)); } } diff --git a/src/main/java/frc/robot/subsystems/index_subsystem.java b/src/main/java/frc/robot/subsystems/index_subsystem.java index 7258484..0b30190 100644 --- a/src/main/java/frc/robot/subsystems/index_subsystem.java +++ b/src/main/java/frc/robot/subsystems/index_subsystem.java @@ -9,7 +9,6 @@ import edu.wpi.first.wpilibj.command.Subsystem; import frc.robot.Robot; -import frc.robot.RobotMap; import frc.robot.commands.index_command; import edu.wpi.first.wpilibj.Compressor; import edu.wpi.first.wpilibj.DoubleSolenoid.Value; diff --git a/src/main/java/frc/robot/subsystems/shooter_subsystem.java b/src/main/java/frc/robot/subsystems/shooter_subsystem.java index 9161315..097a652 100644 --- a/src/main/java/frc/robot/subsystems/shooter_subsystem.java +++ b/src/main/java/frc/robot/subsystems/shooter_subsystem.java @@ -9,7 +9,6 @@ import com.revrobotics.CANEncoder; import com.revrobotics.CANPIDController; import com.revrobotics.CANSparkMax; -import com.revrobotics.ControlType; import com.revrobotics.CANSparkMaxLowLevel.MotorType; import edu.wpi.first.wpilibj.command.Subsystem; import frc.robot.RobotMap; @@ -22,15 +21,10 @@ public class shooter_subsystem extends Subsystem { // here. Call these from Commands. CANPIDController bottomPID; CANPIDController topPID; - CANEncoder topEncoder; + public CANEncoder topEncoder; public CANEncoder bottomEncoder; - public CANSparkMax bottomMotor; + CANSparkMax bottomMotor; CANSparkMax topMotor; - double kP = 0; - double kI = 0; - double kD = 0; - double kIz = 0; - double kFF = 0; @Override public void initDefaultCommand() { setDefaultCommand(new shooter_command()); @@ -41,49 +35,16 @@ public void initDefaultCommand() { public shooter_subsystem(){ topMotor = new CANSparkMax(RobotMap.MOTOR_SHOOT_TOP, MotorType.kBrushless); bottomMotor = new CANSparkMax(RobotMap.MOTOR_SHOOT_BOTTOM, MotorType.kBrushless); - topMotor.setInverted(true); - topPID = topMotor.getPIDController(); - bottomPID = bottomMotor.getPIDController(); topEncoder = new CANEncoder(topMotor); bottomEncoder = new CANEncoder(bottomMotor); - topPID.setReference(0, ControlType.kSmartMotion); - bottomPID.setReference(0, ControlType.kSmartMotion); - topPID.setP(kP); - topPID.setI(kI); - topPID.setFF(kFF); - topPID.setIZone(kIz); - bottomPID.setP(kP); - bottomPID.setI(kI); - bottomPID.setFF(kFF); - bottomPID.setIZone(kIz); } /** Sets the shooters speeds (in RPM) *@param topRPM the max RPM for the top of the shooter (between 5700RPM-1000RPM) *@param bottomRPM the max RPM for the bottom of the shooter (between 5700RPM-1000RPM) */ - public void setShooterSpeeds(double topRPM, double bottomRPM){ - if(topRPM < 5700 && bottomRPM < 5700 && topRPM > 1000 && bottomRPM > 1000){ - bottomPID.setSmartMotionMaxVelocity(bottomRPM, 0); - topPID.setSmartMotionMaxVelocity(topRPM, 0); - bottomPID.setSmartMotionMinOutputVelocity(bottomRPM-100, 0); - topPID.setSmartMotionMinOutputVelocity(topRPM-100, 0); - bottomPID.setSmartMotionMaxAccel(1500, 0); - topPID.setSmartMotionMaxAccel(1500, 0); - } - else{ - System.out.println("Too fast!"); - topMotor.stopMotor(); - bottomMotor.stopMotor(); - } - } - public void shootAnywayTop(double topMotorSpeed){ + public void shooterSet(double topMotorSpeed, double bottomMotorSpeed){ topMotor.set(topMotorSpeed); - } - public void shootAnywayBottom(double bottomMotorSpeed){ bottomMotor.set(bottomMotorSpeed); - } - public void shootAnywayBoth(double speed){ - shootAnywayBottom(speed); - shootAnywayTop(speed); + } } From ebd7965a5aa467985b9c695cf2139d17adc028d9 Mon Sep 17 00:00:00 2001 From: Levy8Me Date: Fri, 13 Mar 2020 07:45:14 -0500 Subject: [PATCH 9/9] some final clean up probably ready for master :/ --- src/main/java/frc/robot/Robot.java | 4 ++-- src/main/java/frc/robot/subsystems/shooter_subsystem.java | 5 +++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/main/java/frc/robot/Robot.java b/src/main/java/frc/robot/Robot.java index 7db8827..d89d249 100644 --- a/src/main/java/frc/robot/Robot.java +++ b/src/main/java/frc/robot/Robot.java @@ -59,8 +59,8 @@ public void robotInit() { System.out.println("Made it"); index_subsystem = new index_subsystem(); shooter_subsystem = new shooter_subsystem(); - //colorWheel_subsystem = new colorWheel_subsystem(); - //drive_subsystem = new drive_subsystem(); + colorWheel_subsystem = new colorWheel_subsystem(); + drive_subsystem = new drive_subsystem(); intake_subsystem = new intake_subsystem(); m_oi = new OI(); m_oi.bind(); //bind the buttons to commands diff --git a/src/main/java/frc/robot/subsystems/shooter_subsystem.java b/src/main/java/frc/robot/subsystems/shooter_subsystem.java index 097a652..b26cce1 100644 --- a/src/main/java/frc/robot/subsystems/shooter_subsystem.java +++ b/src/main/java/frc/robot/subsystems/shooter_subsystem.java @@ -37,10 +37,11 @@ public shooter_subsystem(){ bottomMotor = new CANSparkMax(RobotMap.MOTOR_SHOOT_BOTTOM, MotorType.kBrushless); topEncoder = new CANEncoder(topMotor); bottomEncoder = new CANEncoder(bottomMotor); + topMotor.setInverted(true); } /** Sets the shooters speeds (in RPM) - *@param topRPM the max RPM for the top of the shooter (between 5700RPM-1000RPM) - *@param bottomRPM the max RPM for the bottom of the shooter (between 5700RPM-1000RPM) + *@param topMotorSpeed the speed for the top of the shooter (-1 to 1) + *@param bottomMotorSpeed the speed for the bottom of the shooter (-1 to 1) */ public void shooterSet(double topMotorSpeed, double bottomMotorSpeed){ topMotor.set(topMotorSpeed);