コード例 #1
0
    def run(self, x, y, rotation):
        '''Intended for use in telelop. Use .cartesian() for auto.'''
        # Map joystick values to curve
        x = self.curve(helpers.deadband(x, 0.1))
        y = self.curve(helpers.deadband(y, 0.1))
        rotation = helpers.deadband(-rotation * 0.5, 0.1)

        # write manipulated values to motors
        self.cartesian(-x, y, rotation)
コード例 #2
0
    def run(self, heightRate, runIn, open, runOut, bottom, angle, calibrate):
        '''
        Intended to be called with a periodic loop
        and with button toggles.
        '''

        # if elevator is at limit switch
        self.calibrateAsync()

        if (runIn):
            self.intakeM.set(-1)
        elif (runOut):
            self.intakeM.set(1)
        else:
            self.intakeM.set(0)

        if (open):
            self.jawsSol.set(self.jawsSol.Value.kForward)
        else:
            self.jawsSol.set(self.jawsSol.Value.kReverse)

        if (bottom):
            self.goToHeight(0)
        else:
            if (calibrate):
                self.calibrateSync()
            else:
                self.setElevator(heightRate)

        self.setJaws(helpers.deadband(angle, 0.1))
コード例 #3
0
    def curve(self, value):
        """Because this divides by sin(1), an input
        in range [-1, 1] will always have an output
        range of [-1, 1]. """

        value = helpers.deadband(helpers.raiseKeepSign(value, 1), self.jDeadband)

        return (math.sin(value) / math.sin(1));
コード例 #4
0
ファイル: robot.py プロジェクト: 3299/2019
    def teleopPeriodic(self):
        """This function is called periodically during operator control."""
        '''Components'''
        # Rumble
        averageDriveCurrent = self.power.getAverageCurrent([0, 1, 14, 15])
        if (averageDriveCurrent > 8):
            self.joystick.setRumble(0, 1)
        else:
            self.joystick.setRumble(0, 0)
        #print(self.metabox.getEncoder())
        '''
        TODO: calibrate sparks
        '''

        # Drive
        self.drive.run(self.joystick.getRawAxis(0),
                       self.joystick.getRawAxis(1),
                       self.joystick.getRawAxis(4))

        # MetaBox
        self.metabox.run(
            self.leftJ.getY(),  # elevator rate of change
            self.leftJ.getRawButton(3),  # run intake wheels in
            self.leftJ.getRawButton(1),  # open jaws
            self.leftJ.getRawButton(2),  # run intake wheels out
            self.leftJ.getRawButton(4),  # go to bottom
            self.leftJ.getRawAxis(2),  # set angle of jaws
            self.leftJ.getRawButton(8),  # calibrate elevator
            self.leftJ.getRawButton(9))  #set intake wheels to pull in
        '''

        self.Frontlift.run(self.leftJ.getRawButton(6),
                           self.leftJ.getRawButton(7),
                           self.leftJ.getRawButton(11),
                           self.leftJ.getRawButton(10),
                           self.leftJ.getRawButton(8))
        '''
        # Lights
        self.lights.setColor(self.driverStation.getAlliance())

        if (self.driverStation.getMatchTime() < 30
                and self.driverStation.getMatchTime() != -1):
            self.lights.run({'effect': 'flash', 'fade': True, 'speed': 200})
        elif (helpers.deadband(self.leftJ.getY(), 0.1) != 0):
            self.lights.run({'effect': 'stagger'})
        elif (self.leftJ.getRawButton(1) or self.leftJ.getRawButton(2)):
            self.lights.run({'effect': 'flash', 'fade': False, 'speed': 20})
        else:
            self.lights.run({'effect': 'rainbow'})