public void autonomousPeriodic() { relay.set(Relay.Value.kOn); smart.putNumber("distance", ultrasonic.getVoltage()); drive.setRun(false); loadAndShoot.setRun(false); // relay.set(Relay.Value.kOn); if (autoTimer.get() < autoMoveForwardTime) { System.out.println( "Moving forward, Timer at " + autoTimer.get() + ", Ultrasonic at " + ultrasonic.getAverageVoltage()); } if (autoTimer.get() >= autoMoveForwardTime && ultrasonic.getAverageVoltage() <= AUTO_DISTANCE) { stop(); if (!autonomousStopped) { autonomousStopped = true; autoTimeAtStop = autoTimer.get(); } System.out.println("Stopped, Ultrasonic at " + ultrasonic.getAverageVoltage()); } if (autoTimer.get() >= autoTimeAtStop + 1 && ultrasonic.getAverageVoltage() <= AUTO_DISTANCE) { autoStop = true; shoot(); System.out.println("Shooting, Ultrasonic at " + ultrasonic.getAverageVoltage()); } }
/* * reads the value of the digital input of the specified channel * requires that the readArudiono() method has already been called * param 1: the channel to be read * return: value of the specified digital input */ public boolean getInput(int channelID) { byte temp; if (timer.get() > 2.0) { DriverStationLCD.getInstance() .println(DriverStationLCD.Line.kUser3, 1, " "); DriverStationLCD.getInstance().updateLCD(); timer.stop(); timer.reset(); } if (Math.abs(channelID - (13 / 2)) - (13 / 2) > 0) // returns true if less than zero or greater than thirteen { timer.start(); DriverStationLCD.getInstance().println(DriverStationLCD.Line.kUser3, 1, "Invalid ID"); DriverStationLCD.getInstance().updateLCD(); return false; } else if (channelID < 8) { temp = (byte) (loByte & (1 << channelID)); return temp != 0; } else { temp = (byte) (hiByte & (1 << channelID - 8)); return temp != 0; } }
/** This function is called periodically during operator control */ public void teleopPeriodic() { Watchdog.getInstance().feed(); // Tell watchdog we are running // activate the robot by pushing start button if (xboxDriver.getBtnSTART()) { teleopActive = true; } if (!teleopActive) { return; // only run if teleop is active } if (lightsTimer.get() > 90000) { lightsOutput1.set(true); lightsOutput2.set(true); lightsOutput3.set(false); } drive(); shooterUse(); // shooterLoft(); armUse(); }
/** * May be overridden to provide an alternate executor service. * * @return by default, {@link Timer#get} */ protected ExecutorService executorService() { return Timer.get(); }