예제 #1
0
    def robotInit(self):
        '''Robot-wide initialization code should go here'''

        #start camera
        wpilib.CameraServer.launch()

        Command.getRobot = lambda x=0: self
        #Variables that are used by the code
        self.drivetrain = Drivetrain()
        self.elevator = Elevator()
        self.intake = Intake()
        self.table = networktables.NetworkTables.getTable("String")
        self.joystick = getJoystick()
        self.joystick1 = getJoystick1()
        #self.auto =  driveForward.DriveForward(16)
        #self.auto = AutoEncoders(20)
        #self.auto = ProfiledForward(10)
        self.auto = StateSpaceDriveCommand("straight3m.tra")
        #self.auto = autonomous.Autonomuscc()
        #self.auto = AutoEncoders()
        self.elevatorSwitch = ElevatorSwitch()
        self.elevatorScale = ElevatorScale()
        self.elevatorIntake = ElevatorIntake()

        self.driveForward = driveForward.DriveForward(10)
예제 #2
0
    def robotInit(self):
        '''Robot-wide initialization code should go here'''

        #start camera
        wpilib.CameraServer.launch()

        Command.getRobot = lambda x=0: self
        #Variables that are used by the code
        self.drivetrain = Drivetrain()
        self.elevator = Elevator()
        self.intake = Intake()
        self.table = networktables.NetworkTables.getTable("String")
        self.joystick = getJoystick()
        #self.auto = autonomous.ForwardOnly()
        self.auto = autonomous.SwitchCommands()
        #self.auto = TurnRight(90)
        #self.auto = Wait9ThenForward()
        #self.auto = RightPosRightSwitchAuto()
        #self.auto = AutoEncodersTurnLeft(90)
        #self.auto = MiddlePosLeftSwitchAuto()
        self.elevatorSwitch = ElevatorSwitch()
        self.elevatorScale = ElevatorScale()
        self.elevatorIntake = ElevatorIntake()


        self.driveForward = driveForward.DriveForward(10)
예제 #3
0
    def robotInit(self):
        '''Robot-wide initialization code should go here'''

        Command.getRobot = lambda x=0: self
        #Variables that are used by the code
        self.drivetrain = Drivetrain()
        self.elevator = Elevator()
        self.intake = Intake()
        self.table = networktables.NetworkTables.getTable("String")
        self.joystick = getJoystick()
        self.angle = turnlikeistuesday.Turnlikeistuesday(90)
        self.DriveForward = driveForward.DriveForward()
        '''
예제 #4
0
class Gneiss(CommandBasedRobot):
    '''Main robot class'''

    def robotInit(self):
        '''Robot-wide initialization code should go here'''

        Command.getRobot = lambda x=0: self
        #Variables that are used by the code
        self.drivetrain = Drivetrain()
        self.elevator = Elevator()
        self.intake = Intake()
        self.table = networktables.NetworkTables.getTable("String")
        self.joystick = getJoystick()
        #self.angle = turnlikeistuesday.Turnlikeistuesday(90)
        self.angle = turn_profiled.TurnProfiled(90)
        self.DriveForward = driveForward.DriveForward()
        '''
        self.goToPickup = commands.elevatorPickupHeight()
        self.goToScale = commands.elevatorScaleHeight()
        self.goToSwitch = commands.elevatorSwitchHeight()
        self.goDown = commands.elevatorDownHeight()
        self.pullIn = commands.grabberPullIn()
        self.spitOut = commands.grabberSpitOut()
        '''


    def autonomousInit(self):
        '''Called only at the beginning of autonomous mode'''
        self.elevator.setSolenoidState(true) #assumes true is open
        pass

    def disabledInit(self):
        '''Called only at the beginning of disabled mode'''
        pass

    def teleopInit(self):
        '''Called only at the beginning of teleoperated mode'''
        #How the buttons for the xbox controller are mapped
        self.drivetrain.init_logger()
        b = JoystickButton(self.joystick, 1) #A
        b2 = JoystickButton(self.joystick, 2) #B
        b.whenPressed(self.angle)
        b2.cancelWhenPressed(self.angle)

        b3 = JoystickButton(self.joystick, 3) #X
        b4 = JoystickButton(self.joystick, 4) #Y
        b3.whenPressed(self.DriveForward)
        b4.cancelWhenPressed(self.DriveForward)

        '''
예제 #5
0
class Gneiss(CommandBasedRobot):
    '''Main robot class'''

    def robotInit(self):
        '''Robot-wide initialization code should go here'''

        #start camera
        wpilib.CameraServer.launch()

        Command.getRobot = lambda x=0: self
        #Variables that are used by the code
        self.drivetrain = Drivetrain()
        self.elevator = Elevator()
        self.intake = Intake()
        self.table = networktables.NetworkTables.getTable("String")
        self.joystick = getJoystick()
        #self.auto = autonomous.ForwardOnly()
        self.auto = autonomous.SwitchCommands()
        #self.auto = TurnRight(90)
        #self.auto = Wait9ThenForward()
        #self.auto = RightPosRightSwitchAuto()
        #self.auto = AutoEncodersTurnLeft(90)
        #self.auto = MiddlePosLeftSwitchAuto()
        self.elevatorSwitch = ElevatorSwitch()
        self.elevatorScale = ElevatorScale()
        self.elevatorIntake = ElevatorIntake()


        self.driveForward = driveForward.DriveForward(10)

    def teleopInit(self):
        self.drivetrain.zeroEncoders()
        self.drivetrain.zeroNavx()
        buttonA = JoystickButton(self.joystick, 1)
        buttonB = JoystickButton(self.joystick, 2)
        buttonY = JoystickButton(self.joystick, 4)

        buttonA.whenPressed(self.elevatorIntake)
        buttonY.whenPressed(self.elevatorScale)
        buttonB.whenPressed(self.elevatorSwitch)

    def teleopPeriodic(self):
        super().teleopPeriodic()
        self.table.putString("Joystick", self.joystick.getName())

    def autonomousInit(self):
        self.elevator.zeroEncoder()
        self.drivetrain.zeroEncoders()
        self.drivetrain.zeroNavx()
        self.auto.start()

    def disabledInit(self):
        '''Called only at the beginning of disabled mode'''
        pass
예제 #6
0
    def robotInit(self):
        '''Robot-wide initialization code should go here'''

        Command.getRobot = lambda x=0: self
        #Variables that are used by the code
        self.startSide = "l"  #starting side
        self.gamecode = "rlr"  #wpilib.DriverStation.getGameSpecificMessage()
        self.drivetrain = Drivetrain()
        self.elevator = Elevator()
        self.intake = Intake()
        self.table = networktables.NetworkTables.getTable("String")
        self.joystick = getJoystick()
        #self.angle = turnlikeistuesday.Turnlikeistuesday(90)
        self.angle = turn_profiled.TurnProfiled(90)
        self.auto = driveForward.DriveForward(10)
        '''self.elevatorZero = elevatorZero.elevatorZero()'''

        #self.driveForward = driveForward.DriveForward(10)
        self.driveForward = automous.Test()
        '''
예제 #7
0
class Rockslide(CommandBasedRobot):
    '''Main robot class'''
    def robotInit(self):
        '''Robot-wide initialization code should go here'''

        #start camera
        wpilib.CameraServer.launch()

        Command.getRobot = lambda x=0: self
        #Variables that are used by the code
        self.drivetrain = Drivetrain()
        self.elevator = Elevator()
        self.intake = Intake()
        self.table = networktables.NetworkTables.getTable("String")
        self.joystick = getJoystick()
        self.joystick1 = getJoystick1()
        #self.auto =  driveForward.DriveForward(16)
        #self.auto = AutoEncoders(20)
        #self.auto = ProfiledForward(10)
        self.auto = StateSpaceDriveCommand("straight3m.tra")
        #self.auto = autonomous.Autonomuscc()
        #self.auto = AutoEncoders()
        self.elevatorSwitch = ElevatorSwitch()
        self.elevatorScale = ElevatorScale()
        self.elevatorIntake = ElevatorIntake()

        self.driveForward = driveForward.DriveForward(10)

    def teleopInit(self):
        self.drivetrain.zeroEncoders()
        self.drivetrain.zeroNavx()
        buttonA = JoystickButton(self.joystick1, 1)
        buttonY = JoystickButton(self.joystick1, 4)

        #buttonA.whenPressed(ElevatorTest2())
        buttonA.whenPressed(self.elevatorIntake)
        buttonY.whenPressed(self.elevatorScale)

    def teleopPeriodic(self):
        super().teleopPeriodic()
        self.table.putString("Joystick", self.joystick.getName())

    def autonomousInit(self):
        self.elevator.zeroEncoder()
        self.drivetrain.zeroEncoders()
        self.drivetrain.zeroNavx()
        self.auto.start()

    def disabledInit(self):
        '''Called only at the beginning of disabled mode'''
        pass
예제 #8
0
class Gneiss(CommandBasedRobot):
    '''Main robot class'''
    def robotInit(self):
        '''Robot-wide initialization code should go here'''

        Command.getRobot = lambda x=0: self
        #Variables that are used by the code
        self.startSide = "l"  #starting side
        self.gamecode = "rlr"  #wpilib.DriverStation.getGameSpecificMessage()
        self.drivetrain = Drivetrain()
        self.drivetrain.zeroEncoders()
        self.elevator = Elevator()
        self.intake = Intake()
        self.table = networktables.NetworkTables.getTable("String")
        self.joystick = getJoystick()
        #self.angle = turnlikeistuesday.Turnlikeistuesday(90)
        self.angle = turn_profiled.TurnProfiled(90)
        self.auto = driveForward.DriveForward(10)
        #self.autoTimeBased = autoTimeBased.TimeBasedStart()
        self.autoEncoders = commands.autoEncoders.AutoEncoders(5)
        '''self.elevatorZero = elevatorZero.elevatorZero()'''

        self.driveForward = driveForward.DriveForward(10)
        #self.driveForward = automous.Test()

    def autonomousInit(self):
        '''Called only at the beginning of autonomous mode'''
        '''if self.startSide == "l":
            if self.gamecode[1:] == "l": #L the Letter
                gotoSwitchL.gotoSwitchL("l").start()
            else: if self.gamecode[:2][1:] == "l":
                goToScaleL.goToScaleL("l").start()
            else:
                goToSwitchL.gotoSwitchL("r").start()'''
        self.autoEncoders.start()

    def disabledInit(self):
        '''Called only at the beginning of disabled mode'''
        pass

    def teleopInit(self):
        '''Called only at the beginning of teleoperated mode'''
        self.drivetrain.zeroEncoders()
        #How the buttons for the xbox controller are mapped
        self.drivetrain.init_logger()
        b = JoystickButton(self.joystick, 7)  #A
        b2 = JoystickButton(self.joystick, 8)  #B
        #b.whenPressed(self.angle)
        b2.cancelWhenPressed(self.angle)
예제 #9
0
from time import sleep

import multiprocessing


def worker():
    print "Robot in running"
    return


p = multiprocessing.Process(target=worker)
p.start()
p.join()

# H-drive drivetrain
drivetrain = Drivetrain()
# sensor_stick = SensorStick()
status_light = StatusLight()

#testsystem = Test()


def drive_in_square():
    drivetrain.arcade_drive(1.0, 0.0, 0.0)
    sleep(1)
    drivetrain.arcade_drive(0.0, 0.0, 1.0)
    sleep(1)
    drivetrain.arcade_drive(-1.0, 0.0, 0.0)
    sleep(1)
    drivetrain.arcade_drive(0.0, 0.0, -1.0)
    sleep(1)
예제 #10
0
from subsystems import Drivetrain

# H-drive drivetrain
drivetrain = Drivetrain()

drivetrain.arcade_drive(0.0, 0.0, 0.0)
예제 #11
0
class Gneiss(CommandBasedRobot):
    '''Main robot class'''
    def robotInit(self):
        '''Robot-wide initialization code should go here'''

        Command.getRobot = lambda x=0: self
        #Variables that are used by the code
        self.startSide = "l"  #starting side
        self.gamecode = "rlr"  #wpilib.DriverStation.getGameSpecificMessage()
        self.drivetrain = Drivetrain()
        self.elevator = Elevator()
        self.intake = Intake()
        self.table = networktables.NetworkTables.getTable("String")
        self.joystick = getJoystick()
        #self.angle = turnlikeistuesday.Turnlikeistuesday(90)
        self.angle = turn_profiled.TurnProfiled(90)
        self.auto = driveForward.DriveForward(10)
        '''self.elevatorZero = elevatorZero.elevatorZero()'''

        #self.driveForward = driveForward.DriveForward(10)
        self.driveForward = automous.Test()
        '''
        self.goToPickup = commands.elevatorPickupHeight()
        self.goToScale = commands.elevatorScaleHeight()
        self.goToSwitch = commands.elevatorSwitchHeight()
        self.goDown = commands.elevatorDownHeight()
        self.pullIn = commands.grabberPullIn()
        self.spitOut = commands.grabberSpitOut()
        '''

    def autonomousInit(self):
        '''Called only at the beginning of autonomous mode'''
        '''if self.startSide == "l":
            if self.gamecode[1:] == "l": #L the Letter
                gotoSwitchL.gotoSwitchL("l").start()
            else: if self.gamecode[:2][1:] == "l":
                goToScaleL.goToScaleL("l").start()
            else:
                goToSwitchL.gotoSwitchL("r").start()'''

    def disabledInit(self):
        '''Called only at the beginning of disabled mode'''
        pass

    def teleopInit(self):
        '''Called only at the beginning of teleoperated mode'''
        #How the buttons for the xbox controller are mapped
        self.drivetrain.init_logger()
        b = JoystickButton(self.joystick, 1)  #A
        b2 = JoystickButton(self.joystick, 2)  #B
        b.whenPressed(self.angle)
        b2.cancelWhenPressed(self.angle)

        b3 = JoystickButton(self.joystick, 3)  #X
        b4 = JoystickButton(self.joystick, 4)  #Y
        b3.whenPressed(self.driveForward)
        b4.cancelWhenPressed(self.driveForward)

        b5 = JoystickButton(self.joystick, 5)  #leftbumper
        b6 = JoystickButton(self.joystick, 6)  #rightbumper
        b5.whenPressed(self.auto)
        b6.cancelWhenPressed(self.auto)
        '''