From 10772a76b5deed4852dd70fa5f94de49dfbdb625 Mon Sep 17 00:00:00 2001 From: Brian Semrau Date: Sat, 3 Mar 2018 12:57:40 -0500 Subject: [PATCH] Prevent joysticks from overriding in Autonomous mode --- src/org/usfirst/frc/team4737/robot/OI.java | 10 +++++----- src/org/usfirst/frc/team4737/robot/Robot.java | 8 ++++++++ 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/src/org/usfirst/frc/team4737/robot/OI.java b/src/org/usfirst/frc/team4737/robot/OI.java index ec11a87..e29c93d 100644 --- a/src/org/usfirst/frc/team4737/robot/OI.java +++ b/src/org/usfirst/frc/team4737/robot/OI.java @@ -60,23 +60,23 @@ public OI() { // User override to take control of the intake new Trigger() { public boolean get() { - return operator.getAxis("LT").get() != 0 || operator.getAxis("RT").get() != 0 - || operator.getAxis("RS_X").get() != 0; + return !Robot.getInstance().isAutonomous() && (operator.getAxis("LT").get() != 0 + || operator.getAxis("RT").get() != 0 || operator.getAxis("RS_X").get() != 0); } }.whileActive(new ControlIntake()); // User override to take control of driving new Trigger() { public boolean get() { - return driver.getThumbstick("LS").X.get() != 0 || driver.getAxis("LT").get() != 0 - || driver.getAxis("RT").get() != 0; + return !Robot.getInstance().isAutonomous() && (driver.getThumbstick("LS").X.get() != 0 + || driver.getAxis("LT").get() != 0 || driver.getAxis("RT").get() != 0); } }.whileActive(new TeleopRacingDrive()); // User override to take control of the elevator new Trigger() { public boolean get() { - return operator.getAxis("LS_Y").get() != 0; + return !Robot.getInstance().isAutonomous() && (operator.getAxis("LS_Y").get() != 0); } }.whileActive(new ControlElevator()); diff --git a/src/org/usfirst/frc/team4737/robot/Robot.java b/src/org/usfirst/frc/team4737/robot/Robot.java index a253926..c9d3ea8 100644 --- a/src/org/usfirst/frc/team4737/robot/Robot.java +++ b/src/org/usfirst/frc/team4737/robot/Robot.java @@ -25,6 +25,12 @@ * project. */ public class Robot extends TimedRobot { + + private static Robot instance; + + public static Robot getInstance() { + return instance; + } public static final Drivetrain DRIVETRAIN = new Drivetrain(); public static final Elevator ELEVATOR = new Elevator(); @@ -44,6 +50,8 @@ public class Robot extends TimedRobot { */ @Override public void robotInit() { + instance = this; + chooser.addDefault("No Auto", null); chooser.addObject("Blind Baseline", new AutoBlindBaseline()); // Add new autonomous routines here