Skip to content
This repository was archived by the owner on Dec 15, 2021. It is now read-only.

Transferring and Receiving Table Values

Aleks edited this page Apr 16, 2018 · 4 revisions

WIP

The code for this if fairly similar regardless of what language you are using.

Java (roboRio code)

NetworkTable visionTable = NetworkTableInstance.getDefault().getTable("Vision Table");

this will return a table that we can use to place entries in. To add an entry, simply do:

NetworkTableEntry xLoc = visionTable.getEntry("XLocation");

To set the entry to a value, do:

xLoc.setBoolean(true);

To retrieve a value, do

xLoc.getBoolean(boolean bool); 

where bool is the default return value. I am currently working on a class that makes handling network tables easier, so stay tuned.

Python (client code)

This code can be ran on any co-processor Pre-requisites: * Be connected to the robot router. This can be done via ethernet or wifi. * pynetworktables must be installed

from networktables import NetworkTables

#follow FIRST ip naming conventions
#if team # is 4488, ip is 10.44.88.2

ip = '10.64.43.2'
NetworkTables.initialize(ip)
table = NetworkTables.getTable('SmartDashboard')
while True:
table.putNumber('arbitraryEntryName', 4488)

When actually using real code, you'll be pushing new values every time the loop is called, in which case just repeat the last line.

Clone this wiki locally