pykit.networktables package

Submodules

pykit.networktables.loggeddashboardchooser module

class pykit.networktables.loggeddashboardchooser.LoggedDashboardChooser(key: str)[source]

Bases: LoggedNetworkInput, Generic[T]

A wrapper for SendableChooser that supports logging and replay.

This class allows for creating a dashboard-configurable chooser whose selection can be recorded and replayed.

Initializes the LoggedDashboardChooser.

Parameters:

key – The key to use for publishing the chooser to SmartDashboard.

addOption(key: str, value: T)[source]

Adds an option to the chooser.

Parameters:
  • key – The name of the option shown on the dashboard.

  • value – The value to be returned when this option is selected.

fromLog(table: LogTable, prefix: str) None[source]

Loads the selected value from the table.

Parameters:
  • table – The log table.

  • prefix – The prefix for the log entry.

getSelected() T | None[source]

Gets the currently selected value.

Returns:

The selected value, or None if no value is selected.

key: str
listener: Callable[[T], None] | None
onChange(callback: Callable[[T], None]) None[source]

Registers a callback to use upon value changes.

Parameters:

callback – The function to call when the internal value has changed

options: dict[str, T] = {}
periodic() None[source]

Updates the chooser’s state. In normal mode, it reads from NetworkTables. In replay mode, it reads from the log.

previousValue: str | None
selectedValue: str = ''
sendableChooser: SendableChooser
setDefaultOption(key: str, value: T)[source]

Sets the default option for the chooser.

Parameters:
  • key – The name of the default option.

  • value – The value to be returned by default.

toLog(table: LogTable, prefix: str) None[source]

Logs the selected value to the table.

Parameters:
  • table – The log table.

  • prefix – The prefix for the log entry.

pykit.networktables.loggednetworkboolean module

class pykit.networktables.loggednetworkboolean.LoggedNetworkBoolean(key, defaultValue: bool = False)[source]

Bases: LoggedNetworkValue[bool, BooleanEntry]

A loggable network value for booleans.

This class provides a convenient way to interact with boolean values on NetworkTables while ensuring they are properly logged and replayed.

Initializes a LoggedNetworkBoolean.

Parameters:
  • key – The NetworkTables key.

  • defaultValue – The default value to use if the key is not present.

pykit.networktables.loggednetworkinput module

class pykit.networktables.loggednetworkinput.LoggedNetworkInput[source]

Bases: object

A base class for handling network inputs that can be logged and replayed. This class provides a common interface for periodic updates and key management.

Initializes the LoggedNetworkInput.

periodic()[source]

A method called periodically to update the input’s value. Subclasses should override this to implement their specific logic.

prefix: str = 'NetworkInputs'
static removeSlash(key: str)[source]

Removes a leading slash from a key if it exists.

Parameters:

key – The key string.

Returns:

The key without a leading slash.

pykit.networktables.loggednetworknumber module

class pykit.networktables.loggednetworknumber.LoggedNetworkNumber(key, defaultValue: float = 0.0)[source]

Bases: LoggedNetworkValue[float, DoubleEntry]

A loggable network value for numbers (doubles).

This class provides a convenient way to interact with numeric values on NetworkTables while ensuring they are properly logged and replayed.

Initializes a LoggedNetworkNumber.

Parameters:
  • key – The NetworkTables key.

  • defaultValue – The default value to use if the key is not present.

pykit.networktables.loggednetworkstring module

class pykit.networktables.loggednetworkstring.LoggedNetworkString(key, defaultValue: str = '')[source]

Bases: LoggedNetworkValue[str, StringEntry]

A loggable network value for strings.

This class provides a convenient way to interact with string values on NetworkTables while ensuring they are properly logged and replayed.

Initializes a LoggedNetworkString.

Parameters:
  • key – The NetworkTables key.

  • defaultValue – The default value to use if the key is not present.

pykit.networktables.loggednetworkvalue module

class pykit.networktables.loggednetworkvalue.LoggedNetworkValue(key: str, defaultValue: T)[source]

Bases: LoggedNetworkInput, Generic[T, V]

A generic base class for loggable NetworkTables values.

This class provides a common framework for handling different types of NetworkTables entries that need to be logged and replayed.

Initializes a LoggedNetworkValue.

Parameters:
  • key – The NetworkTables key.

  • defaultValue – The default value.

fromLog(table: LogTable, prefix: str)[source]

Loads the value from the log table.

Parameters:
  • table – The log table.

  • prefix – The prefix for the log entry.

periodic()[source]

Updates the value periodically. In normal mode, it reads from NetworkTables. In replay mode, it relies on fromLog to update the value.

setDefault(defaultValue: T) None[source]

Sets the default value for the network entry.

Parameters:

defaultValue – The new default value.

toLog(table: LogTable, prefix: str)[source]

Logs the current value to the log table.

Parameters:
  • table – The log table.

  • prefix – The prefix for the log entry.

property value: T

The current value of the network entry.

pykit.networktables.nt4Publisher module

class pykit.networktables.nt4Publisher.NT4Publisher(actLikeAKit: bool = False)[source]

Bases: LogDataReciever

A data receiver that publishes log data to NetworkTables.

This class listens for log table updates and publishes the data to a specified NetworkTable, allowing for real-time monitoring.

Initializes the NT4Publisher.

Parameters:

actLikeAKit – If True, publishes to the “/AdvantageKit” table. Otherwise, publishes to the “/PyKit” table.

lastTable: LogTable = <pykit.logtable.LogTable object>
publishers: dict[str, GenericPublisher] = {}
putTable(table: LogTable)[source]

Publishes the contents of a LogTable to NetworkTables.

This method compares the new table with the last one received and only publishes the values that have changed.

Parameters:

table – The LogTable to publish.

pykitTable: NetworkTable
timestampPublisher: IntegerPublisher
units: dict[str, str] = {}