def __init__(self, robot): # Setup the joystick for the driver self.driverJoystick = Joystick(DRIVER_JOYSTICK) # self.driverRightAnalog = Joystick(DRIVER_JOYSTICK) # self.driverRightAnalog.setXChannel(4) # self.driverRightAnalog.setYChannel(5) # Setup the joystick for the operator self.operatorJoystick = Joystick(OPERATOR_JOYSTICK) # self.operatorRightAnalog = Joystick(DRIVER_JOYSTICK) # self.operatorRightAnalog.setXChannel(4) # self.operatorRightAnalog.setYChannel(5) # Driver commands and control btn(self.driverJoystick, 1).whileHeld(IntakeMotorsIn(robot)) btn(self.driverJoystick, 2).whileHeld(IntakeMotorsOut(robot, INTAKE_OUT_SWITCH_FAST)) btn(self.driverJoystick, 3).whileHeld(IntakeMotorsOut(robot, INTAKE_OUT_SCALE)) btn(self.driverJoystick, 4).whileHeld(IntakeMotorsOut(robot, INTAKE_OUT_SWITCH_SLOW)) # Operator commands and control # Per Dylan, boom control A-intake X-switch Y- scale btn(self.operatorJoystick, 1).whenPressed(IntakePneumaticsOpenClose(robot)) btn(self.operatorJoystick, 3).whenPressed(BoomToSwitch(robot)) btn(self.operatorJoystick, 2).whenPressed(BoomToIntake(robot)) btn(self.operatorJoystick, 4).whenPressed(BoomToScale(robot))
def createObjects(self): self.shiftBaseSolenoid = wpilib.DoubleSolenoid( rMap.conf_shifterSolenoid1, rMap.conf_shifterSolenoid2) self.rightFrontBaseMotor = CANTalon(rMap.conf_rightFrontBaseTalon) self.rightRearBaseMotor = CANTalon(rMap.conf_rightRearBaseTalon) self.leftFrontBaseMotor = CANTalon(rMap.conf_leftFrontBaseTalon) self.leftRearBaseMotor = CANTalon(rMap.conf_leftRearBaseTalon) self.rightFrontBaseMotor.enableControl() self.rightRearBaseMotor.enableControl() self.rightRearBaseMotor.setControlMode(CANTalon.ControlMode.Follower) self.rightRearBaseMotor.set(rMap.conf_rightFrontBaseTalon) self.leftFrontBaseMotor.enableControl() self.leftRearBaseMotor.enableControl() self.leftFrontBaseMotor.setInverted(True) self.leftRearBaseMotor.setControlMode(CANTalon.ControlMode.Follower) self.leftRearBaseMotor.set(rMap.conf_leftFrontBaseTalon) self.leftJoy = Joystick(rMap.conf_left_joy) self.rightJoy = Joystick(rMap.conf_right_joy) self.xbox = Joystick(rMap.conf_xbox) self.robotDrive = wpilib.RobotDrive(self.leftFrontBaseMotor, self.rightFrontBaseMotor)
def createControllers(self, ConSpec): con = None if ConSpec['jobType'] == 'main': if ConSpec['Type'] == 'xbox': con = XboxController(ConSpec['Id']) elif ConSpec['Type'] == 'xtreme': con = Joystick(ConSpec['Id']) elif ConSpec['Type'] == 'gameCube': con = Joystick(ConSpec['Id']) else: print("IDK your Controller") elif ConSpec['jobType'] == 'side': if ConSpec['Type'] == 'xbox': con = XboxController(ConSpec['Id']) elif ConSpec['Type'] == 'xtreme': con = Joystick(ConSpec['Id']) elif ConSpec['Type'] == 'custom': con = Joystick(ConSpec['Id']) else: print("IDK your Controller") else: print("IDK your Controller") return con
def robotInit(self): """ This function is called upon program startup and should be used for any initialization code. """ self.pneumaticControlModuleCANID = robotmap.PCM self.kDriveTrain = robotmap.DriveTrain self.kCubeGrabber = robotmap.CubeGrabber self.kSticks = robotmap.Sticks self.dStick = Joystick(self.kSticks['drive']) self.cStick = Joystick(self.kSticks['control']) self.drive = Drive(self) self.cubeGrabber = Grabber(self)
def robotInit(self): """ This function is called upon program startup and should be used for any initialization code. """ self.drive = Drive() self.stick = Joystick(0)
def robotInit(self): # Note the lack of the camera server initialization here. # Initializing drive motors RLMotor = Spark(self.RLMotorChannel) RRMotor = Spark(self.RRMotorChannel) FLMotor = Spark(self.FLMotorChannel) FRMotor = Spark(self.FRMotorChannel) # Grouping drive motors into left and right. self.Left = SpeedControllerGroup(RLMotor, FLMotor) self.Right = SpeedControllerGroup(RRMotor, FRMotor) # Initializing drive Joystick. self.DriveStick = Joystick(self.DriveStickChannel) # Initializing drive function. self.drive = DifferentialDrive(self.Left, self.Right) # Sets the right side motors to be inverted. self.drive.setRightSideInverted(rightSideInverted=True) # Turns the drive off after .1 seconds of inactivity. self.drive.setExpiration(0.1) # Components is a dictionary that contains any variables you want to put into it. All of the variables put into # components dictionary is given to the autonomous modes. self.components = {"drive": self.drive} # Sets up the autonomous mode selector by telling it where the autonomous modes are at and what the autonomous # modes should inherit. self.automodes = autonomous.AutonomousModeSelector( "Sim_Autonomous", self.components)
def robotInit(self): """Set up everything we need for a working robot.""" self.stick = Joystick(0) self.toLoop = Infinite() JoystickButton(self.stick, 1).whenHeld(Test()) JoystickButton(self.stick, 2).whenHeld(SecondTest())
def createObjects(self): """ Create motors, sensors and all your components here. """ self.chassis_left_master = WPI_TalonSRX(1) self.chassis_left_slave = WPI_TalonSRX(2) self.chassis_right_master = WPI_TalonSRX(3) self.chassis_right_slave = WPI_TalonSRX(4) self.chassis_gyro = AHRS.create_spi() self.joystick = Joystick(0)
def __init__(self, port): """ :param port: The port on the driver station that the controller is plugged into. :type port: int """ self.joy = Joystick(port) self.debounce = DpadDebouncer()
class oi: ps4_ctrl = Joystick(0) def __init__(self): pass #example button press action #triangle = JoystickButton(ps4_ctrl, 3) #triangle.whenPressed("place command here")
def robotInit(self): self.controller = Joystick(0) self.joystick = Joystick(1) CameraServer.launch('vision.py:main') self.autoChooser = SendableChooser() self.autoChooser.addDefault("switch_scale", switch_scale) # self.autoChooser.addObject("drive_forward", drive_straight) SmartDashboard.putData("Autonomous Mode Chooser", self.autoChooser) self.autoSideChooser = SendableChooser() self.autoSideChooser.addDefault("left", "L") self.autoSideChooser.addObject("right", "R") self.autoSideChooser.addObject("middle", "M") SmartDashboard.putData("Side Chooser", self.autoSideChooser) RobotMap.driver_component.set_low_gear()
def init(): """ Initialize operator input (OI) objects. """ global joystick, controller, start_btn, divider joystick = Joystick(robotmap.joystick.port) controller = XboxController(robotmap.joystick.port) start_btn = JoystickButton(joystick, 7) divider = 1
def getJoystick(): """ Assign commands to button actions, and publish your joysticks so you can read values from them later. """ joystick = Joystick(0) trigger = JoystickButton(joystick, Joystick.ButtonType.kTriggerButton) trigger.whenPressed(Crash()) return joystick
def init(): global joystick, A, B, X, Y, bumper_L, bumper_R, back, start, stick_L, stick_R joystick = Joystick(robotmap.joystick) A = JoystickButton(joystick, 1) B = JoystickButton(joystick, 2) X = JoystickButton(joystick, 3) Y = JoystickButton(joystick, 4) bumper_L = JoystickButton(joystick, 5) bumper_R = JoystickButton(joystick, 6) back = JoystickButton(joystick, 7) start = JoystickButton(joystick, 8) stick_L = JoystickButton(joystick, 9) stick_R = JoystickButton(joystick, 10)
def __init__(self): self.reversed = True self.arcade_drive = True self.turbo = False self.controls = { "reverse": 2, # top "arcade_switch": 3, "turbo": 1, # trigger "reset": 4 } self.driver_controller = Joystick(0) self.left_power = 0 self.right_power = 0
def init(): global logger, joystick, A, B, X, Y, bumper_L, bumper_R, back, start, stick_L, stick_R logger = logging.getLogger("OI") joystick = Joystick(robotmap.joystick) A = JoystickButton(joystick, 1) B = JoystickButton(joystick, 2) X = JoystickButton(joystick, 3) Y = JoystickButton(joystick, 4) bumper_L = JoystickButton(joystick, 5) bumper_R = JoystickButton(joystick, 6) back = JoystickButton(joystick, 7) start = JoystickButton(joystick, 8) stick_L = JoystickButton(joystick, 9) stick_R = JoystickButton(joystick, 10) logger.debug("OI initialized")
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
def createObjects(self): '''Create motors and stuff here''' with self.consumeExceptions(): Map.load_json( os.path.join(os.path.dirname(os.path.realpath(__file__)), "map.json")) self.chassis_ports = Map.get_map( )["subsystems"]["chassis"]["can_motors"] self.chassis_left_master = WPI_TalonSRX( self.chassis_ports["left_master"]) self.chassis_left_slave = WPI_TalonSRX( self.chassis_ports["left_slave"]) self.chassis_right_master = WPI_TalonSRX( self.chassis_ports["right_master"]) self.chassis_right_slave = WPI_TalonSRX( self.chassis_ports["right_slave"]) self.chassis_navx = AHRS.create_spi() self.left_joystick = Joystick( Map.get_map()["operator_ports"]["left_stick"])
def __init__(self): self.stick = Joystick(0)
def __init__(self, port): self.joystick = Joystick(port)
def __init__(self, channel): self.channel = channel self.joystick = Joystick(channel) self.button_mapping = {} self.invert_mapping = {}
def __init__(self, robot): self.robot = robot self.firstDriver = Joystick(0)
def robotInit(self): self.driver = Joystick(0) CameraServer.launch('vision.py:main')
from wpilib import VictorSP, Joystick, Solenoid from util.enums import init_buttons SWERVE = 0 TANK = 1 LOGGING = False controller = Joystick(0) driving_motors = [] steering_motors = [] gate_mtr = VictorSP(5) auto_state = 0 encoders = None enc_ratio = 0.8692153 drop_sole = None shoot_sole = None # driving motors and steering motors setup for i in range(4): driving_motors.append(VictorSP(i)) # steering_motors.append(VictorSP(i + 4)) init_buttons(controller)
def __init__(self, port): """ Initializes the joystick with some USB port. """ super().__init__() self.j = Joystick(port)
def robotInit(self): self.joystick = Joystick(0) self.motor = Talon(10) self.motor.configClearPositionOnLimitF(True)
def robotInit(self): self.maxVolts = 10 self.joystick = Joystick(0) self.motor: Talon = Talon(31) self.motor.configClearPositionOnLimitF(True) self.motor.configVoltageCompSaturation(self.maxVolts)
def __init__(self, robot): self.driver = Joystick(0) JoystickButton(self.driver, 3).whenPressed(OpenGripper(robot)) JoystickButton(self.driver, 4).whenPressed(CloseGripper(robot)) JoystickButton(self.driver, 1).whenPressed(ToggleGripper(robot))
def get_joysticks(): left = Joystick(0) right = Joystick(1) return left, right