Go to Post To think that one can "learn" engineering in 6 weeks while under the strain of building a robot too is proposterous. FIRST isn't about teaching. It's about inspiring. - Collin Fultz [more]
Home
Go Back   Chief Delphi > Technical > Programming > Python
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
Reply
 
Thread Tools Rate Thread Display Modes
  #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
  #2   Spotlight this post!  
Unread 19-05-2016, 09:18
virtuald's Avatar
virtuald virtuald is offline
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,032
virtuald has a brilliant futurevirtuald has a brilliant futurevirtuald has a brilliant futurevirtuald has a brilliant futurevirtuald has a brilliant futurevirtuald has a brilliant futurevirtuald has a brilliant futurevirtuald has a brilliant futurevirtuald has a brilliant futurevirtuald has a brilliant futurevirtuald has a brilliant future
Re: Can't put data or get data from network table using pynetworktables

Quote:
Originally Posted by dithier View Post
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
Reply With Quote
  #3   Spotlight this post!  
Unread 19-05-2016, 10:34
dithier dithier is offline
Registered User
FRC #0501
 
Join Date: May 2016
Location: Manchester
Posts: 5
dithier is an unknown quantity at this point
Re: Can't put data or get data from network table using pynetworktables

Yes, that is the robot ip address that we are trying to connect to. We have also tried roborio-501.local with no success. Our code looks identical to the trouble shooting guide and we have been using WPI's TableViewer, and it appears that nothing is being transmitted.

I'm not sure if a connection is being made. I enabled logging, but when I run the program in spyder there are no logging messages appearing in the IPython console. Is there somewhere else I'm supposed to be looking for logging messages? If not, the docs say that if this happens there's still a problem. What should I do next?

Thanks!
Reply With Quote
  #4   Spotlight this post!  
Unread 19-05-2016, 11:28
virtuald's Avatar
virtuald virtuald is offline
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,032
virtuald has a brilliant futurevirtuald has a brilliant futurevirtuald has a brilliant futurevirtuald has a brilliant futurevirtuald has a brilliant futurevirtuald has a brilliant futurevirtuald has a brilliant futurevirtuald has a brilliant futurevirtuald has a brilliant futurevirtuald has a brilliant futurevirtuald has a brilliant future
Re: Can't put data or get data from network table using pynetworktables

Quote:
Originally Posted by dithier View Post
Yes, that is the robot ip address that we are trying to connect to. We have also tried roborio-501.local with no success. Our code looks identical to the trouble shooting guide and we have been using WPI's TableViewer, and it appears that nothing is being transmitted.

I'm not sure if a connection is being made. I enabled logging, but when I run the program in spyder there are no logging messages appearing in the IPython console. Is there somewhere else I'm supposed to be looking for logging messages? If not, the docs say that if this happens there's still a problem. What should I do next?

Thanks!
Does the table viewer connect successfully? (eg, it can see changes in NT on the robot?). If not, there's probably a networking issue of some kind.

The log messages should show up in the console. If they don't show up, then it's not connecting. One experiment you can do is you can tell tableviewer to be a server, and tell pynetworktables to connect to localhost... that should work, and you'll see the appropriate log messages.

10.xx.xx.11 is a strange IP for the roborio.
__________________
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
Reply With Quote
  #5   Spotlight this post!  
Unread 19-05-2016, 11:39
Arhowk's Avatar
Arhowk Arhowk is offline
FiM CSA
AKA: Jake Niman
FRC #1684 (The Chimeras) (5460 Mentor)
 
Join Date: Jan 2013
Rookie Year: 2013
Location: Lapeer
Posts: 542
Arhowk is a splendid one to beholdArhowk is a splendid one to beholdArhowk is a splendid one to beholdArhowk is a splendid one to beholdArhowk is a splendid one to beholdArhowk is a splendid one to behold
Re: Can't put data or get data from network table using pynetworktables

Quote:
Originally Posted by dithier View Post
Yes, that is the robot ip address that we are trying to connect to. We have also tried roborio-501.local with no success. Our code looks identical to the trouble shooting guide and we have been using WPI's TableViewer, and it appears that nothing is being transmitted.

I'm not sure if a connection is being made. I enabled logging, but when I run the program in spyder there are no logging messages appearing in the IPython console. Is there somewhere else I'm supposed to be looking for logging messages? If not, the docs say that if this happens there's still a problem. What should I do next?

Thanks!
.11 is the camera

Your mDNS is also incorrect, should be roborio-501-frc.local

If the top isn't true you messed up your networking settings
If the bottom isn't true than your RIO is not updated
__________________
FRC Team 1684 - Head Programmer (2013-2016)
FRC Team 5460 - Programming Mentor (2015-2016)

FIRST in Michigan - Technical Crew (2015-continuing)
Reply With Quote
  #6   Spotlight this post!  
Unread 20-05-2016, 14:22
dithier dithier is offline
Registered User
FRC #0501
 
Join Date: May 2016
Location: Manchester
Posts: 5
dithier is an unknown quantity at this point
Re: Can't put data or get data from network table using pynetworktables

The connection was the problem because you were right about me putting the wrong ip address! It's all set now; thank you very much!
Reply With Quote
Reply


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT -5. The time now is 21:35.

The Chief Delphi Forums are sponsored by Innovation First International, Inc.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi