loading
 
DoubleArray for Java Network Tables
Tim Griesser from United States  [3 posts]
11 year
Where do I get DoubleArray for this Java example, i.e. which library or plug-in is DoubleArray  in?

http://www.roborealm.com/help/Network_Tables.php
Steven Gentner from United States  [1446 posts] 11 year
Actually, checking the most recent source, I think FIRST changed that to NumberArray. Should be in the edu.wpi.first.wpilib.networktables2.type folder.

We'll update the documentation.

Thanks,
STeven.
Tim Griesser from United States  [3 posts] 11 year
Hi Steven,
Thanks! That helps a lot.
Is NumberArray the right class when reading "BFR_COORDINATES"? (Best fit rectangle coordinates)?

When we use the example with "testla" replaced by "BFR_COORDINATES" we get Exception in thread "main" edu.wpi.first.wpilibj.networktables2.TableKeyExistsWithDifferentTypeException: Illegal put - key '/SmartDashboard/BFR_COORDINATES" exists with type 'NetworkTable type: Double'.  Is not a complex data type
at edu.wpi.first.wpilibj.networktables2.NetworkTableNode.retrieveValue(Unknown Source)
Steven Gentner from United States  [1446 posts] 11 year
Tim,

Be sure to have the most recent copy of RR when running this. The issue is that before a target is in view, the system will put the BFR_COORDINATES as 0.0 since it doesn't know its actually an array. Only when a target is in view does this variable become and array.

An update was made about 2 weeks ago to ensure that the type is NOT committed to the NT before RR knows if the variable is an array or not.

So, download the latest RR and shut down everything (robot, PC, etc.) to ensure the NT table is cleared out. Then bring back up everything with the new version of RR and it should be ok.

The error is specifically complaining that the variable being requested is a double and not an array of doubles.

STeven.
Tim Griesser from United States  [3 posts] 11 year
Hooray, we got it now.  Thanks for your help.  Here's what fixed it:

In RoboRealm, under Network_Tables, you have to set "Send Variable Types" to "Automatic".  Also, you have to put "BFR_COORDINATES" in the list uner "Send"

Now we can read with this code:

NetworkTable table = NetworkTable.getTable("SmartDashboard");

while(true) {

   final NumberArray d = new NumberArray();
   table.retrieveValue(BFR_COORDINATES", d);
   System.out.println("Size ="+d.size());
   for(int i=0; i<d.size(); i++)
      {
      System.out.println("Index "+i+"   Values "+d.get(i));
      }
   }

Thanks again!!

This forum thread has been closed due to inactivity (more than 4 months) or number of replies (more than 50 messages). Please start a New Post and enter a new forum thread with the appropriate title.

 New Post   Forum Index