src/main/java/frc/robot/commands/MoveLift.java
// Called repeatedly when this Command is scheduled to run
Called repeatedly when this Command is scheduled to run
Called repeatedly when this Command is scheduled to run
@Override
  protected void execute() {
    int threshold = 600;
    long current = Robot.m_lift.getLiftMotor().getSelectedSensorPosition(); 
    long error = ticks - current; 
    /*
    //Use limit switches for safety
    if(Robot.m_lift.getTopLimit() && error > 0){
      ticks = current;
    }else if(Robot.m_lift.getBottomLimit() && error < 0){
      ticks = current;
    }
    */
    if(Robot.m_lift.getBottomLimit() && error < 0){
      ticks = current;
      Robot.m_lift.setCurrentPosition(0);
    }else if(Robot.m_lift.getBottomLimit()){
      Robot.m_lift.setCurrentPosition(0);
    }
    if(error > threshold){
      Robot.m_lift.setPercentage(RobotMap.SCALER_LIFT_AUTO * Robot.m_oi.getRightThrottleScaler());
    }else if (error < -1 * threshold){
      Robot.m_lift.setPercentage(-1 * (RobotMap.SCALER_LIFT_AUTO * Robot.m_oi.getRightThrottleScaler()));
    }else {
      Robot.m_lift.setPercentage(0);
    }
    System.out.println(current);
  }
@ Override protected void execute ( ) { int threshold = 600 ; long current = Robot . m_lift . getLiftMotor ( ) . getSelectedSensorPosition ( ) ; long error = ticks - current ; /*
    //Use limit switches for safety
    if(Robot.m_lift.getTopLimit() && error > 0){
      ticks = current;
    }else if(Robot.m_lift.getBottomLimit() && error < 0){
      ticks = current;
    }
    */ if ( Robot . m_lift . getBottomLimit ( ) && error < 0 ) { ticks = current ; Robot . m_lift . setCurrentPosition ( 0 ) ; } else if ( Robot . m_lift . getBottomLimit ( ) ) { Robot . m_lift . setCurrentPosition ( 0 ) ; } if ( error > threshold ) { Robot . m_lift . setPercentage ( RobotMap . SCALER_LIFT_AUTO * Robot . m_oi . getRightThrottleScaler ( ) ) ; } else if ( error < - 1 * threshold ) { Robot . m_lift . setPercentage ( - 1 * ( RobotMap . SCALER_LIFT_AUTO * Robot . m_oi . getRightThrottleScaler ( ) ) ) ; } else { Robot . m_lift . setPercentage ( 0 ) ; } System . out . println ( current ) ; }
Called repeatedly when this Command is scheduled to run
Called repeatedly when this Command is scheduled to run
//Get current position //Find the error of the current position and our desired position //Debugging Print Statement //System.out.println(error + " ; " + current); //Go to the desired position, within the threshold to prevent osolation 