fovea1959
26-03-2013, 10:14
probably moving from LV to Java for 2014, starting to think about how we did some things in LV, and what the corresponding analogs in Java would be. Can't start slinging code for a while, no cRIOs to practice with (all are on bots), so asking questions right now instead of trying.
If one has put together a command based Java robot, and one wants to have continuous updates in the dashboard of critical sensors, is creating and scheduling a TimerTask to do the updates a good practice? I'm looking at Frog Force' 2013 code:
private static final TimerTask SpeedTask = new TimerTask(){
// ..
public void run() {
if(isOn()&& DriverStation.getInstance().isEnabled()){
SmartDashboard.putNumber("Shooter Output", output);
SmartDashboard.putNumber("gear tooth speed graph", speed);
SmartDashboard.putNumber("gear tooth speed view", speed);
// ...
}
}
};
private static final long SPEED_TASK_PERIOD = 60;
private static final Timer timer = new Timer();
static{
timer.schedule(SpeedTask, 0, SPEED_TASK_PERIOD);
}
Are there alternative practices?
If one has put together a command based Java robot, and one wants to have continuous updates in the dashboard of critical sensors, is creating and scheduling a TimerTask to do the updates a good practice? I'm looking at Frog Force' 2013 code:
private static final TimerTask SpeedTask = new TimerTask(){
// ..
public void run() {
if(isOn()&& DriverStation.getInstance().isEnabled()){
SmartDashboard.putNumber("Shooter Output", output);
SmartDashboard.putNumber("gear tooth speed graph", speed);
SmartDashboard.putNumber("gear tooth speed view", speed);
// ...
}
}
};
private static final long SPEED_TASK_PERIOD = 60;
private static final Timer timer = new Timer();
static{
timer.schedule(SpeedTask, 0, SPEED_TASK_PERIOD);
}
Are there alternative practices?