<commit_before>package com.precisionguessworks.frc;

import edu.wpi.first.wpilibj.CANJaguar;
import edu.wpi.first.wpilibj.PIDController;
import edu.wpi.first.wpilibj.PIDOutput;
import edu.wpi.first.wpilibj.PIDSource;
import edu.wpi.first.wpilibj.can.CANTimeoutException;

public class Arm {
    private static final double P = 1.0;
    private static final double I = 0.0;
    private static final double D = 0.0;

    private final ArmOutput armOutput;
    private final PIDController controller;
    private final Tower tower;

    public Arm(PIDSource armPotentiometer, CANJaguar topMotor, CANJaguar bottomMotor, Tower tower) {
        this.armOutput = new ArmOutput(topMotor, bottomMotor);
        this.controller = new PIDController(P, I, D, armPotentiometer, armOutput);
        this.tower = tower;
    }

    public void setPosition(int position) {
        this.controller.setSetpoint(position);
    }

    public void setFloorPosition() {
        this.tower.lower();
        this.setPosition(0);
    }

    public void gotoProtectedPosition() {
        this.tower.raise();
        this.setPosition(100);
    }

    public void manualDrive(double output) {
        this.armOutput.drive(output);
    }

    protected static double limit(double num) {
        if (num > 1.0) {
            return 1.0;
        }
        if (num < -1.0) {
            return -1.0;
        }
        
        return num;
    }

    public class ArmOutput implements PIDOutput {
        private CANJaguar topMotor;
        private CANJaguar bottomMotor;
<commit_msg>Added code to get PID control working<commit_after>package com.precisionguessworks.frc;

import edu.wpi.first.wpilibj.CANJaguar;
import edu.wpi.first.wpilibj.PIDController;
import edu.wpi.first.wpilibj.PIDOutput;
import edu.wpi.first.wpilibj.PIDSource;
import edu.wpi.first.wpilibj.can.CANTimeoutException;

public class Arm {
    public static final double kP = 0.001;
    public static final double kI = 0.0;
    public static final double kD = 0.0;

    private final ArmOutput armOutput;
    private final PIDController controller;
    private final Tower tower;

    public Arm(PIDSource armPotentiometer, CANJaguar topMotor, CANJaguar bottomMotor, Tower tower) {
        this.armOutput = new ArmOutput(topMotor, bottomMotor);
        this.controller = new PIDController(kP, kI, kD, armPotentiometer, armOutput);
        this.controller.setOutputRange(-0.5, 0.5);
        this.controller.setInputRange(0, 1000);

        this.tower = tower;
    }

    public void setPosition(int position) {
        this.controller.setSetpoint(position);
        this.controller.enable();
    }

    public void setFloorPosition() {
        this.tower.lower();
        this.setPosition(0);
    }

    public void gotoProtectedPosition() {
        this.tower.raise();
        this.setPosition(100);
    }

    public void manualDrive(double output) {
        this.armOutput.drive(output);
    }

    protected static double limit(double num) {
        if (num > 1.0) {
            return 1.0;
        }
        if (num < -1.0) {
            return -1.0;
        }
        
        return num;
    }

    public class ArmOutput implements PIDOutput {
        private CANJaguar topMotor;
        private CANJaguar bottomMotor;

{'fraction_non_alphanumeric': 0.09193993257738278, 'fraction_numerical': 0.014403922770456636, 'mean_word_length': 2.5789473684210527, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, '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': '3420283', 'n_tokens_mistral': 1074, 'n_tokens_neox': 1007, 'n_words': 241}