Working robot in testing

This commit is contained in:
Michael Mikovsky
2026-02-10 17:33:39 -08:00
parent 6ce6d0eb0b
commit 539c1bd8eb
8 changed files with 74 additions and 61 deletions
@@ -33,17 +33,10 @@ public class Intake extends SubsystemBase {
Retracted,
}
private IntakeMode mode = IntakeMode.Extended;
public void setMode(IntakeMode mode) {
switch (mode) {
case Extended:
io.setArmAngle(state, Rotations.of(IntakeConstants.ARM_LIMIT_EXTENDED.get()));
io.setRollerVelocity(state, RotationsPerSecond.of(IntakeConstants.ROLLER_ACTIVE.get()));
break;
case Retracted:
io.setArmAngle(state, Rotations.of(IntakeConstants.ARM_LIMIT_RETRACTED.get()));
io.setRollerVelocity(state, RotationsPerSecond.of(0));
break;
}
this.mode = mode;
}
@@ -70,6 +63,17 @@ public class Intake extends SubsystemBase {
io.updateInputs(state);
switch (mode) {
case Extended:
io.setArmAngle(state, Rotations.of(IntakeConstants.ARM_LIMIT_EXTENDED.get()));
io.setRollerVelocity(state, RotationsPerSecond.of(IntakeConstants.ROLLER_ACTIVE.get()));
break;
case Retracted:
io.setArmAngle(state, Rotations.of(IntakeConstants.ARM_LIMIT_RETRACTED.get()));
io.setRollerVelocity(state, RotationsPerSecond.of(0));
break;
}
}
}
@@ -18,8 +18,8 @@ import frc4388.utility.status.CanDevice;
public class IntakeConstants {
// Motor conversions
public static final double ARM_MOTOR_GEAR_RATIO = 1/100;
public static final double ROLLER_MOTOR_GEAR_RATIO = 1/3;
public static final double ARM_MOTOR_GEAR_RATIO = 100;
public static final double ROLLER_MOTOR_GEAR_RATIO = 3;
//IDs
@@ -37,8 +37,8 @@ public class IntakeConstants {
// public static final Angle ARM_LIMIT_LOWER = Degrees.of(90);
// public static final Angle ARM_LIMIT_UPPER = Degrees.of(-90);
public static final ConfigurableDouble ARM_LIMIT_RETRACTED = new ConfigurableDouble("Arm angle retracted", 0);
public static final ConfigurableDouble ARM_LIMIT_EXTENDED = new ConfigurableDouble("Arm angle extended", 0.25);
public static final ConfigurableDouble ARM_LIMIT_RETRACTED = new ConfigurableDouble("Arm angle retracted", -0.3);
public static final ConfigurableDouble ARM_LIMIT_EXTENDED = new ConfigurableDouble("Arm angle extended", 0);
public static final ConfigurableDouble ROLLER_ACTIVE = new ConfigurableDouble("Rolelr Active", 10);
// public static final ConfigurableDouble ROLL = new ConfigurableDouble("Arm angle extended", 0.25);
@@ -58,8 +58,8 @@ public class IntakeConstants {
.withKD(0.0);
public static ConfigurableDouble arm_kP = new ConfigurableDouble("ARM KP", 0.2);
public static ConfigurableDouble arm_kI = new ConfigurableDouble("ARM KP", 0);
public static ConfigurableDouble arm_kD = new ConfigurableDouble("ARM KP", 0);
public static ConfigurableDouble arm_kI = new ConfigurableDouble("ARM KI", 0);
public static ConfigurableDouble arm_kD = new ConfigurableDouble("ARM KD", 0);
public static ConfigurableDouble roller_kP = new ConfigurableDouble("Roller KP", 0.2);
public static ConfigurableDouble roller_kI = new ConfigurableDouble("Roller KI", 0);
@@ -65,7 +65,7 @@ public class IntakeReal implements IntakeIO {
}
// (REAL_ROT / SEC) * (MOTOR_ROT / REAL_ROT) = (MOTOR_ROT / SEC)
AngularVelocity motorSpeed = angularVelocity.div(IntakeConstants.ROLLER_MOTOR_GEAR_RATIO);
AngularVelocity motorSpeed = angularVelocity.times(IntakeConstants.ROLLER_MOTOR_GEAR_RATIO);
// m_rollerMotor.set(motorSpeed);
// VelocityDutyCycle velocity = new VelocityDutyCycle(motorSpeed);
@@ -80,7 +80,7 @@ public class IntakeReal implements IntakeIO {
// (REAL_ROT) * (MOTOR_ROT / REAL_ROT) = MOTOR_ROT
Angle motorAngle = angle.div(IntakeConstants.ARM_MOTOR_GEAR_RATIO);
Angle motorAngle = angle.times(IntakeConstants.ARM_MOTOR_GEAR_RATIO);
// PositionDutyCycle posRequest = new PositionDutyCycle(motorTargetAngle);
m_armMotor.setControl(armPosition.withPosition(motorAngle));
@@ -88,10 +88,10 @@ public class IntakeReal implements IntakeIO {
@Override
public void updateInputs(IntakeState state) {
state.armAngle = m_armMotor.getPosition().getValue().times(IntakeConstants.ARM_MOTOR_GEAR_RATIO);
state.armMotorCurrent = m_armMotor.getStatorCurrent(false).getValue();
state.armAngle = m_armMotor.getPosition().getValue().div(IntakeConstants.ARM_MOTOR_GEAR_RATIO);
state.armMotorCurrent = m_armMotor.getStatorCurrent().getValue();
state.rollerVelocity = m_rollerMotor.getVelocity().getValue();
state.rollerVelocity = m_rollerMotor.getVelocity().getValue().div(IntakeConstants.ROLLER_MOTOR_GEAR_RATIO);
state.rollerMotorCurrent = m_rollerMotor.getStatorCurrent().getValue();
}
@@ -101,11 +101,11 @@ public class IntakeReal implements IntakeIO {
IntakeConstants.ARM_PID.kP = IntakeConstants.arm_kP.get();
IntakeConstants.ARM_PID.kI = IntakeConstants.arm_kI.get();
IntakeConstants.ARM_PID.kD = IntakeConstants.arm_kD.get();
m_armMotor.getConfigurator().apply(IntakeConstants.ARM_MOTOR_CONFIG);
m_armMotor.getConfigurator().apply(IntakeConstants.ARM_PID);
IntakeConstants.ROLLER_PID.kP = IntakeConstants.roller_kP.get();
IntakeConstants.ROLLER_PID.kI = IntakeConstants.roller_kI.get();
IntakeConstants.ROLLER_PID.kD = IntakeConstants.roller_kD.get();
m_rollerMotor.getConfigurator().apply(IntakeConstants.ROLLER_MOTOR_CONFIG);
m_rollerMotor.getConfigurator().apply(IntakeConstants.ROLLER_PID);
}
}