public class Intake extends SubsystemBase implements IntakeIO{
private TalonFX flyWheelMotor = new TalonFX(IdConstants.INTAKE_FLYWHEEL_ID, Constants.SUBSYSTEM_CANIVORE_CAN);
- private TalonFX baseMotor = new TalonFX(IdConstants.INTAKE_BASE_ID, Constants.SUBSYSTEM_CANIVORE_CAN);
+ private TalonFX baseMotorLeft = new TalonFX(IdConstants.INTAKE_BASE_LEFT_ID, Constants.SUBSYSTEM_CANIVORE_CAN);
+ private TalonFX baseMotorRight = new TalonFX(IdConstants.INTAKE_BASE_RIGHT_ID, Constants.SUBSYSTEM_CANIVORE_CAN);
double basePower;
double flyWheelPower;
public Intake() {
updateInputs();
- encoderSim = baseMotor.getSimState();
+ encoderSim = baseMotorLeft.getSimState();
intakeSim = new SingleJointedArmSim(
baseIntakeMotorSim,
Units.degreesToRadians(0),
Units.degreesToRadians(360),
true,
- Units.degreesToRadians(IntakeConstants.START_ANGLE)
+ Units.degreesToRadians(IntakeConstants.STOW_ANGLE)
);
double absoluteAngleDegrees = getAbsoluteEncoderAngle() - IntakeConstants.ABSOLUTE_OFFSET_ANGLE;
- baseMotor.setPosition(Units.degreesToRotations(absoluteAngleDegrees * IntakeConstants.PIVOT_GEAR_RATIO));
- baseMotor.setNeutralMode(NeutralModeValue.Coast);
+ baseMotorLeft.setPosition(Units.degreesToRotations(absoluteAngleDegrees * IntakeConstants.PIVOT_GEAR_RATIO));
+ baseMotorLeft.setNeutralMode(NeutralModeValue.Coast);
+ baseMotorRight.setPosition(Units.degreesToRotations(absoluteAngleDegrees * IntakeConstants.PIVOT_GEAR_RATIO));
+ baseMotorRight.setNeutralMode(NeutralModeValue.Coast);
TalonFXConfiguration config = new TalonFXConfiguration();
config.Slot0.kS = 0.1; // Static friction compensation (should be >0 if friction exists)
config.MotorOutput.Inverted = InvertedValue.CounterClockwise_Positive;
- baseMotor.getConfigurator().apply(config);
+ baseMotorLeft.getConfigurator().apply(config);
+
+ config.MotorOutput.Inverted = InvertedValue.Clockwise_Positive;
+
+ baseMotorRight.getConfigurator().apply(config);
CurrentLimitsConfigs limitConfig = new CurrentLimitsConfigs();
limitConfig.StatorCurrentLimit = 30; // 120
limitConfig.StatorCurrentLimitEnable = true;
- baseMotor.getConfigurator().apply(limitConfig);
+ baseMotorLeft.getConfigurator().apply(limitConfig);
+ baseMotorRight.getConfigurator().apply(limitConfig);
flyWheelMotor.getConfigurator().apply(
new MotorOutputConfigs().withInverted(InvertedValue.Clockwise_Positive)
public void setSetpoint(double setpoint) {
double clampedSetpoint = MathUtil.clamp(setpoint, 90.0, 180.0);
- baseMotor.setControl(voltageRequest.withPosition(Units.degreesToRotations(clampedSetpoint) * IntakeConstants.PIVOT_GEAR_RATIO).withFeedForward(feedforward.calculate(Units.degreesToRadians(getAngle()), 0)));
+ baseMotorLeft.setControl(voltageRequest.withPosition(Units.degreesToRotations(clampedSetpoint) * IntakeConstants.PIVOT_GEAR_RATIO).withFeedForward(feedforward.calculate(Units.degreesToRadians(getAngle()), 0)));
+ baseMotorRight.setControl(voltageRequest.withPosition(Units.degreesToRotations(clampedSetpoint) * IntakeConstants.PIVOT_GEAR_RATIO).withFeedForward(feedforward.calculate(Units.degreesToRadians(getAngle()), 0)));
}
@AutoLogOutput
// if(RobotBase.isSimulation()){
// return position;
// }
- return inputs.measuredAngle;
+ return inputs.measuredAngleLeft;
}
public double getFlyWheelVelocity() {
}
public double getAppliedVoltage() {
- return baseMotor.getMotorVoltage().getValueAsDouble();
+ return baseMotorLeft.getMotorVoltage().getValueAsDouble();
}
@Override
public void simulationPeriodic() {
- double voltsMotor = baseMotor.getMotorVoltage().getValueAsDouble();
+ double voltsMotor = baseMotorLeft.getMotorVoltage().getValueAsDouble();
intakeSim.setInputVoltage(voltsMotor);
intakeSim.update(Constants.LOOP_TIME);
@Override
public void updateInputs() {
- inputs.measuredAngle = Units.rotationsToDegrees(baseMotor.getPosition().getValueAsDouble()/ IntakeConstants.PIVOT_GEAR_RATIO);
- inputs.currentAmps = baseMotor.getStatorCurrent().getValueAsDouble();
+ inputs.measuredAngleLeft = Units.rotationsToDegrees(baseMotorLeft.getPosition().getValueAsDouble()/ IntakeConstants.PIVOT_GEAR_RATIO);
+ inputs.measuredAngleRight = Units.rotationsToDegrees(baseMotorLeft.getPosition().getValueAsDouble()/ IntakeConstants.PIVOT_GEAR_RATIO);
+ inputs.currentAmps = baseMotorLeft.getStatorCurrent().getValueAsDouble();
inputs.flyWheelVelocity = Units.rotationsPerMinuteToRadiansPerSecond(flyWheelMotor.getVelocity().getValueAsDouble() * 60);
Logger.processInputs("Intake", inputs);
package frc.robot.subsystems.intake;
public class IntakeConstants {
- public static final double PIVOT_GEAR_RATIO = 1/(18.0*18.0*10.0/54.0/60.0/38.0); //38
+ public static final double PIVOT_GEAR_RATIO = 3.0; //38
public static final double MASS = 1.5753263; // kilograms: mass of arm specifically
public static final double CENTER_OF_MASS_LENGTH = 0.199608903192622; // meters
public static final double MAX_VELOCITY = 15.0; // rad/s
public static final double MAX_ACCELERATION = 100.0; // rad/s^2
- public static final double START_ANGLE = 101.7539148;
+ // TODO: Find these
+ public static final double STOW_ANGLE = 101.7539148;
public static final double INTAKE_ANGLE = 142.48;
- public static final double STOW_ANGLE = 107.0;
//TODO: find this
public static final double FLYWHEEL_SPEED = 1.0;
//TODO: find this
- public static final double ABSOLUTE_OFFSET_ANGLE = (139.1748046875 - START_ANGLE + 30);
+ public static final double ABSOLUTE_OFFSET_ANGLE = 0.0;
}
\ No newline at end of file