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

Support for non-critical controllers that don't report unplugged warnings, even when FMS is attached #7207

Open
ArchdukeTim opened this issue Oct 14, 2024 · 2 comments
Labels
component: wpilibc WPILib C++ component: wpilibj WPILib Java type: feature Brand new functionality, features, pages, workflows, endpoints, etc.

Comments

@ArchdukeTim
Copy link
Contributor

Especially with the introduction of SysId routines, it's common to have button bindings that are used only on a practice field / workshop. An easy solution for this is to bind to buttons on an unused controller port, and set the test controller to use that port during testing.

At competition, this means the messages pane is filled with unplugged messages, possible hiding more critical information.

It would be nice if you could mark specific controllers / ports as 'non-critical', and have these warnings hidden if silenceJoystickWarnings = true, even when FMS is connected

@calcmogul
Copy link
Member

calcmogul commented Oct 14, 2024

My concern is teams will abuse that functionality to preemptively disable joystick warnings for all ports. Alerts are a better way to organize faults and declutter the console.

We currently have a function to disable all warnings, but we should get rid of it now that alerts exist and are supported by all major dashboards:
https://github.wpilib.org/allwpilib/docs/release/java/edu/wpi/first/wpilibj/DriverStation.html#silenceJoystickConnectionWarning(boolean)

@calcmogul calcmogul added type: feature Brand new functionality, features, pages, workflows, endpoints, etc. component: wpilibj WPILib Java component: wpilibc WPILib C++ labels Oct 14, 2024
@chauser
Copy link
Contributor

chauser commented Oct 16, 2024

What we did to avoid this is create a trigger hooked to the presence of the test controller. Only when the controller is plugged in do we bind its buttons, etc. Here's the code:

...imports etc...
class TestBehaviors {
    CommandXboxController m_testerController = 
        new CommandXboxController(DTIConstants.kTesterControllerPort);
    boolean m_buttonsBound = false;
    DriveSubsystem m_drive;
    ArmSubsystem m_arm;
    ShooterSubsystem m_shooter;
   public TestBehaviors(DriveSubsystem drive, 
                           ArmSubsystem arm,
                           ShooterSubsystem shooter) {
        m_drive = drive;
        m_arm = arm;
        m_shooter = shooter;

        // Defer binding the buttons on the test controller until the controller is present.
        // This way, there are no warnings about missing buttons in normal operation, when
        // the test controller is not expected to be connected.

        // Also note: at least in simulation, isConnected() is false until the robot is enabled.
        // On the real robot it seems isConnected is true from the outset so we don't get a
        // false -> true transition to run the command. Therefore, we will test for connection
        // here and bind if connected, otherwise defer to the connection event.
        if (m_testerController.getHID().isConnected()) {
            bindButtons();
        } else {
        new Trigger(m_testerController.getHID()::isConnected)
                    .onTrue(Commands.run(this::bindButtons).ignoringDisable(true));
        }                                
    }

    private void bindButtons() {

        if (m_buttonsBound || !m_testerController.getHID().isConnected()) return;
        m_buttonsBound = true;
        // B button: intake motor test - full speed
        m_testerController.b()
            .whileTrue(m_shooter.runIntake());

        // X button: shooter motor test - full speed
        m_testerController.x()
            .whileTrue(m_shooter.runShooter());

        // Left joystick backward - raise lower arm slowly
        new Trigger(() -> (m_testerController.getLeftY()>0.1))
            .whileTrue(m_arm.moveLowerUp());
        
        // Left joystick forward - lower lower arm slowly
        new Trigger(() -> (m_testerController.getLeftY()<-0.1))
            .whileTrue(m_arm.moveLowerDown());

        // Right joystick backward - raise upper arm slowly
        new Trigger(() -> (m_testerController.getRightY()>0.1))
            .whileTrue(m_arm.moveUpperUp());
   
    ...etc...

    }
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component: wpilibc WPILib C++ component: wpilibj WPILib Java type: feature Brand new functionality, features, pages, workflows, endpoints, etc.
Projects
None yet
Development

No branches or pull requests

3 participants