Exemplo n.º 1
0
def getJoystick():
    """This function creates an instance of the joystick, and assigns commands
       to the joystick buttons."""

    joystick = Joystick(0)

    trigger = JoystickButton(joystick, Joystick.ButtonType.kTrigger)
    trigger.whileHeld(GrippersIntake())

    thumb = JoystickButton(joystick, Joystick.ButtonType.kTop)
    thumb.whileHeld(GrippersExhaust())

    POV_up = POVButton(joystick, 0)
    POV_down = POVButton(joystick, 180)

    POV_up.whileActive(ElevatorUp())
    POV_down.whileActive(ElevatorDown())

    button_5 = JoystickButton(joystick, 5)
    button_5.whenPressed(HandlesState(HandlesOpen(), HandlesClose()))

    button_6 = JoystickButton(joystick, 6)
    button_6.whenPressed(DrivetrainState(StrengthState(), SpeedState()))

    return joystick
Exemplo n.º 2
0
def getJoystick():
    """
    Assign commands to button actions, and publish your joysticks so you
    can read values from them later.
    """

    joystick = Joystick(0)

    button1 = JoystickButton(joystick, 1)

    button1.whileHeld(Targeting())

    return Joystick
Exemplo n.º 3
0
def get_joystick():
    joystick = Joystick(0)

    thumb = JoystickButton(joystick, Joystick.ButtonType.kTop)
    thumb.whenPressed(SwitchMode())

    trigger = JoystickButton(joystick, Joystick.ButtonType.kTrigger)
    trigger.whileHeld(OperateConveyor())

    button_11 = JoystickButton(joystick, 11)
    button_11.whenPressed(AutoTargetY())

    button_12 = JoystickButton(joystick, 12)
    button_12.whenPressed(AutoTargetX())

    button_9 = JoystickButton(joystick, 9)
    button_9.whenPressed(AutoTargetAngle())

    return joystick
Exemplo n.º 4
0
def getJoystick():
    """
    Assign commands to button actions, and publish your joysticks so you
    can read values from them later.
    """

    joystick = Joystick(0)

    button5 = JoystickButton(joystick, 5)
    button6 = JoystickButton(joystick, 6)
    button3 = JoystickButton(joystick, 3)
    button4 = JoystickButton(joystick, 4)
    button1 = JoystickButton(joystick, 1)
    button2 = JoystickButton(joystick, 2)
    button7 = JoystickButton(joystick, 7)

    button5.whenPressed(BallIntake())
    button6.whileHeld(BallOutake())
    button3.whileHeld(LiftArm())
    button4.whileHeld(LowerArm())
    button1.whileHeld(HatchUp())
    button2.whileHeld(HatchDown())
    button7.whileHeld(FindTarget())

    return joystick
Exemplo n.º 5
0
def init():
    """
    Assign commands to button actions, and publish your joysticks so you
    can read values from them later.
    """

    global leftDriverStick
    global rightDriverStick
    global goGamePad

    try:
        leftDriverStick = T16000M(0)
    except:
        print(
            'OI: Error - Could not instantiate Left Driver Stick on USB port 0!!!'
        )

    try:
        rightDriverStick = T16000M(1)
    except:
        print(
            'OI: Error - Could not instantiate Right Driver Stick on USB port 0!!!'
        )

    try:
        goGamePad = Joystick(2)
    except:
        print('OI: Error - Could not instantiate GO GamePad on USB port 2!!!')

# ----------------------------------------------------------
# Driver Controls
# ----------------------------------------------------------

#global resetYawBtn
#resetYawBtn = JoystickButton(rightDriverStick, config.btnResetYawAngleIndex)
#resetYawBtn.whenPressed(NavxResetYawAngle())

#global btnDriveSlow
#btnDriveSlow = JoystickButton(leftDriverStick, config.btnDriveSlow)

    global btnEnableLightSensor
    btnEnableLightSensor = JoystickButton(leftDriverStick,
                                          config.btnEnableLightSensorIndex)

    global btnResetEncoders
    btnResetEncoders = JoystickButton(leftDriverStick,
                                      config.btnResetEncodersIndex)
    btnResetEncoders.whenPressed(ElevatorResetEncoders())

    # ----------------------------------------------------------
    # Manipulators (Cargo and Hatch)
    # ----------------------------------------------------------

    global btnCargoGrabTog
    btnCargoGrabTog = JoystickButton(goGamePad, config.btnCargoGrabTogIndex)
    btnCargoGrabTog.whenPressed(CargoToggleTrigger())

    global btnHatchGrabTog
    btnHatchGrabTog = JoystickButton(goGamePad, config.btnHatchGrabTogIndex)
    btnHatchGrabTog.whenPressed(HatchToggleTrigger())

    global btnExtendSuctionsTog
    btnExtendSuctionsTog = JoystickButton(goGamePad,
                                          config.btnExtendSuctionsTogIndex)
    btnExtendSuctionsTog.whenPressed(ExtendSuctionsTrigger())

    # ----------------------------------------------------------
    # Elevator system
    # ----------------------------------------------------------

    global btnElevatorHatchHeight
    btnElevatorHatchHeight = JoystickButton(goGamePad,
                                            config.btnElevatorHatchHeightIndex)
    btnElevatorHatchHeight.whenPressed(ElevatorMoveHatchHeight())

    global btnElevatorCargoHeight
    btnElevatorCargoHeight = JoystickButton(goGamePad,
                                            config.btnElevatorCargoHeightIndex)
    btnElevatorCargoHeight.whenPressed(ElevatorCargoHeight())

    # ----------------------------------------------------------
    # Ramp system
    # ----------------------------------------------------------

    #global btnRampExtendTog
    #btnRampExtendTog = JoystickButton(goGamePad, config.btnRampExtendTogIndex)
    #btnRampExtendTog.whenPressed(RampExtend())

    #global btnRampRetractTog
    #btnRampRetractTog = JoystickButton(goGamePad, config.btnRampRetractTogIndex)
    #btnRampRetractTog.whenPressed(RampRetract())

    global btnRampTog
    btnRampTog = JoystickButton(goGamePad, config.btnRampTogIndex)
    btnRampTog.whenPressed(RampToggleTrigger())

    # ----------------------------------------------------------
    # Lift system
    # ----------------------------------------------------------

    global btnAutoClimb
    btnAutoClimb = JoystickButton(leftDriverStick, config.btnAutoClimbIndex)
    btnAutoClimb.whileHeld(AutoClimb())

    #global btnTogAllLift
    #btnTogAllLift = JoystickButton(rightDriverStick, config.btnTogAllLiftIndex)
    #btnTogAllLift.whenPressed(AllLiftTogTrigger())

    global btnExtendAll
    btnExtendAll = JoystickButton(rightDriverStick, config.btnExtendAllIndex)
    btnExtendAll.whenPressed(ExtendAll())

    global btnRetractAll
    btnRetractAll = JoystickButton(rightDriverStick, config.btnRetractAllIndex)
    btnRetractAll.whenPressed(RetractAll())

    #global btnTogFrontLift
    #btnTogFrontLift = JoystickButton(rightDriverStick, config.btnTogFrontLiftIndex)
    #btnTogFrontLift.whenPressed(FrontLiftTogTrigger())

    global btnExtendFront
    btnExtendFront = JoystickButton(rightDriverStick,
                                    config.btnExtendFrontIndex)
    btnExtendFront.whenPressed(ExtendFront())

    global btnRetractFront
    btnRetractFront = JoystickButton(rightDriverStick,
                                     config.btnRetractFrontIndex)
    btnRetractFront.whenPressed(RetractFront())

    #global btnTogBackLift
    #btnTogBackLift = JoystickButton(rightDriverStick, config.btnTogBackLiftIndex)
    #btnTogBackLift.whenPressed(BackLiftTogTrigger())

    global btnExtendBack
    btnExtendBack = JoystickButton(rightDriverStick, config.btnExtendBackIndex)
    btnExtendBack.whenPressed(ExtendBack())

    global btnRetractBack
    btnRetractBack = JoystickButton(rightDriverStick,
                                    config.btnRetractBackIndex)
    btnRetractBack.whenPressed(RetractBack())
Exemplo n.º 6
0
class MyRobot(commandbased.CommandBasedRobot):
    
    def robotInit(self): 
        '''This is where the robot code starts.'''
        team3200.getRobot = lambda x=0:self
        self.map = team3200.robotMap.RobotMap()
        self.networkTableInit()
        self.dtSub = team3200.subsystems.driveTrain.DriveTrainSub()
        self.jGreatDrive = joystickDrive.JoystickDrive(-.8)
        self.jDrive = self.jGreatDrive
        self.driveInit(self.jDrive)
        self.liftHold = True
        self.liftSub = team3200.subsystems.lifter.LifterSub()
        self.pistonSub = team3200.subsystems.lifter.PlatePiston()
        self.driveController = wpilib.XboxController(self.map.controllerMap.driverController['controllerId'])
        self.auxController = wpilib.XboxController(self.map.controllerMap.auxController['controllerId'])
        self.controllerInit()
        self.healthMonitor = team3200.subsystems.healthMonitor.HealthMonitor()
    
    def networkTableInit(self):
        '''This sets up the network tables and adds a variable called sensitivity'''
        NetworkTables.initialize(server = 'roborio-3200-frc.local')
        self.liveWindowTable = NetworkTables.getTable('Custom')
        
        for k, v in self.map.networkTableMap.networkTableValues.items():
            #K for key, V for value
            self.liveWindowTable.putNumber(k, v)
        
        

    def controllerInit(self):
        self.driveController = wpilib.XboxController(self.map.controllerMap.driverController['controllerId'])
        self.auxController = wpilib.XboxController(self.map.controllerMap.auxController['controllerId'])
        
        self.driveControllerMap = self.map.controllerMap.driverController
        self.auxControllerMap = self.map.controllerMap.auxController
        
        
        
        #Spacing added for readability
        
        '''Buttons for the Drive Controller'''
        self.lightButton = JoystickButton(self.driveController, self.driveControllerMap['ledToggle'])
        self.lightButton.whenPressed(Lights())
        
        self.leftButton = JoystickButton(self.driveController, self.driveControllerMap['leftButton'])
        self.leftButton.whenPressed(joystickDrive.GearDown(self))
        
        self.rightButton = JoystickButton(self.driveController, self.driveControllerMap['rightButton'])
        self.rightButton.whileHeld(joystickDrive.GearUp(self))
        
        self.alignButton = JoystickButton(self.driveController, self.driveControllerMap['alignButton'])
        self.alignButton.whenPressed(AlignButton(self.dtSub))
        
        self.straightButton = JoystickButton(self.driveController, self.driveControllerMap['straightButton'])
        self.straightButton.whileHeld(DriveStraight(self.dtSub))
        
        
        
        '''Buttons for the Auxiliary Controller'''
        self.raiseButton = JoystickButton(self.auxController, self.auxControllerMap['RaiseButton'])
        if self.liftHold:
            self.raiseButton.whileHeld(lifterControl.RaiseButton(self.liftSub))
            self.raiseButton.whenReleased(lifterControl.StopButton(self.liftSub))
        else:
            self.raiseButton.whenPressed(lifterControl.RaiseButton(self.liftSub))
        
        
        self.lowerButton = JoystickButton(self.auxController, self.auxControllerMap['LowerButton'])
        if self.liftHold:
            self.lowerButton.whileHeld(lifterControl.LowerButton(self.liftSub))
            self.lowerButton.whenReleased(lifterControl.StopButton(self.liftSub))
        else:
            self.lowerButton.whenPressed(lifterControl.LowerButton(self.liftSub))
        
        
        self.pistonButton = JoystickButton(self.auxController, self.auxControllerMap['PistonButton'])
        self.pistonButton.whenPressed(lifterControl.PistonButton(self.pistonSub))
        
        self.rollerIO = JoystickButton(self.auxController, self.auxControllerMap['RollerIO'])
        self.rollerIO.whenPressed(lifterControl.ForwardRoller(self.liftSub))
        self.rollerIO.whenReleased(lifterControl.StopRoller(self.liftSub))
        
        self.rollerToggle = JoystickButton(self.auxController, self.auxControllerMap['RollerToggle'])
        self.rollerToggle.whenPressed(lifterControl.ReverseRoller(self.liftSub))
        self.rollerToggle.whenReleased(lifterControl.StopRoller(self.liftSub))


    def driveInit(self, jDrive):
        self.dtSub = team3200.subsystems.driveTrain.DriveTrainSub()
        self.jDrive = jDrive
        sensName = "ControllerSensitivity"
        if sensName in self.map.networkTableMap.networkTableValues:
            
            sensEntry = self.liveWindowTable.getEntry(sensName)
            self.jDrive = team3200.commands.joystickDrive.JoystickDrive(sensEntry)
            self.dtSub.setDefaultCommand(self.jDrive)
Exemplo n.º 7
0
class OI(object):

    def __init__(self):
        # Create Joysticks
        self._driveJoy = XboxController(0)
        self._cyController = Joystick(1)

        # Create Buttons
        self._blastenTheHatches = JoystickButton(self._driveJoy, 2)
        self._servoOpen = JoystickButton(self._driveJoy, 4)
        self._servoHalf = JoystickButton(self._driveJoy, 3)
        self._servoClose = JoystickButton(self._driveJoy, 1)

        self._suplexButton = JoystickButton(self._driveJoy, 8)
        self._backButton = JoystickButton(self._driveJoy, 7)

        # Testing
        self._moveMastUpButton = JoystickButton(self._cyController, 8)
        self._moveMastDownButton = JoystickButton(self._cyController, 9)

        # Connect Buttons to Commands
        hatchEffector = Command.getRobot().hatchEffector
        self._blastenTheHatches.whileHeld(hatchEffector.ParallelShoot(hatchEffector))
        self._servoOpen.whileHeld(hatchEffector.ServoOpen(hatchEffector))
        self._servoHalf.whileHeld(hatchEffector.ServoHalf(hatchEffector))
        self._servoClose.whileHeld(hatchEffector.ServoClose(hatchEffector))

        suplex = Command.getRobot().suplex
        self._suplexButton.whileHeld(suplex.Smash(suplex, Flipper.FlipDirection.UP))
        self._backButton.whileHeld(suplex.Smash(suplex, Flipper.FlipDirection.DOWN))

        mastyBoi = Command.getRobot().mastyBoi
        self._moveMastUpButton.whileHeld(mastyBoi.HoistTheColors(mastyBoi))
        self._moveMastDownButton.whileHeld(mastyBoi.RetrieveTheColors(mastyBoi))

    @property
    def driveJoy(self):
        return self._driveJoy
Exemplo n.º 8
0
def init():
    '''
    Assign commands to button actions, and publish your joysticks so you
    can read values from them later.
    '''

    global joystick

    joystick = Joystick(0)

    brakeButton = JoystickButton(joystick, RobotMap.buttons.brake)
    brakeButton.whileHeld(Brake())

    # resetRevolutionsButton = JoystickButton(joystick, RobotMap.buttons.resetRevolutions)
    # resetRevolutionsButton.whenPressed(ResetRevolutions())

    preciseDriveButton = JoystickButton(joystick, RobotMap.buttons.preciseDrive)
    preciseDriveButton.whileHeld(PreciseDriveWithJoystick())

    # climbButton = JoystickButton(joystick, RobotMap.buttons.climb)
    # climbButton.whileHeld(Climb())

    # dropButton = JoystickButton(joystick, RobotMap.buttons.drop)
    # dropButton.whileHeld(Drop())

    # stopClimbButton = JoystickButton(joystick, RobotMap.buttons.stopClimb)
    # stopClimbButton.whileHeld(StopClimb())

    # suckCubeButton = JoystickButton(joystick, RobotMap.buttons.suckCube)
    # suckCubeButton.whileHeld(SuckCube())

    retractCubeButton = JoystickButton(joystick, RobotMap.buttons.retractCube)
    retractCubeButton.whileHeld(RetractCube())

    retractCubeButton2 = JoystickButton(joystick, RobotMap.buttons.retractCube2)
    retractCubeButton2.whileHeld(RetractCube())

    winchUpButton = JoystickButton(joystick, RobotMap.buttons.winchUp)
    winchUpButton.whileHeld(WinchUp())

    winchDownButton = JoystickButton(joystick, RobotMap.buttons.winchDown)
    winchDownButton.whileHeld(WinchDown())