A Python app that graphs data sent from the roboRIO of an FRC robot over NetworkTables.
These instructions will get you a copy of the project up and running on your local machine for development, testing, and use.
This requires RobotPy NetworkTables and SimpleWebSocketServer. To install just run:
$ pip3 install -r './requirements.txt'
Follow this guide to install FRC-Grapher locally.
First clone this repository:
$ git clone https://github.com/SumiGovindaraju/FRC-Grapher.git
Install prerequisites (see Prerequisites). Then create a directory called cache/
.
To run FRC-Grapher, start the Python WebSocket server and open index.html
:
$ ./main.py
To start the dummy NetworkTables server, run:
$ ./python test_server.py
For testing, start the Python WebSocket server, open index.html
, and then start the dummy NetworkTables server last.
To see a list of command-line arguments available, run:
$ ./main.py --help
To add SmartDashboard keys to the graph, click "Add Dataset" in the navbar, type in the the SmartDashboard key into the modal, and click the "Add Dataset" button.
To save the current key configuration to a file, click "Save Configuration" in the navbar. To run this program with the saved configuration, run the Python WebSocket server with the -c
or --config
flag.
FRC-Grapher graphs Value vs. Time graphs. The Time data is sent over NetworkTables using the key frc-grapher-timestamp
and is measured in seconds in the dummy server. Here are some examples of how to do this on the robot:
Java:
import edu.wpi.first.wpilibj.Timer;
import edu.wpi.first.wpilibj.smartdashboard.SmartDashboard;
// When the robot code is initialized
double startTime = Timer.getFPGATimestamp();
// In each periodic cycle
SmartDashboard.putNumber("frc-grapher-timestamp", Timer.getFPGATimestamp() - startTime);
C++:
#include "WPILib.h"
using namespace frc;
// When the robot code is initialized
double startTime = Timer::GetFPGATimestamp();
// In each periodic cycle
SmartDashboard::PutNumber("frc-grapher-timestamp", Timer::GetFPGATimestamp() - startTime);
Keep in mind that if multiple values are sent for a single timestamp, FRC-Grapher caches and graphs only the latest value, and discards any previous values for that specific timestamp.
FRC-Grapher automatically caches data during the match in a JSON file in the cache/
directory, named for the starting datetime of execution. To graph the cached data, run:
$ python main.py -r [path to JSON cache file]
The default IP address for the NetworkTables server is localhost
, which is what the dummy NetworkTables server runs on. To run this program where the NetworkTables server is the roboRIO, run:
$ python main.py -i [IP address of robot]
See this for information on your robot's IP address.
Downloadable Screenshot of Graph:
- Chart.js - Library used for graphing
- Bootstrap - Library used for styling
- jQuery - Bootstrap dependency
- Font Awesome - Icons
- Sumi Govindaraju
This project is licensed under the MIT License - see the LICENSE file for details