Beispiel #1
0
    def __init__(self):
        """Instantiates the motor object."""

        super().__init__("DoubleMotor")

        self.motor = wpilib.PWMVictorSPX(5)
        self.motor2 = wpilib.PWMVictorSPX(6)
Beispiel #2
0
    def __init__(self):
        super().__init__("Mecanum")

        # motors and the channels they are connected to

        self.frontLeftMotor = wpilib.VictorSP(1)
        self.rearLeftMotor = wpilib.PWMVictorSPX(2)
        self.frontRightMotor = wpilib.VictorSP(0)
        self.rearRightMotor = wpilib.PWMVictorSPX(3)

        # invert the left side motors
        self.frontLeftMotor.setInverted(False)

        # you may need to change or remove this to match your robot
        self.rearLeftMotor.setInverted(False)
        self.rearRightMotor.setInverted(False) #added this to match motor

        self.drive = MecanumDrive(
            self.frontLeftMotor,
            self.rearLeftMotor,
            self.frontRightMotor,
            self.rearRightMotor,
        )

        self.drive.setExpiration(0.1)
        self.drive.setSafetyEnabled(False)
Beispiel #3
0
    def __init__(self) -> None:
        super().__init__()

        self.left1 = wpilib.PWMVictorSPX(constants.kLeftMotor1Port)
        self.left2 = wpilib.PWMVictorSPX(constants.kLeftMotor2Port)
        self.right1 = wpilib.PWMVictorSPX(constants.kRightMotor1Port)
        self.right2 = wpilib.PWMVictorSPX(constants.kRightMotor2Port)

        # The robot's drive
        self.drive = wpilib.drive.DifferentialDrive(
            wpilib.SpeedControllerGroup(self.left1, self.left2),
            wpilib.SpeedControllerGroup(self.right1, self.right2),
        )

        # The left-side drive encoder
        self.leftEncoder = wpilib.Encoder(
            *constants.kLeftEncoderPorts,
            reverseDirection=constants.kLeftEncoderReversed)

        # The right-side drive encoder
        self.rightEncoder = wpilib.Encoder(
            *constants.kRightEncoderPorts,
            reverseDirection=constants.kRightEncoderReversed)

        # Sets the distance per pulse for the encoders
        self.leftEncoder.setDistancePerPulse(
            constants.kEncoderDistancePerPulse)
        self.rightEncoder.setDistancePerPulse(
            constants.kEncoderDistancePerPulse)
Beispiel #4
0
    def robotInit(self) -> None:
        # Create the motors, on pins 0 -to 4.
        self.right_motor_back = wpilib.PWMVictorSPX(0)
        self.right_motor_front = wpilib.PWMVictorSPX(1)
        self.left_motor_front = wpilib.PWMVictorSPX(2)
        self.left_motor_back = wpilib.PWMVictorSPX(3)

        # Because we're using a gearbox (don't remember which), we need to make speed groups.
        self.right_speed_group = wpilib.SpeedControllerGroup(self.right_motor_back, self.right_motor_front)
        self.left_speed_group = wpilib.SpeedControllerGroup(self.left_motor_back, self.left_motor_front)

        # Differential drive from the two speed controllers.
        self.drive = wpilib.drive.DifferentialDrive(self.left_speed_group, self.right_speed_group)

        wpilib.CameraServer.launch("vision.py:main")
Beispiel #5
0
 def __init__(self):
     #Initialize Left motors
     # Two motors cause TuffBox
     # Also 0 is generally reserved for PDP or something
     left_one = (wpilib.PWMVictorSPX(3))
     left_two = (wpilib.VictorSP(6))
     self.left_motor_group = wpilib.SpeedControllerGroup(left_one, left_two)
Beispiel #6
0
 def robotInit(self):
     
     #drive define
     self.fL = wpilib.PWMTalonFX(0)
     self.fR = wpilib.PWMTalonFX(1)
     self.bL = wpilib.PWMTalonFX(2)
     self.bR = wpilib.PWMTalonFX(3)
     
     #shooter define
     self.wheelL = wpilib.PWMVictorSPX(4)
     self.wheelR = wpilib.PWMVictorSPX(5)
     self.conveyor = wpilib.PWMVictorSPX(6)
     
     #lift
     self.liftUp = wpilib.PWMVictorSPX(7)
     self.liftDown = wpilib.PWMVictorSPX(8)
     
             self.driverXbox = wpilib.XboxController(0)
Beispiel #7
0
    def __init__(self):
        super().__init__("Arcade")

        # motors and the channels they are connected to

        self.frontLeftMotor = wpilib.PWMVictorSPX(0)
        self.rearLeftMotor = wpilib.PWMVictorSPX(1)
        self.frontRightMotor = wpilib.PWMVictorSPX(2)
        self.rearRightMotor = wpilib.PWMVictorSPX(3)

        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.drive.setSafetyEnabled(False)
Beispiel #8
0
    def robotInit(self):
        self.tankDrive = DifferentialDrive(
            wpilib.PWMVictorSPX(0), wpilib.PWMVictorSPX(1)
        )
        self.leftEncoder = wpilib.Encoder(0, 1)
        self.rightEncoder = wpilib.Encoder(2, 3)

        self.elevatorMotor = wpilib.PWMVictorSPX(2)
        self.elevatorPot = wpilib.AnalogPotentiometer(0)

        # Add a 'max speed' widget to a tab named 'Configuration', using a number slider
        # The widget will be placed in the second column and row and will be two columns wide
        self.maxSpeed = (
            Shuffleboard.getTab("Configuration")
            .add(title="Max Speed", value=1)
            .withWidget("Number Slider")
            .withPosition(1, 1)
            .withSize(2, 1)
            .getEntry()
        )

        # Add the tank drive and encoders to a 'Drivebase' tab
        driveBaseTab = Shuffleboard.getTab("Drivebase")
        driveBaseTab.add(title="Tank Drive", value=self.tankDrive)
        # Put both encoders in a list layout
        encoders = (
            driveBaseTab.getLayout(type="List Layout", title="Encoders")
            .withPosition(0, 0)
            .withSize(2, 2)
        )
        encoders.add(title="Left Encoder", value=self.leftEncoder)
        encoders.add(title="Right Encoder", value=self.rightEncoder)

        # Add the elevator motor and potentiometer to an 'Elevator' tab
        elevatorTab = Shuffleboard.getTab("Elevator")
        elevatorTab.add(title="Motor", value=self.elevatorMotor)
        elevatorTab.add(title="Potentiometer", value=self.elevatorPot)
 def __init__(self):
     #Initialize Right motors
     right_one = (wpilib.PWMVictorSPX(2))
     right_two = (wpilib.PWMVictorSPX(9))
     self.right_motor_group = wpilib.SpeedControllerGroup(
         right_one, right_two)
Beispiel #10
0
    def robotInit(self):

        #Networktables
        self.netTable = NetworkTables.getTable('SmartDashboard')

        #Hud Data Handlers
        self.statUpdater = SU.StatusUpdater(self, self.netTable)

        #Camera Server
        wpilib.CameraServer.launch()

        #Drive Motors
        self.motor1 = ctre.WPI_TalonSRX(1)
        self.motor2 = ctre.WPI_TalonSRX(2)
        self.motor3 = ctre.WPI_TalonSRX(9)
        self.motor4 = ctre.WPI_TalonSRX(10)

        #Intake Motors
        self.stage1Left = ctre.WPI_TalonSRX(5)
        self.stage1Right = ctre.WPI_TalonSRX(6)
        self.stage2Left = ctre.WPI_TalonSRX(4)
        self.stage2Right = ctre.WPI_TalonSRX(7)
        self.stage3Left = ctre.WPI_TalonSRX(3)
        self.stage3Right = ctre.WPI_TalonSRX(8)

        #Pan Arm Controls
        self.leftPanArm = wpilib.PWMVictorSPX(0)
        self.rightPanArm = wpilib.PWMVictorSPX(1)

        #Shifters
        self.shifter = wpilib.DoubleSolenoid(1, 2)

        #Climb
        self.pto = wpilib.DoubleSolenoid(3, 4)
        self.climbLift = wpilib.Solenoid(5)

        #User Inputs
        self.playerOne = wpilib.XboxController(0)
        self.playerTwo = wpilib.XboxController(1)

        #Navx
        self.navx = navx.AHRS.create_spi()

        self.power_board = wpilib.PowerDistributionPanel()

        #User Inputs
        self.playerOne = wpilib.XboxController(0)
        self.playerTwo = wpilib.XboxController(1)

        #Navx
        self.navx = navx.AHRS.create_spi()

        #Points
        #self.points = []

        #Setup Logic
        self.rightDriveMotors = wpilib.SpeedControllerGroup(
            self.motor3, self.motor4)

        self.leftDriveMotors = wpilib.SpeedControllerGroup(
            self.motor1, self.motor2)

        self.leftDriveMotors.setInverted(True)

        self.robotDrive = DifferentialDrive(self.leftDriveMotors,
                                            self.rightDriveMotors)

        self.lowerIntakeMotors = wpilib.SpeedControllerGroup(
            self.stage1Left, self.stage1Right, self.stage2Left,
            self.stage2Right)

        self.stage3 = wpilib.SpeedControllerGroup(self.stage3Left,
                                                  self.stage3Right)

        if wpilib.SolenoidBase.getPCMSolenoidVoltageStickyFault(0) == True:
            wpilib.SolenoidBase.clearAllPCMStickyFaults(0)

        self.pto.set(wpilib.DoubleSolenoid.Value.kReverse)

        #Drive.py init
        self.drive = drive.Drive(self.robotDrive, self.navx, self.motor1,
                                 self.motor2, self.motor3, self.motor4,
                                 self.shifter)

        #Intake.py
        self.intake = intake.Intake(self.lowerIntakeMotors, self.stage3,
                                    self.leftPanArm, self.rightPanArm)

        #Driver Station Instance
        self.driverStation = wpilib.DriverStation.getInstance()

        #Auto mode variables
        self.components = {'drive': self.drive, 'intake': self.intake}
        self.automodes = AutonomousModeSelector('autonomous', self.components)
def create_pwm_victor_spx(channel):
    return wpilib.PWMVictorSPX(channel)
Beispiel #12
0
    def __init__(self):
        """Instantiates the motor object."""

        super().__init__("SingleMotor2")

        self.motor = wpilib.PWMVictorSPX(7)