Last active
March 22, 2017 05:50
-
-
Save auxiliary-character/5ef5d2309d20429afeed766899c33120 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
from networktables import NetworkTables | |
import urllib.request | |
import re | |
import time | |
from pprint import pprint | |
data_regex = re.compile("(\w+) = ([\d\.\-]+)") | |
def getTable(): | |
with urllib.request.urlopen("http://10.40.9.13/data.html") as f: | |
table = re.findall(data_regex, f.read().decode("utf8")) | |
return {i[0] : float(i[1]) for i in table} | |
def main(): | |
NetworkTables.initialize(server='roborio-4009-frc.local') | |
rs = NetworkTables.getTable('RoboSight') | |
while True: | |
table = getTable() | |
pprint(table) | |
for name in table: | |
rs.putNumber(name, table[name]) | |
time.sleep(.1) | |
if __name__ == "__main__": | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment