
19-05-2016, 09:18
|
 |
RobotPy Guy
AKA: Dustin Spicuzza
 FRC #1418 (), FRC #1973, FRC #4796, FRC #6367 ()
Team Role: Mentor
|
|
Join Date: Dec 2008
Rookie Year: 2003
Location: Boston, MA
Posts: 1,043
|
|
|
Re: Can't put data or get data from network table using pynetworktables
Quote:
Originally Posted by dithier
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!
|
I refer you to the troubleshooting section of the documentation:
http://pynetworktables.readthedocs.i...eshooting.html
Why are you telling it to connect to x.x.x.11? Is that the Robot IP? It will only work if there's a NT server to connect to (eg, a robot).
__________________
Maintainer of RobotPy - Python for FRC
Creator of pyfrc (Robot Simulator + utilities for Python) and pynetworktables/ pynetworktables2js (NetworkTables for Python & Javascript)
2017 Season: Teams #1973, #4796, #6369
Team #1418 (remote mentor): Newton Quarterfinalists, 2016 Chesapeake District Champion, 2x Innovation in Control award, 2x district event winner
Team #1418: 2015 DC Regional Innovation In Control Award, #2 seed; 2014 VA Industrial Design Award; 2014 Finalists in DC & VA
Team #2423: 2012 & 2013 Boston Regional Innovation in Control Award
Resources: FIRSTWiki (relaunched!) | My Software Stuff
|