Skip to content

Commit

Permalink
Remove try block for no longer thrown exception
Browse files Browse the repository at this point in the history
Since v9.0.0, gamepad.copy() no longer throws a RobotCoreException.
  • Loading branch information
seakrueger authored Oct 9, 2023
1 parent 16ec8cb commit 08a0112
Showing 1 changed file with 14 additions and 20 deletions.
34 changes: 14 additions & 20 deletions source/docs/software/tutorials/gamepad.rst
Original file line number Diff line number Diff line change
Expand Up @@ -101,26 +101,20 @@ In a ``LinearOpMode`` based TeleOp program, storing both current and previous ga
// other initialization code goes here
while (opModeIsActive()) {
try {
// Store the gamepad values from the previous loop iteration in
// previousGamepad1/2 to be used in this loop iteration.
// This is equivalent to doing this at the end of the previous
// loop iteration, as it will run in the same order except for
// the first/last iteration of the loop.
previousGamepad1.copy(currentGamepad1);
previousGamepad2.copy(currentGamepad2);
// Store the gamepad values from this loop iteration in
// currentGamepad1/2 to be used for the entirety of this loop iteration.
// This prevents the gamepad values from changing between being
// used and stored in previousGamepad1/2.
currentGamepad1.copy(gamepad1);
currentGamepad2.copy(gamepad2);
}
catch (RobotCoreException e) {
// Swallow the possible exception, it should not happen as
// currentGamepad1/2 are being copied from valid Gamepads.
}
// Store the gamepad values from the previous loop iteration in
// previousGamepad1/2 to be used in this loop iteration.
// This is equivalent to doing this at the end of the previous
// loop iteration, as it will run in the same order except for
// the first/last iteration of the loop.
previousGamepad1.copy(currentGamepad1);
previousGamepad2.copy(currentGamepad2);
// Store the gamepad values from this loop iteration in
// currentGamepad1/2 to be used for the entirety of this loop iteration.
// This prevents the gamepad values from changing between being
// used and stored in previousGamepad1/2.
currentGamepad1.copy(gamepad1);
currentGamepad2.copy(gamepad2);
// Main teleop loop goes here
}
Expand Down

0 comments on commit 08a0112

Please sign in to comment.