I have a LabVIEW dashboard running sending data to Java robot code. Most of the time it works, but sometimes the variable being read in the Java robot code as shown below stops updating and continues outputting the last value. If there is an exception, it should return -1, not the last value, so I’m not sure what’s happening.
/**
* Polls the target dimensions from the dashboard.
* If they are not present, it returns {-1, -1}.
*
* @return an array of the {x center of mass, y center of mass}
* */
public double] getTargetCenterOfMass(){
double x = -1;
double y = -1;
try{
x = SmartDashboard.getNumber("vision_target_x_cm");
y = SmartDashboard.getNumber("vision_target_y_cm");
}catch(Exception e){
e.printStackTrace();
}
double data] = {x, y};
return data;
}
I attached a screenshot of the console where I was debugging our targeting when this started happening (and it has happened many times before, but only this season since we just started using Java this year).
I can see through the Network Variables tab on the LabVIEW dashboard that the values are indeed being updated, yet the Java SmartDashbord.getNumber() is not reflecting the changes. Sometimes disconnecting, waiting, and reconnecting to the robot fixes it. Other times I have to reboot the robot.
Does anyone know why this would happen?
Thanks in advance.