<commit_before>package org.usfirst.frc.team4215.robot.prototypes;

import edu.wpi.first.wpilibj.PIDOutput;
import edu.wpi.first.wpilibj.PIDSource;
import edu.wpi.first.wpilibj.PIDController;

/**
 * Made to allow easy creation of a PIDTask
 * @author waweros
 *
 */
public class PIDTask implements Runnable {
	PIDController control;
	double margin;
	
	/**
	 * Makes a PIDTask
	 * You need Kp, Ki, Kd
	 * 
	 * @param sensor
	 * @param motor
	 * @param Kp
	 * @param Ki
	 * @param Kd
	 * @param margin
	 */
	public PIDTask(PIDSource sensor, PIDOutput motor, 
					double Kp, double Ki, double Kd,double setpoint,double margin) {
		PIDController control = new PIDController(Kp,Ki,Kd,sensor,motor);
		control.setSetpoint(setpoint);
		this.control = control;
		this.margin = margin;
	}
	
	/**
	 * Starts and monitors PIDCotroller
	 */
	@Override
	public void run() {
		
		//Sets up error value to watch
		double error = control.getAvgError();;
		
		//enables controller
		control.enable();
		int count = 0;
		// Waits till the error is small
		while(count < 10){
			if(error > margin){
				error = control.getAvgError();
				++count;
			}
		}
		
		// Disables the controller
		control.disable();
		
	}
	
	public void disable(){
		control.disable();
	}
	
	public double getError(){
		return control.getAvgError();
	}
}<commit_msg>Corrected some bugs in PIDTask<commit_after>package org.usfirst.frc.team4215.robot.prototypes;

import edu.wpi.first.wpilibj.PIDOutput;
import edu.wpi.first.wpilibj.PIDSource;
import edu.wpi.first.wpilibj.PIDController;

/**
 * Made to allow easy creation of a PIDTask
 * @author waweros
 *
 */
public class PIDTask implements Runnable {
	PIDController control;
	double margin;
	private int smearCount = 10;
	
	
	public PIDTask(PIDSource sensor, PIDOutput motor, 
			double Kp, double Ki, double Kd,double setpoint,double margin, int smear) {
		
		
		PIDController control = new PIDController(Kp,Ki,Kd,sensor,motor);
		control.setSetpoint(setpoint);
		this.control = control;
		this.margin = margin;
		smearCount = smear;
		
	}
	
	/**
	 * Makes a PIDTask
	 * You need Kp, Ki, Kd
	 * 
	 * @param sensor
	 * @param motor
	 * @param Kp
	 * @param Ki
	 * @param Kd
	 * @param margin
	 */
	public PIDTask(PIDSource sensor, PIDOutput motor, 
					double Kp, double Ki, double Kd,double setpoint,double margin) {
		this(sensor,motor,Kp,Ki,Kd,setpoint,margin,10);
	}
	
	
	/**
	 * Starts and monitors PIDCotroller
	 */
	@Override
	public void run() {
		
		//Sets up error value to watch
		double error = control.getAvgError();;
		
		//enables controller
		control.enable();
		int count = 0;
		// Waits till the error is small
		while(count < 10){
			
			if(error < margin){
				error = control.getAvgError();
				++count;
			}else{
				count = 0;
			}
			
		}
		
		// Disables the controller
		control.disable();
		
	}
	
	public void disable(){
		control.disable();
	}
	
	public double getError(){
		return control.getAvgError();
	}
	
	public void setSmearCount(int count){
		smearCount = count;
	}
	
	public int getSmearCount(){
		return smearCount;
	}
}
{'fraction_non_alphanumeric': 0.11465798045602606, 'fraction_numerical': 0.006188925081433224, 'mean_word_length': 3.2300275482093666, 'pattern_counts': {'":': 0, '<': 6, '<?xml version=': 0, '>': 4, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6961717', 'n_tokens_mistral': 1240, 'n_tokens_neox': 1036, 'n_words': 276}