Forwards NetworkTables traffic to a web page via a Websocket
NetworkTables is a protocol used for robot communication in the FIRST Robotics Competition, and can be used to talk to SmartDashboard/SFX. It does not have any security, and should never be used on untrusted networks.
Documentation can be found at http://pynetworktables2js.readthedocs.org/
Easy install (Windows only)
- Download the latest pynetworktables2js.exe from GitHub at https://github.com/robotpy/pynetworktables2js/releases .
- Extract the exe from the zipfile, and copy it to your directory of HTML/JS files.
- Double click the exe to run it!
By default, it will connect to 127.0.0.1. To connect to a robot, you will need to pass the exe arguments to tell it where the robot is. Use --help to see the available options.
Make sure to install python 2 or 3 on your computer, and on Windows you can execute:
py -m pip install pynetworktables2js
On Linux/OSX you can execute:
pip install pynetworktables2js
Technically, there’s nothing stopping you from installing this on your robot, as there is a python interpreter available on the roboRIO (RobotPy). However, due to FRC bandwidth limitations, it’s probably best to run the UI + server on your driver station laptop.
TL;DR: It’s simpler.
pynetworktables2js lowers the barrier of entry for teams that want an additional way to tune/control their robot with a minimal amount of programming.
You can just distribute your HTML files, and run a pynetworktables server using the following command from inside the directory:
python -m pynetworktables2js
Or on Windows:
py -m pynetworktables2js
This will start a pynetworktables2js server using Tornado (which is installed by default) and it will serve the current directory. You can navigate your browser (I recommend Chrome) to http://127.0.0.1:8888 and see your website.
You will want to also pass either the --robot or --team switch:
py -m pynetworktables2js --robot roborio-XXXX-frc.local py -m pynetworktables2js --team XXXX
Dashboard mode currently doesn’t work, as the underlying support in pynetworktables hasn’t been implemented yet for the newer FRC Driver Station.
Customized python server
Go to the ‘example’ directory distributed with pynetworktables2js, and run:
python tornado_server.py --robot 127.0.0.1
If you want to try this out with your current robot, you can do:
python tornado_server.py --robot roborio-XXX.local
If you are running pynetworktables2js on your driver station laptop, you can receive robot IP information directly from the Driver Station (handy during actual competitions):
python tornado_server.py --dashboard
If you navigate your browser (I recommend Chrome) to http://127.0.0.1:8888, all of the current NetworkTables values will be shown as they change.
One way of testing this out is use FIRST’s TableViewer application (you can launch it using the “Outline Viewer” WPILib menu item in Eclipse), and start it in server mode.
Feel free to copy the example directory to create your own customized dashboard. Just add your custom files to the www directory.
Contributing new changes
pynetworktables2js is intended to be a project that all members of the
community can quickly and easily contribute to. If you find a bug, or have an
idea that you think others can use:
- Fork this git repository to your GitHub account
- Create your feature branch (git checkout -b my-new-feature)
- Commit your changes (git commit -am 'Add some feature')
- Push to the branch (git push -u origin my-new-feature)
- Create new Pull Request on GitHub