/** * {@inheritDoc} */ @Override public void updateTable() { ITable table = getTable(); if (table != null) { table.putNumber("Value", getAngle()); table.putNumber("Pitch", getPitch()); table.putNumber("Roll", getRoll()); table.putNumber("Yaw", getYaw()); table.putNumber("AccelX", getAccelX()); table.putNumber("AccelY", getAccelY()); table.putNumber("AccelZ", getAccelZ()); table.putNumber("AngleX", getAngleX()); table.putNumber("AngleY", getAngleY()); table.putNumber("AngleZ", getAngleZ()); } }
private void initPhoneVars(VisionContainer container, double defaultTargetWidth, double defaultTargetHeight) { ITable range = container.table.getSubTable("colorRange"); if (!range.containsKey("lower")) { range.putNumberArray("lower", new double[] {0, 0, 0}); } if (!range.containsKey("upper")) { range.putNumberArray("upper", new double[] {0, 0, 0}); } range.setPersistent("lower"); range.setPersistent("upper"); ITable target = container.table.getSubTable("target"); if (!target.containsKey("width")) { target.putNumber("width", defaultTargetWidth); } if (!target.containsKey("height")) { target.putNumber("height", defaultTargetHeight); } target.setPersistent("width"); target.setPersistent("height"); }
@Override protected void poll() throws Exception { ITable robotTable = Robot.getTable(); if (robotTable != null && mCoordinateGui != null) { double x = Robot.getTable().getNumber(SmartDashBoardNames.sX_POSITION, 0) / 12; double y = Robot.getTable().getNumber(SmartDashBoardNames.sY_POSITION, 0) / 12; double angle = Robot.getTable().getNumber(SmartDashBoardNames.sORIENTATION, 0); Coordinate coord = new Coordinate(x, y, angle); mCoordinateGui.addCoordinate(coord); List<Ray> rays = parseRays(); mCoordinateGui.setRays(rays); } }
/** * Initialize all the LiveWindow elements the first time we enter LiveWindow mode. By holding off * creating the NetworkTable entries, it allows them to be redefined before the first time in * LiveWindow mode. This allows default sensor and actuator values to be created that are replaced * with the custom names from users calling addActuator and addSensor. */ private static void initializeLiveWindowComponents() { System.out.println("Initializing the components first time"); livewindowTable = NetworkTable.getTable("LiveWindow"); statusTable = livewindowTable.getSubTable("~STATUS~"); for (Enumeration e = components.keys(); e.hasMoreElements(); ) { LiveWindowSendable component = (LiveWindowSendable) e.nextElement(); LiveWindowComponent liveWindowComponent = (LiveWindowComponent) components.get(component); String subsystem = liveWindowComponent.getSubsystem(); String name = liveWindowComponent.getName(); System.out.println("Initializing table for '" + subsystem + "' '" + name + "'"); livewindowTable.getSubTable(subsystem).putString("~TYPE~", "LW Subsystem"); ITable table = livewindowTable.getSubTable(subsystem).getSubTable(name); table.putString("~TYPE~", component.getSmartDashboardType()); table.putString("Name", name); table.putString("Subsystem", subsystem); component.initTable(table); if (liveWindowComponent.isSensor()) { sensors.addElement(component); } } }
/** * {@inheritDoc} */ @Override public void startLiveWindowMode() { m_table_listener = new ITableListener() { @Override public void valueChanged(ITable itable, String key, Object value, boolean bln) { String val = ((String) value); if (val.equals("Off")) { set(Value.kOff); } else if (val.equals("On")) { set(Value.kOn); } else if (val.equals("Forward")) { set(Value.kForward); } else if (val.equals("Reverse")) { set(Value.kReverse); } } }; m_table.addTableListener("Value", m_table_listener, true); }
@Override public void startLiveWindowMode() { m_tableListener = new ITableListener() { @Override public void valueChanged(ITable itable, String key, Object value, boolean bln) { String val = ((String) value); if (val.equals("Off")) { set(Value.kOff); } else if (val.equals("On")) { set(Value.kOn); } else if (val.equals("Forward")) { set(Value.kForward); } else if (val.equals("Reverse")) { set(Value.kReverse); } } }; m_table.addTableListener("Value", m_tableListener, true); }
@Override public default void updateTable() { ITable table = getTable(); if(table != null) { table.putString("~TYPE~", SMART_DASHBOARD_TYPE); table.putString("Type", getClass().getSimpleName()); // "CANTalon", "CANJaguar" table.putNumber("Mode", getControlMode().getValue()); if (getControlMode().isPID()) { // CANJaguar throws an exception if you try to get its PID constants // when it's not in a PID-compatible mode table.putNumber("p", getP()); table.putNumber("i", getI()); table.putNumber("d", getD()); table.putNumber("f", getF()); } table.putBoolean("Enabled", isEnabled()); table.putNumber("Value", get()); } }
@Override public void initTable(ITable table) { m_table = table; if (table != null) { if (m_defaultCommand != null) { table.putBoolean("hasDefault", true); table.putString("default", m_defaultCommand.getName()); } else { table.putBoolean("hasDefault", false); } if (m_currentCommand != null) { table.putBoolean("hasCommand", true); table.putString("command", m_currentCommand.getName()); } else { table.putBoolean("hasCommand", false); } } }
public void initTable(ITable subtable) { if (this.m_table != null) this.m_table.removeTableListener(m_listener); this.m_table = subtable; m_table.addTableListener(m_listener); // values expected to come from robot or dashboard this.AutoAimEnabled = m_table.getBoolean("AutoAimEnabled", false); this.TargetHigh = m_table.getBoolean("TargetHigh", true); // values expected to arrive from jetson this.FPS = (int) m_table.getNumber("FPS", 0.); this.TargetAcquired = (int) m_table.getNumber("TargetAcquired", 0); this.TargetX = m_table.getNumber("TargetX", 0); this.TargetY = m_table.getNumber("TargetY", 0); }
/** * {@inheritDoc} */ public void startLiveWindowMode() { setSpeed(0); // Stop for safety m_table_listener = new ITableListener() { public void valueChanged(ITable itable, String key, Object value, boolean bln) { setSpeed(((Double) value).doubleValue()); } }; m_table.addTableListener("Value", m_table_listener, true); }
@Override public void startLiveWindowMode() { setSpeed(0); // Stop for safety m_tableListener = new ITableListener() { public void valueChanged(ITable itable, String key, Object value, boolean bln) { setSpeed((Double) value); } }; m_table.addTableListener("Value", m_tableListener, true); }
/** * Returns the value at the specified key. * * @param key the key * @return the value * @throws NetworkTableKeyNotDefined if there is no value mapped to by the key * @throws IllegalArgumentException if the key is null */ public static Sendable getData(String key) { ITable subtable = table.getSubTable(key); Object data = tablesToData.get(subtable); if (data == null) { throw new IllegalArgumentException("SmartDashboard data does not exist: " + key); } else { return (Sendable) data; } }
@Override public void initTable(ITable table) { m_table = table; if (table != null) { table.putStringArray(OPTIONS, m_map.keySet().toArray(new String[0])); if (m_defaultChoice != null) { table.putString(DEFAULT, m_defaultChoice); } } }
/** * {@inheritDoc} */ public void startLiveWindowMode() { set(false); // Stop for safety m_table_listener = new ITableListener() { public void valueChanged(ITable itable, String key, Object value, boolean bln) { set(((Boolean) value).booleanValue()); } }; m_table.addTableListener("Value", m_table_listener, true); }
@Override public void initTable(ITable table) { m_table = table; if (table != null) { table.putBoolean("pressed", get()); } }
/** * {@inheritDoc} */ @Override public void startLiveWindowMode() { m_table_listener = new ITableListener() { @Override public void valueChanged(ITable itable, String key, Object value, boolean bln) { set(((Boolean) value).booleanValue()); } }; m_table.addTableListener("Value", m_table_listener, true); }
@Override public void initTable(ITable table) { if (m_table != null) { m_table.removeTableListener(m_listener); } m_table = table; if (table != null) { table.putString("name", getName()); table.putBoolean("running", isRunning()); table.putBoolean("isParented", m_parent != null); table.addTableListener("running", m_listener, false); } }
@Override public void initTable(ITable subtable) { m_table = subtable; m_table.putStringArray("Names", new String[0]); m_table.putNumberArray("Ids", new double[0]); m_table.putNumberArray("Cancel", new double[0]); }
/** * Creates a CommandParser object. * * @param aSnobot * The robot using the CommandParser. * @param aStartPosition */ public CommandParser(Snobot aSnobot, ITable aAutonTable, String aParserName, SelectStartPosition aStartPosition, CommandParser aDefenseParser, DefenseInFront aDefenseGetter) { super(" ", "#"); mSnobot = aSnobot; mAutonTable = aAutonTable; mParserName = aParserName; mDefenseParser = aDefenseParser; mDefenseGetter = aDefenseGetter; mStartPosition = aStartPosition; }
@Override public void valueChanged(ITable table, String key, Object value, boolean isNew) { /* * All numbers are stored as doubles in the network tables, event * those posted as int, float. */ /* debug: System.out.println(key + " " + value + " " + value.getClass().getName()); */ if (key.equals("~TYPE~")) { return; } else if (key.equals("AutoAimEnabled")) { s_instance.AutoAimEnabled = (boolean) value; } else { // System.out.println(key + " " + value); double num = (Double) value; int ival = (int) num; if (key.equals("FPS")) s_instance.FPS = ival; else if (key.equals("TargetAcquired")) s_instance.TargetAcquired = ival; else if (key.equals("TargetX")) { s_instance.TargetX = num; } else if (key.equals("TargetY")) s_instance.TargetY = num; else System.out.println(key + " " + value + " " + value.getClass().getName()); } }
@Override public void valueChangedEx(ITable table, String key, Object value, int newP) { timeLastSeen = time.get(); boolean newKey = (newP & 0x04) != 0; boolean updated = (newP & 0x10) != 0; if (updated) { VisionHandler.getInstance().update(table); } }
public Line[] getLines(ITable lineReport) { // This marshals stuff from the // NetworkTable to // a bunch of line objects. double[] x1s = lineReport.getNumberArray("x1", Constants.emptydoubleTable); double[] x2s = lineReport.getNumberArray("x2", Constants.emptydoubleTable); double[] y1s = lineReport.getNumberArray("y1", Constants.emptydoubleTable); double[] y2s = lineReport.getNumberArray("y2", Constants.emptydoubleTable); double[] lengths = lineReport.getNumberArray("length", Constants.emptydoubleTable); double[] angles = lineReport.getNumberArray("angle", Constants.emptydoubleTable); Line[] lineTable = new Line[x1s.length + 10]; for (int i = 0; i < x1s.length; i++) { lineTable[i] = new Line(); } for (int i = 0; i < x1s.length; i++) { lineTable[i].x1 = x1s[i]; } for (int i = 0; i < x2s.length; i++) { lineTable[i].x2 = x2s[i]; } for (int i = 0; i < y1s.length; i++) { lineTable[i].y1 = y1s[i]; } for (int i = 0; i < y2s.length; i++) { lineTable[i].y2 = y2s[i]; } for (int i = 0; i < lengths.length; i++) { lineTable[i].length = lengths[i]; } for (int i = 0; i < angles.length; i++) { lineTable[i].angle = angles[i]; } return lineTable; }
@Override public void initTable(ITable subtable) { _table = subtable; updateTable(); }
@Override public ITable getTable() { return _table; }
@Override public void valueChanged(ITable table, String key, Object value, boolean isNew) { // unused }
@Override public ITable getTable() { return m_table; }
/** * {@inheritDoc} */ @Override public void initTable(ITable subtable) { m_table = subtable; updateTable(); }
/** * {@inheritDoc} */ @Override public ITable getTable() { return m_table; }
/** * {@inheritDoc} */ public void initTable(ITable subtable) { m_table = subtable; updateTable(); }
public void initTable(ITable itable) { m_table = itable; updateTable(); }
/** {@inheritDoc} */ public ITable getTable() { return m_table; }