A question on modifying Shuffleboard widget properties after creation

Hi, new user here, first post. I would appreciate anyones input!

Context

I am new to Java, trying to figure out a good way to tune a PID controlled subsystem. I have made a couple of widgets to go on the Shuffleboard dashboard, and the values can be pushed to the robot. The goal is for very easy tuning and manual control of the subsystem during testing.

I created an indicator widget for current encoder position, and a slider for the setpoint. When instantiating the shuffleboard widgets, I can easily configure the widgets exactly how I want in the subsystem class constructor:

liftPosition = shuffleHopperTab
    .add("Lift Position", 0.0)
    .withWidget(BuiltInWidgets.kNumberBar)
    .withProperties(
        Map.of(
            "Min", Subsystem.Hopper.LIFT_DOWN,
            "Max", Subsystem.Hopper.LIFT_UP))
    .withSize(4, 1)
    .withPosition(0, 2)
    .getEntry();
liftSetpoint = shuffleHopperTab
    .add("Lift Setpoint", 0.0)
    .withWidget(BuiltInWidgets.kNumberSlider)
    .withProperties(
        Map.of(
            "Min", Subsystem.Hopper.LIFT_DOWN,
            "Max", Subsystem.Hopper.LIFT_UP))
    .withSize(4, 1)
    .withPosition(0, 3)
    .getEntry();

Problem

Point is, I can set the min and max value for the slider and indicator during instantiation, but I would like to update the min and max values when the maximum value is changed when the robot is running.

Is there a way to get the reference to the widget after instantiation? Could I save the widget reference to a variable, then get the entry from that and assign it to a NetTables variable, then from then on use the widget reference to update the mapping? Would this cause issues with the Shuffleboard?

Thanks!

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