Skip to content

Instantly share code, notes, and snippets.

@auxiliary-character
Last active March 22, 2017 05:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save auxiliary-character/5ef5d2309d20429afeed766899c33120 to your computer and use it in GitHub Desktop.
Save auxiliary-character/5ef5d2309d20429afeed766899c33120 to your computer and use it in GitHub Desktop.
#!/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