Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
#!/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
You can’t perform that action at this time.