Open mcolinj opened 5 years ago
See the example of the listener callback in ContinuingEducation:
Here's some notion (maybe wrong) about how to do it. Note that you need to research what the notification reports in info and connection, and need to know what it indicates (is it safe to get a table, a value, or what?)
NetworkTables.initialize(server=ip)
connected = False
def connectionListener(connected, info):
# test for info and connected for SmartDashboard?
connected = True
NetworkTables.addConnectionListener(connectionListener, immediateNotify=True)
while not connected:
# do nothing, maybe sleep for a second
# Now you should be able to use the NetworkTables
If the pi powers up before the robot does, then it will need some wait time to connect to the SmartDashboard so it can publish the ntproperty for target detection.
Try to be robust about that.