Go to Post And then since this is GTR-W there's also maple syrup somewhere and the drive team says "Sooory." - PayneTrain [more]
Home
Go Back   Chief Delphi > Technical > Programming > Java
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
Reply
Thread Tools Rate Thread Display Modes
  #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
  #2   Spotlight this post!  
Unread 26-03-2013, 15:20
Ginto8's Avatar
Ginto8 Ginto8 is offline
Programming Lead
AKA: Joe Doyle
FRC #2729 (Storm)
Team Role: Programmer
 
Join Date: Oct 2010
Rookie Year: 2010
Location: Marlton, NJ
Posts: 174
Ginto8 is a glorious beacon of lightGinto8 is a glorious beacon of lightGinto8 is a glorious beacon of lightGinto8 is a glorious beacon of lightGinto8 is a glorious beacon of light
Re: Updating the Dashboard

We actually use a Command to update values to the dashboard, which, if you're calling Scheduler.getInstance().run() in both Periodic() methods, has the same effect as that TimerTask (though a different frequency). I have considered changing it to something that will send data regardless of whether the robot is enabled, but I'm loathe to change working code any more than I have to. Maybe next year.
__________________
I code stuff.
Reply With Quote
  #3   Spotlight this post!  
Unread 26-03-2013, 15:49
Bryce Paputa's Avatar
Bryce Paputa Bryce Paputa is offline
FF TSL: Frog Farce
FRC #0503 (Frog Force)
Team Role: Alumni
 
Join Date: Jan 2012
Rookie Year: 2008
Location: Novi Michigan
Posts: 454
Bryce Paputa has a reputation beyond reputeBryce Paputa has a reputation beyond reputeBryce Paputa has a reputation beyond reputeBryce Paputa has a reputation beyond reputeBryce Paputa has a reputation beyond reputeBryce Paputa has a reputation beyond reputeBryce Paputa has a reputation beyond reputeBryce Paputa has a reputation beyond reputeBryce Paputa has a reputation beyond reputeBryce Paputa has a reputation beyond reputeBryce Paputa has a reputation beyond repute
Re: Updating the Dashboard

We used the timer task so we could change the frame rate of the speed control without effecting everything else, for most of the sensor stuff we either put it where the sensor was being used, or in the main file's teleopPeriodic. Either way works, however, putting them in teleopPeriodic is probably a bit more organized.
Reply With Quote
  #4   Spotlight this post!  
Unread 26-03-2013, 21:17
shindigo shindigo is offline
Registered User
AKA: Mike Parker
FRC #0102
Team Role: Mentor
 
Join Date: Feb 2012
Rookie Year: 2009
Location: Somerville, NJ
Posts: 33
shindigo is an unknown quantity at this point
Re: Updating the Dashboard

We're very interested in this:
Quote:
Originally Posted by Ginto8 View Post
will send data regardless of whether the robot is enabled,
Any advice on an approach to this?
Reply With Quote
  #5   Spotlight this post!  
Unread 26-03-2013, 22:11
Ginto8's Avatar
Ginto8 Ginto8 is offline
Programming Lead
AKA: Joe Doyle
FRC #2729 (Storm)
Team Role: Programmer
 
Join Date: Oct 2010
Rookie Year: 2010
Location: Marlton, NJ
Posts: 174
Ginto8 is a glorious beacon of lightGinto8 is a glorious beacon of lightGinto8 is a glorious beacon of lightGinto8 is a glorious beacon of lightGinto8 is a glorious beacon of light
Re: Updating the Dashboard

Quote:
Originally Posted by shindigo View Post
Any advice on an approach to this?
Well, NetworkTables, SmartDashboard and sensors don't depend on the robot being enabled; as far as I know, the only things hardware-wise that are really disabled by disabled mode are PWMs (and possibly normal digital outputs, but I have only know PWMs for certain). So if you have a TimerTask like in the original post, but remove the condition checking for an on/enabled state, it should continue sending data even in disabled mode.
__________________
I code stuff.
Reply With Quote
  #6   Spotlight this post!  
Unread 26-03-2013, 22:56
Joe Ross's Avatar Unsung FIRST Hero
Joe Ross Joe Ross is offline
Registered User
FRC #0330 (Beachbots)
Team Role: Engineer
 
Join Date: Jun 2001
Rookie Year: 1997
Location: Los Angeles, CA
Posts: 8,561
Joe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond repute
Re: Updating the Dashboard

Quote:
Originally Posted by Ginto8 View Post
We actually use a Command to update values to the dashboard, which, if you're calling Scheduler.getInstance().run() in both Periodic() methods, has the same effect as that TimerTask (though a different frequency). I have considered changing it to something that will send data regardless of whether the robot is enabled, but I'm loathe to change working code any more than I have to. Maybe next year.
If you call the setRunWhileDisabled method for your command and add the scheduler run to disabledPeriodic, you can run your command while disabled with minimal code changes.
Reply With Quote
  #7   Spotlight this post!  
Unread 26-03-2013, 23:17
Ginto8's Avatar
Ginto8 Ginto8 is offline
Programming Lead
AKA: Joe Doyle
FRC #2729 (Storm)
Team Role: Programmer
 
Join Date: Oct 2010
Rookie Year: 2010
Location: Marlton, NJ
Posts: 174
Ginto8 is a glorious beacon of lightGinto8 is a glorious beacon of lightGinto8 is a glorious beacon of lightGinto8 is a glorious beacon of lightGinto8 is a glorious beacon of light
Re: Updating the Dashboard

Quote:
Originally Posted by Joe Ross View Post
If you call the setRunWhileDisabled method for your command and add the scheduler run to disabledPeriodic, you can run your command while disabled with minimal code changes.
I didn't even realize this functionality existed. That's pretty awesome.
__________________
I code stuff.
Reply With Quote
Reply


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT -5. The time now is 09:52.

The Chief Delphi Forums are sponsored by Innovation First International, Inc.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi