View Single Post
  #22   Spotlight this post!  
Unread 13-01-2016, 18:40
shlynfrhm shlynfrhm is offline
Registered User
FRC #3039 (Wildcat Robotics)
Team Role: Programmer
 
Join Date: Jan 2015
Rookie Year: 2012
Location: Cambridge, MA
Posts: 6
shlynfrhm is an unknown quantity at this point
Re: We are going to Want a GRIP fourm

Hey, I'm also having problems accessing the data from my NetworkTables. This is my code, and I've also imported NetworkTables before my program. I'm not able to see live publishing from GRIP to the Network Tables, has anyone been able to successfully do this and could give me an example? I followed the instructions on WPILib, but I feel as if I'm missing some code. Also, we program in command-based and I'm not sure where to implement this code in that format.

Code:
public class Robot extends SampleRobot {
    final String defaultAuto = "Default";
    final String customAuto = "My Auto";
    String autoSelected;
    SendableChooser chooser;
    NetworkTable table;
	
    /**
     * This function is run when the robot is first started up and should be
     * used for any initialization code.
     */
    public Robot() {
    	table = NetworkTable.getTable("/GRIP/myContoursReport");
    }
    public void robotInit() {
    	
        chooser = new SendableChooser();
        chooser.addDefault("Default Auto", defaultAuto);
        chooser.addObject("My Auto", customAuto);
        SmartDashboard.putData("Auto choices", chooser);
        double[] defaultValue = new double[0];
        while(true){
        	double[]areas=table.getNumberArray("area", defaultValue);
        	System.out.print("areas:");
        	for(double area:areas){
        		System.out.print(area + " ");
        	}
        	System.out.println();
        	Timer.delay(1);
        }
    }
Thanks!
Ashlyn