SmartDashboard.putNumber("Spindexer Power", power);
SmartDashboard.putNumber("Spindexer Velocity", inputs.spindexerVelocity);
+
+ // scale threshold based on power
+ double velocityThreshold = SpindexerConstants.spindexerVelocityWithBall * power;
+ SmartDashboard.putNumber("Spindexer Velocity Threshold", velocityThreshold);
SmartDashboard.putNumber("Spindexer Ball Count", ballCount);
- boolean isSpindexerSlow = inputs.spindexerVelocity < SpindexerConstants.spindexerVelocityWithBall;
+ boolean isSpindexerSlow = inputs.spindexerVelocity < velocityThreshold;
if (wasSpindexerSlow && !isSpindexerSlow && power > 0.1) {
ballCount++;
}
@Override
public void updateInputs() {
- inputs.spindexerVelocity = motor.getVelocity().getValueAsDouble();
+ inputs.spindexerVelocity = motor.getVelocity().getValueAsDouble() * SpindexerConstants.gearRatio;
inputs.spindexerCurrent = motor.getStatorCurrent().getValueAsDouble();
Logger.processInputs("Spindexer", inputs);
}
package frc.robot.subsystems.spindexer;
public class SpindexerConstants {
- public static final double spindexerVelocityWithBall = 6.0; // rps (for counting balls)
+ public static final double gearRatio = 1.0 / 27.0;
+ // TODO: measure actual velocity with/without ball to tune threshold
+ public static final double spindexerVelocityWithBall = 6.0 * gearRatio; // output rps at full power
public static final double spindexerMaxPower = 1.0;
public static final int currentLimit = 20; // amps
}