|
Re: Network Tables?
NetworkTable object can be used to pass data to/from robot code and another program running on another computer on the network. SmartDashboard uses it to pass data to/from robot.
We use it to pass data from image processing software running on the driver station back to the robot.
Here is example code:
Code:
//========================================
//Robot Code
// declare object
NetworkTable cameraTable;
// getinstance (table is a singleton, if one does not exist then one will
// be created otherwise returns reference to existing instance
cameraTable = NetworkTable.getTable("camera");
// get data element from the table
// default values returned if no data has been provided from another source yet
cameraTable.beginTransaction();
Boolean imageFound = cameraTable.getBoolean("found", false );
Double imageOffset = cameraTable.getDouble("offset", -1.0);
Double imageDistance = cameraTable.getDouble("distance", -1.0);
cameraTable.endTransaction();
System.out.println( "found = " + imageFound);
System.out.println( "offset = " + imageOffset);
System.out.println( "distance = " + imageDistance);
//=======================================
// Driver Station PC
// camera image processing is done in C# application on DS
// declare it
private NetworkTable table;
// Init NetworkTable
NetworkTable.setIPAddress("10.6.23.2"); // ip of crio
table = NetworkTable.getTable("camera");
// in the image processing loop
table.beginTransaction();
table.putBoolean("found", true);
table.putDouble("distance", distance);
table.putDouble("offset", offset);
table.endTransaction();
__________________
FRC 623 2003,2004,2005,2006,2007,2008, 2009, 2010, 2011
FRC 1900 2007
FVC 60 and 193 2006
FVC 3271 2007
FTC 226 and 369 2008, 2009, 2010, 2011
FTC 3806 2010
|