|
|
|
![]() |
|
|||||||
|
||||||||
![]() |
| Thread Tools | Rate Thread | Display Modes |
|
#1
|
||||
|
||||
|
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())
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')
|
|
#2
|
||||
|
||||
|
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? |
|
#3
|
||||
|
||||
|
Re: Can't seem to retrieve SmartDashboard data for PyNetworkTables?
Quote:
|
|
#4
|
||||
|
||||
|
Re: Can't seem to retrieve SmartDashboard data for PyNetworkTables?
The DS code. The robot already has logging enabled by default.
|
|
#5
|
||||
|
||||
|
Re: Can't seem to retrieve SmartDashboard data for PyNetworkTables?
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?
|
|
#6
|
||||
|
||||
|
Re: Can't seem to retrieve SmartDashboard data for PyNetworkTables?
|
|
#7
|
||||
|
||||
|
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? |
|
#8
|
||||
|
||||
|
Re: Can't seem to retrieve SmartDashboard data for PyNetworkTables?
Quote:
The global listener sample is great for figuring out if the other side has placed anything in NetworkTables. |
|
#9
|
||||
|
||||
|
Re: Can't seem to retrieve SmartDashboard data for PyNetworkTables?
Quote:
|
|
#10
|
||||
|
||||
|
Re: Can't seem to retrieve SmartDashboard data for PyNetworkTables?
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.
|
|
#11
|
||||
|
||||
|
Re: Can't seem to retrieve SmartDashboard data for PyNetworkTables?
Quote:
|
|
#12
|
||||
|
||||
|
Re: Can't seem to retrieve SmartDashboard data for PyNetworkTables?
Peter said he's been busy, but has been working on it. He promised to post whatever he's got by Wednesday.
|
|
#13
|
||||
|
||||
|
Re: Can't seem to retrieve SmartDashboard data for PyNetworkTables?
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. |
|
#14
|
||||
|
||||
|
Re: Can't seem to retrieve SmartDashboard data for PyNetworkTables?
Quote:
Was able to upload values and they appeared on the LabVIEW dashboard. Thanks. |
|
#15
|
||||
|
||||
|
Re: Can't seem to retrieve SmartDashboard data for PyNetworkTables?
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.
|
![]() |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|