View Single Post
  #1   Spotlight this post!  
Unread 26-03-2013, 10:14
fovea1959's Avatar
fovea1959 fovea1959 is offline
Herder of programmers
AKA: Doug Wegscheid
FRC #3620 (The Average Joes)
Team Role: Mentor
 
Join Date: Jan 2011
Rookie Year: 2011
Location: St Joseph
Posts: 330
fovea1959 will become famous soon enough
Updating the Dashboard

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:

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?
Reply With Quote