<commit_before>#!/usr/bin/env python3

import wpilib
RelayValue = wpilib.Relay.Value

from components import drive, alignment
from components.forklift import ToteForklift, CanForklift
from common.distance_sensors import SharpIR2Y0A02, SharpIRGP2Y0A41SK0F, CombinedSensor
from common.button import Button
from common.sensor import Sensor

from components.interference_measurement import Calibrator


from networktables import NetworkTable

from robotpy_ext.misc import PreciseDelay
from robotpy_ext.autonomous import AutonomousModeSelector

class MyRobot(wpilib.SampleRobot):

    def robotInit(self):
        self.sd = NetworkTable.getTable('SmartDashboard')

        # #INITIALIZE JOYSTICKS##
        self.joystick1 = wpilib.Joystick(0)
        self.joystick2 = wpilib.Joystick(1)
        self.ui_joystick = wpilib.Joystick(2)

        # hello
        # #INITIALIZE MOTORS##
        self.lf_motor = wpilib.Talon(0)
        self.lr_motor = wpilib.Talon(1)
        self.rf_motor = wpilib.Talon(2)
        self.rr_motor = wpilib.Talon(3)

        # #ROBOT DRIVE##
        self.robot_drive = wpilib.RobotDrive(self.lf_motor, self.lr_motor, self.rf_motor, self.rr_motor)
        self.robot_drive.setInvertedMotor(wpilib.RobotDrive.MotorType.kFrontRight, True)
        self.robot_drive.setInvertedMotor(wpilib.RobotDrive.MotorType.kRearRight, True)

        # #INITIALIZE SENSORS#
        
        self.sweeper_relay = wpilib.Relay(0)

        self.gyro = wpilib.Gyro(0)

        self.tote_motor = wpilib.CANTalon(5)
        self.can_motor = wpilib.CANTalon(15)

        self.sensor = Sensor(self.tote_motor, self.can_motor)
        
        self.tote_forklift = ToteForklift(self.tote_motor,self.sensor,2)
        self.can_forklift = CanForklift(self.can_motor,self.sensor,3)
        
        
        self.calibrator = Calibrator(self.tote_forklift, self.sensor)
        
        self.next_pos = 1

                
        self.backSensor = SharpIRGP2Y0A41SK0F(6)
        
        self.drive = drive.Drive(self.robot_drive, self.gyro, self.backSensor)

        self.align = alignment.Alignment(self.sensor, self.tote_forklift, self.drive)
        
        
        self.components = {
            'tote_forklift': self.tote_forklift,
            'can_forklift': self.can_forklift,
            'drive': self.drive,
            'align': self.align,
            'sensors': self.sensor
        }

        self.control_loop_wait_time = 0.025
        self.automodes = AutonomousModeSelector('autonomous', self.components)

        # #Defining Buttons##
        self.canUp = Button(self.joystick1,3)
        self.canDown = Button(self.joystick1,2)
        self.canTop = Button(self.joystick1,6)
        self.canBottom = Button(self.joystick1,7)
        self.toteUp = Button(self.joystick2, 3)
        self.toteDown = Button(self.joystick2, 2)
        self.toteTop = Button(self.joystick2, 6)
        self.toteBottom = Button(self.joystick2, 7)
        self.ui_joystick_tote_down = Button(self.ui_joystick, 4)
        self.ui_joystick_tote_up = Button(self.ui_joystick, 6)
        self.ui_joystick_can_up = Button(self.ui_joystick, 5)
        self.ui_joystick_can_down = Button(self.ui_joystick, 3)
        
        self.reverseDirection = Button(self.joystick1, 1)
        #self.alignTrigger = Button(self.joystick2, 1)
        
        self.toteTo=0
        self.oldTote=0
        self.canTo=0
        self.oldCan=0
        self.reverseRobot = False
        self.oldReverseRobot = False
        self.autoLift = False
        
    def autonomous(self):
        self.automodes.run(self.control_loop_wait_time, self.update)

    def operatorControl(self):

        self.can_forklift.set_manual(0)
        self.tote_forklift.set_manual(0)
        
        delay = PreciseDelay(self.control_loop_wait_time)

        self.logger.info("Entering teleop mode")

        while self.isOperatorControl() and self.isEnabled():
            
            self.sensor.update()
            
            #self.calibrator.calibrate()<commit_msg>set default smartdashbord variables<commit_after>#!/usr/bin/env python3

import wpilib
RelayValue = wpilib.Relay.Value

from components import drive, alignment
from components.forklift import ToteForklift, CanForklift
from common.distance_sensors import SharpIR2Y0A02, SharpIRGP2Y0A41SK0F, CombinedSensor
from common.button import Button
from common.sensor import Sensor

from components.interference_measurement import Calibrator


from networktables import NetworkTable

from robotpy_ext.misc import PreciseDelay
from robotpy_ext.autonomous import AutonomousModeSelector

class MyRobot(wpilib.SampleRobot):

    def robotInit(self):
        self.sd = NetworkTable.getTable('SmartDashboard')

        # #INITIALIZE JOYSTICKS##
        self.joystick1 = wpilib.Joystick(0)
        self.joystick2 = wpilib.Joystick(1)
        self.ui_joystick = wpilib.Joystick(2)

        # hello
        # #INITIALIZE MOTORS##
        self.lf_motor = wpilib.Talon(0)
        self.lr_motor = wpilib.Talon(1)
        self.rf_motor = wpilib.Talon(2)
        self.rr_motor = wpilib.Talon(3)

        # #ROBOT DRIVE##
        self.robot_drive = wpilib.RobotDrive(self.lf_motor, self.lr_motor, self.rf_motor, self.rr_motor)
        self.robot_drive.setInvertedMotor(wpilib.RobotDrive.MotorType.kFrontRight, True)
        self.robot_drive.setInvertedMotor(wpilib.RobotDrive.MotorType.kRearRight, True)

        # #INITIALIZE SENSORS#
        
        self.sweeper_relay = wpilib.Relay(0)

        self.gyro = wpilib.Gyro(0)

        self.tote_motor = wpilib.CANTalon(5)
        self.can_motor = wpilib.CANTalon(15)

        self.sensor = Sensor(self.tote_motor, self.can_motor)
        
        self.tote_forklift = ToteForklift(self.tote_motor,self.sensor,2)
        self.can_forklift = CanForklift(self.can_motor,self.sensor,3)
        
        
        self.calibrator = Calibrator(self.tote_forklift, self.sensor)
        
        self.next_pos = 1

                
        self.backSensor = SharpIRGP2Y0A41SK0F(6)
        
        self.drive = drive.Drive(self.robot_drive, self.gyro, self.backSensor)

        self.align = alignment.Alignment(self.sensor, self.tote_forklift, self.drive)
        
        
        self.components = {
            'tote_forklift': self.tote_forklift,
            'can_forklift': self.can_forklift,
            'drive': self.drive,
            'align': self.align,
            'sensors': self.sensor
        }

        self.control_loop_wait_time = 0.025
        self.automodes = AutonomousModeSelector('autonomous', self.components)

        # #Defining Buttons##
        self.canUp = Button(self.joystick1,3)
        self.canDown = Button(self.joystick1,2)
        self.canTop = Button(self.joystick1,6)
        self.canBottom = Button(self.joystick1,7)
        self.toteUp = Button(self.joystick2, 3)
        self.toteDown = Button(self.joystick2, 2)
        self.toteTop = Button(self.joystick2, 6)
        self.toteBottom = Button(self.joystick2, 7)
        self.ui_joystick_tote_down = Button(self.ui_joystick, 4)
        self.ui_joystick_tote_up = Button(self.ui_joystick, 6)
        self.ui_joystick_can_up = Button(self.ui_joystick, 5)
        self.ui_joystick_can_down = Button(self.ui_joystick, 3)
        
        self.reverseDirection = Button(self.joystick1, 1)
        #self.alignTrigger = Button(self.joystick2, 1)
        
        self.toteTo=0
        self.oldTote=0
        self.canTo=0
        self.oldCan=0
        self.reverseRobot = False
        self.oldReverseRobot = False
        self.autoLift = False
        
        self.sd.putNumber('liftTo', 0)
        self.sd.putNumber('binTo', 0)
        self.sd.putBoolean('autoLift', False)
        self.sd.putBoolean('reverseRobot',False)
        
        
        
    def autonomous(self):
        self.automodes.run(self.control_loop_wait_time, self.update)

    def operatorControl(self):

        self.can_forklift.set_manual(0)
        self.tote_forklift.set_manual(0)
        
        delay = PreciseDelay(self.control_loop_wait_time)

        self.logger.info("Entering teleop mode")

        while self.isOperatorControl() and self.isEnabled():
            
            self.sensor.update()
            
            #self.calibrator.calibrate()
{'fraction_non_alphanumeric': 0.09545729860690491, 'fraction_numerical': 0.016474863718958208, 'mean_word_length': 2.5072217502124046, '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': '1249757', 'n_tokens_mistral': 2998, 'n_tokens_neox': 2724, 'n_words': 407}