View Single Post
  #1   Spotlight this post!  
Unread 18-05-2016, 23:13
dithier dithier is offline
Registered User
FRC #0501
 
Join Date: May 2016
Location: Manchester
Posts: 5
dithier is an unknown quantity at this point
Can't put data or get data from network table using pynetworktables

Hello,

This season we used RoboRealm for vision and used their network tables to talk to our RoboRio which is running Java and didn't have a problem. We decided to switch to opencv (python), but have not had any luck with pynetworktables even though we're following the examples online. We're using pynetwortables version 2015.3.4 and python 2.7.11 through Anaconda 4.0.0 on a Windows machine. The code relating to the network tables that we have is:

from networktables import NetworkTable
import logging
logging.basicConfig(level=logging.DEBUG)
NetworkTable.setIPAddress('10.5.1.11')
NetworkTable.setClientMode()
NetworkTable.initialize()

sd = NetworkTable.getTable("SmartDashboard")
sd.putNumber('Distance', distance)

(Note: in the regular code distance is a defined variable and SmartDashboard is the correct name of our dashboard)

When we run this we don't get an error, but our table doesn't get updated with the variable and its value. When we try getting numbers from the table with sd.getNumber('variable') then we get a keyError.

Additionally, if I run the code,stop it, and then run it again I get an error saying the table has already been initialized. However if I exit spyder (the IDLE) I'm using in between each time I run the code I don't get the error.

Does anyone have any idea why these things are happening and how to fix them?

Thanks in advance!
Reply With Quote