Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG]: NetworkButton quirks? #83

Open
rayluo opened this issue Jan 26, 2025 · 2 comments
Open

[BUG]: NetworkButton quirks? #83

rayluo opened this issue Jan 26, 2025 · 2 comments

Comments

@rayluo
Copy link

rayluo commented Jan 26, 2025

Problem description

The code snippet below adds a boolean switch onto shuffleboard. Strangely, line 3 works, but line 4 doesn't.

table.getEntry("Switch").setDefaultBoolean(False)  # Must setDefault* to make entry visible on Shuffleboard
switch_subscriber = table.getBooleanTopic("Switch").subscribe(False)
button.Trigger(switch_subscriber.get).onTrue(some_command)
button.NetworkButton(switch_subscriber).onTrue(some_command)

My investigation found that the difference in line 4 is that its implementation uses an isConnected() whose document sounds weird: "Return whether or not the instance is connected to another node." What does it mean by "another node"? I am currently just debugging an XRP running locally; isn't it always connected to the current and only node?

BTW, could a future version of NetworkButton also has line 1 built-in, so that the users won't need to deal with that quirk?

Operating System

Linux

Installed Python Packages

$ pip list
Package                  Version
------------------------ ----------
bcrypt                   4.2.1
cffi                     1.17.1
cryptography             44.0.0
flexcache                0.3
flexparser               0.4
iniconfig                2.0.0
packaging                23.2
paramiko                 3.5.0
Pint                     0.24.4
pip                      24.3.1
platformdirs             4.3.6
pluggy                   1.5.0
pycparser                2.22
pyfrc                    2025.0.0
PyNaCl                   1.5.0
pynetconsole             2.0.4
pyntcore                 2025.1.1.0
pytest                   8.3.4
pytest-reraise           2.1.2
robotpy                  2025.1.1.1
robotpy-cli              2024.0.0
robotpy-commands-v2      2025.1.1
robotpy-hal              2025.1.1.0
robotpy-halsim-gui       2025.1.1.0
robotpy-installer        2025.0.0
robotpy-wpilib-utilities 2025.0.0
robotpy-wpimath          2025.1.1.0
robotpy-wpinet           2025.1.1.0
robotpy-wpiutil          2025.1.1.0
robotpy-xrp              2025.1.1.0
tomli                    2.2.1
tomlkit                  0.13.2
typing_extensions        4.12.2
wpilib                   2025.1.1.0

Reproducible example code


@virtuald
Copy link
Member

I don't know if the behavior is correct or not, but it appears that Java has the same behavior (https://github.com/wpilibsuite/allwpilib/blob/b44a80c07a809cf4e1d1d10abc9afa2bac648da5/wpilibNewCommands/src/main/java/edu/wpi/first/wpilibj2/command/button/NetworkButton.java#L35)... @PeterJohnson you added that as part of NT4 upgrades, any thoughts on this?

@PeterJohnson
Copy link
Member

"Node" here means any NetworkTables client. Since the robot code is a server, this checks to see if there's any NetworkTables client connected to the server. Thus, isConnected() should be returning true when Shuffleboard is connected.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants