<commit_before>
try:
    import wpilib
except ImportError:
    from pyfrc import wpilib

class AutoShooting(object):
    ''' sample autonomous program'''
    
    DEFAULT = True
    MODE_NAME = "AutoShooting"
    
    def __init__(self, components):
        '''Assume that any components needed will be passed in as a parameter. Store them so you can use them'''
        self.drive = components['drive']
        self.intake = components['intake']
        self.catapult = components['catapult']
        self.timer = wpilib.Timer()
        self.goalHot=0                 #-1,not active,1 active, 0 maybe
        
        self.position=wpilib.SmartDashboard.GetNumber("position")            #-1 left, 0 center, 1 right
        #self.position=0
        
        self.rotate=0
        self.rotateTimeLength=0
        self.rotateTimer=wpilib.Timer()
        
        if self.position is -1:             #45 degrees to the right
            self.rotate=45
        if self.position is 0:              #30 degrees to the right
            self.rotate=45
        if self.position is 1:              #45 degrees to the left
            self.rotate=-45
    def on_enable(self):
        pass

    def on_disable(self):
        '''This function is called when autonomous mode is disabled'''
        pass

    def update(self, time_elapsed):

        
        
        self.intake.armDown()
        self.catapult.pulldown()
        self.goalHot=wpilib.SmartDashboard.GetNumber("Goal Hot")
        if not self.in_range:
            self.drive.move(0,1,0)
        if self.drive.closePosition():
            self.in_range=True
            self.timer.Start()
            if self.timer.HasPeriodPassed(2):
                self.nextStage = True
        

        if self.nextStage:
            if self.position is 0 and time_elapsed<3:       #rotates to the left for 1 second
                self.drive.move(0,0,-1)
            if self.goalHot is -1:
                if time_elapsed>8:
                    self.catapult.ShootNoSensor()
                    print("Shoot, 8 seconds elapsed")
                elif time_elapsed>5:                #after 5 seconds if the current goal is not hot rotate and shoot
                    rotateToPosition(self.rotate)
            elif self.goalHot is 0:                 #maybe generally means sensors aren't working. shoot after 5 seconds
                if time_elapsed>5:
                    self.catapult.ShootNoSensor()
                    print("shoot, sensor value is maybe")
            elif self.goalHot is 1:                 #if the goal is currently hot then shoot
                self.catapult.ShootNoSensor()
                
    def rotateToPosition(self,degrees):   #degrees is the number of degrees we want to rotate. - for left, + for right
        #2.5 seconds for a full 360 degrees. probably a bit inaccurate
        degreesPerSecond=144
        self.rotateTimeLength=math.fabs(degrees/degreesPerSecond)
        self.rotateTimer.Start()<commit_msg>Should be working now<commit_after>
try:
    import wpilib
except ImportError:
    from pyfrc import wpilib

class AutoShooting(object):
    ''' sample autonomous program'''
    
    DEFAULT = True
    MODE_NAME = "AutoShooting"
    
    def __init__(self, components):
        '''Assume that any components needed will be passed in as a parameter. Store them so you can use them'''
        self.drive = components['drive']
        self.intake = components['intake']
        self.catapult = components['catapult']
        self.timer = wpilib.Timer()
        self.goalHot=0                 #-1,not active,1 active, 0 maybe
        wpilib.SmartDashboard.PutNumber("position",0)
        wpilib.SmartDashboard.PutNumber("Goal Hot",0)
    def on_enable(self):
        
        self.nextStage = False
        self.in_range = False
        self.ball = False
        self.launchTime = None
        
        
        self.position=wpilib.SmartDashboard.GetNumber("position")            #-1 left, 0 center, 1 right
        #self.position=0
        
        self.rotate=0
        self.rotateTimeLength=0
        self.rotateTimer=wpilib.Timer()
        
        if self.position is -1:             #45 degrees to the right
            self.rotate=45
        if self.position is 0:              #30 degrees to the right
            self.rotate=45
        if self.position is 1:              #45 degrees to the left
            self.rotate=-45

    def on_disable(self):
        '''This function is called when autonomous mode is disabled'''
        pass

    def update(self, time_elapsed):

        
        self.intake.armDown()
        self.catapult.pulldown()
        self.goalHot=wpilib.SmartDashboard.GetNumber("Goal Hot")
        if not self.in_range:
            print("not in range")
            self.drive.move(0,1,0)
        if self.drive.closePosition():
            
            self.in_range=True
            self.timer.Start()
            if self.timer.HasPeriodPassed(2):

                self.nextStage = True

        if self.nextStage:
            print("next Stage is true")            
            if self.position is 0 and time_elapsed<3:       #rotates to the left for 1 second
                self.drive.move(0,0,-1)
                print("moving")
            if self.goalHot is -1:
                if time_elapsed>8:
                    self.catapult.ShootNoSensor()
                    print("Shoot, 8 seconds elapsed")
                elif time_elapsed>5:                #after 5 seconds if the current goal is not hot rotate and shoot
                    rotateToPosition(self.rotate)
            elif self.goalHot is 0:                 #maybe generally means sensors aren't working. shoot after 5 seconds
                if time_elapsed>5:
                    self.catapult.ShootNoSensor()
                    print("shoot, sensor value is maybe")
            elif self.goalHot is 1:                 #if the goal is currently hot then shoot
                self.catapult.ShootNoSensor()
                
    def rotateToPosition(self,degrees):   #degrees is the number of degrees we want to rotate. - for left, + for right
        #assuming 2.5 seconds for a full 360 degrees. probably a bit inaccurate
        degreesPerSecond=144
        self.rotateTimeLength=math.fabs(degrees/degreesPerSecond)
        self.rotateTimer.Start()
{'fraction_non_alphanumeric': 0.08022741629816804, 'fraction_numerical': 0.016740366392924828, 'mean_word_length': 1.6914577135571611, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 9, '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': '2967776', 'n_tokens_mistral': 1800, 'n_tokens_neox': 1685, 'n_words': 497}