コード例 #1
0
    def __init__(self, robot):
        super().__init__("Pneumatics")
        self.robot = robot

        self.pressureSensor = wpilib.AnalogInput(3)
        if robot.isReal():
            self.compressor = wpilib.Compressor()
コード例 #2
0
ファイル: robot.py プロジェクト: tulser/5549-2018
    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()
コード例 #3
0
    def __init__(self):
        super().__init__()
        self.dog = self.GetWatchdog()
        self.stick1 = wpilib.Joystick(1)
        self.stick2 = wpilib.Joystick(2)
        self.stick3 = wpilib.Joystick(3)

        self.leftArmStick = wpilib.KinectStick(1)
        self.rightArmStick = wpilib.KinectStick(2)

        self.motor1 = wpilib.CANJaguar(1)
        self.motor2 = wpilib.CANJaguar(2)

        self.leftArm = wpilib.Servo(1)
        self.rightArm = wpilib.Servo(2)
        self.leftLeg = wpilib.Servo(3)
        self.rightLeg = wpilib.Servo(4)
        self.spinner = wpilib.Servo(5)

        self.compressor = wpilib.Compressor(1, 1)
        self.compressor.Start()
        self.relayMotor = wpilib.Relay(2)

        self.solenoid1 = wpilib.Solenoid(1)
        self.solenoid2 = wpilib.Solenoid(2)
コード例 #4
0
    def __init__(self):
        self.topSpinner = ctre.WPI_TalonSRX(21)
        self.topSpinner.configFactoryDefault(0)
        self.bottomSpinner = ctre.WPI_TalonSRX(20)
        self.bottomSpinner.configFactoryDefault(0)

        # TODO fix names
        self.solenoid0 = wpilib.Solenoid(0)
        self.solenoid1 = wpilib.Solenoid(1)
        self.solenoid2 = wpilib.Solenoid(2)
        self.solenoid3 = wpilib.Solenoid(3)
        self.compressor = wpilib.Compressor(0)
        self.stopCompressor()

        self.armOut = False
        self.grabOut = False

        self.slideMotor = ctre.WPI_TalonSRX(30)
        self.slideMotor.configFactoryDefault(0)
        self.slideMotor.configSelectedFeedbackSensor(ctre.FeedbackDevice.QuadEncoder, 0, 0)
        self.slideMotor.setSensorPhase(False)
        self.slideMotor.config_kP(0, 0.3, 0)
        self.slideMotor.config_kI(0, 0, 0)
        self.slideMotor.config_kD(0, 3, 0)
        self.slideMotor.config_kF(0, 0, 0)
        self.slideMotor.configPeakOutputReverse(-0.75, 0)
        self.slideValue = None

        self.resetAllSensors()
コード例 #5
0
    def createObjects(self):
        """Create non-components here."""

        self.module_a = SwerveModule(  # top left module
            # "a", steer_talon=ctre.TalonSRX(48), drive_talon=ctre.TalonSRX(49),
            "a",
            steer_talon=ctre.TalonSRX(48),
            drive_talon=ctre.TalonSRX(41),
            x_pos=0.25,
            y_pos=0.31,
            drive_free_speed=Robot.module_drive_free_speed)
        self.module_b = SwerveModule(  # bottom left modulet
            "b",
            steer_talon=ctre.TalonSRX(58),
            drive_talon=ctre.TalonSRX(51),
            x_pos=-0.25,
            y_pos=0.31,
            drive_free_speed=Robot.module_drive_free_speed)
        self.module_c = SwerveModule(  # bottom right modulet
            "c",
            steer_talon=ctre.TalonSRX(52),
            drive_talon=ctre.TalonSRX(53),
            x_pos=-0.25,
            y_pos=-0.31,
            drive_free_speed=Robot.module_drive_free_speed)
        self.module_d = SwerveModule(  # top right modulet
            "d",
            steer_talon=ctre.TalonSRX(42),
            drive_talon=ctre.TalonSRX(43),
            x_pos=0.25,
            y_pos=-0.31,
            drive_free_speed=Robot.module_drive_free_speed)

        self.intake_left_motor = ctre.TalonSRX(14)
        self.intake_right_motor = ctre.TalonSRX(2)
        self.clamp_arm = wpilib.Solenoid(2)
        self.intake_kicker = wpilib.Solenoid(3)
        self.left_extension = wpilib.Solenoid(6)
        self.right_extension = wpilib.DoubleSolenoid(forwardChannel=5,
                                                     reverseChannel=4)
        self.compressor = wpilib.Compressor()
        self.lifter_motor = ctre.TalonSRX(3)
        self.centre_switch = wpilib.DigitalInput(1)
        self.top_switch = wpilib.DigitalInput(2)

        self.intake_cube_switch = wpilib.DigitalInput(3)

        # create the imu object
        self.imu = IMU('navx')

        # boilerplate setup for the joystick
        self.joystick = wpilib.Joystick(0)
        self.gamepad = wpilib.XboxController(1)

        self.spin_rate = 1.5

        self.sd = NetworkTables.getTable("SmartDashboard")

        self.range_finder_counter = wpilib.Counter(
            4, mode=wpilib.Counter.Mode.kPulseLength)
コード例 #6
0
    def robotInit(self):
        """Robot initialization function"""

        self.motors = {
            "left": [rev.CANSparkMax(3),
                     rev.CANSparkMax(4)],
            "right": [rev.CANSparkMax(1),
                      rev.CANSparkMax(2)],
        }

        self.drive = wpilib.drive.DifferentialDrive(
            wpilib.SpeedControllerGroup(*self.motors["left"]),
            wpilib.SpeedControllerGroup(*self.motors["right"]),
        )
        # self.drive.setExpiration(0.5)

        self.shifter = wpilib.DoubleSolenoid(0, 1)

        self.compressor = wpilib.Compressor(0)

        # wpilib.CameraServer.launch()
        # camera_alpha = cameraserver.getInstance().startAutomaticCapture(0)
        # camera_beta = cameraserver.getInstance().startAutomaticCapture(1)
        # cameraserver.CameraServer.launch()
        cameraserver.CameraServer.launch("camera.py:main")
コード例 #7
0
 def initSubsystems(self):
     #initialize subsystems; run at robot startup
     self.arm = subsystems.Arm()
     self.end_effector = subsystems.EndEffector()
     self.drivetrain = subsystems.Drivetrain()
     self.ramp = subsystems.Ramp()
     self.blinkin = subsystems.Lights()
     self.compressor = wpilib.Compressor()
コード例 #8
0
    def robotInit(self):
        self.controller = wpilib.XboxController(0)

        self.motor_one = ctre.WPI_TalonSRX(5)
        self.motor_two = ctre.WPI_TalonSRX(
            1)  #use this motor for encoder (motor_two)

        self.compressor = wpilib.Compressor()
        self.manipulator_one = wpilib.DoubleSolenoid(0, 2)
コード例 #9
0
ファイル: robot.py プロジェクト: auscompgeek/pysteamworks
    def createObjects(self):
        '''Create motors and stuff here'''

        # Objects that are created here are shared with all classes
        # that declare them. For example, if I had:
        # self.elevator_motor = wpilib.TalonSRX(2)
        # here, then I could have
        # class Elevator:
        #     elevator_motor = wpilib.TalonSRX
        # and that variable would be available to both the MyRobot
        # class and the Elevator class. This "variable injection"
        # is especially useful if you want to certain objects with
        # multiple different classes.

        # create the imu object
        self.bno055 = BNO055()

        # the "logger" - allows you to print to the logging screen
        # of the control computer
        self.logger = logging.getLogger("robot")
        # the SmartDashboard network table allows you to send
        # information to a html dashboard. useful for data display
        # for drivers, and also for plotting variables over time
        # while debugging
        self.sd = NetworkTable.getTable('SmartDashboard')

        # boilerplate setup for the joystick
        self.joystick = wpilib.Joystick(0)
        self.gamepad = XboxController(1)
        self.pressed_buttons_js = set()
        self.pressed_buttons_gp = set()
        self.drive_motor_a = CANTalon(2)
        self.drive_motor_b = CANTalon(5)
        self.drive_motor_c = CANTalon(4)
        self.drive_motor_d = CANTalon(3)
        self.gear_alignment_motor = CANTalon(14)
        self.winch_motor = CANTalon(11)
        self.winch_motor.setInverted(True)
        self.rope_lock_solenoid = wpilib.DoubleSolenoid(forwardChannel=0,
                                                        reverseChannel=1)
        # self.rope_lock_solenoid = wpilib.DoubleSolenoid(forwardChannel=3,
        #         reverseChannel=4)
        self.gear_push_solenoid = wpilib.Solenoid(2)
        self.gear_drop_solenoid = wpilib.Solenoid(3)
        # self.gear_push_solenoid = wpilib.DoubleSolenoid(forwardChannel=1, reverseChannel=2)
        # self.gear_drop_solenoid = wpilib.Solenoid(0)

        self.test_trajectory = generate_trapezoidal_trajectory(
            0, 0, 3, 0, Chassis.max_vel, 1, -1, Chassis.motion_profile_freq)

        self.throttle = 1.0
        self.direction = 1.0

        self.led_dio = wpilib.DigitalOutput(1)

        self.compressor = wpilib.Compressor()
コード例 #10
0
ファイル: oldrobot.py プロジェクト: TheDragons/2018
    def robotInit(self):
        '''Robot initialization function'''
        self.motorFrontRight = wp.VictorSP(2)
        self.motorBackRight = wp.VictorSP(4)
        self.motorMiddleRight = wp.VictorSP(6)
        self.motorFrontLeft = wp.VictorSP(1)
        self.motorBackLeft = wp.VictorSP(3)
        self.motorMiddleLeft = wp.VictorSP(5)
        self.intakeMotor = wp.VictorSP(8)
        self.shootMotor1 = wp.VictorSP(7)
        self.shootMotor2 = wp.VictorSP(9)
        self.liftMotor = wp.VictorSP(0)

        self.gyro = wp.ADXRS450_Gyro(0)
        self.accel = wp.BuiltInAccelerometer()
        self.gearSensor = wp.DigitalInput(6)
        self.LED = wp.DigitalOutput(9)
        self.rightEncd = wp.Encoder(0, 1)
        self.leftEncd = wp.Encoder(2, 3)
        self.shootEncd = wp.Counter(4)

        self.compressor = wp.Compressor()
        self.shifter = wp.DoubleSolenoid(0, 1)
        self.ptoSol = wp.DoubleSolenoid(2, 3)
        self.kicker = wp.DoubleSolenoid(4, 5)
        self.gearFlap = wp.DoubleSolenoid(6, 7)

        self.stick = wp.Joystick(0)
        self.stick2 = wp.Joystick(1)
        self.stick3 = wp.Joystick(2)

        #Initial Dashboard Code
        wp.SmartDashboard.putNumber("Turn Left pos 1:", 11500)
        wp.SmartDashboard.putNumber("Lpos 2:", -57)
        wp.SmartDashboard.putNumber("Lpos 3:", 5000)
        wp.SmartDashboard.putNumber("stdist:", 6000)
        wp.SmartDashboard.putNumber("Turn Right pos 1:", 11500)
        wp.SmartDashboard.putNumber("Rpos 2:", 57)
        wp.SmartDashboard.putNumber("Rpos 3:", 5000)
        wp.SmartDashboard.putNumber("pos 4:", 39)
        wp.SmartDashboard.putNumber("-pos 4:", -39)
        wp.SmartDashboard.putNumber("Time", 5)
        wp.SmartDashboard.putBoolean("Shooting Auto", False)
        wp.SmartDashboard.putNumber("P", .08)
        wp.SmartDashboard.putNumber("I", 0.005)
        wp.SmartDashboard.putNumber("D", 0)
        wp.SmartDashboard.putNumber("FF", 0.85)
        self.chooser = wp.SendableChooser()
        self.chooser.addDefault("None", 4)
        self.chooser.addObject("Left Turn Auto", 1)
        self.chooser.addObject("Straight/Enc", 2)
        self.chooser.addObject("Right Turn Auto", 3)
        self.chooser.addObject("Straight/Timer", 5)
        self.chooser.addObject("Shoot ONLY", 6)
        wp.SmartDashboard.putData("Choice", self.chooser)
        wp.CameraServer.launch("vision.py:main")
コード例 #11
0
    def __init__(self, robot):
        super().__init__()
        self.robot = robot

        self.pressureSensor = wpilib.AnalogInput(3)
        if robot.isReal():
            self.compressor = wpilib.Compressor()

        wpilib.LiveWindow.addSensor("Pneumatics", "Pressure Sensor",
                                    self.pressureSensor)
コード例 #12
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)
コード例 #13
0
def compressorFactory(descp):
    """
    Creates compressor objects from descp.
    """
    try:
        if descp["type"] == "compressor":
            return wpilib.Compressor()
    except Exception as e:
        logging.error("Failed to create compressor for %s err %s", descp, e)
    return None
コード例 #14
0
    def robotInit(self):
        """ Functions """
        self.dashboard = Dashboard()
        self.drive = Drive()
        self.indexer = Indexer()
        self.intake = Intake()
        self.lift = Lift()
        self.semicircle = Semicircle()
        self.shooter = Shooter()
        self.vision = Vision()
        """ Joystick """
        # setting joysticks and xbox controllers
        self.leftJoystick = wpilib.Joystick(0)
        self.rightJoystick = wpilib.Joystick(1)
        self.xbox = wpilib.Joystick(2)
        """ Button Status and Toggles """
        # button for switching between arcade and tank drive
        self.driveButtonStatus = Toggle(self.rightJoystick, 2)

        # button for gear shifting
        self.gearButtonStatus = Toggle(self.rightJoystick, 1)

        # button for lift actuation
        self.liftButtonStatus = Toggle(self.xbox, 5)

        # button to run intake, indexer, and semicircle
        self.intakeBall = self.xbox.getRawAxis(1)
        self.dpadForward = False
        self.dpadBackwards = False

        # button for autoaim
        self.turnButtonStatus = self.xbox.getRawButton(6)
        """ Sensors """
        # color sensor
        i2cPort = wpilib.I2C.Port.kOnboard
        self.colorSensor = ColorSensorV3(i2cPort)
        self.colorSensitivity = 170  # boundary between not seeing an object and seeing an object
        """ Limit Switch """
        self.limitSwitch = wpilib.DigitalInput(0)
        self.ballsInPossession = 0
        self.limitSwitchTriggered = False
        """ Pneumatics """
        # pneumatic compressor
        self.compressor = wpilib.Compressor(0)
        self.compressor.setClosedLoopControl(True)
        self.compressor.start()
        """ Shooter """
        self.setpointReached = False
        self.shooterRun = False
        """ NavX """
        # self.drive.navx.reset()
        """ Timer """
        self.timer = wpilib.Timer()

        self.dashboard.limelightLed(False)
コード例 #15
0
    def createObjects(self):

        # Define Driving Motors
        self.rightDrive = wpilib.VictorSP(0)
        self.leftDrive = wpilib.VictorSP(1)

        # Create Robot Drive
        self.robotDrive = wpilib.drive.DifferentialDrive(
            self.rightDrive, self.leftDrive)

        # Create Shifter Pneumatics
        self.shifterSolenoid = wpilib.DoubleSolenoid(0, 0, 1)

        # Joysticks and Controllers
        self.driveJoystick = wpilib.Joystick(0)
        self.driveController = XboxController(0)

        self.subsystemJoystick = wpilib.Joystick(1)
        self.subsystemController = XboxController(1)

        # Create NavX and Accel
        self.navX = navx.AHRS.create_spi()
        self.accel = wpilib.BuiltInAccelerometer()

        # Set Drivespeed
        self.driveSpeed = 0

        # Intake Motors
        self.intakeMotor = wpilib.VictorSP(2)

        # Intake Lifter
        self.intakeLifter = wpilib.Spark(6)

        # Create Cube Intake Pneumatics
        self.intakeSolenoid = wpilib.Solenoid(0, 2)

        # Create Ramp Motors
        self.rightRamp = wpilib.Spark(5)
        self.leftRamp = wpilib.Spark(4)

        # Create Ramp Deploy Pneumatics
        self.rampSolenoid = wpilib.Solenoid(0, 3)

        # Create Timer (For Making Timed Events)
        self.timer = wpilib.Timer()

        # Initialize Compressor
        self.compressor = wpilib.Compressor()

        # Create CameraServer
        wpilib.CameraServer.launch("common/multipleCameras.py:main")

        # Set Gear in Dashboard
        wpilib.SmartDashboard.putString("Shift State", "Low Gear")
        wpilib.SmartDashboard.putString("Cube State", "Unclamped")
コード例 #16
0
	def robotInit(self):
		self.pop = Camara2.main()
		wpilib.CameraServer.launch()

		# NetworkTables.startClientTeam(5716)
		logging.basicConfig(level=logging.DEBUG)
		NetworkTables.initialize()
		self.pc = NetworkTables.getTable("SmartDashboard")
		# self.cond = threading.Condition()
		# self.notified = [False]
		#NetworkTables.initialize(server='roborio-5716-frc.local')
		
		#NetworkTables.initialize()
		#self.sd = NetworkTables.getTable('SmartDashboard')
		# wpilib.CameraServer.launch()
		# cap = cv2.VideoCapture(0)

		# self.Video = VideoRecorder()
		# wpilib.CameraServer.launch()

		# self.chasis_controller = wpilib.Joystick(0)

		self.timer = wpilib.Timer()


		self.left_cannon_motor = wpilib.Talon(5)
		self.right_cannon_motor = wpilib.Talon(6)

		self.sucker = wpilib.Talon(7)

		self.front_left_motor = wpilib.Talon(3)
		self.rear_left_motor = wpilib.Talon(1)
		self.front_right_motor = wpilib.Talon(4)
		self.rear_right_motor = wpilib.Talon(2)

		self.front_left_motor.setInverted(True)

		self.color_wheel = wpilib.Talon(8)

		self.drive = MecanumDrive(
			self.front_left_motor,
			self.rear_left_motor,
			self.front_right_motor,
			self.rear_right_motor)

		#led
		self.green_led = wpilib.DigitalOutput(0)

		#cannon pneumatic
		self.Compressor = wpilib.Compressor(0)
		self.PSV = self.Compressor.getPressureSwitchValue()
		self.cannon_piston = wpilib.Solenoid(0,5)
		self.hook1 = wpilib.Solenoid(0,0) 
		self.hook2 = wpilib.Solenoid(0,7) 
コード例 #17
0
ファイル: robot.py プロジェクト: Aurobots7456/Pluto
    def robotInit(self):
        # Robot initialization function

        # VictorSPX = Motor Controllers
        self.frontLeftMotor = ctre.WPI_VictorSPX(0)
        self.rearLeftMotor = ctre.WPI_VictorSPX(1)

        self.frontRightMotor = ctre.WPI_VictorSPX(4)
        self.rearRightMotor = ctre.WPI_VictorSPX(5)

        self.basketMotor = ctre.WPI_VictorSPX(3)

        # Digital Inputs (Limit Switch)
        self.basketLimitSwitch = wpilib.DigitalInput(0)

        # Motor controller groups for each side of the robot
        self.left = wpilib.SpeedControllerGroup(self.frontLeftMotor,
                                                self.rearLeftMotor)
        self.right = wpilib.SpeedControllerGroup(self.frontRightMotor,
                                                 self.rearRightMotor)

        # Differential drive with left and right motor controller groups
        self.myRobot = DifferentialDrive(self.left, self.right)
        self.myRobot.setExpiration(0.1)

        self.direction = -1

        # Declare gamepad
        self.gamepad = wpilib.Joystick(0)

        # Declare buttons
        # Controller mapping (1-10): B (East), A (South), Y (North), X (West), Right Bumper, Left Bumper, ?, ?, ?, ?
        self.toggleHatchButton = JoystickButton(self.gamepad, 1)
        self.toggleBasketButton = JoystickButton(self.gamepad, 2)
        self.toggleDirectionButton = JoystickButton(self.gamepad, 3)
        self.speedUpButton = JoystickButton(self.gamepad, 4)

        self.raiseBasketButton = JoystickButton(self.gamepad, 5)
        self.lowerBasketButton = JoystickButton(self.gamepad, 6)

        # Determine if already acted on
        self.hatchActed = False
        self.basketActed = False
        self.directionActed = False

        # Solenoids
        self.hatchSolenoid = wpilib.DoubleSolenoid(0, 1)
        self.basketSolenoid = wpilib.DoubleSolenoid(2, 3)

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

        # Camera Server
        wpilib.CameraServer.launch()
コード例 #18
0
ファイル: robot.py プロジェクト: BlountCountyRobotics/2020
    def robotInit(self):
        command.Command.getRobot = lambda x: self

        self.compressor = wpilib.Compressor()
        self.controller = wpilib.Joystick(0)

        self.drivetrain = subsystems.DriveTrain()
        self.shooter = subsystems.Shooter()
        #self.feeder = subsystems.Feeder()

        self.initOI()
コード例 #19
0
ファイル: robot.py プロジェクト: Team5045/2018-bot
    def createObjects(self):
        # TEMP - PRACTICE BOT ONLY
        # Launch cameraserver
        # wpilib.CameraServer.launch()

        # Practice bot
        # On practice bot, DIO is shorted
        # self.is_practice_bot = wpilib.DigitalInput(30)
        if hal.HALIsSimulation():
            self.is_practice_bot = wpilib.DigitalInput(20)
        else:
            self.is_practice_bot = wpilib.DigitalInput(30)

        # Drivetrain
        self.drivetrain_left_motor_master = ctre.WPI_TalonSRX(4)
        self.drivetrain_left_motor_slave = ctre.WPI_TalonSRX(7)  # was 3
        self.drivetrain_right_motor_master = ctre.WPI_TalonSRX(5)
        self.drivetrain_right_motor_slave = ctre.WPI_TalonSRX(6)
        self.drivetrain_shifter_solenoid = wpilib.Solenoid(0)

        # Elevator
        self.elevator_motor = ctre.WPI_TalonSRX(8)
        self.elevator_solenoid = wpilib.DoubleSolenoid(1, 2)
        self.elevator_reverse_limit = wpilib.DigitalInput(0)

        # Grabber
        self.grabber_left_motor = ctre.WPI_TalonSRX(1)
        self.grabber_right_motor = ctre.WPI_TalonSRX(2)

        # Ramp
        self.ramp_solenoid = wpilib.DoubleSolenoid(3, 4)
        self.ramp_motor = ctre.WPI_TalonSRX(3)  # was 7
        self.hold_start_time = None

        # Controllers
        self.drive_controller = wpilib.XboxController(0)
        self.operator_controller = wpilib.XboxController(1)

        # Compressor
        self.compressor = wpilib.Compressor()

        # LEDs
        self.led_driver = wpilib.Spark(0)

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

        # Macros / path recorder
        self._is_recording_macro = False
        self._is_playing_macro = False
        self._is_recording_path = False

        # Flippy toggle
        self._is_flippy = False
コード例 #20
0
    def __init__(self, robot):
        print("[HatchSystem] initializing")

        super().__init__("HatchSystem")
        self.robot = robot

        self.motor = ctre.WPI_TalonSRX(self.SLIDER_MOTOR)
        self.led = wpilib.Solenoid(self.PCM_CAN_ID, self.LED_SOLENOID_ID)
        self.ejector = wpilib.Solenoid(self.PCM_CAN_ID, self.PISTON_SOLENOID_ID)
        self.compressor = wpilib.Compressor(self.COMPRESSOR_PIN)

        wpilib.LiveWindow.addActuator("HatchSystem", "Alignment Motor", self.motor)

        print("[HatchSystem] initialized")
コード例 #21
0
ファイル: robot.py プロジェクト: 4924/2017-Offseason
    def robotInit(self):
        """
        This function is called upon program startup and
        should be used for any initialization code.
        """

        self.table = NetworkTables.getTable("SmartDashboard")
        self.robot_drive = wpilib.drive.DifferentialDrive(
            wpilib.Spark(0), wpilib.Spark(1))
        self.stick = wpilib.Joystick(0)
        self.elevatorMotor = wpilib.VictorSP(5)
        self.intakeMotor = wpilib.VictorSP(2)
        self.intakeMotorLeft = wpilib.VictorSP(3)
        self.intakeMotorRight = wpilib.VictorSP(4)
        self.climbMotor = wpilib.VictorSP(6)
        self.ahrs = AHRS.create_i2c(0)
        #self.gearSpeed = .5
        #self.lights = wpilib.Relay(1)
        #self.lightToggle = False
        #self.lightToggleBool = True
        #self.togglev = 0

        self.robot_drive.setSafetyEnabled(False)

        wpilib.CameraServer.launch()
        self.xb = wpilib.Joystick(1)

        self.Compressor = wpilib.Compressor(0)
        self.Compressor.setClosedLoopControl(True)
        self.enabled = self.Compressor.enabled()
        self.PSV = self.Compressor.getPressureSwitchValue()
        self.LeftSolenoid = wpilib.DoubleSolenoid(0, 1)
        self.RightSolenoid = wpilib.DoubleSolenoid(2, 3)
        self.Compressor.start()

        self.wheel = wpilib.Encoder(0, 1)
        self.wheel2 = wpilib.Encoder(2, 3, True)
        self.encoder = Sensors.Encode(self.wheel, self.wheel2)
        #wpilib.CameraServer.launch()
        self.ultrasonic = wpilib.AnalogInput(0)
        self.autoSchedule = Auto.Auto(self, )
        self.intakeToggle = False
        self.intakePos = False
        self.openSwitch = wpilib.DigitalInput(9)
        self.closedSwitch = wpilib.DigitalInput(8)

        self.speed = 0.6
        self.leftSpeed = 0.7
        self.rightSpeed = 0.7
        self.speedToggle = False
コード例 #22
0
    def createObjects(self):
        self.controller = wpilib.XboxController(0)

        self.motor_one = ctre.WPI_TalonSRX(1)

        self.encodermotor_motor = ctre.WPI_TalonSRX(5)

        self.compressor = wpilib.Compressor()
        self.manipulator_solenoid = wpilib.DoubleSolenoid(1, 3)

        self.turret_turretMotor = ctre.WPI_TalonSRX(2)

        self.shooter_shooterMotor = ctre.WPI_TalonSRX(3)
        self.shooter_hopperMotor = ctre.WPI_TalonSRX(4)
コード例 #23
0
ファイル: robot.py プロジェクト: Swift1332/2019FRC
 def robotInit(self):
     self.activated = False
     """Robot-wide initialization code should go here."""
     #SwiftCameraServer().launch('camera1.py:main')
     #SwiftCameraServer().launch('camera2.py:main')
     wpilib.CameraServer.launch()
     self.configuration = constants.COMP_BOT
     self.arm = Arm(self)
     self.drivetrain = DriveTrain(self)
     self.pneumatic = Pneumatic(self)
     self.compressor = wpilib.Compressor()
     self.camera_servo_1 = CameraServo(self, constants.CAMERA_1_PWM,
                                       constants.CAMERA_1_DEFAULT)
     self.camera_servo_2 = CameraServo(self, constants.CAMERA_2_PWM,
                                       constants.CAMERA_2_DEFAULT)
     self.oi = OI(self)
コード例 #24
0
ファイル: robot.py プロジェクト: Pigmice2733/frc-2018
    def createObjects(self):
        wpilib.CameraServer.launch()
        wpilib.LiveWindow.disableAllTelemetry()

        self.left_drive_motor = WPI_TalonSRX(0)
        WPI_TalonSRX(1).set(WPI_TalonSRX.ControlMode.Follower,
                            self.left_drive_motor.getDeviceID())
        self.right_drive_motor = WPI_TalonSRX(2)
        WPI_TalonSRX(3).set(WPI_TalonSRX.ControlMode.Follower,
                            self.right_drive_motor.getDeviceID())

        self.robot_drive = wpilib.drive.DifferentialDrive(
            self.left_drive_motor, self.right_drive_motor)

        self.r_intake_motor = WPI_VictorSPX(4)
        self.l_intake_motor = WPI_VictorSPX(5)

        self.elevator_winch = WPI_TalonSRX(6)

        self.climber_motor = WPI_TalonSRX(7)
        self.wrist_motor = WPI_TalonSRX(8)

        self.intake_ir = wpilib.AnalogInput(0)

        self.intake_solenoid = wpilib.DoubleSolenoid(2, 3)

        self.right_drive_joystick = wpilib.Joystick(0)
        self.left_drive_joystick = wpilib.Joystick(1)
        self.operator_joystick = wpilib.Joystick(2)

        self.compressor = wpilib.Compressor()

        self.elevator_limit_switch = wpilib.DigitalInput(0)

        self.climber_motor = WPI_TalonSRX(7)

        self.navx = AHRS.create_spi()

        self.path_tracking_table = NetworkTables.getTable("path_tracking")

        self.down_button = ButtonDebouncer(self.operator_joystick, 1)
        self.right_button = ButtonDebouncer(self.operator_joystick, 2)
        self.left_button = ButtonDebouncer(self.operator_joystick, 3)
        self.has_cube_button = ButtonDebouncer(self.operator_joystick, 5)
        self.up_button = ButtonDebouncer(self.operator_joystick, 4)
        self.left_bumper_button = JoystickButton(self.operator_joystick, 5)
        self.right_bumper_button = JoystickButton(self.operator_joystick, 6)
コード例 #25
0
    def robotInit(self):
        '''
        This is a good place to set up your subsystems and anything else that
        you will need to access later.
        '''

        #  Command.getRobot = lambda x=0: self
        #  self.motor = singlemotor.SingleMotor()
        subsystems.init()
        self.compressor = wpilib.Compressor(0)

        #  self.autonomousProgram = AutonomousProgram()
        '''
        Since OI instantiates commands and commands need access to subsystems,
        OI must be initialized after subsystems.
        '''
        oi.init()
コード例 #26
0
    def robotInit(self):
        """Initialization method for the Frobo class.  Initializes objects needed elsewhere throughout the code."""

        # Initialize Joystick
        self.controller = Joystick(Values.CONTROLLER_ID)

        # Initialize Drive Sub-System
        self.drive = FroboDrive(self, Values.DRIVE_LEFT_MAIN_ID,
                                Values.DRIVE_LEFT_SLAVE_ID,
                                Values.DRIVE_RIGHT_MAIN_ID,
                                Values.DRIVE_RIGHT_SLAVE_ID)

        # Initialize Shooter Sub-System
        self.compressor = wpilib.Compressor()
        self.shooter = Shooter(self, Values.SHOOT_FRONT_ID,
                               Values.SHOOT_BACK_ID,
                               Values.SHOOT_SOLENOID_FORWARD_CHANNEL_ID,
                               Values.SHOOT_SOLENOID_REVERSE_CHANNEL_ID)
コード例 #27
0
ファイル: robot.py プロジェクト: OliverGrayson/frc2015
    def robotInit(self):
        """
        This function is called upon program startup and
        should be used for any initialization code.
        """
        self.stick = wpilib.Joystick(1)
        self.drive = wpilib.RobotDrive(0, 1, 2, 3)
        self.gyro = wpilib.Gyro(0)
        self.lift1 = wpilib.Jaguar(4)
        self.lift2 = wpilib.Jaguar(5)
        #self.backclaw = wpilib.Jaguar(7)
        self.encoder = wpilib.Encoder(1, 2)
        self.encoder.setDistancePerPulse(0.333)
        self.compressor = wpilib.Compressor()
        self.squeeze = wpilib.DoubleSolenoid(0, 1)

        self.RobotDrive.setInvertedMotor(2, True)
        self.RobotDrive.setInvertedMotor(3, True)
コード例 #28
0
    def robotInit(self):
        '''Robot initialization function'''
        self.leftMotor1 = ctre.WPI_VictorSPX(1)  #motor initialization
        self.leftMotor2 = ctre.WPI_VictorSPX(3)
        self.leftMotor3 = ctre.WPI_VictorSPX(5)
        self.rightMotor1 = ctre.WPI_VictorSPX(0)
        self.rightMotor2 = ctre.WPI_VictorSPX(2)
        self.rightMotor3 = ctre.WPI_VictorSPX(4)
        self.armMotor = ctre.WPI_VictorSPX(6)
        self.leftIntakeMotor = ctre.WPI_VictorSPX(7)
        self.rightIntakeMotor = ctre.WPI_VictorSPX(8)

        self.leftSide = wp.SpeedControllerGroup(
            self.leftMotor1, self.leftMotor2,
            self.leftMotor3)  #speed controller groups
        self.rightSide = wp.SpeedControllerGroup(self.rightMotor1,
                                                 self.rightMotor2,
                                                 self.rightMotor3)
        self.intakeMotors = wp.SpeedControllerGroup(self.leftIntakeMotor,
                                                    self.rightIntakeMotor)

        self.myRobot = DifferentialDrive(self.leftSide, self.rightSide)
        self.myRobot.setExpiration(0.1)

        self.leftStick = wp.Joystick(0)
        self.rightStick = wp.Joystick(1)
        self.armStick = wp.Joystick(2)

        self.gyro = wp.ADXRS450_Gyro(0)
        self.rightEncd = wp.Encoder(0, 1)
        self.leftEncd = wp.Encoder(2, 3)

        self.compressor = wp.Compressor()

        wp.SmartDashboard.putNumber("Straight Position", 4000)
        self.chooser = wp.SendableChooser()
        self.chooser.addDefault("None", 4)
        self.chooser.addObject("Straight/Enc", 1)
        self.chooser.addObject("Left Turn Auto", 2)
        self.chooser.addObject("Right Turn Auto", 3)
        self.chooser.addObject("Straight/Timer", 5)
        wp.SmartDashboard.putData("Choice", self.chooser)
        wp.CameraServer.launch("vision.py:main")
コード例 #29
0
    def createObjects(self):

        drive = Drive
        lift = Lift
        #collection = Collection

        self.compressor = wpilib.Compressor()

        #Establishing Dashboard
        self.HUD = wpilib.SmartDashboard

        self.limitSwitchIn = wpilib.DigitalInput(0)

        #Left motors
        self.motor_l1 = ctre.WPI_TalonSRX(8)
        self.motor_l2 = ctre.WPI_TalonSRX(9)
        self.motor_l3 = ctre.WPI_TalonSRX(10)

        #Right motors
        self.motor_r1 = ctre.WPI_TalonSRX(2)
        self.motor_r2 = ctre.WPI_TalonSRX(3)
        self.motor_r3 = ctre.WPI_TalonSRX(4)

        #Lift motors
        self.lift_motor1 = ctre.WPI_TalonSRX(1)
        self.lift_motor2 = ctre.WPI_TalonSRX(7)

        #Collection motors
        self.collection_motor = ctre.WPI_TalonSRX(11)

        self.climbing_motor1 = ctre.WPI_TalonSRX(5)
        self.climbing_motor2 = ctre.WPI_TalonSRX(12)

        #DoubleSolenoids
        self.doubleS = wpilib.DoubleSolenoid(0, 1)
        self.doubleS2 = wpilib.DoubleSolenoid(2, 3)

        #Controllers
        self.stick = wpilib.Joystick(0)
        self.stick2 = wpilib.Joystick(1)
コード例 #30
0
    def robotInit(self):
        '''Robot initialization function'''
        #positions = [0,-625,-1210,-1815,-2425,-2635]
        positions = [0, -325, -650, -975, -1300, -1395]
        scorePos = [0, 0, -275, -545, -805, -1075]

        self.motorFrontRight = wp.TalonSRX(frontRightPort)
        self.motorBackRight = wp.TalonSRX(backRightPort)
        self.motorFrontLeft = wp.TalonSRX(frontLeftPort)
        self.motorBackLeft = wp.TalonSRX(backLeftPort)

        self.stick = joy.happyHappyJoyJoy(leftDriveJoyPort)
        self.stick2 = joy.happyHappyJoyJoy(rightDriveJoyPort)
        self.cop = joy.happyHappyJoyJoy(coPilotJoyPort)
        self.smartDs = wp.SmartDashboard()  #the smart dashboard communication
        self.accel = wp.BuiltInAccelerometer()

        self.driveEncd = wp.Encoder(driveEncdAPort, driveEncdBPort)

        self.feeders = feed.feedMe(feederLeftPort, feederRightPort,
                                   feedUpChannel, feedDownChannel, 0.35)

        self.rightSwitch = wp.DigitalInput(rightToteDetPort)
        self.leftSwitch = wp.DigitalInput(leftToteDetPort)
        self.autoSwitch = wp.DigitalInput(autoSwitchPort)

        self.comp = wp.Compressor()
        self.Vator = ele.elevatorObj(liftMotPort, liftEncdAPort, liftEncdBPort,
                                     positions, scorePos, 0.75, 30)

        try:
            self.camServ = wp.CameraServer()
            self.usbCam = wp.USBCamera()
            self.usbCam.setExposureManual(50)
            self.usbCam.setBrightness(80)
            self.usbCam.updateSettings()  # force update before we start thread
            self.camServ.startAutomaticCapture(self.usbCam)
        except:
            pass