Go to Post When your team becomes ubiquitous with the phrase "Always a bridesmaid, never the bride" - Peyton Yeung [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

 
 
 
Thread Tools Rate Thread Display Modes
Prev Previous Post   Next Post Next
  #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: 214
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
 


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 03:47.

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