Go to Post As everyone knows, our students don't actually design or build the robot, so to make it look like they were working on it for the video, we hid cookies inside the unfinished frame and turned them loose. It looks believable. - Mike Soukup [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 20-02-2012, 00:43
agartner01 agartner01 is offline
Captain + Control Sys & Design
FRC #4174
Team Role: Engineer
 
Join Date: Feb 2012
Rookie Year: 2012
Location: Hector MN
Posts: 109
agartner01 is an unknown quantity at this point
Network Tables?

Was just hoping someone could give me the down low on what they are used for/ how to use them?
Reply With Quote
  #2   Spotlight this post!  
Unread 20-02-2012, 08:48
charrisTTI charrisTTI is offline
Ramblin' Wreck
AKA: Charles Harris
FRC #0623
Team Role: Mentor
 
Join Date: Jan 2005
Rookie Year: 2003
Location: Vienna, VA
Posts: 106
charrisTTI has a spectacular aura aboutcharrisTTI has a spectacular aura about
Send a message via AIM to charrisTTI
Re: Network Tables?

NetworkTable object can be used to pass data to/from robot code and another program running on another computer on the network. SmartDashboard uses it to pass data to/from robot.

We use it to pass data from image processing software running on the driver station back to the robot.

Here is example code:

Code:
//========================================
//Robot Code
// declare object
NetworkTable cameraTable;

// getinstance (table is a singleton, if one does not exist then one will
// be created otherwise returns reference to existing instance
cameraTable = NetworkTable.getTable("camera");

// get data element from the table
// default values returned if no data has been provided from another source yet

cameraTable.beginTransaction();
Boolean imageFound = cameraTable.getBoolean("found", false );
Double imageOffset = cameraTable.getDouble("offset", -1.0);
Double imageDistance = cameraTable.getDouble("distance", -1.0);
cameraTable.endTransaction();

System.out.println( "found = " + imageFound);
System.out.println( "offset = " + imageOffset);
System.out.println( "distance = " + imageDistance);

//=======================================
// Driver Station PC
// camera image processing is done in C# application on DS

// declare it
private NetworkTable table;

// Init NetworkTable
NetworkTable.setIPAddress("10.6.23.2");  // ip of crio
table = NetworkTable.getTable("camera");


// in the image processing loop

table.beginTransaction();
table.putBoolean("found", true);
table.putDouble("distance", distance);
table.putDouble("offset", offset);
table.endTransaction();
__________________
FRC 623 2003,2004,2005,2006,2007,2008, 2009, 2010, 2011
FRC 1900 2007
FVC 60 and 193 2006
FVC 3271 2007
FTC 226 and 369 2008, 2009, 2010, 2011
FTC 3806 2010
Reply With Quote
  #3   Spotlight this post!  
Unread 20-02-2012, 14:50
mikets's Avatar
mikets mikets is offline
Software Engineer
FRC #0492 (Titan Robotics)
Team Role: Mentor
 
Join Date: Jan 2010
Rookie Year: 2008
Location: Bellevue, WA
Posts: 667
mikets is a glorious beacon of lightmikets is a glorious beacon of lightmikets is a glorious beacon of lightmikets is a glorious beacon of lightmikets is a glorious beacon of lightmikets is a glorious beacon of light
Re: Network Tables?

Quote:
Originally Posted by charrisTTI View Post
NetworkTable object can be used to pass data to/from robot code and another program running on another computer on the network. SmartDashboard uses it to pass data to/from robot.

We use it to pass data from image processing software running on the driver station back to the robot.
Charles, we are interested in doing something with NetworkTable but we are not familiar with it, so here are a few questions:
1. On the Robot side, I can see WPILib has provided the NetworkTable class, so that part seems straight forward.
2. On the PC side, who provides the NetworkTable class. Is there an SDK of some sort we need to download? We are planning to develop with C++ on the PC side with Microsoft Visual Studio (C# is fine too if necessary).
__________________
Reply With Quote
  #4   Spotlight this post!  
Unread 20-02-2012, 15:52
charrisTTI charrisTTI is offline
Ramblin' Wreck
AKA: Charles Harris
FRC #0623
Team Role: Mentor
 
Join Date: Jan 2005
Rookie Year: 2003
Location: Vienna, VA
Posts: 106
charrisTTI has a spectacular aura aboutcharrisTTI has a spectacular aura about
Send a message via AIM to charrisTTI
Re: Network Tables?

NetworkTable is part of smartdashboard, available at

http://firstforge.wpi.edu/svn/repos/smart_dashboard

We were looking at a number of solutions to get from PC into smartdashboard or directly to robot.

Just the other day I came across IKVM.

http://www.ikvm.net/

You can use this tool to "convert" a jar file into a .net assembly.

run IKVM.exe NetworkTable_Client.jar and you get NetworkClient_Table.dll.

Add it as a reference to your managed code project and start "talking" to your robot (see attached screen shot)
Attached Thumbnails
Click image for larger version

Name:	NetworkTableDotNet.png
Views:	420
Size:	82.2 KB
ID:	12018  
__________________
FRC 623 2003,2004,2005,2006,2007,2008, 2009, 2010, 2011
FRC 1900 2007
FVC 60 and 193 2006
FVC 3271 2007
FTC 226 and 369 2008, 2009, 2010, 2011
FTC 3806 2010
Reply With Quote
  #5   Spotlight this post!  
Unread 20-02-2012, 16:17
mikets's Avatar
mikets mikets is offline
Software Engineer
FRC #0492 (Titan Robotics)
Team Role: Mentor
 
Join Date: Jan 2010
Rookie Year: 2008
Location: Bellevue, WA
Posts: 667
mikets is a glorious beacon of lightmikets is a glorious beacon of lightmikets is a glorious beacon of lightmikets is a glorious beacon of lightmikets is a glorious beacon of lightmikets is a glorious beacon of light
Re: Network Tables?

Thanks. I don't have svn at work so I will download the smartdashboard code tonight and take a look. Without looking at the code, I am hoping the NetworkTable_Client.jar file is not overly long and complex. If so, in theory, I could just port it to C++ by hand. C++ and Java are similar enough that it should not be too difficult.

BTW, I did try to look for the NetworkTable_Client.jar file over the web browser interface but the source tree has many branches and very deep. Do you happen to know the path to that file?

Thanks.
__________________
Reply With Quote
  #6   Spotlight this post!  
Unread 21-02-2012, 00:14
charrisTTI charrisTTI is offline
Ramblin' Wreck
AKA: Charles Harris
FRC #0623
Team Role: Mentor
 
Join Date: Jan 2005
Rookie Year: 2003
Location: Vienna, VA
Posts: 106
charrisTTI has a spectacular aura aboutcharrisTTI has a spectacular aura about
Send a message via AIM to charrisTTI
Re: Network Tables?

Here is the full url to NetworkTable_Client:

http://firstforge.wpi.edu/svn/repos/...ent/Java/trunk

It was more than I wanted to recode.
__________________
FRC 623 2003,2004,2005,2006,2007,2008, 2009, 2010, 2011
FRC 1900 2007
FVC 60 and 193 2006
FVC 3271 2007
FTC 226 and 369 2008, 2009, 2010, 2011
FTC 3806 2010
Reply With Quote
  #7   Spotlight this post!  
Unread 28-02-2012, 15:22
mbram mbram is offline
Registered User
FRC #3502
 
Join Date: Jan 2011
Location: Florida
Posts: 11
mbram is an unknown quantity at this point
Re: Network Tables?

I just figured out how to put and read data on the preferences grid of the Smartdashboard using Network Tables but there's is this harmless yet annoying issue that's bugging me.

I changed the name of the Key / Value in my code but instead of it replacing the old one, it made a second one. the old one is still there on the smartdashboard preferences grid and i can't figure out how to get rid of it.... any ideas?
Reply With Quote
  #8   Spotlight this post!  
Unread 05-03-2012, 13:31
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,050
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: Network Tables?

There is a python implementation of NetworkTables available in RobotPy. See the source tree in github.
__________________
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
  #9   Spotlight this post!  
Unread 29-03-2015, 00:00
gegozi gegozi is offline
Registered User
no team
 
Join Date: Apr 2014
Rookie Year: 2012
Location: Bellaire, TX
Posts: 44
gegozi is an unknown quantity at this point
Re: Network Tables?

Quote:
Originally Posted by charrisTTI View Post
NetworkTable object can be used to pass data to/from robot code and another program running on another computer on the network. SmartDashboard uses it to pass data to/from robot.

We use it to pass data from image processing software running on the driver station back to the robot.

Here is example code:

Code:
//========================================
//Robot Code
// declare object
NetworkTable cameraTable;

// getinstance (table is a singleton, if one does not exist then one will
// be created otherwise returns reference to existing instance
cameraTable = NetworkTable.getTable("camera");

// get data element from the table
// default values returned if no data has been provided from another source yet

cameraTable.beginTransaction();
Boolean imageFound = cameraTable.getBoolean("found", false );
Double imageOffset = cameraTable.getDouble("offset", -1.0);
Double imageDistance = cameraTable.getDouble("distance", -1.0);
cameraTable.endTransaction();

System.out.println( "found = " + imageFound);
System.out.println( "offset = " + imageOffset);
System.out.println( "distance = " + imageDistance);

//=======================================
// Driver Station PC
// camera image processing is done in C# application on DS

// declare it
private NetworkTable table;

// Init NetworkTable
NetworkTable.setIPAddress("10.6.23.2");  // ip of crio
table = NetworkTable.getTable("camera");


// in the image processing loop

table.beginTransaction();
table.putBoolean("found", true);
table.putDouble("distance", distance);
table.putDouble("offset", offset);
table.endTransaction();
This doesn't work. I'm using eclipse on a windows 7 pc and the wpi lib.
Code:
package org.usfirst.frc.team2585.robot;
import edu.wpi.first.wpilibj.tables.ITable;
import edu.wpi.first.wpilibj.tables.ITableListener;
import edu.wpi.first.wpilibj.networktables.NetworkTable;

public class VisionCalib implements ITableListener{
	private double xCoord;
	private double yCoord;
	private double distance;
	private NetworkTable nt;
	//private ITableListener table;
	/**
	 * 
	 */
	public VisionCalib() {
		nt = NetworkTable.getTable("SmartDashboard");
		nt.addTableListener(this);
	}
	
	private void update(){
		System.out.println("Hello");
		nt.beginTransaction();
		xCoord = nt.getNumber("COG_X", 1);
		yCoord = nt.getNumber("COG_Y", 0);
		distance = nt.getNumber("TL_TARGET_DISTANCE", 0);
		nt.endTransaction();
	}
	
	public void valueChanged(ITable itable, String key, Object obj, boolean isNew)
	{
		update();
	}
	public void setNums()
	{
		nt.putNumber("COG_X", 0.0);
		nt.putNumber("COG_Y", 0.0);
		nt.putNumber("TL_TARGET_DISTANCE", 0.0);
	}
	public double getDistance() {return distance;}
	public double getX() {return xCoord;}
	public double getY() {return yCoord;}
	public NetworkTable getNt() {
		return nt;
	}
	public void setNt(String table) {
		this.nt = NetworkTable.getTable(table);
	}
	@Override
	public String toString()
	{
		update();
		String s="";
		s+="xCoord = "+xCoord;
		s+="\n"+"yCoord = "+yCoord;
		s+="\n"+"Distance = "+distance;
		return s;
	}
}
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 13: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