View Single Post
  #7   Spotlight this post!  
Unread 20-08-2012, 22:00
Djur's Avatar
Djur Djur is offline
WPILib
AKA: Sam Carlberg
no team
Team Role: Mentor
 
Join Date: Jan 2011
Rookie Year: 2009
Location: Massachusetts
Posts: 182
Djur will become famous soon enough
Re: Getting values from SmartDashboard

To answer OP's question, you could call NetworkTable.putDouble() in a widget to send a number and then call NetworkTable.getDouble() in the robot's code to retrieve it.

Driver's side:
Code:
NetworkTable.getTable("SmartDashboard").putDouble("Pi", 3.14159);
Robot side:
Code:
double pi = NetworkTable.getTable("SmartDashboard").getDouble("Pi");
Slightly offtopic here; this is aimed towards Ginto8.
Quote:
Originally Posted by Ginto8 View Post
You would put the code wherever you want to send or receive a new value - for example, if you have an extension that retrieves the state of the robot's drive train, you could have a TimerTask which periodically refreshes it, and the data retrieval would go in there.

I'm pretty sure that there's also some way to have the data automatically refreshed when it changes, but I haven't figured out how to use it yet - though I'm guessing it's possible by implementing NetworkListener or NetworkAdditionListener.
Don't bother with using a TimerTask; the new NetworkTables will use listeners to update values when they change in the table.
__________________
WPILib dev (RobotBuilder, SmartDashboard, GRIP)
Reply With Quote