ovl.connections.network_tables_connection module

class ovl.connections.network_tables_connection.NetworkTablesConnection(roborio: str, table_name: str = 'Vision', table_key: str = 'vision_result')[source]

Bases: ovl.connections.connection.Connection

Note: In Order to use NetworkTablesConnection you must have pynetworktables installed. (It is automatically installed when installing ovl)

A connection to that uses NetworkTables (The FRC network protocol).

NetworkTables are a group of Dictionaries (Hash tables) that are shared by all computers in the network. In the case of the FRC it is created by the RoboRIO and shared by other computers on the network like: the driver station, any connected co-processor (like a raspberry pi) etc.

NetworkTablesConnection creates defaults to writing to the Vision table. You can then read from /vision/vision_result the result sent.

For Additional information about NetworkTables please refer to: https://docs.wpilib.org/en/latest/docs/software/networktables/networktables-intro.html

get_table(table)[source]

Fetches a table by name, if table exists in cache it returns the cached table instead. If table is none it returns the default table (set in the constructor)

Parameters:table – the name of the table examples: “usage”, “SmartDashboard”, “vision”

if it doesnt exist it is created :return: the table

receive(table_key: str = None, table: str = None, default_value=None, *args, **kwargs) → Any[source]

Gets a value from a specific key and table, can be used to read values shared by all computers in the network.

Default table and table keys are the ones initialized.

import ovl

TEAM_NUMBER = "1937"
connection = ovl.NetworkTablesConnection(TEAM_NUMBER)

connection.send("hello", table_key="my_key")

print(connection.receive(table_key="my_key"))
# prints "hello"
Parameters:
  • table_key – the specific table to read from, None
  • table – the table to receive from (Use “Vision” if you are not sure)
  • default_value – the value to return if the given table key does not exist
send(data, table_key: Union[str, Any] = None, table: Union[str, Any] = None, *args, **kwargs) → None[source]

A function used to put a value in a given table and key in the connected NetworkTable. For more information about NetworkTables functionality please refer to: https://docs.wpilib.org/en/latest/docs/software/networktables/networktables-intro.html

Parameters:
  • data – the data to send (post to the NetworkTables)
  • table_key – the specific table to read from
  • table – the table to receive from. Examples are SmartDashboard or Usage. Use “Vision” if you are not sure)