mirror of
https://github.com/Team4388/2026KPopRobotHunters.git
synced 2026-06-09 00:38:03 -06:00
Indexer
This commit is contained in:
@@ -152,19 +152,15 @@ public class Shooter extends SubsystemBase {
|
|||||||
switch (mode) {
|
switch (mode) {
|
||||||
case Shooting:
|
case Shooting:
|
||||||
io.setShooterVelocity(state, RotationsPerSecond.of(ShooterConstants.SHOOTER_ACTIVE_VELOCITY.get()));
|
io.setShooterVelocity(state, RotationsPerSecond.of(ShooterConstants.SHOOTER_ACTIVE_VELOCITY.get()));
|
||||||
if(state.motor1Velocity.in(RotationsPerSecond) > 30){
|
io.setIndexerOutput(state, ShooterConstants.INDEXER_FORWARD_OUTPUT.get());
|
||||||
io.setIndexerVelocity(state, RotationsPerSecond.of(ShooterConstants.INDEXER_FORWARD_VELOCITY.get()));
|
|
||||||
}else{
|
|
||||||
io.setIndexerVelocity(state, RotationsPerSecond.of(ShooterConstants.INDEXER_REVERSE_VELOCITY.get()));
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
case Ready:
|
case Ready:
|
||||||
io.setShooterVelocity(state, RotationsPerSecond.of(ShooterConstants.SHOOTER_ACTIVE_VELOCITY.get()));
|
io.setShooterVelocity(state, RotationsPerSecond.of(ShooterConstants.SHOOTER_ACTIVE_VELOCITY.get()));
|
||||||
io.setIndexerVelocity(state, RotationsPerSecond.of(ShooterConstants.INDEXER_REVERSE_VELOCITY.get()));
|
io.setIndexerOutput(state, ShooterConstants.INDEXER_REVERSE_OUTPUT.get());
|
||||||
break;
|
break;
|
||||||
case NotReady:
|
case NotReady:
|
||||||
io.setShooterVelocity(state, RotationsPerSecond.of(ShooterConstants.SHOOTER_RESTING_VELOCITY.get()));
|
io.setShooterVelocity(state, RotationsPerSecond.of(ShooterConstants.SHOOTER_RESTING_VELOCITY.get()));
|
||||||
io.setIndexerVelocity(state, RotationsPerSecond.of(ShooterConstants.INDEXER_REVERSE_VELOCITY.get()));
|
io.setIndexerOutput(state, ShooterConstants.INDEXER_REVERSE_OUTPUT.get());
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -25,8 +25,8 @@ public class ShooterConstants {
|
|||||||
public static final ConfigurableDouble SHOOTER_ACTIVE_VELOCITY = new ConfigurableDouble("Shooter Active Velocity", -35);
|
public static final ConfigurableDouble SHOOTER_ACTIVE_VELOCITY = new ConfigurableDouble("Shooter Active Velocity", -35);
|
||||||
public static final ConfigurableDouble SHOOTER_RESTING_VELOCITY = new ConfigurableDouble("Shooter Resting Velocity", -10);
|
public static final ConfigurableDouble SHOOTER_RESTING_VELOCITY = new ConfigurableDouble("Shooter Resting Velocity", -10);
|
||||||
|
|
||||||
public static final ConfigurableDouble INDEXER_FORWARD_VELOCITY = new ConfigurableDouble("Indexer FWD Velocity", -10);
|
public static final ConfigurableDouble INDEXER_FORWARD_OUTPUT = new ConfigurableDouble("Indexer FWD Velocity", -10);
|
||||||
public static final ConfigurableDouble INDEXER_REVERSE_VELOCITY = new ConfigurableDouble("Indexer reverse Velocity", 10);
|
public static final ConfigurableDouble INDEXER_REVERSE_OUTPUT = new ConfigurableDouble("Indexer reverse Velocity", 10);
|
||||||
|
|
||||||
|
|
||||||
// Tolerances
|
// Tolerances
|
||||||
|
|||||||
@@ -21,11 +21,12 @@ public interface ShooterIO {
|
|||||||
|
|
||||||
AngularVelocity motor1TargetVelocity = RotationsPerSecond.of(0);
|
AngularVelocity motor1TargetVelocity = RotationsPerSecond.of(0);
|
||||||
AngularVelocity motor2TargetVelocity = RotationsPerSecond.of(0);
|
AngularVelocity motor2TargetVelocity = RotationsPerSecond.of(0);
|
||||||
AngularVelocity indexerTargetVelocity = RotationsPerSecond.of(0);
|
double indexerTargetOutput = 0;
|
||||||
|
|
||||||
|
|
||||||
AngularVelocity motor1Velocity = RotationsPerSecond.of(0);
|
AngularVelocity motor1Velocity = RotationsPerSecond.of(0);
|
||||||
AngularVelocity motor2Velocity = RotationsPerSecond.of(0);
|
AngularVelocity motor2Velocity = RotationsPerSecond.of(0);
|
||||||
AngularVelocity indexerVelocity = RotationsPerSecond.of(0);
|
double indexerOutput = 0;
|
||||||
|
|
||||||
Current motor1Current = Amps.of(0);
|
Current motor1Current = Amps.of(0);
|
||||||
Current motor2Current = Amps.of(0);
|
Current motor2Current = Amps.of(0);
|
||||||
@@ -38,7 +39,7 @@ public interface ShooterIO {
|
|||||||
// public default void setShooterPitch(ShooterState state, Angle angle) {}
|
// public default void setShooterPitch(ShooterState state, Angle angle) {}
|
||||||
public default void setShooterVelocity(ShooterState state, AngularVelocity angularVelocity) {}
|
public default void setShooterVelocity(ShooterState state, AngularVelocity angularVelocity) {}
|
||||||
// public default void setMotor2Velocity(ShooterState state, AngularVelocity angularVelocity) {}
|
// public default void setMotor2Velocity(ShooterState state, AngularVelocity angularVelocity) {}
|
||||||
public default void setIndexerVelocity(ShooterState state, AngularVelocity linearVelocity) {}
|
public default void setIndexerOutput(ShooterState state, double percentOutput) {}
|
||||||
|
|
||||||
public default void updateInputs(ShooterState state) {}
|
public default void updateInputs(ShooterState state) {}
|
||||||
|
|
||||||
|
|||||||
@@ -56,16 +56,18 @@ public class ShooterReal implements ShooterIO {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setIndexerVelocity(ShooterState state, AngularVelocity target) {
|
public void setIndexerOutput(ShooterState state, double percentOutput) {
|
||||||
state.indexerTargetVelocity = target;
|
state.indexerTargetOutput = percentOutput;
|
||||||
|
|
||||||
if(target.baseUnitMagnitude() == 0) {
|
if(percentOutput == 0) {
|
||||||
m_indexerMotor.set(0);
|
m_indexerMotor.set(0);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
AngularVelocity motorRps = target.times(ShooterConstants.INDEXER_GEAR_RATIO);
|
|
||||||
m_indexerMotor.setControl(m_indexerVelocity.withVelocity(motorRps));
|
|
||||||
|
// AngularVelocity motorRps = target.times(ShooterConstants.INDEXER_GEAR_RATIO);
|
||||||
|
m_indexerMotor.set(percentOutput);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -74,7 +76,8 @@ public class ShooterReal implements ShooterIO {
|
|||||||
|
|
||||||
state.motor1Velocity = m_shooter1Motor.getVelocity().getValue().div(ShooterConstants.SHOOTERMOTOR_GEAR_RATIO);
|
state.motor1Velocity = m_shooter1Motor.getVelocity().getValue().div(ShooterConstants.SHOOTERMOTOR_GEAR_RATIO);
|
||||||
state.motor2Velocity = m_shooter2Motor.getVelocity().getValue().div(ShooterConstants.SHOOTERMOTOR_GEAR_RATIO);
|
state.motor2Velocity = m_shooter2Motor.getVelocity().getValue().div(ShooterConstants.SHOOTERMOTOR_GEAR_RATIO);
|
||||||
state.indexerVelocity = m_indexerMotor.getVelocity().getValue().div(ShooterConstants.INDEXER_GEAR_RATIO);
|
state.indexerOutput = m_indexerMotor.get();
|
||||||
|
// state.indexerOutput = m_indexerMotor.getVelocity().getValue().div(ShooterConstants.INDEXER_GEAR_RATIO);
|
||||||
|
|
||||||
// state.motorLinearVelocity = InchesPerSecond.of(m_shooter1Motor.getVelocity().getValue().in(RotationsPerSecond) * ShooterConstants.FEEDER_INCHES_PER_ROT);
|
// state.motorLinearVelocity = InchesPerSecond.of(m_shooter1Motor.getVelocity().getValue().in(RotationsPerSecond) * ShooterConstants.FEEDER_INCHES_PER_ROT);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user