Can somebody give me a run-down on NetworkTables connections?

I’ve looked over the NetworkTables2 headers in the C++ distrib. of the WPILib.

A couple questions:

  1. Can I just set a listen on a port so I can utilize other networking libraries, like socket.io?

  2. Following the above, does NetworkTables require a client-server relationship? That is, does the client have to establish a connection with a server written in NetworkTables? Or could it be something else?

If I understand the question correctly, the robot is treated as the server and everything else (programming laptops, driver station, onboard imaging processors) are called clients. The primary difference is that the server unions all of the client variables with its own and assigning Field IDs for various names of variables. Also, race conditions let the server win, and clients do not talk to each other but to the server. The implementation of client and server is actually quite similar otherwise.

Greg McKaskle

My real question is whether I could use Javascript with something like socket.io to send information to and from the robot using Network Tables. That is, have a NT Server running on the robot with various clients using other communications libraries on other networked devices to send and receive information.

 Libraries like NT, socket.io, and websockets all have their own way of handling servers and clients. Can I mess with them so that I can open a connection from a websockets client to receive data from a NT server node on the cRio?

Those higher level protocols are typically based on TCP. You can use those on the client, but you may need to use a lower level TCP API on the robot. I am not that familiar with the libraries/protocols you list, so perhaps others are familiar with them on the cRIO.

Greg McKaskle

After looking at the LV default robot code and dashboard projects, it looks like a server is instantiated, and then sends/reads Key:Value pairs in a table. The NT Server listens on a specified TCP/IP port, and the Client creates a TCP connection to some IP address and a specified port.

So then, how does that implementation work? Is there anything I missed that might be crucial to using something else?

I think the protocol you are describing is called Network Tables. It isn’t too complicated, but includes a notion of a sequence number to arbitrate simultaneous updates and it includes a bootstrapping mechanism for getting all of the variables duplicated across clients and servers.

Greg McKaskle

I found A description of the Network Tables 2.0 spec on the WPILib project: http://firstforge.wpi.edu/sf/docman/do/listDocuments/projects.wpilib/docman.root

Thanks a ton for the help guys!

Does anyone know where the current NetworkTables code for JavaSE is located? FirstForge has a Network Tables 2.0 project but the latest file release is from July 2012. We’ve tried that code but changes aren’t being seen on the cRIO.

Want to make sure it should work before spending a lot of time debugging.

it’s included in the java plugins. See C:\Users<username>\sunspotfrcsdk\desktop-lib

Thanks. Will give that a try tonight and report back.

Just spent the evening wrestling with this. Finally tracked the problem to the desktop lib defaulting to server mode. There doesn’t seem to be a method to switch to client mode. Just recompiled the JAR with NetworkTable.java line 39 changed. It works great now.

What’s the best place to report this issue? Firstforge, but NetworkTables or WPILib?

Report it in the NetworkTables project. This should be fixed in the next update.

Posted to WPILib Java tracker. NetworkTables 2.0 project doesn’t give me the option to post new issues.

This seems kindof dead, but could anybody give me some insight about how the Server – Client handshake works with NetworkTables? (I promise I’ll do the legwork and write it in javascript myself)

Here’s the protocol spec
http://firstforge.wpi.edu/sf/go/doc1318?nav=1

That was linked earlier in the thread, and simply says that the client sends a “Client Hello” message. There was no further description about how the handshake works.
Could somebody tell me where in the header files it is please? (Any language).

I couldn’t find the official WPILib source repository (the SVN at FIRST Forge seems very old–perhaps I’m looking at the wrong location). Here’s the 2013 kick-off code I just pushed to github.

The connection messages seem implemented here:
https://github.com/FRC3322/WPILib/blob/master/networktables2/connection/NetworkTableConnection.cpp

The constants used in those messages are here:
https://github.com/FRC3322/WPILib/blob/master/networktables2/NetworkTableMessageType.h

Further down in the document are details on the Client Hello message.
The actual implementations of the handshake are in the ClientConnectionAdapter and the ServerConnectionAdapter in the client and server packages respectively.