Chief Delphi

Chief Delphi (http://www.chiefdelphi.com/forums/index.php)
-   Python (http://www.chiefdelphi.com/forums/forumdisplay.php?f=187)
-   -   Can't seem to retrieve SmartDashboard data for PyNetworkTables? (http://www.chiefdelphi.com/forums/showthread.php?t=142141)

team-4480 19-01-2016 16:03

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.

virtuald 19-01-2016 17:39

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?

team-4480 19-01-2016 19:43

Re: Can't seem to retrieve SmartDashboard data for PyNetworkTables?
 
Quote:

Originally Posted by virtuald (Post 1526804)
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!

virtuald 19-01-2016 23:21

Re: Can't seem to retrieve SmartDashboard data for PyNetworkTables?
 
Quote:

Originally Posted by team-4480 (Post 1526874)
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.

team-4480 20-01-2016 14:45

Re: Can't seem to retrieve SmartDashboard data for PyNetworkTables?
 
Quote:

Originally Posted by virtuald (Post 1527002)
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?

virtuald 20-01-2016 16:56

Re: Can't seem to retrieve SmartDashboard data for PyNetworkTables?
 
Check out the global listener sample.

https://github.com/robotpy/pynetwork...al_listener.py

cjl2625 25-01-2016 19:24

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?

virtuald 25-01-2016 22:17

Re: Can't seem to retrieve SmartDashboard data for PyNetworkTables?
 
Quote:

Originally Posted by cjl2625 (Post 1529999)
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.

cjl2625 25-01-2016 22:31

Re: Can't seem to retrieve SmartDashboard data for PyNetworkTables?
 
Quote:

Originally Posted by virtuald (Post 1530075)
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?

virtuald 26-01-2016 10:17

Re: Can't seem to retrieve SmartDashboard data for PyNetworkTables?
 
Quote:

Originally Posted by cjl2625 (Post 1530082)
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.

cjl2625 08-02-2016 22:22

Re: Can't seem to retrieve SmartDashboard data for PyNetworkTables?
 
Quote:

Originally Posted by virtuald (Post 1530287)
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?

virtuald 09-02-2016 10:24

Re: Can't seem to retrieve SmartDashboard data for PyNetworkTables?
 
Quote:

Originally Posted by cjl2625 (Post 1537351)
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.

virtuald 10-02-2016 09:19

Re: Can't seem to retrieve SmartDashboard data for PyNetworkTables?
 
Quote:

Originally Posted by cjl2625 (Post 1537351)
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.

cjl2625 11-02-2016 21:03

Re: Can't seem to retrieve SmartDashboard data for PyNetworkTables?
 
Quote:

Originally Posted by virtuald (Post 1537972)
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.

virtuald 14-02-2016 19:36

Re: Can't seem to retrieve SmartDashboard data for PyNetworkTables?
 
Quote:

Originally Posted by cjl2625 (Post 1538873)
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.


All times are GMT -5. The time now is 19:52.

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