<commit_before>package org.usfirst.frc2832.Robot_2016;

import edu.wpi.first.wpilibj.CANTalon;
import edu.wpi.first.wpilibj.Preferences;
import edu.wpi.first.wpilibj.command.Subsystem;
import edu.wpi.first.wpilibj.smartdashboard.SmartDashboard;

public class Aimer extends Subsystem {
	public static int currentLevel = 0;
	public static int[] levelPositions = {0,3000,4500,5500};
	//public static final int MOVE_SPEED_UP = 200;
	public static String mode = "position";
	//public static final int MOVE_SPEED_DOWN = -175;
	public static final double UP_PID_P = Preferences.getInstance().getDouble("Aimer Up kP", 5.0),
							   UP_PID_I = Preferences.getInstance().getDouble("Aimer Up kI", 0.001),
							   UP_PID_D = Preferences.getInstance().getDouble("Aimer Up kD", 0.0),
							   DOWN_PID_P = Preferences.getInstance().getDouble("Aimer Down kP", 2.0),
							   DOWN_PID_I = Preferences.getInstance().getDouble("Aimer Down kI", 0.02),
							   DOWN_PID_D = Preferences.getInstance().getDouble("Aimer Down kD", 0.0);
	public static final int	MOVE_SPEED_UP = Preferences.getInstance().getInt("Aimer Up Speed", 200),
							MOVE_SPEED_DOWN = Preferences.getInstance().getInt("Aimer Down Speed", -175);
			
	
	@Override
	protected void initDefaultCommand() {
		// TODO Auto-generated method stub
		
	}

	public static void upSpeedMode()
	{
		RobotMap.winchMotor.changeControlMode(CANTalon.TalonControlMode.Speed);
		RobotMap.winchMotor.setPID(UP_PID_P, UP_PID_I, UP_PID_D);
		RobotMap.winchMotor.setAllowableClosedLoopErr(0);
	}
	public static void downSpeedMode()
	{
		RobotMap.winchMotor.changeControlMode(CANTalon.TalonControlMode.Speed);
		RobotMap.winchMotor.setPID(DOWN_PID_P, DOWN_PID_I, DOWN_PID_D);
		RobotMap.winchMotor.setAllowableClosedLoopErr(0);
	}
	public static void toPositionMode()
	{
		RobotMap.winchMotor.changeControlMode(CANTalon.TalonControlMode.Position);
		RobotMap.winchMotor.setPID(20, 0, 0);
		RobotMap.winchMotor.setAllowableClosedLoopErr(0);
	}
	/**
	 * Position mode ONLY
	 * "freezes" the winch in its current position
	 */<commit_msg>Fix issue with loading preferences before robot is ready<commit_after>package org.usfirst.frc2832.Robot_2016;

import edu.wpi.first.wpilibj.CANTalon;
import edu.wpi.first.wpilibj.Preferences;
import edu.wpi.first.wpilibj.command.Subsystem;
import edu.wpi.first.wpilibj.smartdashboard.SmartDashboard;

public class Aimer extends Subsystem {
	public static int currentLevel = 0;
	public static int[] levelPositions = {0,3000,4500,5500};
	//public static final int MOVE_SPEED_UP = 200;
	public static String mode = "position";
	//public static final int MOVE_SPEED_DOWN = -175;
	public static double UP_PID_P, UP_PID_I, UP_PID_D,
							   DOWN_PID_P, DOWN_PID_I, DOWN_PID_D;
	public static int MOVE_SPEED_UP, MOVE_SPEED_DOWN;
			
	
	public static void loadPreferences() {
		UP_PID_P = Preferences.getInstance().getDouble("Aimer Up kP", 5.0);
		UP_PID_I = Preferences.getInstance().getDouble("Aimer Up kI", 0.001);
		UP_PID_D = Preferences.getInstance().getDouble("Aimer Up kD", 0.0);
		DOWN_PID_P = Preferences.getInstance().getDouble("Aimer Down kP", 2.0);
		DOWN_PID_I = Preferences.getInstance().getDouble("Aimer Down kI", 0.02);
		DOWN_PID_D = Preferences.getInstance().getDouble("Aimer Down kD", 0.0);
		
		MOVE_SPEED_UP = Preferences.getInstance().getInt("Aimer Up Speed", 200);
		MOVE_SPEED_DOWN = Preferences.getInstance().getInt("Aimer Down Speed", -175);
	}
	
	@Override
	protected void initDefaultCommand() {
		// TODO Auto-generated method stub
		
	}

	public static void upSpeedMode()
	{
		RobotMap.winchMotor.changeControlMode(CANTalon.TalonControlMode.Speed);
		RobotMap.winchMotor.setPID(UP_PID_P, UP_PID_I, UP_PID_D);
		RobotMap.winchMotor.setAllowableClosedLoopErr(0);
	}
	public static void downSpeedMode()
	{
		RobotMap.winchMotor.changeControlMode(CANTalon.TalonControlMode.Speed);
		RobotMap.winchMotor.setPID(DOWN_PID_P, DOWN_PID_I, DOWN_PID_D);
		RobotMap.winchMotor.setAllowableClosedLoopErr(0);
	}
	public static void toPositionMode()
	{
		RobotMap.winchMotor.changeControlMode(CANTalon.TalonControlMode.Position);
		RobotMap.winchMotor.setPID(20, 0, 0);
		RobotMap.winchMotor.setAllowableClosedLoopErr(0);
	}
	/**
	 * Position mode ONLY
	 * "freezes" the winch in its current position
	 */
{'fraction_non_alphanumeric': 0.11256422232601589, 'fraction_numerical': 0.026156001868285848, 'mean_word_length': 5.075177304964539, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '3511884', 'n_tokens_mistral': 1765, 'n_tokens_neox': 1523, 'n_words': 288}