For Valentine's Day, I will spoiler with a spring bouquet.
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 Today, 12:04
jcbaker4050's Avatar
jcbaker4050 jcbaker4050 is offline
Registered User
AKA: John Baker
FRC #4050 (Biohazard)
Team Role: Mentor
 
Join Date: Dec 2016
Rookie Year: 2016
Location: Waynesboro, PA
Posts: 5
jcbaker4050 is an unknown quantity at this point
Creating a custom NetworkTable?

Like a number of other teams, Team 4050 is getting into vision processing this year for the first time. Our processing is pretty rudimentary but so far seems really reliable in picking out the gear lift.

Again, like others, we're looking to run our vision code on a Raspberry Pi. (We were originally planning to use a Jetson, but that introduced more hurdles.) However, the issue that we have run into is our complete inexperience with NetworkTables. We want to create a custom NetworkTable that contains the data that the RPi needs to communicate to the roboRIO so that it knows how to control the robot (e.g., turn left, go forward at 50% speed, etc.) Our lead programmer and I have spent a bunch of time researching NetworkTables; however, in every example that we've found, it assumes that the NT already exists.

We feel we understand the client side of things. What we need to know is how to create the NetworkTable so that it's there for the client to update.

Any suggestions, advice, or examples would be greatly appreciated.
Reply With Quote
  #2   Spotlight this post!  
Unread Today, 12:20
SamCarlberg's Avatar
SamCarlberg SamCarlberg is offline
GRIP, WPILib. 2084 alum
FRC #2084
Team Role: Mentor
 
Join Date: Nov 2015
Rookie Year: 2009
Location: MA
Posts: 169
SamCarlberg is a splendid one to beholdSamCarlberg is a splendid one to beholdSamCarlberg is a splendid one to beholdSamCarlberg is a splendid one to beholdSamCarlberg is a splendid one to beholdSamCarlberg is a splendid one to beholdSamCarlberg is a splendid one to behold
Re: Creating a custom NetworkTable?

Networktables.getTable() will create a new table with that name if it doesn't already exist. Ditto for getSubtable()
__________________
WPILib
GRIP, RobotBuilder
Reply With Quote
  #3   Spotlight this post!  
Unread Today, 12:23
Thad House Thad House is offline
Volunteer, WPILib Contributor
no team (Waiting for 2021)
Team Role: Mentor
 
Join Date: Feb 2011
Rookie Year: 2010
Location: Thousand Oaks, California
Posts: 1,109
Thad House has a reputation beyond reputeThad House has a reputation beyond reputeThad House has a reputation beyond reputeThad House has a reputation beyond reputeThad House has a reputation beyond reputeThad House has a reputation beyond reputeThad House has a reputation beyond reputeThad House has a reputation beyond reputeThad House has a reputation beyond reputeThad House has a reputation beyond reputeThad House has a reputation beyond repute
Re: Creating a custom NetworkTable?

Quote:
Originally Posted by jcbaker4050 View Post
Like a number of other teams, Team 4050 is getting into vision processing this year for the first time. Our processing is pretty rudimentary but so far seems really reliable in picking out the gear lift.

Again, like others, we're looking to run our vision code on a Raspberry Pi. (We were originally planning to use a Jetson, but that introduced more hurdles.) However, the issue that we have run into is our complete inexperience with NetworkTables. We want to create a custom NetworkTable that contains the data that the RPi needs to communicate to the roboRIO so that it knows how to control the robot (e.g., turn left, go forward at 50% speed, etc.) Our lead programmer and I have spent a bunch of time researching NetworkTables; however, in every example that we've found, it assumes that the NT already exists.

We feel we understand the client side of things. What we need to know is how to create the NetworkTable so that it's there for the client to update.

Any suggestions, advice, or examples would be greatly appreciated.
Do you already have the connection started? If not, use the following code on the client side to start up a connection. I'm going to assume your RPi is in Java for now, but these are all very similar in any other language.

Code:
NetworkTable.setClientMode();
NetworkTable.setTeam(xxxx);
NetworkTable.initialize();
(Replace xxxx with your team number).

From that point, you can call
Code:
NetworkTable table = NetworkTable.getTable("Table_Name_Here");
to get access to any table. You can call this function on both the robot side and the client side, and each will get a reference to the specified table, and you can use the newly created table variable to pass data between the two.

Note that on the robot, NetworkTables is already set up, so you only need to call the getTable function.
__________________
All statements made are my own and not the feelings of any of my affiliated teams.
Teams 1510 and 2898 - Student 2010-2012
Team 4488 - Mentor 2013-2016
Co-developer of RobotDotNet, a .NET port of the WPILib.
Reply With Quote
  #4   Spotlight this post!  
Unread Today, 13:34
jcbaker4050's Avatar
jcbaker4050 jcbaker4050 is offline
Registered User
AKA: John Baker
FRC #4050 (Biohazard)
Team Role: Mentor
 
Join Date: Dec 2016
Rookie Year: 2016
Location: Waynesboro, PA
Posts: 5
jcbaker4050 is an unknown quantity at this point
Re: Creating a custom NetworkTable?

Quote:
Originally Posted by SamCarlberg View Post
Networktables.getTable() will create a new table with that name if it doesn't already exist. Ditto for getSubtable()
That smacking sound that you just heard was me face-palming myself. We spent hours reading literally dozens of articles and threads trying to figure this out, and not once did anywhere ever mention getTable() creating tables. Thanks, Sam, for cluing us in.

Thanks to a post in another thread (https://www.chiefdelphi.com/forums/s...17#post1524417) I also figured out that I didn't have the "Windows/amd64" ntcore library in my NetworkTables.jar. (I'm currently working on my Win7 laptop.) I got that resolved.

I now can successfully write to a NetworkTable and see the new tables and values in Outline Viewer.

This just made my week! Thank you!
Reply With Quote
  #5   Spotlight this post!  
Unread Today, 13:42
virtuald's Avatar
virtuald virtuald is online now
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,117
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: Creating a custom NetworkTable?

If you were using python (a lot of teams find OpenCV easier to use in python), the pynetworktables documentation has a lot of examples of various networktables things you can look at: http://robotpy.readthedocs.io/projec.../examples.html

Curiously enough, I hadn't ever thought about the fact that one might think that a 'table' needs to be created. I'll add a note about that to our docs.
__________________
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 Today, 14:04
jcbaker4050's Avatar
jcbaker4050 jcbaker4050 is offline
Registered User
AKA: John Baker
FRC #4050 (Biohazard)
Team Role: Mentor
 
Join Date: Dec 2016
Rookie Year: 2016
Location: Waynesboro, PA
Posts: 5
jcbaker4050 is an unknown quantity at this point
Re: Creating a custom NetworkTable?

Quote:
Originally Posted by virtuald View Post
If you were using python (a lot of teams find OpenCV easier to use in python), the pynetworktables documentation has a lot of examples of various networktables things you can look at: http://robotpy.readthedocs.io/projec.../examples.html

Curiously enough, I hadn't ever thought about the fact that one might think that a 'table' needs to be created. I'll add a note about that to our docs.
I have noticed that there are far more C++ and Python OpenCV examples and tutorials than for Java, which is where most of our experience currently is. (Well, most of it actually still is in LabVIEW.) Python will be something to think about for future years.

As far as the table creation, I work with databases in my 8-5, so in my mind, a table doesn't exist unless you create it explicitly. Kind of funny how experience can help determine perspectives.
Reply With Quote
  #7   Spotlight this post!  
Unread Today, 14:35
Peter Johnson Peter Johnson is offline
WPILib Developer
FRC #0294 (Beach Cities Robotics)
Team Role: Mentor
 
Join Date: Jan 2010
Rookie Year: 2008
Location: Redondo Beach, CA
Posts: 270
Peter Johnson has much to be proud ofPeter Johnson has much to be proud ofPeter Johnson has much to be proud ofPeter Johnson has much to be proud ofPeter Johnson has much to be proud ofPeter Johnson has much to be proud ofPeter Johnson has much to be proud ofPeter Johnson has much to be proud of
Re: Creating a custom NetworkTable?

Quote:
Originally Posted by jcbaker4050 View Post
As far as the table creation, I work with databases in my 8-5, so in my mind, a table doesn't exist unless you create it explicitly. Kind of funny how experience can help determine perspectives.
Tables in NetworkTables are a convention to help organize keys into logical groupings by using "/" as a separator; the actual NetworkTables key namespace is flat. Tables themselves don't really exist (except as an object in your code to keep track of the table path for convenience sake), so it's not actually necessary to create or delete them.

For example, getTable("/").putNumber("foo/bar", 5) and getTable("/foo").putNumber("bar", 5) are exactly equivalent (both set the key "/foo/bar" to 5).
__________________
Author of cscore - WPILib CameraServer for 2017+
Author of ntcore - WPILib NetworkTables for 2016+
Creator of RobotPy - Python for FRC

2010 FRC World Champions (294, 67, 177)
2007 FTC World Champions (30, 74, 23)
2001 FRC National Champions (71, 294, 125, 365, 279)
Reply With Quote
  #8   Spotlight this post!  
Unread Today, 14:40
jcbaker4050's Avatar
jcbaker4050 jcbaker4050 is offline
Registered User
AKA: John Baker
FRC #4050 (Biohazard)
Team Role: Mentor
 
Join Date: Dec 2016
Rookie Year: 2016
Location: Waynesboro, PA
Posts: 5
jcbaker4050 is an unknown quantity at this point
Re: Creating a custom NetworkTable?

Quote:
Originally Posted by Peter Johnson View Post
Tables in NetworkTables are a convention to help organize keys into logical groupings by using "/" as a separator; the actual NetworkTables key namespace is flat. Tables themselves don't really exist (except as an object in your code to keep track of the table path for convenience sake), so it's not actually necessary to create or delete them.

For example, getTable("/").putNumber("foo/bar", 5) and getTable("/foo").putNumber("bar", 5) are exactly equivalent (both set the key "/foo/bar" to 5).
Peter, thanks for the additional information. That's a bit different than Oracle database tables, which is what I'm used to. Makes sense, though. And seems easy enough to work with now that I've had my misconceptions cleared up.
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 15:31.

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