We go together like a Drill motor, reduced by 3.6:1, and a CIM motor.
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 19-01-2016, 16:03
team-4480's Avatar
team-4480 team-4480 is offline
Debug? What's that?
FRC #4480
 
Join Date: Jan 2015
Rookie Year: 2013
Location: Minnesooota
Posts: 229
team-4480 will become famous soon enoughteam-4480 will become famous soon enough
Can't seem to retrieve SmartDashboard data for PyNetworkTables?

Hi,

Today's problem of the day is the SmartDashboard. I am using this [summarized] code on the robot:
Code:
def robotInit(self):
     self.sensor = wpilib.AnalogInput(3)
     wpilib.SmartDashboard.putNumber("Clicky1", self.sensor.getValue())
def teleopPeriodic(self):
     wpilib.SmartDashboard.putNumber("Clicky1", self.sensor.getValue())
and this code on our driver station computer:
Code:
from networktables import NetworkTable

NetworkTable.setIPAddress("roborio-4480-frc.local")
NetworkTable.setClientMode()
NetworkTable.initialize()
sd - NetworkTable.getTable("SmartDashboard")
while True:
    try:
        print('distance:', sd.getNumber('Clicky1'))
    except KeyError:
        print('distance: N/A')
So I get a KeyError for when it tries to pull "Clicky1". Am I supposed to put more code on the robot to define the Clicky1 name? Or is there a way to make sure I am connected for sure to the robot? Sorry for all the questions.
Reply With Quote
  #2   Spotlight this post!  
Unread 19-01-2016, 17:39
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,115
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 seem to retrieve SmartDashboard data for PyNetworkTables?

That looks correct. There should be a log message that prints out when you actually connect to the robot. You need to enable logging to see it:

Code:
# To see messages from networktables, you must setup logging
import logging
logging.basicConfig(level=logging.DEBUG)

You probably want to add a sleep in that while loop.

I assume you've already looked through the samples?
__________________
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-01-2016, 19:43
team-4480's Avatar
team-4480 team-4480 is offline
Debug? What's that?
FRC #4480
 
Join Date: Jan 2015
Rookie Year: 2013
Location: Minnesooota
Posts: 229
team-4480 will become famous soon enoughteam-4480 will become famous soon enough
Re: Can't seem to retrieve SmartDashboard data for PyNetworkTables?

Quote:
Originally Posted by virtuald View Post
That looks correct. There should be a log message that prints out when you actually connect to the robot. You need to enable logging to see it:

Code:
# To see messages from networktables, you must setup logging
import logging
logging.basicConfig(level=logging.DEBUG)

You probably want to add a sleep in that while loop.

I assume you've already looked through the samples?
So is that logging in the robot code or the driver station code? Thanks!
Reply With Quote
  #4   Spotlight this post!  
Unread 19-01-2016, 23:21
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,115
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 seem to retrieve SmartDashboard data for PyNetworkTables?

Quote:
Originally Posted by team-4480 View Post
So is that logging in the robot code or the driver station code? Thanks!
The DS code. The robot already has logging enabled by default.
__________________
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 20-01-2016, 14:45
team-4480's Avatar
team-4480 team-4480 is offline
Debug? What's that?
FRC #4480
 
Join Date: Jan 2015
Rookie Year: 2013
Location: Minnesooota
Posts: 229
team-4480 will become famous soon enoughteam-4480 will become famous soon enough
Re: Can't seem to retrieve SmartDashboard data for PyNetworkTables?

Quote:
Originally Posted by virtuald View Post
The DS code. The robot already has logging enabled by default.
Is there a way to print out all the available keys? I still get the KeyError right away. Maybe it is not waiting to connect?
Reply With Quote
  #6   Spotlight this post!  
Unread 20-01-2016, 16:56
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,115
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 seem to retrieve SmartDashboard data for PyNetworkTables?

Check out the global listener sample.

https://github.com/robotpy/pynetwork...al_listener.py
__________________
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
  #7   Spotlight this post!  
Unread 25-01-2016, 19:24
cjl2625's Avatar
cjl2625 cjl2625 is offline
apel py
AKA: Cory Lynch
FRC #2067 (Apple Pi)
Team Role: Programmer
 
Join Date: Jan 2013
Rookie Year: 2013
Location: Guilford, CT
Posts: 412
cjl2625 is a splendid one to beholdcjl2625 is a splendid one to beholdcjl2625 is a splendid one to beholdcjl2625 is a splendid one to beholdcjl2625 is a splendid one to beholdcjl2625 is a splendid one to beholdcjl2625 is a splendid one to beholdcjl2625 is a splendid one to behold
Re: Can't seem to retrieve SmartDashboard data for PyNetworkTables?

It's also broken for me.
it gives an error about incompatible version or whatever, so I think it rejects Network Tables 3.0.

Is there a way to get this to work with NT 3.0, or should I give up on PyNetworkTables?
__________________
Head Programmer / Driver
Reply With Quote
  #8   Spotlight this post!  
Unread 25-01-2016, 22:17
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,115
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 seem to retrieve SmartDashboard data for PyNetworkTables?

Quote:
Originally Posted by cjl2625 View Post
It's also broken for me.
it gives an error about incompatible version or whatever, so I think it rejects Network Tables 3.0.

Is there a way to get this to work with NT 3.0, or should I give up on PyNetworkTables?
If you're using LabVIEW then it will not work until we upgrade the implementation to NetworkTables 3.0 (tracked at this github issue). However, it should work correctly with Java/C++ NetworkTables client/servers, despite the warning about incompatible revisions.

The global listener sample is great for figuring out if the other side has placed anything in NetworkTables.
__________________
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
  #9   Spotlight this post!  
Unread 25-01-2016, 22:31
cjl2625's Avatar
cjl2625 cjl2625 is offline
apel py
AKA: Cory Lynch
FRC #2067 (Apple Pi)
Team Role: Programmer
 
Join Date: Jan 2013
Rookie Year: 2013
Location: Guilford, CT
Posts: 412
cjl2625 is a splendid one to beholdcjl2625 is a splendid one to beholdcjl2625 is a splendid one to beholdcjl2625 is a splendid one to beholdcjl2625 is a splendid one to beholdcjl2625 is a splendid one to beholdcjl2625 is a splendid one to beholdcjl2625 is a splendid one to behold
Re: Can't seem to retrieve SmartDashboard data for PyNetworkTables?

Quote:
Originally Posted by virtuald View Post
If you're using LabVIEW then it will not work until we upgrade the implementation to NetworkTables 3.0 (tracked at this github issue). However, it should work correctly with Java/C++ NetworkTables client/servers, despite the warning about incompatible revisions.

The global listener sample is great for figuring out if the other side has placed anything in NetworkTables.
Yes, I'm using LabVIEW. Is the upgrade anticipated to be before the end of the build season?
__________________
Head Programmer / Driver
Reply With Quote
  #10   Spotlight this post!  
Unread 26-01-2016, 10:17
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,115
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 seem to retrieve SmartDashboard data for PyNetworkTables?

Quote:
Originally Posted by cjl2625 View Post
Yes, I'm using LabVIEW. Is the upgrade anticipated to be before the end of the build season?
Peter has been working on a full migration to NT 3.0, but it's a lot of effort and not done yet. I talked to Peter last night and he said he was going to look at putting together something quick this week that would allow us to be compatible with LabVIEW, as the question has come up a few times.
__________________
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
  #11   Spotlight this post!  
Unread 08-02-2016, 22:22
cjl2625's Avatar
cjl2625 cjl2625 is offline
apel py
AKA: Cory Lynch
FRC #2067 (Apple Pi)
Team Role: Programmer
 
Join Date: Jan 2013
Rookie Year: 2013
Location: Guilford, CT
Posts: 412
cjl2625 is a splendid one to beholdcjl2625 is a splendid one to beholdcjl2625 is a splendid one to beholdcjl2625 is a splendid one to beholdcjl2625 is a splendid one to beholdcjl2625 is a splendid one to beholdcjl2625 is a splendid one to beholdcjl2625 is a splendid one to behold
Re: Can't seem to retrieve SmartDashboard data for PyNetworkTables?

Quote:
Originally Posted by virtuald View Post
Peter has been working on a full migration to NT 3.0, but it's a lot of effort and not done yet. I talked to Peter last night and he said he was going to look at putting together something quick this week that would allow us to be compatible with LabVIEW, as the question has come up a few times.
It's been a couple weeks; any update on this?
__________________
Head Programmer / Driver
Reply With Quote
  #12   Spotlight this post!  
Unread 09-02-2016, 10:24
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,115
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 seem to retrieve SmartDashboard data for PyNetworkTables?

Quote:
Originally Posted by cjl2625 View Post
It's been a couple weeks; any update on this?
Peter said he's been busy, but has been working on it. He promised to post whatever he's got by Wednesday.
__________________
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
  #13   Spotlight this post!  
Unread 10-02-2016, 09:19
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,115
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 seem to retrieve SmartDashboard data for PyNetworkTables?

Quote:
Originally Posted by cjl2625 View Post
It's been a couple weeks; any update on this?
Peter pushed a branch, can you try it out and let us know if it works for you? https://github.com/robotpy/pynetwork.../nt3-barebones

He hasn't tried it with LabVIEW, but says it works with the OutlineViewer + NT3.
__________________
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
  #14   Spotlight this post!  
Unread 11-02-2016, 21:03
cjl2625's Avatar
cjl2625 cjl2625 is offline
apel py
AKA: Cory Lynch
FRC #2067 (Apple Pi)
Team Role: Programmer
 
Join Date: Jan 2013
Rookie Year: 2013
Location: Guilford, CT
Posts: 412
cjl2625 is a splendid one to beholdcjl2625 is a splendid one to beholdcjl2625 is a splendid one to beholdcjl2625 is a splendid one to beholdcjl2625 is a splendid one to beholdcjl2625 is a splendid one to beholdcjl2625 is a splendid one to beholdcjl2625 is a splendid one to behold
Re: Can't seem to retrieve SmartDashboard data for PyNetworkTables?

Quote:
Originally Posted by virtuald View Post
Peter pushed a branch, can you try it out and let us know if it works for you? https://github.com/robotpy/pynetwork.../nt3-barebones

He hasn't tried it with LabVIEW, but says it works with the OutlineViewer + NT3.
I gave it a shot, and it seems to work nicely.
Was able to upload values and they appeared on the LabVIEW dashboard.

Thanks.
__________________
Head Programmer / Driver
Reply With Quote
  #15   Spotlight this post!  
Unread 14-02-2016, 19:36
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,115
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 seem to retrieve SmartDashboard data for PyNetworkTables?

Quote:
Originally Posted by cjl2625 View Post
I gave it a shot, and it seems to work nicely.
Was able to upload values and they appeared on the LabVIEW dashboard.

Thanks.
Cool. I've pushed an alpha release of this (2016.0.0alpha1) to pypi in case someone else needs it -- you'll need to specify the --pre argument to pip in order to install it.
__________________
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
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 08:29.

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