<commit_before>__author__ = 'auxiliary-character'
from wpilib.command import Command
import wpilib
import math

class Turn(Command):
    def __init__(self, robot, angle):
        super().__init__()
        self.robot = robot
        self.angle = angle
        self.controller = wpilib.PIDController(-.008, -0.0003, -.001, 5, self.returnPIDInput, self.usePIDOutput)
        self.controller.setAbsoluteTolerance(2)
        self.requires(self.robot.drivetrain)

    def initialize(self):
        self.controller.setSetpoint(self.robot.drivetrain.gyro.getYaw()+self.angle)
        self.controller.enable()

    def isFinished(self):
        return self.controller.onTarget()

    def end(self):
        self.controller.disable()
        self.robot.drivetrain.driveManual(0,0,0)

    def interupted(self):
        self.end()

    def _cancel(self):
        self.end()
        super()._cancel()

    def returnPIDInput(self):
        angle = self.robot.drivetrain.gyro.getYaw()
        set_point = self.controller.getSetpoint()

        angle_greater = angle + 360
        angle_lesser = angle - 360

        use_angle = math.fabs(angle-set_point) < math.fabs(angle_greater - set_point)
        use_angle = use_angle and math.fabs(angle-set_point) < math.fabs(angle_lesser - set_point)
        if use_angle:
            return angle
        elif math.fabs(angle_greater-set_point) < math.fabs(angle_lesser - set_point):
            return angle_greater
        else:
            return angle_lesser

    def usePIDOutput(self, output):
        self.robot.drivetrain.driveManual(0, 0, output**3)
<commit_msg>Simpler turn, maybe?<commit_after>__author__ = 'auxiliary-character'
from wpilib.command import Command
import wpilib
import math

class Turn(Command):
    def __init__(self, robot, angle):
        super().__init__()
        self.robot = robot
        self.angle = angle
        self.controller = wpilib.PIDController(.008, 0, 0, self.returnPIDInput, self.usePIDOutput)
        self.setTimeout(3)
        self.controller.setAbsoluteTolerance(2)
        self.requires(self.robot.drivetrain)

    def initialize(self):
        self.controller.setSetpoint(self.robot.drivetrain.gyro.getYaw()+self.angle)
        self.controller.enable()

    def isFinished(self):
        return self.controller.onTarget() or self.isFinished()

    def end(self):
        self.controller.disable()
        self.robot.drivetrain.driveManual(0,0,0)

    def interupted(self):
        self.end()

    def _cancel(self):
        self.end()
        super()._cancel()

    def returnPIDInput(self):
        angle = self.robot.drivetrain.gyro.getYaw()
        set_point = self.controller.getSetpoint()

        angle_greater = angle + 360
        angle_lesser = angle - 360

        use_angle = math.fabs(angle-set_point) < math.fabs(angle_greater - set_point)
        use_angle = use_angle and math.fabs(angle-set_point) < math.fabs(angle_lesser - set_point)
        if use_angle:
            return angle
        elif math.fabs(angle_greater-set_point) < math.fabs(angle_lesser - set_point):
            return angle_greater
        else:
            return angle_lesser

    def usePIDOutput(self, output):
        self.robot.drivetrain.driveManual(0, 0, output**3)

{'fraction_non_alphanumeric': 0.10730804810360776, 'fraction_numerical': 0.013567684242984891, 'mean_word_length': 2.6531531531531534, 'pattern_counts': {'":': 0, '<': 9, '<?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': '7509540', 'n_tokens_mistral': 1093, 'n_tokens_neox': 1014, 'n_words': 184}