I now have the problem of connecting to GRIP. GRIP seems to be the server and in order to access the variables, you need to use the ClientMode. The problem with that is you need the IP of the server. GRIP is going to be running on our Driver Station and the IP will not stay the same.
How am I supposed to connect to GRIP?
Here is the working code(Just using GRIP locally by setting both to 127.0.0.1):
Code:
import sys
import time
from networktables import NetworkTable
import networktables
ip = "127.0.0.1"
NetworkTable.setIPAddress(ip)
NetworkTable.setClientMode()
NetworkTable.initialize()
table = NetworkTable.getTable('/GRIP/myContoursReport')
default = networktables.NumberArray()
while True:
try:
table.retrieveValue('centerX', default)
except KeyError:
pass
else:
print default
time.sleep(1)
Thanks!