Retrieving data

Unlike SmartDashboard.getNumber and friends, retrieving data from Shuffleboard is also done through the NetworkTableEntries, which we covered in the previous article.

class DriveBase extends Subsystem {
  private ShuffleboardTab tab = Shuffleboard.getTab("Drive");
  private NetworkTableEntry maxSpeed =
      tab.add("Max Speed", 1)
         .getEntry();
  
  private DifferentialDrive robotDrive = ...;
  
  public void drive(double left, double right) {
    // Retrive the maximum speed from the dashboard
    double max = maxSpeed.getDouble(1.0);
    robotDrive.tankDrive(left * max, right * max);
  }
}

This basic example has a glaring flaw: the maximum speed can be set on the dashboard to a value outside [0, 1] - which could cause the inputs to be saturated (always at maximum speed), or even reversed! Fortunately, there is a way to avoid this problem - covered in the next article.

0 Report Errors

Use this form to report any errors with the documentation. For help with WPILib, please use the FIRST Forums at http://forums.usfirst.org For reporting WPILib bugs, please submit an issue on GitHub at https://github.com/wpilibsuite/allwpilib/issues/new

Ignore