/** * The run method is used internally to actually run the commands. * * @return whether or not the command should stay within the {@link Scheduler}. */ synchronized boolean run() { if (!m_runWhenDisabled && m_parent == null && RobotState.isDisabled()) { cancel(); } if (isCanceled()) { return false; } if (!m_initialized) { m_initialized = true; startTiming(); _initialize(); initialize(); } _execute(); execute(); return !isFinished(); }
/** * Runs the autonomous program. * * This will drive the robot forward 9.5 feet at 0.8 speed and then 2 feet at 0.3 speed */ @Override public void auto(){ Timer t = new Timer(); t.start(); while (t.get() < 2 && RobotState.isAutonomous() && RobotState.isEnabled()) { chassis.tankDrive(new MotorValue(-.28), new MotorValue(-.28)); System.out.println(t.get() + " " + chassis.getLeftDistance().getInches() + " " + chassis.getRightDistance().getInches() + " "); } while (t.get() < 3.5 && RobotState.isAutonomous() && RobotState.isEnabled()) { chassis.tankDrive(new MotorValue(-.15),new MotorValue(-.15)); } while (t.get() < 4.0 && RobotState.isAutonomous() && RobotState.isEnabled()) { chassis.tankDrive(new MotorValue(0),new MotorValue(0)); } while (t.get() < 4.30 && RobotState.isAutonomous() && RobotState.isEnabled()) {//icnreased from 4.1 to 4.3 chassis.tankDrive(new MotorValue(.15),new MotorValue(.15)); } chassis.stop(); }
@Override public final Object call() throws Exception { if (isActive) { if (RobotState.isDisabled()) cancel(); if (isCancelled()) return null; startTiming(); initialize(); while (!isFinished() && !isTimedOut()) { if (isCancelled()) { interrupted(); return isCancelled(); } else execute(); } end(); } else { throw new InactiveActionException(); } return null; }
private static String getOpModeName() { if(RobotState.isAutonomous()){ return "Auto"; } else { return "Teleop"; } }
private static int getRobotState() { if(RobotState.isDisabled()){ return 0; } else if (RobotState.isAutonomous()) { return 1; } else if (RobotState.isOperatorControl()) { return 2; } else if (RobotState.isTest()) { return 3; } return -1; }
@Override public double getHIDAxis(int hid, int axis) { if(FlashRobotUtil.inEmergencyStop() || RobotState.isDisabled()) return 0; return ds.getStickAxis(hid, axis); }
@Override public boolean getHIDButton(int hid, int button) { if(FlashRobotUtil.inEmergencyStop() || RobotState.isDisabled()) return false; return ds.getStickButton(hid, (byte)button); }
@Override public int getHIDPOV(int hid, int pov) { if(FlashRobotUtil.inEmergencyStop() || RobotState.isDisabled()) return -1; return ds.getStickPOV(hid, pov); }
public void operatorControl() { TurtleDashboard.teleop(); while (RobotState.isOperatorControl() && RobotState.isEnabled()) { teleUpdate(); } }
public static boolean isAutonomous() { return RobotState.isAutonomous(); }