示例#1
0
    def driveJoystick(self, joystick):

        precision = False

        #set the axes & pass them to the drive_control utility library
        #-----------------------------------------------------------------------
        #the getX() and getY() bits are both 0 indexed according to the joystick
        #documentation for WPIlib, so X = 0, Y = 1, Z = 2, twist (supposedly) =
        #3, etc. The thing is, the default throttle axis is set to 3, and the
        #default twist axis is set to 2.
        #So.
        #When we tested previous versions on the robot with getRawAxis(3), the
        #throttle would do the things (different joystick setup on Lopez Jr
        #iirc, so that's part of it).
        #Now (1/5/16), I've set getRawAxis(2). Works fine.

        x = drive_control(joystick.getX(), precision)
        y = drive_control(joystick.getY(), precision)
        z = z_control(joystick.getRawAxis(2), precision)
        a = 0

        self.driveManual(x, y, a, z)
        if x>1:
            x=1
        elif x<-1:
            x=-1
示例#2
0
    def driveJoystick(self, joystick):
        #Start precision mode
        precision = True

        #set the axes & pass them to the drive_control utility library
        #-----------------------------------------------------------------------
        #the getX() and getY() bits are both 0 indexed according to the joystick
        #documentation for WPIlib, so X = 0, Y = 1, Z = 2, twist (supposedly) =
        #3, etc. The thing is, the default throttle axis is set to 3, and the
        #default twist axis is set to 2.
        #So.
        #When we tested previous versions on the robot with getRawAxis(3), the
        #throttle would do the things (different joystick setup on Lopez Jr
        #iirc, so that's part of it).
        #Now (1/5/16), I've set getRawAxis(2). Works fine.

        x = drive_control(joystick.getX()*1.25, precision)
        y = drive_control(joystick.getY()*1.25, precision)
	z = precision_mode(dead_zone(joystick.getRawAxis(2)*2, .1), precision) #I'm gonna be perfectly honest: I have no idea why I didn't just write an additional function similar to drive_control for this
        a = 0

        self.driveManual(x, y, a, z)
        if x>1:
            x=1
        elif x<-1:
            x=-1
 def driveJoystick(self, joystick):
     precision = True
     x = drive_control(joystick.getX()*2, False, False)
     y = drive_control(joystick.getY(), False, False)
     z = precision_mode(dead_zone(joystick.getRawAxis(3)*.75, .1), False, False)
     if x>1:
         x=1
     elif x<-1:
         x=-1
     self.driveManual(x,y,z)
示例#4
0
    def driveJoystick(self, joystick):
        """Get the values from the joystick, and pass them to the driveManual function."""

        #Set precision to be false so the drivetrain isn't auto-nerfed
        precision = False

        #                      /-twist joystick              /-1st precision button        /-multiplier so it goes to 1
        twist = dead_zone(twist_control(-self.joystick.getRawAxis(2), self.joystick.getRawButton(1))*5, .25)
        y = dead_zone(drive_control(-self.joystick.getRawAxis(1), self.joystick.getRawButton(1))*2.5, .25)
        #                  \-main forward joystick \-1st precision button               \-multiplier so it goes to 1

        #what even is this
        if twist>1:
            twist=1
        elif twist<-1:
            twist=-1

        self.driveManual(y, twist)
    def driveJoystick(self, joystick):
        """Get the values from the joystick, and pass them to the driveManual function."""

        #Set precision to be false so the drivetrain isn't auto-nerfed
        precision = False
        forward = self.joystick.getRawButton(5)
        backward = self.joystick.getRawButton(3)

        #Theoretically, we could have separate button setups for activating
        #precision mode on separate axes. Not sure if that's a good idea.

        #                     /-twist joystick              /-1st precision button      /-2nd precision button      /-multiplier so it goes to 1
        twist = twist_control(-self.joystick.getRawAxis(2), self.joystick.getRawButton(0), self.joystick.getRawButton(1))*5
        y = drive_control(-self.joystick.getY(), self.joystick.getRawButton(0), self.joystick.getRawButton(1))*2.5
        #                  \-main forward joystick \-1st precision button    \-2nd precision button      \-multiplier so it goes to 1

        #what even is this
        if twist>1:
            twist=1
        elif twist<-1:
            twist=-1

        #Call the driveManual function for the lulz
        self.driveManual(y, twist, forward, backward)