I finally was able to pull information from the GRIP NetworkTables but was very disappointed when I only got a static number (area: 1045.5) repeatedly. Even after a reboot of the code the number remained the same. If I take this code out entirely and then run it and then put the code back in and run it then the number changes to whatever the first number from the NetworkTables is, but of course it remains static and repeats itself. My numbers inside the Outline Viewer are constantly changing so I have no idea why this is happening. Here is my code
package org.usfirst.frc4328.Robot2016.commands;
import edu.wpi.first.wpilibj.Timer;
import edu.wpi.first.wpilibj.command.Command;
import edu.wpi.first.wpilibj.networktables.*;
/**
*
*/
public class getAim extends Command {
public getAim() {
// Use requires() here to declare subsystem dependencies
// eg. requires(chassis);
}
// Called just before this Command runs the first time
protected void initialize() {
double] defaultValue = new double[0];
while (true) {
double] areas = NetworkTable.getTable("GRIP/Test").getNumberArray("area", defaultValue);
System.out.print("areas: ");
for (double area : areas) {
System.out.print(area + " ");
}
System.out.println();
Timer.delay(1);
}
}
// Called repeatedly when this Command is scheduled to run
protected void execute() {
}
// Make this return true when this Command no longer needs to run execute()
protected boolean isFinished() {
return false;
}
// Called once after isFinished returns true
protected void end() {
}
// Called when another command which requires one or more of the same
// subsystems is scheduled to run
protected void interrupted() {
}
}
GRIP is on the laptop, couldn’t deploy to the RIO, not a big deal. Running in server mode on localhost. All of my values are changing in the outline viewer as they should. I just cannot for the life of me get the values into Java.
Make sure your team number is set (Tools > Settings). That way, GRIP knows where to send NetworkTables values to.
Also, the roborio is supposed to run the NetworkTables server, so outlineviewer should be in client mode unless you’re testing something without a roborio.
OK but why would it continue to return a static number repeatedly? And the FRC documentation says I can run it on the laptop. However the documentation hasn’t exactly been correct so far BECAUSE THIS IS SO FRUSTRATING sorry I’m fine I swear.
I cannot deploy GRIP to the RoboRIO (along with a mass of people) but the patch is coming shortly. My outline viewer sees the values from GRIP. I can’t show a screenshot as I am not near the robot or the laptop but the values are being seen by Java at least once it’s just that number does not change
You can use outline viewer to run a server on your laptop, but this is only useful when testing something that doesn’t involve the roboRIO (ie: testing GRIP without a robot). If the roboRIO is part of the picture at all, it’s probably running the networktables server.
I’m not sure why it would return a static number. It’s possible that you got it deployed once and it put a number in NetworkTables, and now every time you run it’s getting that same number back. Fixing the networktables server address should fix this
Ok after a very long amount of time I finally got it to work. You are right, GRIP had to be run from the RIO, and the function of Outline Viewer’s server is for anybody wanting to use a coprocessor. The code above was from WPI’s official documentation on FIRST’s website and it was completely irrelevant. I used the code from GRIP’s GitHub page and I overcame the GRIP deployment by manually transferring the jar over with the .grip file. For anybody who is curious as to which jar you have to transfer (deployment is clearly an issue), it is the opencv-frc jar inside of appdata/local.