Skip to content

Shuffleboard API docs do not mention sending data with lambda functions #2617

@SamCarlberg

Description

@SamCarlberg

The docs currently recommend using NT entries directly:

If data needs to be updated (for example, the output of some calculation done on the robot), call getEntry() after defining the value, then update it when needed or in a periodic function

class VisionCalculator {
   private ShuffleboardTab tab = Shuffleboard.getTab("Vision");
   private GenericEntry distanceEntry =
      tab.add("Distance to target", 0)
         .getEntry();

   public void calculate() {
     double distance = ...;
     distanceEntry.setDouble(distance);
   }
}

This should instead recommend addNumber with a lambda function to read a cached distanceToTarget field.

class VisionCalculator {
   private ShuffleboardTab tab = Shuffleboard.getTab("Vision");
   private double distanceToTarget = 0;
   
   public VisionCalculator() {
     tab.addNumber("Distance to target", () -> distanceToTarget);
   }

   public void calculate() {
     double distanceToTarget = /* expensive calculation*/;
   }
}

The NT entry API should only be used for reading data from the dashboard, such as from a slider, button, or text field

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions