public static boolean getBoolean(String key, boolean defaultValue) { boolean value; try { value = getBoolean(key); } catch (TableKeyNotDefinedException e) { putBoolean(key, defaultValue); value = defaultValue; } return value; }
public static double getNumber(String key, double defaultValue) { double value; try { value = getNumber(key); } catch (TableKeyNotDefinedException e) { putNumber(key, defaultValue); value = defaultValue; } return value; }
public static String getString(String key, String defaultValue) { String value; try { value = getString(key); } catch (TableKeyNotDefinedException e) { putString(key, defaultValue); value = defaultValue; } return value; }
protected void execute() { try { if(SmartDashboard.getNumber("isHot") == 1 && (SmartDashboard.getNumber("isVisible") == 1)) { new AutonomousPunchCommand(0).start(); } else { new AutonomousPunchCommand(4).start(); } } catch(TableKeyNotDefinedException t) { System.err.println("ERROR DURING AUTONOMOUS HOT GOAL CHECK"); new AutonomousPunchCommand(0).start(); } }
/** * Finds the distance away the goal is from the robot. * @return Distance from the goal */ public double getDistance() { double distance = 0; try { //distance = table.getNumber("Distance"); } catch (TableKeyNotDefinedException e) { Logger.log(e); } return distance; }
/** * Find the angle that the robot is from the goal. * Zero degrees means the robot is perfectly centered with the goal. * @return Angle from the goal */ public double getAngle() { double angle = 0; try { //angle = table.getNumber("Angle"); } catch (TableKeyNotDefinedException e) { Logger.log(e); } return angle; }
/** * Uses Smart Dashboard to update PID values. */ public void updatePID() { double pVal; double iVal; double dVal; try { pVal = SmartDashboard.getNumber("Tilter P"); iVal = SmartDashboard.getNumber("Tilter I"); dVal = SmartDashboard.getNumber("Tilter D"); controller.setPID(pVal, iVal, dVal); } catch (TableKeyNotDefinedException e) { SmartDashboard.putNumber("Tilter P", 0.0); SmartDashboard.putNumber("Tilter I", 0.0); SmartDashboard.putNumber("Tilter D", 0.0); } }
protected boolean updateVision() { boolean reslt = false; // Get the values we need from current vision results try { final NumberArray targetNum = new NumberArray(); ntserver.retrieveValue("BLOBS", targetNum); if (targetNum.size() > 0) { double blobx = targetNum.get(0); double bloby = targetNum.get(1); // Compute firing angle double baseCameraAngle = Robot.arm.getRawEncoder(); double targetInclineAngle = baseCameraAngle + vFoV * (bloby - ImageH / 2) * ImageH; double cameraHeight = CameraPivotHeight + CameraArmLength * Math.sin(Math.toRadians(baseCameraAngle)); double towerRange = (TargetHeight - cameraHeight) / Math.tan(Math.toRadians(targetInclineAngle)); double firingAngle = Math.toDegrees(Math.atan(Vfire2 / (G * towerRange) - Math.sqrt( Vfire2 * (Vfire2 - 2.0 * G * (TargetHeight - cameraHeight)) / (G * G * towerRange * towerRange) - 1))); Elevate(firingAngle); // Compute turn angle double targetTurnAngle = FoV * (blobx - ImageW / 2) * ImageW; Turn(targetTurnAngle); reslt = true; } } catch (TableKeyNotDefinedException exp) { } return reslt; }
private void updateCameraError() { if (SmartDashboard.getNumber("BLOB_COUNT") > 0) { try { azSteer = SmartDashboard.getNumber("Az_Steer"); azSteer += CAMERA_OFFSET; targetAngle = azSteer + Robot.sensors.getContinuousAngle(); gyroSource.setTargetAngle(targetAngle); } catch (TableKeyNotDefinedException ex) { DriverStation.reportError(ex.getClass().getCanonicalName() + ": " + ex.getMessage() + "\n", true); cancel(); } } }
@Override public Object getValue(String key) throws TableKeyNotDefinedException { MockNetworkTable relevant = tableForKey(key); String name = realKey(key); if (relevant.containsKey(name)) { return relevant.entries.get(name); } else { throw new TableKeyNotDefinedException(key); } }
@Override public Object getValue(String key, Object defaultValue) { MockNetworkTable relevant = tableForKey(key); String name = realKey(key); if (relevant.containsKey(name)) { return relevant.entries.getOrDefault(name, defaultValue); } else { throw new TableKeyNotDefinedException(key); } }
public static double getDistance() { try { double distance = laptop.getNumber("Distance"); return distance; } catch (TableKeyNotDefinedException ex) { return -1.; } }
public static double getDistanceWall() { try { double distancewall = laptop.getNumber("DistanceToWall"); return distancewall; } catch (TableKeyNotDefinedException ex) { return -1; } }
public static double getBlobCount() { try { double blobcount = laptop.getNumber("BLOB_COUNT"); // System.out.println(blobcount); return blobcount; } catch (TableKeyNotDefinedException ex) { return -1; } }
public static double getBlobCount() { try { double blobcount = laptop.getNumber("BlOB_COUNT"); return blobcount; } catch (TableKeyNotDefinedException ex) { return -1; } }