From a1632fa6880ba84f9ddf4515c40c3ef3bb09247d Mon Sep 17 00:00:00 2001 From: "Keenan D. Buckley" Date: Wed, 11 Mar 2020 08:26:27 -0600 Subject: [PATCH] Tune Shooter and Work on DriverStation --- .../driverStation/GOAT DRIVERSTATION.json | 485 +++++++++++++++--- src/main/java/frc4388/robot/Constants.java | 2 +- .../shooter/ShooterVelocityControlPID.java | 23 +- .../frc4388/robot/subsystems/Shooter.java | 2 +- .../frc4388/robot/subsystems/ShooterAim.java | 2 - 5 files changed, 423 insertions(+), 91 deletions(-) diff --git a/src/main/deploy/driverStation/GOAT DRIVERSTATION.json b/src/main/deploy/driverStation/GOAT DRIVERSTATION.json index d28b08f..8fa33b4 100644 --- a/src/main/deploy/driverStation/GOAT DRIVERSTATION.json +++ b/src/main/deploy/driverStation/GOAT DRIVERSTATION.json @@ -198,6 +198,305 @@ "Colors/Color when true": "#7CFC00FF", "Colors/Color when false": "#8B0000FF" } + }, + "9,1": { + "size": [ + 1, + 1 + ], + "content": { + "_type": "Boolean Box", + "_source0": "network_table:///SmartDashboard/Drum Ready", + "_title": "Drum Ready", + "Colors/Color when true": "#7CFC00FF", + "Colors/Color when false": "#8B0000FF" + } + }, + "0,2": { + "size": [ + 1, + 1 + ], + "content": { + "_type": "Boolean Box", + "_source0": "network_table:///SmartDashboard/Shooter Beam", + "_title": "Shooter Beam", + "Colors/Color when true": "#7CFC00FF", + "Colors/Color when false": "#8B0000FF" + } + }, + "3,2": { + "size": [ + 1, + 1 + ], + "content": { + "_type": "Boolean Box", + "_source0": "network_table:///SmartDashboard/Upper Beam", + "_title": "Upper Beam", + "Colors/Color when true": "#7CFC00FF", + "Colors/Color when false": "#8B0000FF" + } + }, + "4,2": { + "size": [ + 1, + 1 + ], + "content": { + "_type": "Boolean Box", + "_source0": "network_table:///SmartDashboard/Turret Aimed", + "_title": "Turret Aimed", + "Colors/Color when true": "#7CFC00FF", + "Colors/Color when false": "#8B0000FF" + } + }, + "8,2": { + "size": [ + 1, + 1 + ], + "content": { + "_type": "Boolean Box", + "_source0": "network_table:///SmartDashboard/Intake Beam", + "_title": "Intake Beam", + "Colors/Color when true": "#7CFC00FF", + "Colors/Color when false": "#8B0000FF" + } + }, + "9,2": { + "size": [ + 1, + 1 + ], + "content": { + "_type": "Boolean Box", + "_source0": "network_table:///SmartDashboard/Storage Beam", + "_title": "Storage Beam", + "Colors/Color when true": "#7CFC00FF", + "Colors/Color when false": "#8B0000FF" + } + }, + "0,3": { + "size": [ + 1, + 1 + ], + "content": { + "_type": "Text View", + "_source0": "network_table:///SmartDashboard/Left Motor Position Raw", + "_title": "Left Motor Position Raw" + } + }, + "1,3": { + "size": [ + 1, + 1 + ], + "content": { + "_type": "Text View", + "_source0": "network_table:///SmartDashboard/Right Motor Position Raw", + "_title": "Right Motor Position Raw" + } + }, + "2,3": { + "size": [ + 1, + 1 + ], + "content": { + "_type": "Text View", + "_source0": "network_table:///SmartDashboard/Average Motor Position Raw", + "_title": "Average Motor Position Raw" + } + }, + "3,3": { + "size": [ + 1, + 1 + ], + "content": { + "_type": "Text View", + "_source0": "network_table:///SmartDashboard/Avg Speed MPH", + "_title": "Avg Speed MPH" + } + }, + "4,3": { + "size": [ + 1, + 1 + ], + "content": { + "_type": "Text View", + "_source0": "network_table:///SmartDashboard/Turret Angle Raw", + "_title": "Turret Angle Raw" + } + }, + "5,3": { + "size": [ + 1, + 1 + ], + "content": { + "_type": "Boolean Box", + "_source0": "network_table:///SmartDashboard/Aim Ready", + "_title": "Aim Ready", + "Colors/Color when true": "#7CFC00FF", + "Colors/Color when false": "#8B0000FF" + } + }, + "6,3": { + "size": [ + 2, + 2 + ], + "content": { + "_type": "Gyro", + "_source0": "network_table:///SmartDashboard/Turret Angle", + "_title": "Turret Angle", + "Visuals/Major tick spacing": 45.0, + "Visuals/Starting angle": 180.0, + "Visuals/Show tick mark ring": true, + "Visuals/Counter clockwise": false + } + }, + "8,3": { + "size": [ + 1, + 1 + ], + "content": { + "_type": "Text View", + "_source0": "network_table:///SmartDashboard/Hood Angle Raw", + "_title": "Hood Angle Raw" + } + }, + "9,3": { + "size": [ + 1, + 1 + ], + "content": { + "_type": "Boolean Box", + "_source0": "network_table:///SmartDashboard/!Ball in Intake!", + "_title": "!Ball in Intake!", + "Colors/Color when true": "#7CFC00FF", + "Colors/Color when false": "#8B0000FF" + } + }, + "0,4": { + "size": [ + 1, + 1 + ], + "content": { + "_type": "Boolean Box", + "_source0": "network_table:///SmartDashboard/!Ball Storage!", + "_title": "!Ball Storage!", + "Colors/Color when true": "#7CFC00FF", + "Colors/Color when false": "#8B0000FF" + } + }, + "1,4": { + "size": [ + 1, + 1 + ], + "content": { + "_type": "Boolean Box", + "_source0": "network_table:///SmartDashboard/!Ball Shooter!", + "_title": "!Ball Shooter!", + "Colors/Color when true": "#7CFC00FF", + "Colors/Color when false": "#8B0000FF" + } + }, + "2,4": { + "size": [ + 1, + 1 + ], + "content": { + "_type": "Text View", + "_source0": "network_table:///SmartDashboard/Distance to Target", + "_title": "Distance to Target" + } + }, + "3,4": { + "size": [ + 1, + 1 + ], + "content": { + "_type": "Text View", + "_source0": "network_table:///SmartDashboard/Center Displacement", + "_title": "Center Displacement" + } + }, + "4,4": { + "size": [ + 1, + 1 + ], + "content": { + "_type": "Text View", + "_source0": "network_table:///SmartDashboard/Is Auto Start?", + "_title": "Is Auto Start?" + } + }, + "5,4": { + "size": [ + 1, + 1 + ], + "content": { + "_type": "Text View", + "_source0": "network_table:///SmartDashboard/Left Motor Pos Inches", + "_title": "Left Motor Pos Inches" + } + }, + "8,4": { + "size": [ + 1, + 1 + ], + "content": { + "_type": "Text View", + "_source0": "network_table:///SmartDashboard/Right Motor Pos Inches", + "_title": "Right Motor Pos Inches" + } + }, + "9,4": { + "size": [ + 1, + 1 + ], + "content": { + "_type": "Text View", + "_source0": "network_table:///SmartDashboard/Left Motor Pos Meters", + "_title": "Left Motor Pos Meters" + } + }, + "0,5": { + "size": [ + 1, + 1 + ], + "content": { + "_type": "Text View", + "_source0": "network_table:///SmartDashboard/Right Motor Pos Meters", + "_title": "Right Motor Pos Meters" + } + }, + "1,5": { + "size": [ + 1, + 1 + ], + "content": { + "_type": "Text View", + "_source0": "network_table:///SmartDashboard/Odometry Values Meters", + "_title": "Odometry Values Meters" + } } } } @@ -310,6 +609,34 @@ "_type": "Text View", "_source0": "network_table:///LiveWindow/Ungrouped/DoubleSolenoid[7,3]/Value", "_title": "DoubleSolenoid[7,3]/Value" + }, + { + "_type": "Boolean Box", + "_source0": "network_table:///LiveWindow/Ungrouped/DigitalInput[13]/Value", + "_title": "DigitalInput[13]/Value", + "Colors/Color when true": "#7CFC00FF", + "Colors/Color when false": "#8B0000FF" + }, + { + "_type": "Boolean Box", + "_source0": "network_table:///LiveWindow/Ungrouped/DigitalInput[11]/Value", + "_title": "DigitalInput[11]/Value", + "Colors/Color when true": "#7CFC00FF", + "Colors/Color when false": "#8B0000FF" + }, + { + "_type": "Boolean Box", + "_source0": "network_table:///LiveWindow/Ungrouped/DigitalInput[14]/Value", + "_title": "DigitalInput[14]/Value", + "Colors/Color when true": "#7CFC00FF", + "Colors/Color when false": "#8B0000FF" + }, + { + "_type": "Boolean Box", + "_source0": "network_table:///LiveWindow/Ungrouped/DigitalInput[12]/Value", + "_title": "DigitalInput[12]/Value", + "Colors/Color when true": "#7CFC00FF", + "Colors/Color when false": "#8B0000FF" } ] } @@ -460,30 +787,6 @@ "Visuals/Counter clockwise": false } }, - "8,8": { - "size": [ - 1, - 1 - ], - "content": { - "_type": "Boolean Box", - "_title": "Boolean Box", - "Colors/Color when true": "#7CFC00FF", - "Colors/Color when false": "#8B0000FF" - } - }, - "9,8": { - "size": [ - 1, - 1 - ], - "content": { - "_type": "Boolean Box", - "_title": "Boolean Box", - "Colors/Color when true": "#7CFC00FF", - "Colors/Color when false": "#8B0000FF" - } - }, "8,5": { "size": [ 2, @@ -497,54 +800,6 @@ "Visuals/Show value": true } }, - "6,0": { - "size": [ - 1, - 1 - ], - "content": { - "_type": "Boolean Box", - "_title": "Boolean Box", - "Colors/Color when true": "#7CFC00FF", - "Colors/Color when false": "#8B0000FF" - } - }, - "4,0": { - "size": [ - 1, - 1 - ], - "content": { - "_type": "Boolean Box", - "_title": "Boolean Box", - "Colors/Color when true": "#7CFC00FF", - "Colors/Color when false": "#8B0000FF" - } - }, - "5,0": { - "size": [ - 1, - 1 - ], - "content": { - "_type": "Boolean Box", - "_title": "Boolean Box", - "Colors/Color when true": "#7CFC00FF", - "Colors/Color when false": "#8B0000FF" - } - }, - "7,0": { - "size": [ - 1, - 1 - ], - "content": { - "_type": "Boolean Box", - "_title": "Boolean Box", - "Colors/Color when true": "#7CFC00FF", - "Colors/Color when false": "#8B0000FF" - } - }, "8,0": { "size": [ 2, @@ -677,15 +932,93 @@ "Wheels/Wheel diameter": 80.0, "Visuals/Show velocity vectors": true } + }, + "8,8": { + "size": [ + 1, + 1 + ], + "content": { + "_type": "Boolean Box", + "_source0": "network_table:///SmartDashboard/Turret Aimed", + "_title": "/SmartDashboard/Turret Aimed", + "Colors/Color when true": "#7CFC00FF", + "Colors/Color when false": "#8B0000FF" + } + }, + "9,8": { + "size": [ + 1, + 1 + ], + "content": { + "_type": "Boolean Box", + "_source0": "network_table:///SmartDashboard/Drum Ready", + "_title": "/SmartDashboard/Drum Ready", + "Colors/Color when true": "#7CFC00FF", + "Colors/Color when false": "#8B0000FF" + } + }, + "6,0": { + "size": [ + 1, + 1 + ], + "content": { + "_type": "Boolean Box", + "_source0": "network_table:///SmartDashboard/Upper Beam", + "_title": "/SmartDashboard/Upper Beam", + "Colors/Color when true": "#7CFC00FF", + "Colors/Color when false": "#8B0000FF" + } + }, + "5,0": { + "size": [ + 1, + 1 + ], + "content": { + "_type": "Boolean Box", + "_source0": "network_table:///SmartDashboard/Storage Beam", + "_title": "/SmartDashboard/Storage Beam", + "Colors/Color when true": "#7CFC00FF", + "Colors/Color when false": "#8B0000FF" + } + }, + "7,0": { + "size": [ + 1, + 1 + ], + "content": { + "_type": "Boolean Box", + "_source0": "network_table:///SmartDashboard/Shooter Beam", + "_title": "/SmartDashboard/Shooter Beam", + "Colors/Color when true": "#7CFC00FF", + "Colors/Color when false": "#8B0000FF" + } + }, + "4,0": { + "size": [ + 1, + 1 + ], + "content": { + "_type": "Boolean Box", + "_source0": "network_table:///SmartDashboard/Intake Beam", + "_title": "/SmartDashboard/Intake Beam", + "Colors/Color when true": "#7CFC00FF", + "Colors/Color when false": "#8B0000FF" + } } } } } ], "windowGeometry": { - "x": 47.20000076293945, - "y": 148.8000030517578, - "width": 1553.5999755859375, - "height": 1448.0 + "x": -7.199999809265137, + "y": -7.199999809265137, + "width": 1550.4000244140625, + "height": 878.4000244140625 } } \ No newline at end of file diff --git a/src/main/java/frc4388/robot/Constants.java b/src/main/java/frc4388/robot/Constants.java index e3a6bcf..c6a8a3e 100644 --- a/src/main/java/frc4388/robot/Constants.java +++ b/src/main/java/frc4388/robot/Constants.java @@ -116,7 +116,7 @@ public final class Constants { public static final int SHOOTER_SLOT_IDX = 0; public static final int SHOOTER_PID_LOOP_IDX = 1; public static final int SHOOTER_TIMEOUT_MS = 30; - public static final Gains DRUM_SHOOTER_GAINS = new Gains(0.55, 0.0, 100, 0.0, 0, 1.0); + public static final Gains DRUM_SHOOTER_GAINS = new Gains(1.5, 0.0, 100, 0.055, 0, 1.0); public static final Gains SHOOTER_TURRET_GAINS = new Gains(0.0, 0.0, 0.0, 0.0, 0, 1.0); public static final Gains SHOOTER_ANGLE_GAINS = new Gains(0.05, 0.0, 0.0, 0.0, 0, 0.3); public static final double SHOOTER_TURRET_MIN = -1.0; diff --git a/src/main/java/frc4388/robot/commands/shooter/ShooterVelocityControlPID.java b/src/main/java/frc4388/robot/commands/shooter/ShooterVelocityControlPID.java index 75a6896..b3d3ac1 100644 --- a/src/main/java/frc4388/robot/commands/shooter/ShooterVelocityControlPID.java +++ b/src/main/java/frc4388/robot/commands/shooter/ShooterVelocityControlPID.java @@ -34,7 +34,18 @@ public class ShooterVelocityControlPID extends CommandBase { // Called every time the scheduler runs while the command is scheduled. @Override public void execute() { - m_shooter.runDrumShooterVelocityPID(m_shooter.addFireVel()); + //Tells whether the target velocity has been reached + m_actualVel = m_shooter.m_shooterFalcon.getSelectedSensorPosition(); + m_targetVel = m_shooter.addFireVel(); + double error = m_actualVel - m_targetVel; + if (Math.abs(error) < ShooterConstants.DRUM_VELOCITY_BOUND){ + m_shooter.m_isDrumReady = true; + m_shooter.runDrumShooterVelocityPID(m_targetVel); + } + else{ + m_shooter.m_isDrumReady = false; + m_shooter.runDrumShooterVelocityPID(m_targetVel); + } } // Called once the command ends or is interrupted. @@ -45,16 +56,6 @@ public class ShooterVelocityControlPID extends CommandBase { // Returns true when the command should end. @Override public boolean isFinished() { - //Tells whether the target velocity has been reached - double upperBound = m_targetVel + ShooterConstants.DRUM_VELOCITY_BOUND; - double lowerBound = m_targetVel - ShooterConstants.DRUM_VELOCITY_BOUND; - if (m_actualVel < upperBound && m_actualVel > lowerBound){ - m_shooter.m_isDrumReady = true; - } - else{ - m_shooter.m_isDrumReady = false; - } - return false; } } diff --git a/src/main/java/frc4388/robot/subsystems/Shooter.java b/src/main/java/frc4388/robot/subsystems/Shooter.java index 0351968..89e1bfb 100644 --- a/src/main/java/frc4388/robot/subsystems/Shooter.java +++ b/src/main/java/frc4388/robot/subsystems/Shooter.java @@ -54,7 +54,7 @@ public class Shooter extends SubsystemBase { m_shooterFalcon.setNeutralMode(NeutralMode.Coast); m_shooterFalcon.setInverted(true); m_shooterFalcon.configOpenloopRamp(1, ShooterConstants.SHOOTER_TIMEOUT_MS); - m_shooterFalcon.configClosedloopRamp(1.0, ShooterConstants.SHOOTER_TIMEOUT_MS); + //m_shooterFalcon.configClosedloopRamp(1.0, ShooterConstants.SHOOTER_TIMEOUT_MS); setShooterGains(); m_shooterFalcon.configPeakOutputReverse(0, ShooterConstants.SHOOTER_TIMEOUT_MS); diff --git a/src/main/java/frc4388/robot/subsystems/ShooterAim.java b/src/main/java/frc4388/robot/subsystems/ShooterAim.java index 4922509..db9d231 100644 --- a/src/main/java/frc4388/robot/subsystems/ShooterAim.java +++ b/src/main/java/frc4388/robot/subsystems/ShooterAim.java @@ -67,8 +67,6 @@ public class ShooterAim extends SubsystemBase { // This method will be called once per scheduler run SmartDashboard.putNumber("Turret Angle Raw", getShooterRotatePosition()); - SmartDashboard.putBoolean("Aim Ready", m_isAimReady); - SmartDashboard.putData("Turret Angle", m_turretGyro); SmartDashboard.putBoolean("Turret Aimed" , m_isAimReady);