Go to Post Omni wheels are cool... but mecanum wheels are COOL!! - dtengineering [more]
Home
Go Back   Chief Delphi > Technical > Programming
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 31-08-2016, 22:05
Technologyman00's Avatar
Technologyman00 Technologyman00 is offline
Registered User
AKA: Collin
FRC #1792 (Round Table Robotics)
Team Role: Mechanical
 
Join Date: Nov 2015
Rookie Year: 2015
Location: Oak Creek WI
Posts: 23
Technologyman00 is an unknown quantity at this point
Send Variables to Other Programs Besides SDB

Is there anyway to send variables to another program besides Smart Dashboard or at least read off of smart dashboard with another program on the PC?

Thanks, Collin
Reply With Quote
  #2   Spotlight this post!  
Unread 31-08-2016, 22:07
414cnewq 414cnewq is offline
Registered User
FRC #3844 (Kentucky Wildbots)
Team Role: Alumni
 
Join Date: Jul 2014
Rookie Year: 2014
Location: KY
Posts: 86
414cnewq has much to be proud of414cnewq has much to be proud of414cnewq has much to be proud of414cnewq has much to be proud of414cnewq has much to be proud of414cnewq has much to be proud of414cnewq has much to be proud of414cnewq has much to be proud of414cnewq has much to be proud of414cnewq has much to be proud of
Re: Send Variables to Other Programs Besides SDB

You can create a socket within a roborio program and then you can write a client program listening to that socket and responding based on the data.
(Edit: Gross Oversimplification. I am no networking expert, someone else on this forum could help you substantially better with this than I can)
Reply With Quote
  #3   Spotlight this post!  
Unread 01-09-2016, 07:37
SndMndBdy SndMndBdy is offline
Registered User
FRC #3419
 
Join Date: Jan 2013
Location: New York
Posts: 18
SndMndBdy is on a distinguished road
Thumbs down Re: Send Variables to Other Programs Besides SDB

On team 3419, we've done what 414cnewq is suggesting (talk via a custom socket between the roboRIO and a program running on the laptop). Unless you're an experienced networking programmer, it can be a quite a bit tricky. That being said, if you want to learn about the low level details of how computers communicate with each other in the "real world", this is a great educational exercise. It's also a good approach if you need to do something very with very low-latency, like having a USB camera on the roboRIO and processing the images on the laptop.

If you want a simpler approach, you can use the NetworkTables. This is how the roboRIO and SmartDashboard talk to each other, and you can write code that acts like the SmartDashboard to read the data. Here's a java example:

-Import NetworkTables.jar (the location changes from year to year. last year it was C:\Users\<USERNAME>\wpilib\java\current\lib). You may also need to include SmartDashboard.jar but I don't think so.
-Create a NetworkTable member variable:


private NetworkTable mNetworkTable;

-Initialize it at startup. I forget if the first two lines here are necessary. I think they are in general, but might not be if you are running in the context of the smartdashboard (like a custom widget)

NetworkTable.setIPAddress("roborio-3419-frc.local");
NetworkTable.setClientMode();

mNetworkTable = NetworkTable.getTable("SmartDashboard");

-To read data out of it, use a line like this:

mNetworkTable.getNumber("SomeVariableThatYouSetOnT heRIO", aDefaultInCaseItHasntBeenSet);

There is also a .NET implementation of NetworkTables ( https://github.com/robotdotnet/NetworkTablesDotNet ). The similar lines of code in C# are:

Declare it:
private NetworkTables.NetworkTable mSmartDashboardTable;


Initialize it:
NetworkTable.SetIPAddress("roborio-3419-frc.local");
//Set Client Mode
NetworkTable.SetClientMode();
//Initialize the client
NetworkTable.Initialize();
mSmartDashboardTable = NetworkTable.GetTable("SmartDashboard");

Use it:
mSmartDashboardTable.GetNumber("SomeVariable", theDefault);


I think there is a C++ implementation as well.

Hope this helps.
Reply With Quote
  #4   Spotlight this post!  
Unread 01-09-2016, 08:13
adciv adciv is offline
One Eyed Man
FRC #0836 (RoboBees)
Team Role: Mentor
 
Join Date: Jan 2012
Rookie Year: 2010
Location: Southern Maryland
Posts: 478
adciv is a name known to alladciv is a name known to alladciv is a name known to alladciv is a name known to alladciv is a name known to alladciv is a name known to all
Re: Send Variables to Other Programs Besides SDB

Quote:
Originally Posted by SndMndBdy View Post
I think there is a C++ implementation as well.
There's also a LabView implementation. I think using network tables is the recommended solution 99% of the time. The 1% comes down to high performance (lower latency) requirements.
__________________
Quote:
Originally Posted by texarkana View Post
I would not want the task of devising a system that 50,000 very smart people try to outwit.
Reply With Quote
  #5   Spotlight this post!  
Unread 01-09-2016, 16:45
virtuald's Avatar
virtuald virtuald is offline
RobotPy Guy
AKA: Dustin Spicuzza
FRC #1418 (), FRC #1973, FRC #4796, FRC #6367 ()
Team Role: Mentor
 
Join Date: Dec 2008
Rookie Year: 2003
Location: Boston, MA
Posts: 1,058
virtuald has a brilliant futurevirtuald has a brilliant futurevirtuald has a brilliant futurevirtuald has a brilliant futurevirtuald has a brilliant futurevirtuald has a brilliant futurevirtuald has a brilliant futurevirtuald has a brilliant futurevirtuald has a brilliant futurevirtuald has a brilliant futurevirtuald has a brilliant future
Re: Send Variables to Other Programs Besides SDB

You can write a dashboard in HTML/Javascript that communicates via NetworkTables too.

https://github.com/robotpy/pynetworktables2js
__________________
Maintainer of RobotPy - Python for FRC
Creator of pyfrc (Robot Simulator + utilities for Python) and pynetworktables/pynetworktables2js (NetworkTables for Python & Javascript)

2017 Season: Teams #1973, #4796, #6369
Team #1418 (remote mentor): Newton Quarterfinalists, 2016 Chesapeake District Champion, 2x Innovation in Control award, 2x district event winner
Team #1418: 2015 DC Regional Innovation In Control Award, #2 seed; 2014 VA Industrial Design Award; 2014 Finalists in DC & VA
Team #2423: 2012 & 2013 Boston Regional Innovation in Control Award


Resources: FIRSTWiki (relaunched!) | My Software Stuff
Reply With Quote
  #6   Spotlight this post!  
Unread 01-09-2016, 17:05
euhlmann's Avatar
euhlmann euhlmann is offline
CTO, Programmer
AKA: Erik Uhlmann
FRC #2877 (LigerBots)
Team Role: Leadership
 
Join Date: Dec 2015
Rookie Year: 2015
Location: United States
Posts: 349
euhlmann has much to be proud ofeuhlmann has much to be proud ofeuhlmann has much to be proud ofeuhlmann has much to be proud ofeuhlmann has much to be proud ofeuhlmann has much to be proud ofeuhlmann has much to be proud ofeuhlmann has much to be proud of
Re: Send Variables to Other Programs Besides SDB

The official repo is at https://github.com/wpilibsuite/ntcore
Building it will give you "desktop" versions of ntcore.lib and ntcore-windows.jar that you can use.
Documentation for NetworkTable is included in the standard wpilibc/j docs

(I've also started bindings for ntcore to node.js, if anybody's interested)
__________________
Creator of SmartDashboard.js, an extensible nodejs/webkit replacement for SmartDashboard


https://ligerbots.org
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 00:37.

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