Go to Post The people that have posted in this thread are intelligent and I know that when they talk, I need to listen. - rtfgnow [more]
Home
Go Back   Chief Delphi > Technical > Programming > C/C++
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 10-02-2014, 18:05
Goldenchest Goldenchest is offline
Goldenchest
AKA: Gary Chien
FRC #1758 (Technomancers)
Team Role: Programmer
 
Join Date: Dec 2012
Rookie Year: 2010
Location: United States
Posts: 17
Goldenchest is an unknown quantity at this point
Using NetworkTables in C++ (need a quick and concise tutorial)

Disclaimer: I have only been programming for a little over a year, so I am still somewhat of an amateur.

My team is thinking of using our driver station to do image processing and sending data to and from the robot. I did some digging around and learned about WPILib's NetworkTable, and I heard about how simple it is to use. However, I'm having some trouble finding sufficient documentation to learn how to use NetworkTable. This is the only thing I could find:

http://wpilib.screenstepslive.com/s/...client-pc-side

However, the most crucial part of the documentation ("The client (laptop) side of the program") is written in Java, which I have been unable to successfully translate into C++. Do any of you know where I could find similar documentation on NetworkTable, specifically for C++? If not, could anyone sort of summarize how it should be used and provide examples in C++? Thank you!
Reply With Quote
  #2   Spotlight this post!  
Unread 10-02-2014, 21:43
BradAMiller BradAMiller is offline
Registered User
AKA: Brad
#0190 ( Gompei and the Herd)
Team Role: Mentor
 
Join Date: Mar 2004
Location: Worcester, MA
Posts: 591
BradAMiller has a brilliant futureBradAMiller has a brilliant futureBradAMiller has a brilliant futureBradAMiller has a brilliant futureBradAMiller has a brilliant futureBradAMiller has a brilliant futureBradAMiller has a brilliant futureBradAMiller has a brilliant futureBradAMiller has a brilliant futureBradAMiller has a brilliant futureBradAMiller has a brilliant future
Re: Using NetworkTables in C++ (need a quick and concise tutorial)

We only supplied a Java desktop version of NetworkTables. Is it possible that you can use that for your application? The problem was that the Windows networking was different enough from our linux test version that it made it difficult to port.
__________________
Brad Miller
Robotics Resource Center
Worcester Polytechnic Institute
Reply With Quote
  #3   Spotlight this post!  
Unread 10-02-2014, 22:15
Goldenchest Goldenchest is offline
Goldenchest
AKA: Gary Chien
FRC #1758 (Technomancers)
Team Role: Programmer
 
Join Date: Dec 2012
Rookie Year: 2010
Location: United States
Posts: 17
Goldenchest is an unknown quantity at this point
Re: Using NetworkTables in C++ (need a quick and concise tutorial)

In that case, are there any C++ based alternatives that you could suggest similar to NetworkTables that can easily send data to and from the robot? I would rather avoid using Java if at all possible, because none of the mentors on my team are familiar with that language.

I wouldn't mind teaching myself some network socket programming if need be. If you could direct me to documentation of any kind relating to communicating between the robot and the driver station, that would be great. Thanks for the response!
Reply With Quote
  #4   Spotlight this post!  
Unread 11-02-2014, 18:05
mhaeberli mhaeberli is offline
Registered User
FRC #3045
 
Join Date: Feb 2014
Location: Redwood City
Posts: 88
mhaeberli is on a distinguished road
Re: Using NetworkTables in C++ (need a quick and concise tutorial)

Hi,

We are facing the same problem / opportunity.

We have recently made good progress in building a prototype interface between C++ and the networktables-desktop.jar java library on the drive laptop Windows platform by using JNI (Java Native Interface).

There is also suggestion from charrisTTI via ChiefDelphi a few years ago at http://www.chiefdelphi.com/forums/sh...d.php?t=103352 that IKVM can be used to convert the .jar into a .dll. Generally, see: http://www.ikvm.net . I have tried it, but I haven't myself had much luck with that beyond the immediate conversion.

It's a little subtle, though.
Basically, the plan is:
-create a JVM instance with its class path pointing at the networktables-desktop.jar
-find and call the appropriate Java methods
If using Visual Studio 2010 C++, which is what we are doing, one has to take some care that the system PATH environment variable is set correctly for the JRE (Java Runtime), etc.

If there is interest, I may be able to post very rough but working code samples via GitHub.

I look forward to responses.

Best,

Martin Haeberli
(one of many)
Mentor(s) to FRC team 3045 - SWAT - San Mateo, CA
----
PS - where is the original NetworkTables java code kept - in GitHub? The WPI FirstForge code doesn't seem to be the most current.
Reply With Quote
  #5   Spotlight this post!  
Unread 11-02-2014, 18:06
mhaeberli mhaeberli is offline
Registered User
FRC #3045
 
Join Date: Feb 2014
Location: Redwood City
Posts: 88
mhaeberli is on a distinguished road
Re: Using NetworkTables in C++ (need a quick and concise tutorial)

Brad,
Can you please point us at the official current source code repository for NetworkTables, especially for networktables-desktop.jar
Thanks,
Martin
Reply With Quote
  #6   Spotlight this post!  
Unread 11-02-2014, 18:14
Goldenchest Goldenchest is offline
Goldenchest
AKA: Gary Chien
FRC #1758 (Technomancers)
Team Role: Programmer
 
Join Date: Dec 2012
Rookie Year: 2010
Location: United States
Posts: 17
Goldenchest is an unknown quantity at this point
Re: Using NetworkTables in C++ (need a quick and concise tutorial)

mhaeberli, it would be great if you would share the GitHub codes!
Reply With Quote
  #7   Spotlight this post!  
Unread 11-02-2014, 18:41
mhaeberli mhaeberli is offline
Registered User
FRC #3045
 
Join Date: Feb 2014
Location: Redwood City
Posts: 88
mhaeberli is on a distinguished road
Re: Using NetworkTables in C++ (need a quick and concise tutorial)

Gary,
I'll try to git it posted on Github tonight and then share it...
YMMV (your mileage may vary)
Best,
Martin
Reply With Quote
  #8   Spotlight this post!  
Unread 11-02-2014, 21:12
mhaeberli mhaeberli is offline
Registered User
FRC #3045
 
Join Date: Feb 2014
Location: Redwood City
Posts: 88
mhaeberli is on a distinguished road
Re: Using NetworkTables in C++ (need a quick and concise tutorial)

Gary,
(and other interested parties):
Here is a kludgy first pass:
https://github.com/SWATRobotics/JniBridgeTest1/
to test it out without a robot, run TableViewer in server mode on, say, the local host. Let's say that localhost's IP address is 1.2.3.4. Change the IP address in the code to "1.2.3.4". (and the PATH environment variable needs to be right, and this code assumes that networktables-desktop.jar is at C:\Windriver\WPILib\desktop-lib\) The JDK and/or the JRE needs to be installed already. I suspect that I have left some dangling references in, which may be why the destroyJVM call had to be commented out.
This is NOT a complete interface to NetworkTables; additional methods can be added. I'll try to post the method signatures for the whole NetworkTables as an additional commit later.
Please let me know if you have any questions.
Best,
Martin
Reply With Quote
  #9   Spotlight this post!  
Unread 12-02-2014, 20:44
ekapalka's Avatar
ekapalka ekapalka is offline
Registered User
FRC #3216
 
Join Date: Dec 2012
Location: Bermuda
Posts: 277
ekapalka has a spectacular aura aboutekapalka has a spectacular aura about
Re: Using NetworkTables in C++ (need a quick and concise tutorial)

I'm guessing everyone here that has posted here has already considered / tried this already, but why not just use TCP / UDP? My team has tried sending data from computer to computer with success, and there's a lot of documented instances of teams using either protocol to send information to and from the cRIO (most of what I've seen have been in regards to sending stills gathered from vision processing to the DS). What we've tried hasn't been particularly difficult, but we have yet to try to integrate with the cRIO...
Reply With Quote
  #10   Spotlight this post!  
Unread 12-02-2014, 21:37
mhaeberli mhaeberli is offline
Registered User
FRC #3045
 
Join Date: Feb 2014
Location: Redwood City
Posts: 88
mhaeberli is on a distinguished road
Re: Using NetworkTables in C++ (need a quick and concise tutorial)

Hi ekapalka,

I'm probably just being dense, but it looks like the standard C++ runtime WPILib on the robot end does not directly support TCP / UDP. NetworkTables support is included.

It looks like there is at least some sockets support in the robot-side Java code. But our team has chosen for whatever set of reasons to use C++ both on the drive station side and on the robot.

Best,

Martin
Reply With Quote
  #11   Spotlight this post!  
Unread 12-02-2014, 21:58
ekapalka's Avatar
ekapalka ekapalka is offline
Registered User
FRC #3216
 
Join Date: Dec 2012
Location: Bermuda
Posts: 277
ekapalka has a spectacular aura aboutekapalka has a spectacular aura about
Re: Using NetworkTables in C++ (need a quick and concise tutorial)

I don't think it's practical, but I based on what I've seen in the NetworkTables code in WPIlib, it appears that VxWorks uses the Berkeley (BSD)/POSIX sockets API (so most Linux / Unix socket code should function). If I'm wrong about that, I'm sure that this thread has sufficient information on how to do it (just skip past all the pessimism in the first few posts) :)
Reply With Quote
  #12   Spotlight this post!  
Unread 12-02-2014, 22:04
wireties's Avatar
wireties wireties is offline
Principal Engineer
AKA: Keith Buchanan
FRC #1296 (Full Metal Jackets)
Team Role: Mentor
 
Join Date: Jan 2006
Rookie Year: 2004
Location: Rockwall, TX
Posts: 1,170
wireties has a reputation beyond reputewireties has a reputation beyond reputewireties has a reputation beyond reputewireties has a reputation beyond reputewireties has a reputation beyond reputewireties has a reputation beyond reputewireties has a reputation beyond reputewireties has a reputation beyond reputewireties has a reputation beyond reputewireties has a reputation beyond reputewireties has a reputation beyond repute
Send a message via AIM to wireties
Re: Using NetworkTables in C++ (need a quick and concise tutorial)

The operating system supports TCP/IP via the Berkeley socket interface. Support via the WPI and/or NI libraries is unnecessary. Most Linux networking example code on the net will run with few or no changes on the robot (in C or C++).

HTH
__________________
Fast, cheap or working - pick any two!

Last edited by wireties : 13-02-2014 at 13:35.
Reply With Quote
  #13   Spotlight this post!  
Unread 13-02-2014, 00:47
mhaeberli mhaeberli is offline
Registered User
FRC #3045
 
Join Date: Feb 2014
Location: Redwood City
Posts: 88
mhaeberli is on a distinguished road
Re: Using NetworkTables in C++ (need a quick and concise tutorial)

wireties / Keith,
Thanks for that observation. We'll keep it in mind.
That said, NetworkTables looks pretty easy to use, now that we have the framework in place.
Best,
Martin
Reply With Quote
  #14   Spotlight this post!  
Unread 13-02-2014, 10:44
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,082
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: Using NetworkTables in C++ (need a quick and concise tutorial)

The pynetworktables project provides bindings to NetworkTables in python. They have been tested on Linux, Windows, and OSX.

The python bindings are based on the C++ WPILib source releases. Some changes have been made to support building on other platforms, like windows. You can find the fixed version of WPILib (which includes NetworkTables) on github, you should be able to build it on Windows without any problems if you create a usable build environment for it. Note that you will need your own implementations of some of the WPILib/vxWorks components to build it -- the components that pynetworktables uses is found here.
__________________
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

Last edited by virtuald : 13-02-2014 at 12:26.
Reply With Quote
  #15   Spotlight this post!  
Unread 13-02-2014, 10:58
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,082
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: Using NetworkTables in C++ (need a quick and concise tutorial)

Quote:
Originally Posted by BradAMiller View Post
We only supplied a Java desktop version of NetworkTables. Is it possible that you can use that for your application? The problem was that the Windows networking was different enough from our linux test version that it made it difficult to port.
I've had the Windows version of NetworkTables C++ working for over a year now. Perhaps you guys should borrow my changes? (see above)
__________________
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
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 03:21.

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