Reduced Error

This commit is contained in:
Aarav Shah
2021-03-12 12:37:06 -07:00
parent 8c9ae1d16e
commit fcc91455ac
5 changed files with 29 additions and 17 deletions
+8 -8
View File
@@ -1,9 +1,9 @@
Distance (in),Hood Ext. (u),Drum Velocity (u/ds),Center Displacment (deg) Distance (in),Hood Ext. (u),Drum Velocity (u/ds),Center Displacment (deg)
0,16,6000,1, 0,16,6000,0,
65.9,16,6000,1, 65.9,16,6000,0,
126.6,20.25,7000,0.95, 126.6,20.25,7000,0,
180,24,8000,1, 180,24,8000,0,
185.85,26.5, 9000,1.625, 185.85,26.5, 9000,1.1,
245,28.9,9500,.98, 245,28.9,9500,0,
262,28.9,9500,.98, 262,28.9,9500,0,
999,28.9,9500,.98, 999,28.9,9500,0,
1 Distance (in),Hood Ext. (u),Drum Velocity (u/ds),Center Displacment (deg)
2 0,16,6000,1, 0,16,6000,0,
3 65.9,16,6000,1, 65.9,16,6000,0,
4 126.6,20.25,7000,0.95, 126.6,20.25,7000,0,
5 180,24,8000,1, 180,24,8000,0,
6 185.85,26.5, 9000,1.625, 185.85,26.5, 9000,1.1,
7 245,28.9,9500,.98, 245,28.9,9500,0,
8 262,28.9,9500,.98, 262,28.9,9500,0,
9 999,28.9,9500,.98, 999,28.9,9500,0,
+11 -1
View File
@@ -26,4 +26,14 @@ IN BETWEEN
185.85,26.5, 9000,1.625, 185.85,26.5, 9000,1.625,
245,27,11000,1, 245,27,11000,1,
262,27,11000,1.25, 262,27,11000,1.25,
999,27,11000,1.25, 999,27,11000,1.25,
HOLD
0,16,6000,1,
65.9,16,6000,1,
126.6,20.25,7000,0.95,
180,24,8000,1,
185.85,26.5, 9000,1.625,
245,28.9,9500,.98,
262,28.9,9500,.98,
999,28.9,9500,.98,
1 Distance (in),Hood Ext. (u),Drum Velocity (u/ds),Center Displacment (deg)
26 262,27,11000,1.25,
27 999,27,11000,1.25,
28 HOLD
29 0,16,6000,1,
30 65.9,16,6000,1,
31 126.6,20.25,7000,0.95,
32 180,24,8000,1,
33 185.85,26.5, 9000,1.625,
34 245,28.9,9500,.98,
35 262,28.9,9500,.98,
36 999,28.9,9500,.98,
37
38
39
+1 -1
View File
@@ -215,7 +215,7 @@ public final class Constants {
public static final double TARGET_HEIGHT = 67.5; public static final double TARGET_HEIGHT = 67.5;
public static final double LIME_ANGLE = 24.7; public static final double LIME_ANGLE = 24.7;
public static final double TURN_P_VALUE = 0.8; public static final double TURN_P_VALUE = 0.8;
public static final double X_ANGLE_ERROR = 1.3; public static final double X_ANGLE_ERROR = 0.5;
public static final double MOTOR_DEAD_ZONE = 0.2; public static final double MOTOR_DEAD_ZONE = 0.2;
public static final double DISTANCE_ERROR_EQUATION_M = 1.1279; public static final double DISTANCE_ERROR_EQUATION_M = 1.1279;
public static final double DISTANCE_ERROR_EQUATION_B = -15.0684; public static final double DISTANCE_ERROR_EQUATION_B = -15.0684;
@@ -254,9 +254,9 @@ public class RobotContainer {
new JoystickButton(getOperatorJoystick(), XboxController.A_BUTTON) new JoystickButton(getOperatorJoystick(), XboxController.A_BUTTON)
.whileHeld(new TrackTarget(m_robotShooterAim)) .whileHeld(new TrackTarget(m_robotShooterAim))
.whileHeld(new RunCommand(() -> m_robotShooterHood.runAngleAdjustPID(m_robotShooterHood.addFireAngle()))) .whileHeld(new RunCommand(() -> m_robotShooterHood.runAngleAdjustPID(m_robotShooterHood.addFireAngle())))
//.whenPressed(new StoragePrep(m_robotStorage))
//.whenReleased(new InterruptSubystem(m_robotStorage))
.whenReleased(new InstantCommand(() -> m_robotLime.limeOff())); .whenReleased(new InstantCommand(() -> m_robotLime.limeOff()));
//.whileHeld(new RunCommand(() -> m_robotShooterAim.runshooterRotatePID()));
//.whileHeld(new RunCommand(() -> m_robotShooter.runDrumShooterVelocityPID(11000))); //.whileHeld(new RunCommand(() -> m_robotShooter.runDrumShooterVelocityPID(11000)));
//.whileHeld(new HoldTarget(m_robotShooter, m_robotShooterAim)) //.whileHeld(new HoldTarget(m_robotShooter, m_robotShooterAim))
//.whileHeld(new RunCommand(() -> m_robotShooter.runAngleAdjustPID(30))); //.whileHeld(new RunCommand(() -> m_robotShooter.runAngleAdjustPID(30)));
@@ -76,17 +76,19 @@ public class TrackTarget extends CommandBase {
if (target == 1.0) { // If target in view if (target == 1.0) { // If target in view
// Aiming Left/Right // Aiming Left/Right
xAngle = xAngle + m_shooter.m_shooterTable.getCenterDisplacement(realDistance); xAngle = xAngle + m_shooter.m_shooterTable.getCenterDisplacement(realDistance);
turnAmount = (xAngle / VisionConstants.FOV) * VisionConstants.TURN_P_VALUE; turnAmount = ((xAngle / VisionConstants.FOV) * VisionConstants.TURN_P_VALUE);
if (Math.abs(xAngle) < VisionConstants.X_ANGLE_ERROR) { if (Math.abs(xAngle) < VisionConstants.X_ANGLE_ERROR) {
turnAmount = 0; turnAmount = 0;
} // Angle Error Zone } // Angle Error Zone
// Deadzones // Deadzones
else if (turnAmount > 0 && turnAmount < VisionConstants.MOTOR_DEAD_ZONE) { else if (turnAmount > 0 && turnAmount < 0.1){// VisionConstants.MOTOR_DEAD_ZONE) {
turnAmount = VisionConstants.MOTOR_DEAD_ZONE; turnAmount = 0.1;//VisionConstants.MOTOR_DEAD_ZONE;
} else if (turnAmount < 0 && turnAmount > -VisionConstants.MOTOR_DEAD_ZONE) { } else if (turnAmount < 0 && turnAmount > -0.1){//-VisionConstants.MOTOR_DEAD_ZONE) {
turnAmount = -VisionConstants.MOTOR_DEAD_ZONE; turnAmount = -0.1;//-VisionConstants.MOTOR_DEAD_ZONE;
} }
m_shooterAim.runShooterWithInput(-turnAmount);// - m_shooter.shooterTrims.m_turretTrim); m_shooterAim.runShooterWithInput(-turnAmount);// - m_shooter.shooterTrims.m_turretTrim);
//m_shooterAim.runshooterRotatePID(targetAngle);
SmartDashboard.putNumber("Distance to Target", realDistance); SmartDashboard.putNumber("Distance to Target", realDistance);
SmartDashboard.putNumber("Center Displacement", m_shooter.m_shooterTable.getCenterDisplacement(realDistance)); SmartDashboard.putNumber("Center Displacement", m_shooter.m_shooterTable.getCenterDisplacement(realDistance));