コード例 #1
0
    def __init__(self, robot):
        Subsystem.__init__(self, 'Turret')

        self.robot = robot
        self.tEncoder = Encoder(4, 5, False, Encoder.EncodingType.k4X)
        motors = {}

        self.map = self.robot.botMap
        self.tmotors = motors

        for name in self.map.motorMap.motors:
            motors[name] = robot.Creator.createMotor(
                self.map.motorMap.motors[name])

        for name in self.tmotors:
            self.tmotors[name].setInverted(
                self.map.motorMap.motors[name]['inverted'])
            self.tmotors[name].setNeutralMode(ctre.NeutralMode.Coast)

        self.kP = 0.05
        self.kI = 0.000
        self.kD = 0.002

        self.turretPID = PID(self.kP, self.kI, self.kD)

        self.turretPID.limitVal(0.3)

        self.setPow = 0
コード例 #2
0
    def __init__(self, robot):
        Subsystem.__init__(self, 'Intake')

        self.robot = robot

        motors = {}
        pistons = {}

        self.map = self.robot.botMap

        for name in self.map.motorMap.motors:
            motors[name] = robot.Creator.createMotor(self.map.motorMap.motors[name])

        for name in self.map.PneumaticMap.pistons:
            pistons[name] = robot.Creator.createPistons(self.map.PneumaticMap.pistons[name])

        self.imotors = motors
        self.ipistons = pistons

        for name in self.imotors:
            self.imotors[name].setInverted(self.map.motorMap.motors[name]['inverted'])
            self.imotors[name].setNeutralMode(ctre.NeutralMode.Coast)

        self.iOut = wpilib.DoubleSolenoid.Value.kForward
        self.iIn = wpilib.DoubleSolenoid.Value.kReverse
コード例 #3
0
ファイル: __init__.py プロジェクト: Secretkeeper626/lightshow
 def __init__(self):
     Subsystem.__init__(self)
     APA102.__init__(self,
                     num_led=144,
                     global_brightness=5,
                     order='rgb',
                     max_speed_hz=1000000)
     LEDSubsystem.instance = self
コード例 #4
0
    def __init__(self):
        Subsystem.__init__(self, "GateShot")
        self.gate_shot = WPI_TalonSRX(0)

        # Close
        self.switchClose = wpilib.DigitalInput(0)
        # Open
        self.switchOpen = wpilib.DigitalInput(1)
        # Switch beneath sushi wheel
        self.switchSushi = wpilib.DigitalInput(2)
コード例 #5
0
    def __init__(self):
        Subsystem.__init__(self, "DriveTrain")

        self.left1 = ctre.TalonSRX(robot_map.drivetrain_motors["left1"])
        self.left2 = ctre.TalonSRX(robot_map.drivetrain_motors["left2"])
        self.left3 = ctre.TalonSRX(robot_map.drivetrain_motors["left3"])

        self.right1 = ctre.TalonSRX(robot_map.drivetrain_motors["right1"])
        self.right2 = ctre.TalonSRX(robot_map.drivetrain_motors["right2"])
        self.right3 = ctre.TalonSRX(robot_map.drivetrain_motors["right3"])
コード例 #6
0
ファイル: pneumatics.py プロジェクト: FRCTeam1571/Robot2020
    def __init__(self):
        Subsystem.__init__(self, "Pneumatics")

        self.compressor = wpilib.Compressor(0)
        # self.compressor.setClosedLoopControl(True)

        self.dsolenoid = wpilib.DoubleSolenoid(0, 1)
        # self.offvalve = self.dsolenoid.Value.kOff
        self.offvalve = wpilib.DoubleSolenoid.Value.kOff
        self.dsolenoid.set(self.offvalve)
コード例 #7
0
    def __init__(self):
        Subsystem.__init__(self, "TestSubsystem")

        self.spinSpeed = 0
        self.motor = ctre.WPI_TalonSRX(SubSystemPort.KMOTORPORT)

        self.motor.setExpiration(2.5)
        self.motor.setSafetyEnabled(False)

        #Show Motor status in NT
        self.addChild("Motor", self.motor)
        self.endSwitch = True
コード例 #8
0
    def __init__(self, robot):
        Subsystem.__init__(self, 'testElectronics')

        self.robot = robot

        self.map = self.robot.botMap.motorMap

        tMotors = {}

        for name in self.map.motors:
            tMotors[name] = self.robot.Creator.createMotor(
                self.map.motors[name])

        self.tMotors = tMotors
コード例 #9
0
    def __init__(self):
        Subsystem.__init__(self, "DropFeeder")
        self.DropFeeder1 = wpilib.Solenoid(robot_map.pcm["Dropper1"])
        self.DropFeeder2 = wpilib.Solenoid(robot_map.pcm["Dropper2"])

        def get(self):
            return self.DropFeeder1.get()
            return self.DropFeeder2.get()

        def set(self, input):
            self.Dropper1.set(input)
            self.Dropper2.set(input)

        def initDefaultCommand(self):
            pass
コード例 #10
0
    def __init__(self, robot):
        Subsystem.__init__(self, 'Flywheel')

        self.CurPos = 0
        self.PasPos = 0

        self.robot = robot
        self.Fenc = Encoder(6, 7, False, Encoder.EncodingType.k4X)
        self.map = self.robot.botMap
        motor = {}
        piston = {}

        for name in self.robot.botMap.motorMap.motors:
            motor[name] = self.robot.Creator.createMotor(
                self.robot.botMap.motorMap.motors[name])

        for name in self.robot.botMap.PneumaticMap.pistons:
            piston[name] = self.robot.Creator.createPistons(
                self.robot.botMap.PneumaticMap.pistons[name])

        self.fmotor = motor
        self.fpiston = piston

        for name in self.fmotor:
            self.fmotor[name].setInverted(
                self.robot.botMap.motorMap.motors[name]['inverted'])
            self.fmotor[name].setNeutralMode(ctre.NeutralMode.Coast)
            if self.map.motorMap.motors[name]['CurLimit'] is True:
                self.fmotor[name].configStatorCurrentLimit(
                    self.robot.Creator.createCurrentConfig(
                        self.robot.botMap.currentConfig['Fly']), 40)

        self.kP = 0.008
        self.kI = 0.00002
        self.kD = 0.00018
        self.kF = 0.0  # tune me when testing

        self.flywheelPID = PID(self.kP, self.kI, self.kD, self.kF)

        self.flywheelPID.MaxIn(680)
        self.flywheelPID.MaxOut(1)
        self.flywheelPID.limitVal(0.95)  # Limit PID output power to 50%

        self.feetToRPS = 51.111
コード例 #11
0
    def __init__(self, robot):
        Subsystem.__init__(self, 'Conveyor')

        self.robot = robot
        self.blaser = DigitalInput(3)

        motors = {}

        self.map = self.robot.botMap

        for name in self.map.motorMap.motors:
            motors[name] = self.robot.Creator.createMotor(
                self.map.motorMap.motors[name])

        self.cMotors = motors

        for name in self.cMotors:
            self.cMotors[name].setInverted(
                self.map.motorMap.motors[name]['inverted'])
            self.cMotors[name].setNeutralMode(ctre.NeutralMode.Coast)
コード例 #12
0
    def __init__(self, robot):
        Subsystem.__init__(self, 'Drive')

        self.robot = robot

        motors = {}
        pistons = {}

        self.map = self.robot.botMap
        self.rEnc = Encoder(0, 1, False, Encoder.EncodingType.k4X)
        self.lEnc = Encoder(2, 3, False, Encoder.EncodingType.k4X)
        self.Gyro = ADXRS450_Gyro()

        for name in self.map.motorMap.motors:
            motors[name] = robot.Creator.createMotor(
                self.map.motorMap.motors[name])

        for name in self.robot.botMap.PneumaticMap.pistons:
            if name == 'Shifter':
                pistons[name] = self.robot.Creator.createPistons(
                    self.robot.botMap.PneumaticMap.pistons[name])

        self.dMotors = motors
        self.dPistons = pistons

        for name in self.dMotors:
            self.dMotors[name].setInverted(
                self.robot.botMap.motorMap.motors[name]['inverted'])
            self.dMotors[name].setNeutralMode(ctre.NeutralMode.Coast)
            if self.map.motorMap.motors[name]['CurLimit'] is True:
                self.dMotors[name].configStatorCurrentLimit(
                    self.robot.Creator.createCurrentConfig(
                        self.robot.botMap.currentConfig['Drive']), 40)

        self.kP = 0.0
        self.kI = 0.0
        self.kD = 0.0

        self.DrivePID = PID(self.kP, self.kI, self.kD)
コード例 #13
0
    def __init__(self):
        # Ensures a single-time initialization
        Subsystem.__init__(self, "DriveTrain")

        # Front Motor Controllers
        self.front_cont_right = ctre.WPI_TalonSRX(3)
        self.rear_cont_right = ctre.WPI_TalonSRX(2)
        self.right = wpilib.SpeedControllerGroup(self.front_cont_right,
                                                 self.rear_cont_right)

        # Rear Motor Controllers
        self.front_cont_left = ctre.WPI_TalonSRX(4)
        self.rear_cont_left = ctre.WPI_TalonSRX(5)
        self.left = wpilib.SpeedControllerGroup(self.front_cont_left,
                                                self.rear_cont_left)

        # Drive Type
        self.drive = DifferentialDrive(self.left, self.right)
        self.drive.setExpiration(0.1)

        # enable safety
        self.drive.setSafetyEnabled(False)
コード例 #14
0
    def __init__(self):
      Subsystem.__init__(self, "SampSubsystem")
        
      self.spinSpeed = 0
      self.motor = wpilib.NidecBrushless(0, 0)
      #self.motor = ctre.WPI_TalonSRX(0)

      self.motor.setExpiration(2.5)
      self.motor.setSafetyEnabled(False)

      #Show Motor status in NT
      self.addChild("Motor", self.motor)   
      self.endSwitch = True

      self.limitSwitch = wpilib.DigitalInput(1)
      self.limitSwitchLow = wpilib.DigitalInput(2)
      #m_simDevice = hal.SimDevice("LimitSwitch", 1)
      #RobotBase.isReal()
      #if m_simDevice :
      #  self.limitSwitch.setSimDevice(1)

      self.counter = wpilib.Counter(self.limitSwitch)

      self.onLED = wpilib.DigitalOutput(3)
コード例 #15
0
 def __init__(self):
     Subsystem.__init__(self, "ColorSpinner")
     #def __init__(self, name = "ColorSpinner"):
     self.spinSpeed = 0
     self.motor = ctre.WPI_TalonSRX(6)  # PMW and DIO pins
     self.motor.setExpiration(0.1)
コード例 #16
0
ファイル: sushi_wheel.py プロジェクト: FRCTeam1571/Robot2020
 def __init__(self):
     Subsystem.__init__(self, 'SushiRotator')
     # Motor controller object
     self.sushi_motor = WPI_TalonSRX(1)
コード例 #17
0
    def __init__(self):
        Subsystem.__init__(self, "IntakeRoller")

        self.roller_motor = ctre.TalonSRX(
            robot_map.IntakeRoller_motors["Roller_Motor"])
コード例 #18
0
    def __init__(self):
        Subsystem.__init__(self, "Feeder")

        self.wheels = ctre.TalonSRX(robot_map.ds4["circle"])
コード例 #19
0
    def __init__(self):
        Subsystem.__init__(self, "Shooter")

        self.motor1 = rev.SparkMax(robot_map.shooter_motors["motor1"])
        self.motor2 = rev.SparkMax(robot_map.shooter_motors["motor2"])
コード例 #20
0
    def __init__(self):
        # Single Time Initialization
        Subsystem.__init__(self, "Gyroscope")
        # Default values

        # self.gyro = ADIS16470_IMU()
        self.gyro = ADXRS450_Gyro
        self.accel = ADXL345_SPI
        # self.m_yawSelected = kYaw_default
        self.m_runCal = False
        self.m_configCal = False
        self.m_reset = False

        # self.m_yawActiveAxis = self.gyro.IMUAxis.kz

        # Adds Options. Very Helpful.
        self.m_autoChooser = wpilib.SendableChooser()
        self.m_autoChooser.addOption(kautoname_custom, kautoname_custom)

        self.m_yawChooser = wpilib.SendableChooser()
        self.m_yawChooser.setDefaultOption(self.kYaw_default,
                                           self.kYaw_default)
        # self.m_yawchooser.addOption(kYaw_xaxis, kYaw_xAxis)
        self.m_yawchooser.addOption(kYaw_yAxis, kYaw_yAxis)

        # SmartDashBoard Statistics
        wpilib.SmartDashboard.putBoolean("Config Calibration", False)
        wpilib.SmartDashboard.putBoolean("Run Calibration", False)
        wpilib.SmartDashboard.putBoolean("Reset Gyro", False)
        wpilib.SmartDashboard.putBoolean("Set Current Axis", False)

        def gyroControls(self):
            # wpilib.SmartDashboard.putNumber("Yaw/Z Angle", self.m_imu.getAngle())
            # wpilib.SmartDashboard.putNumber("X Comp Angle", self.m_imu.getXComplimentaryAngle())
            # wpilib.SmartDashboard.putNumber("Y Comp Angle", self.m_imu.getYComplimentaryAngle())
            wpilib.SmartDashboard.putNumber("Angle", self.gyro.GetAngle())

            # self.m_yawSelected = kYawDefault
            wpilib.SmartDashboard.putNumber("Yaw/Z Angle",
                                            self.m_imu.getAngle())
            wpilib.SmartDashboard.putNumber(
                "X Comp Angle", self.m_imu.getXComplimentaryAngle())
            wpilib.SmartDashboard.putNumber(
                "Y Comp Angle", self.m_imu.getYComplimentaryAngle())

            self.m_yawSelected = kYaw_default

            # Set IMU Settings

            if (self.m_configCal):
                # self.configCalTime(self.imu._8s)
                self.m_configCal = wpilib.SmartDashboard.putBoolean(
                    "Config Calibration", False)

            if (self.m_reset):
                # self.m_imu.reset()
                self.m_reset = wpilib.SmartDashboard.putBoolean(
                    "Reset Gyro", False)

            if (self.m_runCal):
                # self.m_imu.Calibrate()
                self.m_runCal = wpilib.Smartdashboard.putBoolean(
                    "Run Calibration", False)

            # Read the Axis you want to read
            # Sendable Chooser allows you to change the value, hence changing what is displayed.

            if (self.m_yawSelected == "X-Axis"):
                self.m_yawActiveAxis = self.m_imu.IMUAxis.kX

            elif (self.m_yawSelected == "Y-Axis"):
                self.m_yawActiveAxis = self.m_imu.IMUAxis.kY

            else:
                # self.m_yawActiveAxis = self.m_imu.IMUAxis.kZ
                pass
            # Set the Axis you want to read
            if (self.m_setYawAxis):
                self.m_setYawAxis = wpilib.SmartDashboard.putBoolean(
                    "setYawAxis", False)

        """