View Single Post
  #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: 216
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