Shuffleboard API docs do not mention sending data with lambda functions
Opened this issue · 2 comments
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
The NT entry API should only be used for reading data from the dashboard, such as from a slider, button, or text field
Isn't that what getNumber
etc are for?
Isn't that what getNumber etc are for?
Are you thinking of the smartdashboard API? Shuffleboard doesn't have those functions.