View Single Post
  #4   Spotlight this post!  
Unread 23-02-2016, 00: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,043
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: Vision With GRIP

The first thing that I would recommend is using table viewer to ensure that the value is actually available. And, even if it's not available, the retrieveValue API doesn't have functionality to set a default value, so you should do one of two things:
  • Set a default value when your program starts up
  • Surround the retrieveValue() call with a try...except block

Finally, I tested the functionality, and you can use pynetworktables to retrieve a NumberArray. However, the retrieveValue function returns None, not an array. Therefore, the code you have above won't work -- but remove the assignment, and it should be fine:

Code:
table = NetworkTable.getTable('/GRIP/myContoursReport')
na = NumberArray()

...

try:
    table.retrieveValue('centerX', na)
except KeyError:
    # do something else here...
else:
    print(na)
__________________
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