public Robot(){
CanBridge.runTCP();
- PortForwarder.add(5800,"10.9.72.12",5800);
- PortForwarder.add(1182,"10.9.72.12",1182);
+ PortForwarder.add(5800, Constants.VISION_CAMERA_HOST, 5800);
+ PortForwarder.add(1182, Constants.VISION_CAMERA_HOST, 1182);
// Set up data receivers & replay source
switch (Constants.CURRENT_MODE) {
initializeAutoBuilder();
autoChooserInit();
- // put the Chooser on the SmartDashboard
- SmartDashboard.putData("Auto chooser", autoChooser);
-
if (turret != null && drive != null && hood != null && shooter != null) {
SmartDashboard.putData("Lock Shooting", new LockedShoot(turret, drive, hood, shooter));
}
}
}
if (!Constants.DISABLE_SMART_DASHBOARD) {
- SmartDashboard.putString("Alliance", DriverStation.getAlliance().toString());
+ SmartDashboard.putString("Alliance", DriverStation.getAlliance().map(a -> a.name()).orElse("Unknown"));
}
}
}
ChassisSpeeds robotRelVel = drivetrain.getChassisSpeeds();
// Add a phase delay extrapolation component for latency delay
- drivepose.exp(
+ drivepose = drivepose.exp(
new Twist2d(
robotRelVel.vxMetersPerSecond * phaseDelay,
robotRelVel.vyMetersPerSecond * phaseDelay,
ChassisSpeeds robotRelVel = drivetrain.getChassisSpeeds();
// Add a phase delay extrapolation component for latency delay
- drivepose.exp(
+ drivepose = drivepose.exp(
new Twist2d(
robotRelVel.vxMetersPerSecond * phaseDelay,
robotRelVel.vyMetersPerSecond * phaseDelay,
// Enables 3D logs of mechanisms
public static final boolean LOG_MECHANISMS = true;
+
+ // Network setting for vision
+ public static final String VISION_CAMERA_HOST = "10.9.72.12";
}
import lib.controllers.PS5Controller.DPad;
import lib.controllers.PS5Controller.PS5Axis;
import lib.controllers.PS5Controller.PS5Button;
+import org.littletonrobotics.junction.Logger;
/**
* Driver controls for the PS5 controller
private Hood hood;
private Intake intake;
private Spindexer spindexer;
+ private double originalSpindexerCurrentLimit;
public PS5ControllerDriverConfig(
Drivetrain drive,
private void shootFocus(boolean turnOn) {
if (turnOn) {
- System.out.println("Shooting is now Focused");
+ Logger.recordOutput("ShootFocus", "Focused");
+ originalSpindexerCurrentLimit = spindexer.getCurrentLimit();
spindexer.setNewCurrentLimit(SpindexerConstants.currentLimit);
drive.applyNewModuleCurrents(DriveConstants.STEER_PEAK_CURRENT_LIMIT,
DriveConstants.DRIVE_PEAK_CURRENT_LIMIT * 0.25);
} else {
- System.out.println("Shooting back to normal (From focus)");
- spindexer.setNewCurrentLimit(SpindexerConstants.currentLimit);
+ Logger.recordOutput("ShootFocus", "Normal");
+ spindexer.setNewCurrentLimit(originalSpindexerCurrentLimit);
drive.applyNewModuleCurrents(DriveConstants.STEER_PEAK_CURRENT_LIMIT,
DriveConstants.DRIVE_PEAK_CURRENT_LIMIT);
}
*/
public double rotationsToInches(double motorRotations) {
// circumference of the rack pinion
- double circ = 2 * Math.PI * 0.5;
+ double circ = 2 * Math.PI * IntakeConstants.RADIUS_RACK_PINION;
double pinionRotations = motorRotations / IntakeConstants.GEAR_RATIO;
double inches = pinionRotations * circ;
return inches;
* @return motor rotations
*/
public double inchesToRotations(double inches){
- double circ = 2 * Math.PI * 0.5;
+ double circ = 2 * Math.PI * IntakeConstants.RADIUS_RACK_PINION;
double pinionRotations = inches / circ;
double motorRotations = pinionRotations * IntakeConstants.GEAR_RATIO;
return motorRotations;
shooterMotorRight.setControl(voltageRequest.withVelocity(targetVelocityRPS).withEnableFOC(true));
if (!Constants.DISABLE_LOGGING) {
- Logger.recordOutput("Shooter/realVelocity", shooterMotorLeft.getVelocity().getValueAsDouble() * ShooterConstants.SHOOTER_LAUNCH_DIAMETER);
+ Logger.recordOutput("Shooter/realVelocity", Math.PI * ShooterConstants.SHOOTER_LAUNCH_DIAMETER * shooterMotorLeft.getVelocity().getValueAsDouble());
Logger.recordOutput("Shooter/targetVelocity", shooterTargetSpeed);
}
- double actualWheelVelocity = shooterMotorLeft.getVelocity().getValueAsDouble() * ShooterConstants.SHOOTER_LAUNCH_DIAMETER;
+ double actualWheelVelocity = Math.PI * ShooterConstants.SHOOTER_LAUNCH_DIAMETER * shooterMotorLeft.getVelocity().getValueAsDouble();
if (!Constants.DISABLE_SMART_DASHBOARD) {
SmartDashboard.putNumber("Shooter Speed Error (mps)", shooterTargetSpeed - actualWheelVelocity);
private boolean wasSpindexerSlow = false;
private SpindexerState state = SpindexerState.STOPPED;
private SpindexerIOInputsAutoLogged inputs = new SpindexerIOInputsAutoLogged();
+ private double currentLimit = SpindexerConstants.currentLimit;
public boolean noIndexing = false;
}
public void setNewCurrentLimit(double newCurrentLimit) {
+ currentLimit = newCurrentLimit;
CurrentLimitsConfigs limitConfig = new CurrentLimitsConfigs();
limitConfig.StatorCurrentLimit = newCurrentLimit;
limitConfig.StatorCurrentLimitEnable = true;
motor.getConfigurator().apply(limitConfig);
}
+ public double getCurrentLimit() {
+ return currentLimit;
+ }
+
@Override
public void updateInputs() {
inputs.spindexerVelocity = motor.getVelocity().getValueAsDouble(); //SpindexerConstants.gearRatio;