public void drive() { // Driving controls /* flips which direction on the joysticks is 'forward' * the variable 'controlFlipClean' needs some explanation: * it forces the driver to release the button before it recognizes * another click. */ if (xboxDriver.getBtnL3()) { // left stick click if (controlFlipClean) { controlFlipClean = false; controlFlip = !controlFlip; } } else { controlFlipClean = true; } // controls right side double yRight = -xboxDriver.getRightY(); // controls left side double yLeft = xboxDriver.getLeftY(); // trigger values will change the maximum speed of the robot double throttle = xboxDriver.getTriggers(); // half speed if (throttle > 0.5) { yRight = yRight * 0.5; yLeft = yLeft * 0.5; } // quarter speed if (throttle < -0.5) { yRight = yRight * 0.25; yLeft = yLeft * 0.25; } // flip controls if we need to. Make them go 'backwards'. // We need to swap and yRight and yLeft values. if (controlFlip) { double tempRight = yRight; yRight = yLeft; yLeft = tempRight; } /* DEADZONE ** * The springs in the joysticks wear out so they don't always come * back to the centre. To fix this we're going to ignore a small region * around the centre. */ if (yRight > -DEADZONE && yRight < DEADZONE) { yRight = 0; } if (yLeft > -DEADZONE && yLeft < DEADZONE) { yLeft = 0; } vicDriveRight.set(yRight); vicDriveLeft.set(yLeft); } // end of drive