SendableChooser not updating values

Hi, my team is attempting to create an auto chooser using theSendableChooser class. The chooser is appearing on ShuffleBoard, but when we change the selected option, the change does not register in code. We are printing the value on a loop and nothing is changing. Does anyone have any idea what could be happening?

Can you please post some code on how you initialize your SendableChooser, how it’s added to Shuffleboard and how you are getting the values?

1 Like

Thanks for the help! Here is our code. Note that we are using kotlin, which is not that different from java.

object OI {
    enum class ControlMode {
        CONTROLLER, JOYSTICK
    }

    val controlModeChooser = SendableChooser<ControlMode>().apply {
        addOption("Joystick", ControlMode.JOYSTICK)
        addOption("Controller", ControlMode.CONTROLLER)
    }
}

And in the main file,

fun main() {
    SmartDashboard.putData("Control Mode",  OI.controlModeChooser)
}

Ah nice to see some Kotlin every once in a while. Shouldn’t your main function have a call to RobotBase.startRobot? The standard Kotlin template is very similar to the Java template: https://github.com/wpilibsuite/GradleRIO/tree/master/examples/kotlin/src/main/kotlin/frc/team0000/robot

I’m also curious to how you are getting that value in a loop. You shouldn’t have any code in your main method, just RobotBase(::Robot). Initialization should take place in a Robot class.

Also, I recommend changing one of the calls from addOption to setDefaultOption so there’s a default if Shuffleboard/SmartDashboard isn’t open.

1 Like

Hi, thank you. We are actually using a different framework than the traditional WPILib robot class. However, the sendable chooser should be indifferent to these changes. We have been using a sendable chooser with our framework for a while and it has always worked for us. Is there something that has changed in wpilib regarding the sendable chooser?

Also we did use setDefaultOption and it doesn’t seem to help. When the default option is selected, there is a green checkmark. But when anything else is selected, there is a red ! next to the option.

Yeah, the setDefaultOption won’t solve your problem, but it might help out later if you actually want a default option to be selected.

Not much has changed regarding the SendableChooser, but everything Sendable related has been changed from 2019 so that might be affecting it. However, as long as your framework is calling SmartDashboard.updateValues() or Shuffleboard.update() it should work as expected.

That’s my best guess to why it’s not working. Do you have a link to the Github of the framework you’re using? I might be able to point out bugs in the framework itself.

Also how the program interacts with the HAL has changed a lot. Chances are if it worked last year and isn’t working this year, it’s because a new change broke something.

1 Like

The link to the framework is https://github.com/SouthEugeneRoboticsTeam/sertain/. The problem was that we were not calling SmartDashboard.update(). Thanks so much!

1 Like

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.