diff --git a/src/main/java/frc/robot/subsystems/arm/ArmIOKraken.java b/src/main/java/frc/robot/subsystems/arm/ArmIOKraken.java index 343a5b1d..4b37ddad 100644 --- a/src/main/java/frc/robot/subsystems/arm/ArmIOKraken.java +++ b/src/main/java/frc/robot/subsystems/arm/ArmIOKraken.java @@ -41,8 +41,8 @@ public class ArmIOKraken implements ArmIO { private final HeavyDoubleProperty m_wristMaxVelDegS; private final HeavyDoubleProperty m_accelTimeSecs; - private final MotionMagicConfigs m_armMMConfigs = new MotionMagicConfigs(); - private final MotionMagicConfigs m_wristMMConfigs = new MotionMagicConfigs(); + private double m_armMaxVel; + private double m_wristMaxVel; // Control outputs private final DynamicMotionMagicVoltage m_wristDynMMRequest; @@ -51,8 +51,6 @@ public class ArmIOKraken implements ArmIO { private final Follower m_wristFollowerRequest; private final NeutralOut m_stopRequest; - private boolean m_tracking = false; - private double m_prevArmVelocityMult = 0.0; private double m_prevWristVelocityMult = 0.0; @@ -141,16 +139,16 @@ public ArmIOKraken() { .build(); m_armMaxVelDegS = new HeavyDoubleProperty( - (double maxVel) -> m_armDynMMRequest.Velocity = Units.degreesToRotations(maxVel), + (double maxVel) -> m_armMaxVel = Units.degreesToRotations(maxVel), new GosDoubleProperty(false, "Arm/Arm Max Vel DegsS", 120)); m_wristMaxVelDegS = new HeavyDoubleProperty( - (double maxVel) -> m_wristDynMMRequest.Velocity = Units.degreesToRotations(maxVel), + (double maxVel) -> m_wristMaxVel = Units.degreesToRotations(maxVel), new GosDoubleProperty(false, "Arm/Wrist Max Vel DegsS", 120)); m_accelTimeSecs = new HeavyDoubleProperty((double accel) -> { - m_armDynMMRequest.Acceleration = m_armDynMMRequest.Velocity / accel; - m_wristDynMMRequest.Acceleration = m_wristDynMMRequest.Velocity / accel; + m_armDynMMRequest.Acceleration = m_armMaxVel / accel; + m_wristDynMMRequest.Acceleration = m_wristMaxVel / accel; }, new GosDoubleProperty(false, "Arm/Acceleration Time Secs", 1)); m_armMaxVelDegS.updateIfChanged(true); @@ -256,11 +254,7 @@ public void setArmVoltage(double voltage) { @Override public void setArmAngle(double degrees, double velocityMult) { - if (m_prevArmVelocityMult != velocityMult) { - m_armMaxVelDegS.updateIfChanged(true); - } - m_prevArmVelocityMult = velocityMult; - m_armDynMMRequest.Velocity = m_armDynMMRequest.Velocity * velocityMult; + m_armDynMMRequest.Velocity = m_armMaxVel * velocityMult; m_armMaster.setControl(m_armDynMMRequest.withPosition(degrees / 360)); m_armFollower.setControl(m_armFollowerRequest); @@ -274,11 +268,7 @@ public void setWristVoltage(double voltage) { @Override public void setWristAngle(double degrees, double velocityMult) { - if (m_prevWristVelocityMult != velocityMult) { - m_wristMaxVelDegS.updateIfChanged(true); - } - m_prevWristVelocityMult = velocityMult; - m_wristDynMMRequest.Velocity = m_wristDynMMRequest.Velocity * velocityMult; + m_wristDynMMRequest.Velocity = m_wristMaxVel * velocityMult; m_wristMaster.setControl(m_wristDynMMRequest.withPosition(degrees / 360)); m_wristFollower.setControl(m_wristFollowerRequest); diff --git a/src/main/java/frc/robot/subsystems/drive/DriveSubsystem.java b/src/main/java/frc/robot/subsystems/drive/DriveSubsystem.java index f2555ef3..c42c1e93 100644 --- a/src/main/java/frc/robot/subsystems/drive/DriveSubsystem.java +++ b/src/main/java/frc/robot/subsystems/drive/DriveSubsystem.java @@ -293,16 +293,16 @@ public void periodic() { public void runVelocity(ChassisSpeeds speeds) { // Calculate module setpoints ChassisSpeeds discreteSpeeds = ChassisSpeeds.discretize(speeds, 0.02); - SwerveModuleState[] m_setpointStates = kinematics.toSwerveModuleStates(discreteSpeeds); - SwerveDriveKinematics.desaturateWheelSpeeds(m_setpointStates, DriveConstants.MAX_LINEAR_SPEED); + SwerveModuleState[] setpointStates = kinematics.toSwerveModuleStates(discreteSpeeds); + SwerveDriveKinematics.desaturateWheelSpeeds(setpointStates, DriveConstants.MAX_LINEAR_SPEED); // Send setpoints to modules for (int i = 0; i < 4; i++) { // The module returns the optimized state, useful for logging - m_optimizedStates[i] = modules[i].runSetpoint(m_setpointStates[i]); + m_optimizedStates[i] = modules[i].runSetpoint(setpointStates[i]); } - Logger.recordOutput("SwerveStates/Setpoints", m_setpointStates); + Logger.recordOutput("SwerveStates/Setpoints", setpointStates); Logger.recordOutput("SwerveStates/Optimized", m_optimizedStates); }