So we are having an issue with turn to target with limelight. IT will start turning but then stop, and we won’t be able to start.
We do get a warning when we start the bot and sometimes when running. printLoopOverrunMessage.
Our turn looks like this
public void turnToTarget(Drivetrain drivetrain, Shooter shooter){
if (this.table.getEntry("ledMode").setNumber(1)){
SmartDashboard.putString("ledMode ","Set");
} else {
SmartDashboard.putString("ledMode ","Not set");
}
SmartDashboard.putString("turnToTarget ","Started");
double turn = 0;
double min = ShooterConstants.MIN_TURN;
boolean check = hasTarget();
SmartDashboard.putString("Target ","" + check);
SmartDashboard.putString("Initial TY","" + getTy().getDouble(0.0));
int loop = 0;
if(Math.abs(getTy().getDouble(0.0)) >= 3 && hasTarget()){
turn = getTy().getDouble(0.0)*0.03;
if (Math.abs(turn) < min){
turn = turn > 0 ? min:-min;
}
drivetrain.getDrive().tankDrive(-turn, turn);
SmartDashboard.putString("Loop TY:",loop++ + ":" + getTy().getDouble(0.0));
}
this.table.getEntry("ledMode").setNumber(3);
SmartDashboard.putString("Ending TY","" + getTy().getDouble(0.0));
SmartDashboard.putString("Turning Complete","Turning Complete");
}
And is called like this
new JoystickButton(driverController, XboxController.Button.kBumperRight.value)
.whileHeld(new InstantCommand(() -> m_Limelight
.turnToTarget(m_driveTrain,shooter) , m_driveTrain, m_Limelight, shooter )
.andThen(new InstantCommand(() -> SmartDashboard.putString("Info", "Turn To Target Command Finsihed"))));