You can use the
getTrigger() method on a
Joystick to determine whether or not the button is being pressed. If it is, call the
tankDrive() method, and if it isn't, tell the robot to stop driving. This could be done by calling
drive() with 0.0 as the speed and curve values.
Example:
Code:
// Assumptions: these are already set up and configured.
RobotDrive drive;
Joystick leftStick, rightStick;
// In teleop control:
if (rightStick.getTrigger())
drive.tankDrive(leftStick, rightStick); // Drive when trigger is pressed
else
drive.drive(0.0, 0.0); // Stop driving if trigger is released