Created
May 2, 2017 20:03
-
-
Save primetoxinz/5584f4dbe0b8d30f0287bf2273bd23fb to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import time | |
import random | |
#pip install pynetworktables | |
from networktables import NetworkTables | |
# To see messages from networktables, you must setup logging | |
import logging | |
logging.basicConfig(level=logging.DEBUG) | |
sd = NetworkTables.getTable("SmartDashboard") | |
i = 135 | |
while True: | |
try: | |
print('robotTime:', sd.getNumber('robotTime')) | |
except KeyError: | |
print('dsTime: N/A') | |
for key in sd.getKeys(): | |
print(str(sd.getValue(key))) | |
if i <= 0: | |
phase = 'Disabled' | |
elif i >= 30: | |
phase = 'Teleop' | |
else: | |
phase = 'Autonomous' | |
sd.putString('robotPhase', phase) | |
sd.putNumber('robotTime', i) | |
sd.putNumber('voltage', 12 + random.randint(-100, 100) * 0.05) | |
sd.putNumber('current', 7 + random.randint(-10, 10) * 0.05) | |
time.sleep(1) | |
if i > 0: | |
i -= 1 | |
else: | |
i = 135 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment