def robotInit(self): self.leftFront = wpilib.Talon(3) self.leftRear = wpilib.Talon(1) self.rightFront = wpilib.Talon(4) self.rightRear = wpilib.Talon(2) # Create motor groups for WPI-style differential driving self.leftDrive = wpilib.SpeedControllerGroup(self.leftFront, self.leftRear) self.rightDrive = wpilib.SpeedControllerGroup(self.rightFront, self.rightRear) self.drive = wpilib.drive.DifferentialDrive(self.leftDrive, self.rightDrive) self.controller = wpilib.Joystick(0) self.forward = wpilib.buttons.JoystickButton(self.controller, PS4Button["TRIANGLE"]) self.backward = wpilib.buttons.JoystickButton(self.controller, PS4Button["CROSS"]) self.right = wpilib.buttons.JoystickButton(self.controller, PS4Button["CIRCLE"]) self.left = wpilib.buttons.JoystickButton(self.controller, PS4Button["SQUARE"]) # Position gets automatically updated as robot moves self.gyro = wpilib.AnalogGyro(1)
def robotInit(self): #Velcrolastick self.lift_motor1 = wpilib.Spark(6) self.lift_motor2 = wpilib.Spark(7) self.sensor1 = wpilib.DigitalInput(7) self.sensor2 = wpilib.DigitalInput(8) # Ismafeeder self.cargo_motor = wpilib.Spark(4) self.lift_motor = wpilib.Spark(5) # Mecanum drive self.frontLeftMotor = wpilib.Talon(0) self.rearLeftMotor = wpilib.Talon(1) self.frontRightMotor = wpilib.Talon(2) self.rearRightMotor = wpilib.Talon(3) self.sensor_1_mec = wpilib.DigitalInput(9) self.frontLeftMotor.setInverted(True) self.rearLeftMotor.setInverted(True) self.drive = MecanumDrive(self.frontLeftMotor, self.rearLeftMotor, self.frontRightMotor, self.rearRightMotor)
def robotInit(self): if not wpilib.RobotBase.isSimulation(): import ctre self.motor1 = ctre.CANTalon(1) self.motor2 = ctre.CANTalon(2) self.motor3 = ctre.CANTalon(3) self.motor4 = ctre.CANTalon(4) else: self.motor1 = wpilib.Talon(1) self.motor2 = wpilib.Talon(2) self.motor3 = wpilib.Talon(3) self.motor4 = wpilib.Talon(4) #Defining Constants # self.LeftTread = wpilib.Talon(0) # self.RightTread = wpilib.Talon(1) self.robotDrive = wpilib.RobotDrive(self.motor1, self.motor2, self.motor3, self.motor4) self.xboxController = wpilib.Joystick(0) self.xboxAbutton = wpilib.buttons.JoystickButton( self.xboxController, 1) self.xboxBbutton = wpilib.buttons.JoystickButton( self.xboxController, 2) self.xboxYbutton = wpilib.buttons.JoystickButton( self.xboxController, 4) #self.navx = navx.AHRS.create_spi() # self.drive = drive.Drive(self.robotDrive, self.xboxController, self.navx) #Defining Variables self.dm = True
def robotInit(self): #Motors self.leftMotorInput = wpilib.Talon(1) # AEN self.rightMotorInput = wpilib.Talon(2) # AEN self.drive = wpilib.drive.DifferentialDrive(self.leftMotorInput, self.rightMotorInput) #Inputs self.xboxController = wpilib.Joystick(0) self.xboxAbutton = wpilib.buttons.JoystickButton(self.xboxController, 1) self.xboxBbutton = wpilib.buttons.JoystickButton(self.xboxController, 2) self.xboxYbutton = wpilib.buttons.JoystickButton(self.xboxController, 4) #Navigation and Logistics #Defining Variables self.dm = True #Auto mode variables self.components = { 'drive': self.drive } self.automodes = AutonomousModeSelector('autonomous', self.components)
def robotInit(self): '''Robot initialization function''' # object that handles basic drive operations self.frontLeftMotor = wpilib.Talon(1) self.rearLeftMotor = wpilib.Talon(2) self.frontRightMotor = wpilib.Talon(3) self.rearRightMotor = wpilib.Talon(4) self.left = wpilib.SpeedControllerGroup(self.frontLeftMotor, self.rearLeftMotor) self.right = wpilib.SpeedControllerGroup(self.frontRightMotor, self.rearRightMotor) self.drive = DifferentialDrive(self.left, self.right) self.drive.setExpiration(0.1) self.timer = wpilib.Timer() # joystick 1 on the driver station self.stick = wpilib.Joystick(1) # Initialization of the pneumatic system self.Compressor = wpilib.Compressor(0) self.Compressor.setClosedLoopControl(True) self.enabled = self.Compressor.enabled() self.PSV = self.Compressor.getPressureSwitchValue() self.DS = wpilib.DoubleSolenoid(0, 1) self.Compressor.start() # Initialization of the camera server wpilib.CameraServer.launch()
def __init__(self): print('MecDrive: init called') super().__init__('MecDrive') self.logPrefix = "MecDrive: " self.leftFrontSpdCtrl = wpilib.Talon( robotmap.driveLine.leftFrontMotorPort) if robotmap.driveLine.invertLeftFront: self.leftFrontSpdCtrl.setInverted(True) self.rightFrontSpdCtrl = wpilib.Talon( robotmap.driveLine.rightFrontMotorPort) if robotmap.driveLine.invertRightFront: self.rightFrontSpdCtrl.setInverted(True) self.leftRearSpdCtrl = wpilib.Talon( robotmap.driveLine.leftRearMotorPort) if robotmap.driveLine.invertLeftRear: self.leftRearSpdCtrl.setInverted(True) self.rightRearSpdCtrl = wpilib.Talon( robotmap.driveLine.rightRearMotorPort) if robotmap.driveLine.invertRightRear: self.rightRearSpdCtrl.setInverted(True) #https://robotpy.readthedocs.io/projects/wpilib/en/latest/wpilib.drive/MecanumDrive.html#wpilib.drive.mecanumdrive.MecanumDrive self.mecanumDrive = MecanumDrive(self.leftFrontSpdCtrl, self.leftRearSpdCtrl, self.rightFrontSpdCtrl, self.rightRearSpdCtrl)
def __init__(self): super().__init__() self.joystick = wpilib.XboxController(0) self.left_drive_motor = wpilib.Talon(0) self.left_drive_motor_2 = wpilib.Talon(1) self.right_drive_motor = wpilib.Talon(2) self.right_drive_motor_2 = wpilib.Talon(3) self.left_drive_motor_group = wpilib.SpeedControllerGroup( self.left_drive_motor, self.left_drive_motor_2) self.right_drive_motor_group = wpilib.SpeedControllerGroup( self.right_drive_motor, self.right_drive_motor_2) self.drive = DifferentialDrive(self.left_drive_motor_group, self.right_drive_motor_group) self.drive_rev = False self.lift_motor = wpilib.Spark(4) self.lift_motor_2 = wpilib.Spark(5) self.lift_motor_group = wpilib.SpeedControllerGroup( self.lift_motor, self.lift_motor_2) self.lift_motor_speed = 0 self.lock_controls = False self.front_motor = wpilib.Spark(6) self.front_motor_2 = wpilib.Spark(7) self.front_motor_2.setInverted(True) self.front_motor_group = wpilib.SpeedControllerGroup( self.front_motor, self.front_motor_2) self.hatch_solenoid = wpilib.DoubleSolenoid(0, 1) self.encoder = wpilib.Encoder(aChannel=0, bChannel=1)
def robotInit(self): """Robot initialization function""" self.frontLeftMotor = wpilib.Talon(self.frontLeftChannel) self.rearLeftMotor = wpilib.Talon(self.rearLeftChannel) self.frontRightMotor = wpilib.Talon(self.frontRightChannel) self.rearRightMotor = wpilib.Talon(self.rearRightChannel) # invert the left side motors self.frontLeftMotor.setInverted(True) # you may need to change or remove this to match your robot self.rearLeftMotor.setInverted(True) self.drive = MecanumDrive( self.frontLeftMotor, self.rearLeftMotor, self.frontRightMotor, self.rearRightMotor, ) self.drive.setExpiration(0.1) self.lstick = wpilib.Joystick(self.lStickChannel) self.rstick = wpilib.Joystick(self.rStickChannel) # Position gets automatically updated as robot moves self.gyro = wpilib.AnalogGyro(1)
def robotInit(self): '''Robot initialization function''' gyroChannel = 0 # analog input self.joystickChannel = 0 # usb number in DriverStation # channels for motors self.leftMotorChannel = 1 self.rightMotorChannel = 0 self.leftRearMotorChannel = 3 self.rightRearMotorChannel = 2 self.angleSetpoint = 0.0 self.pGain = 1 # propotional turning constant # gyro calibration constant, may need to be adjusted # gyro value of 360 is set to correspond to one full revolution self.voltsPerDegreePerSecond = .0128 self.left = wpilib.SpeedControllerGroup( wpilib.Talon(self.leftMotorChannel), wpilib.Talon(self.leftRearMotorChannel)) self.right = wpilib.SpeedControllerGroup( wpilib.Talon(self.rightMotorChannel), wpilib.Talon(self.rightRearMotorChannel)) self.myRobot = DifferentialDrive(self.left, self.right) self.gyro = wpilib.AnalogGyro(gyroChannel) self.joystick = wpilib.Joystick(self.joystickChannel)
def robotInit(self): """Robot initialization function""" self.frontLeftMotor = wpilib.Talon(self.frontLeftChannel) self.rearLeftMotor = wpilib.Talon(self.rearLeftChannel) self.frontRightMotor = wpilib.Talon(self.frontRightChannel) self.rearRightMotor = wpilib.Talon(self.rearRightChannel) # invert the left side motors self.frontLeftMotor.setInverted(True) # you may need to change or remove this to match your robot self.rearLeftMotor.setInverted(True) self.drive = MecanumDrive( self.frontLeftMotor, self.rearLeftMotor, self.frontRightMotor, self.rearRightMotor, ) self.drive.setExpiration(0.1) self.stick = wpilib.Joystick(self.joystickChannel)
def __init__(self): #Climber Motor Setup self.climberRight = wpilib.Talon(4) self.climberLeft = wpilib.Talon(3) self.climberBack = wpilib.Talon(2) self.climberWheel = wpilib.Talon(18) #Encoders Setup self.backEncoder = wpilib.Encoder(2, 3, False, wpilib.Encoder.EncodingType.k1X) self.leftEncoder = wpilib.Encoder(4, 5, False, wpilib.Encoder.EncodingType.k1X) self.rightEncoder = wpilib.Encoder(0, 1, False, wpilib.Encoder.EncodingType.k1X) # These are commented out because I think they're redundant, # encoder counts should automatically be set to zero upon initialization # self.backEncoder.reset() # self.leftEncoder.reset() # self.rightEncoder.reset() #Misc Variables Setup self.extend19 = 247000 #the number of encoder counts to extend any actuator by 19 inches self.extend6 = 78000 #the number of encoder counts to extend any actuator by 6 inches self.fullRetract = 500 self.extendSpeed = .35 self.retactSpeed = -.25 self.climbWheelSpeed = .1 self.encoderMotor = {self.backEncoder : self.climberBack, self.rightEncoder : self.climberRight, self.leftEncoder : self.climberLeft}
def __init__(self): super().__init__() self.talon_left = wpilib.Talon(0) self.talon_right = wpilib.Talon(1) self.drive = wpilib.RobotDrive(self.talon_left, self.talon_right) self.drive.setInvertedMotor(wpilib.RobotDrive.MotorType.kRearLeft, False) self.drive.setInvertedMotor(wpilib.RobotDrive.MotorType.kRearRight, True) self.joystick = wpilib.Joystick(0) self.width = 2 self.top_speed = 15 self.teleop = lambda: False dashboard2.graph("Forward", self.joystick.getY) dashboard2.graph("Turn", self.joystick.getX) dashboard2.graph("Talon Left", self.talon_left.get) dashboard2.graph("Talon Right", self.talon_right.get) dashboard2.chooser("Drive", ["Radius", "Arcade"]) dashboard2.indicator("Teleop", self.teleop) simulbot.load(self.width, self.top_speed) self.time = 0 dashboard2.run()
def __init__(self, robot): super().__init__("DriveTrain") self.robot = robot self.front_left_motor = wpilib.Talon(1) self.back_left_motor = wpilib.Talon(2) self.front_right_motor = wpilib.Talon(3) self.back_right_motor = wpilib.Talon(4) left_motors = wpilib.SpeedControllerGroup( self.front_left_motor, self.back_left_motor ) right_motors = wpilib.SpeedControllerGroup( self.front_right_motor, self.back_right_motor ) self.drive = wpilib.drive.DifferentialDrive(left_motors, right_motors) self.left_encoder = wpilib.Encoder(1, 2) self.right_encoder = wpilib.Encoder(3, 4) # Encoders may measure differently in the real world and in # simulation. In this example the robot moves 0.042 barleycorns # per tick in the real world, but the simulated encoders # simulate 360 tick encoders. This if statement allows for the # real robot to handle this difference in devices. if robot.isReal(): self.left_encoder.setDistancePerPulse(0.042) self.right_encoder.setDistancePerPulse(0.042) else: # Circumference in ft = 4in/12(in/ft)*PI self.left_encoder.setDistancePerPulse((4.0 / 12.0 * math.pi) / 360.0) self.right_encoder.setDistancePerPulse((4.0 / 12.0 * math.pi) / 360.0) self.rangefinder = wpilib.AnalogInput(6) self.gyro = wpilib.AnalogGyro(1)
def robotInit(self): """Robot initialization function""" # variables for managing pneumatics sequence self.State = -1 self.wait_timer = wpilib.Timer() # object that handles basic drive operations self.leftMotor = wpilib.Talon(1) self.rightMotor = wpilib.Talon(2) self.frontSolExtend = wpilib.Solenoid(1, 1) self.frontSolRetract = wpilib.Solenoid(1, 0) self.rearSolExtend = wpilib.Solenoid(1, 3) self.rearSolRetract = wpilib.Solenoid(1, 2) self.frontSolExtend.set(False) self.frontSolRetract.set(True) self.rearSolExtend.set(False) self.rearSolRetract.set(True) self.myRobot = DifferentialDrive(self.leftMotor, self.rightMotor) self.myRobot.setExpiration(0.1) # joysticks 1 & 2 on the driver station self.stick = wpilib.Joystick(0)
def robotInit(self): #update channels self.frontR = wpi.Talon(1) self.frontL = wpi.Talon(2) self.rearR = wpi.Talon(0) self.rearL = wpi.Talon(3) self.gyro = wpi.AnalogGyro(0) self.joystick = wpi.Joystick(0) self.right = wpi.SpeedControllerGroup(self.frontR, self.rearR) self.left = wpi.SpeedControllerGroup(self.frontL, self.rearL) self.dTrain = wpi.drive.DifferentialDrive(self.right, self.left) self.xDeadZone = .05 self.yDeadZone = .05 self.xConstant = .55 self.yConstant = .85 logging.basicConfig(level=logging.DEBUG) NetworkTables.initialize(server='10.28.75.2') NetworkTables.addConnectionListener(connectionListener, immediateNotify=True) with cond: print("Waiting") if not notified[0]: cond.wait() print("Connected") self.table = NetworkTables.getTable('SmartDashboard')
def robotInit(self): '''Robot initialization function - Define your inputs, and what channels they connect to''' self.robotDrive = wpilib.RobotDrive(self.frontLeftChannel, self.rearLeftChannel, self.frontRightChannel, self.rearRightChannel) self.robotDrive.setExpiration(0.1) self.robotDrive.setInvertedMotor(RobotDrive.MotorType.kFrontLeft, True) self.robotDrive.setInvertedMotor(RobotDrive.MotorType.kRearLeft, True) self.winch_motor2 = wpilib.Talon(self.winchMotor2) self.winch_motor1 = wpilib.Talon(self.winchMotor1) self.stick = wpilib.Joystick(self.joystickChannel) self.fire_single_piston = wpilib.buttons.JoystickButton(self.stick, 1) self.fire_double_forward = wpilib.buttons.JoystickButton(self.stick, 2) self.fire_double_backward = wpilib.buttons.JoystickButton(self.stick, 3) self.single_solenoid = wpilib.Solenoid(1) self.double_solenoid = wpilib.DoubleSolenoid(2,3)
def robotInit(self): """Robot initialization function""" self.frontLeftMotor = wpilib.Talon(self.frontLeftChannel) self.rearLeftMotor = wpilib.Talon(self.rearLeftChannel) self.frontRightMotor = wpilib.Talon(self.frontRightChannel) self.rearRightMotor = wpilib.Talon(self.rearRightChannel) self.lstick = wpilib.Joystick(self.lStickChannel) self.rstick = wpilib.Joystick(self.rStickChannel) # Position gets automatically updated as robot moves self.gyro = wpilib.AnalogGyro(1) self.sd = NetworkTables.getTable("SmartDashboard") # Setting up Kinematics (an algorithm to determine chassi speed from wheel speed) # The 2d Translation tells the algorithm how far off center (in Meter) our wheels are # Ours are about 11.3 (x) by 10.11(y) inches off, so this equates to roughly .288 X .257 Meters # We use the X and Y Offsets above. m_frontLeftLocation = Translation2d(XOffset, YOffset) m_frontRightLocation = Translation2d(XOffset, (-1 * YOffset)) m_backLeftLocation = Translation2d((-1 * XOffset), (YOffset)) m_backRightLocation = Translation2d((-1 * XOffset), (-1 * YOffset)) # Creat our kinematics object using the wheel locations. self.m_kinematics = MecanumDriveKinematics( m_frontLeftLocation, m_frontRightLocation, m_backLeftLocation, m_backRightLocation, ) # Create the Odometry Object self.MecanumDriveOdometry = MecanumDriveOdometry( self.m_kinematics, Rotation2d.fromDegrees(-self.gyro.getAngle()), Pose2d(0, 0, Rotation2d(0)), ) self.drive = MecanumDrive( self.frontLeftMotor, self.rearLeftMotor, self.frontRightMotor, self.rearRightMotor, ) self.f_l_encoder = wpilib.Encoder(0, 1) self.f_l_encoder.setDistancePerPulse( (math.pi * self.WHEEL_DIAMETER) / self.ENCODER_COUNTS_PER_REV) self.r_l_encoder = wpilib.Encoder(3, 4) self.r_l_encoder.setDistancePerPulse( (math.pi * self.WHEEL_DIAMETER) / self.ENCODER_COUNTS_PER_REV) self.f_r_encoder = wpilib.Encoder(1, 2) self.f_r_encoder.setDistancePerPulse( (math.pi * self.WHEEL_DIAMETER) / self.ENCODER_COUNTS_PER_REV) self.r_r_encoder = wpilib.Encoder(3, 4) self.r_r_encoder.setDistancePerPulse( (math.pi * self.WHEEL_DIAMETER) / self.ENCODER_COUNTS_PER_REV)
def robotInit(self): self.LeftMec = wpilib.Talon(0) self.RightMec = wpilib.Talon(1) self.robotDrive = wpilib.RobotDrive(self.LeftMec, self.RightMec) self.pg = wpilib.Talon(2) self.xboxController = wpilib.XboxController( 0) # <-- This is for using Xbox controllers
def robotInit(self): """ This function is called upon program startup and should be used for any initialization code. """ frontLeft = wpilib.Talon(0) frontRight = wpilib.Talon(1) self.robot_drive = wpilib.RobotDrive(frontLeft, frontRight) self.stick = wpilib.Joystick(1)
def createObjects(self): """Initialize all wpilib motors & sensors""" # TODO: create button example here self.component1_motor = wpilib.Talon(1) self.some_motor = wpilib.Talon(2) self.joystick = wpilib.Joystick(0)
def __init__(self, robot): #Drivetrain Motor Setup self.rightFrontMotor = wpilib.Talon(7) #Right front self.rightBackMotor = wpilib.Talon(6) #Right back self.leftFrontMotor = wpilib.Talon(8) #Left front self.leftBackMotor = wpilib.Talon(9) #Left back #Mecanum Drive Setup robot.drive = MecanumDrive(self.leftFrontMotor, self.leftBackMotor, self.rightFrontMotor, self.rightBackMotor)
def __init__(self): '''Instantiates the motor object.''' super().__init__('DriveSubsystem') self.leftFront = wpilib.Talon(3) self.leftFront.setInverted(True) self.leftRear = wpilib.Talon(1) self.leftRear.setInverted(True) self.rightFront = wpilib.Talon(4) self.rightRear = wpilib.Talon(2)
def __init__(self, sensors, joystick): self.openIntake = wpilib.Solenoid(robot_map.OPEN_INTAKE) self.closeIntake = wpilib.Solenoid(robot_map.CLOSE_INTAKE) self.rightIntake = wpilib.Talon(robot_map.RIGHT_INTAKE) self.leftIntake = wpilib.Talon(robot_map.LEFT_INTAKE) self.sensors = sensors self.joystick = joystick self.pdp = wpilib.PowerDistributionPanel()
def robotInit(self): self.leftStick = wpilib.Joystick(0) self.rightStick = wpilib.Joystick(1) self.left = wpilib.Talon(12) #self.left2 = wpilib.Talon(13) self.right = wpilib.Talon(14) #self.right2 = wpilib.Talon(15) #self.left = wpilib.SpeedControllerGroup(self.left1, self.left2) #self.right = wpilib.SpeedControllerGroup(self.right1, self.right2) self.drive = wpilib.drive.DifferentialDrive(self.left, self.right) self.timer = wpilib.Timer()
def __init__(self): super().__init__('DriveTrain') self.leftMotors = wpilib.Talon(robotmap.portsList.leftMotorID) # self.leftMotors.setInverted(True) self.rightMotors = wpilib.Talon(robotmap.portsList.rightMotorID) # self.leftMotorsEncoder = wpilib.Encoder(robotmap.portsList.leftMotorsEncoderChannelAID, robotmap.portsList.leftMotorsEncoderChannelBID) # self.rightMotorsEncoder = wpilib.Encoder(robotmap.portsList.rightMotorsEncoderChannelAID, robotmap.portsList.rightMotorsEncoderChannelBID) self.robotDrive = wpilib.RobotDrive(self.leftMotors, self.rightMotors) self.robotDrive.setInvertedMotor(wpilib.RobotDrive.MotorType.kRearLeft, True)
def robotInit(self): #Joysticks self.Joystick = wpilib.Joystick(self.Joystick_Channel) self.Sec_Joystick = wpilib.Joystick(self.Sec_Joystick_Channel) #Magnetic Limit Switches self.switch1 = wpilib.DigitalInput(0) #Mechanisms self.Elevator = ctre.WPI_TalonSRX(self.Elevator_Motor) self.LF_Intake = ctre.WPI_TalonSRX(self.Left_Front_Intake) self.RF_Intake = ctre.WPI_TalonSRX(self.Right_Front_Intake) #PWM Mechanisms self.Climber = wpilib.Talon(self.Climber_Motor) #Drive Motors self.LMF = wpilib.Talon(self.Left_Motor_Front) self.RMF = wpilib.Talon(self.Right_Motor_Front) self.LMB = wpilib.Talon(self.Left_Motor_Back) self.RMB = wpilib.Talon(self.Right_Motor_Back) self.Left = wpilib.SpeedControllerGroup(self.LMF, self.LMB) self.Right = wpilib.SpeedControllerGroup(self.RMF, self.RMB) #This is not the built-in robot drive self.My_Robot = DifferentialDrive(self.Left, self.Right) self.My_Robot.setExpiration(0.1) #SmartDashboard self.spChooser = wpilib.SendableChooser() self.spChooser.addDefault("Left", 1) self.spChooser.addObject("Middle", 2) self.spChooser.addObject("Right", 3) wpilib.SmartDashboard.putData('StartingPosition', self.spChooser) self.amChooser = wpilib.SendableChooser() self.amChooser.addDefault("Scale", 1) self.amChooser.addObject("Other Lever", 2) self.amChooser.addObject("Line", 3) self.amChooser.addObject("None", 0) wpilib.SmartDashboard.putData('AutoMode', self.amChooser) self.writeAutoChooser = wpilib.SendableChooser() self.writeAutoChooser.addDefault("Read Auto", 0) self.writeAutoChooser.addObject("Write Auto", 1) wpilib.SmartDashboard.putData('WriteAuto', self.writeAutoChooser) self.infoChooser = wpilib.SendableChooser() self.infoChooser.addDefault("0", 0) for line in customParsing.read(): self.infoChooser.addObject(line, line) wpilib.SmartDashboard.putData("InfoChooserChannel", self.infoChooser)
def robotInit(self): self.frontLeft = wpilib.Talon(2) self.backLeft = wpilib.Talon(3) self.leftMotors = wpilib.SpeedControllerGroup(self.frontLeft, self.backLeft) self.frontRight = wpilib.Talon(0) self.backRight = wpilib.Talon(1) self.rightMotors = wpilib.SpeedControllerGroup(self.frontRight, self.backRight) self.leftJs = Joystick(0) self.rightJs = Joystick(1) self.timer = wpilib.Timer()
def robotInit(self): self.motorL1 = wpilib.Talon(0) self.motorL2 = wpilib.Talon(1) self.motorR1 = wpilib.Talon(2) self.motorR2 = wpilib.Talon(3) self.robot_driveL = wpilib.SpeedControllerGroup( self.motorL1, self.motorL2) self.robot_driveR = wpilib.SpeedControllerGroup( self.motorR1, self.motorR2) self.stick1 = wpilib.Joystick(0) self.stick2 = wpilib.Joystick(1)
def robotInit(self): """Robot initialization function""" # create motor controller objects m_left = wpilib.Talon(0) m_right = wpilib.Talon(1) # object that handles basic drive operations self.myRobot = wpilib.drive.DifferentialDrive(m_left, m_right) self.myRobot.setExpiration(0.1) # joystick #0 self.stick = wpilib.Joystick(0)
def __init__(self): print('TankDrive: init called') super().__init__('TankDrive') self.logPrefix = "TankDrive: " self.leftSpdCtrl = wpilib.Talon(robotmap.driveLine.leftMotorPort) if robotmap.driveLine.invertLeft: self.leftSpdCtrl.setInverted(True) self.rightSpdCtrl = wpilib.Talon(robotmap.driveLine.rightMotorPort) if robotmap.driveLine.invertRight: self.rightSpdCtrl.setInverted(True)