origamitaco
19-01-2016, 13:16
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() {
}
}
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() {
}
}