CtrlK
BlogDocsLog inGet started
Tessl Logo

tessl/pypi-pynetworktables

A pure Python implementation of NetworkTables, used for robot communications in the FIRST Robotics Competition.

75

1.01x
Overview
Eval results
Files

task.mdevals/scenario-1/

SmartDashboard Chooser Bridge

Expose a thin controller that interacts with a SmartDashboard chooser, allowing dashboard code to observe available options, read the current selection (falling back to a default), push a new selection, and stop listening cleanly.

Capabilities

Reads chooser state

  • With no chooser entries present, get_choices returns an empty sequence and get_selection returns None. @test
  • When only a default option is present and no explicit selection exists, get_selection returns that default value. @test

Responds to remote updates

  • When the dashboard updates the options entry for the chooser key, the provided on_choices callback is invoked with the new options in order. @test
  • When the dashboard updates the active selection entry, the provided on_selection callback is invoked with the new selection value. @test

Applies selection changes

  • Calling set_selection publishes the new selection to the chooser entries so subsequent reads return that value. @test

Lifecycle management

  • After close is called, further dashboard updates do not trigger callbacks, but the last known selection can still be read. @test

Implementation

@generates

API

from typing import Callable, Optional, Sequence

class SmartDashboardChooserBridge:
    def __init__(
        self,
        key: str,
        on_choices: Optional[Callable[[Sequence[str]], None]] = None,
        on_selection: Optional[Callable[[Optional[str]], None]] = None,
    ) -> None: ...

    def get_choices(self) -> Sequence[str]: ...

    def get_selection(self) -> Optional[str]: ...

    def set_selection(self, selection: str) -> None: ...

    def close(self) -> None: ...

Dependencies { .dependencies }

pynetworktables { .dependency }

Use this dependency to connect to the SmartDashboard chooser entries and rely on its chooser integration utilities.

Install with Tessl CLI

npx tessl i tessl/pypi-pynetworktables

tile.json