I know there is a offical guide on it (https://wpilib.screenstepslive.com/s/currentCS/m/vision/l/479908-reading-array-values-published-by-networktables), but it seems the code is VERY depricated, any tips on how to at least read Network tables would be greatly appreciated!
Sincerely,
A Newbie Programmer
You can get the Network table from the default instance of NetworkTableInstance
Here is an example on reading values from Network Tables in Java:
NetworkTable table = NetworkTableInstance.getDefault().getTable("VisionTable");
NetworkTableEntry rangeEntry = table.getEntry("range");
NetworkTableEntry bearingEntry = table.getEntry("bearing");
Then use getEntry()
. The parameter is a default value (0.0 in this case).
double range = rangeEntry.getEntry(0.0);
double bearing = bearingEntry.getEntry(0.0);
Then if you want to change the values in the NT entries use:
double x = 10.0;
double y = 15.0;
rangeEntry.setDouble(x);
bearingEntry.setDouble(y);
or any of the other methods here: http://first.wpi.edu/FRC/roborio/release/docs/java/edu/wpi/first/networktables/NetworkTableEntry.html
2 Likes