Shuffleboard for field calibration

So has anyone used shuffleboard to store offsets for field imperfections?

That is say target x on the blue side is 2m higher than the specs and the red side is right on. IT seems useful to figure those out during field calibration. Now those offsets could be hard coded and just change them in the code, but it might be nice to have those as shuffleboard values. So any ideas where to start on saving values entered in shuffleboard to the rio to persist beyond reboot?

You could have it write all the data to a file on the Rio and reread it on startup. Then when you change the configuration in shuffleboard it updates the file.

1 Like

That is a way, I was thinking there was a persistent portion of the network tables.

I played around with it, it seems the addPersistent is what I want works quite well.
Something like this demonstrates the capability. Change the values on shuffleboard, shut shuffleboard down, shut down the bot, come back and they are there. This would not be how I do the final implementation but it demonstrates the point.

ShuffleboardTab fieldCalibration = Shuffleboard.getTab("Field Calibration");
  /** The container for the robot. Contains subsystems, OI devices, and commands. */
  public RobotContainer() {
    fieldCalibration.addPersistent("Blue", 0);
    fieldCalibration.addPersistent("Red", 0);
    NetworkTable x =  NetworkTableInstance.getDefault().getTable("Shuffleboard");
    NetworkTable y  = x.getSubTable("Field Calibration");
    System.out.println("Blue" + y.getEntry("Blue").getNumber(0));
    System.out.println("Red" + y.getEntry("Red").getNumber(0));

Any issues with this approach?

1 Like

It effectively reimplements WPILib’s preferences class. Setting Robot Preferences — FIRST Robotics Competition documentation

1 Like

Certainly does, looks like that is what I was looking for.

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