Using shuffleboard SimpleWidgetExample?

I am trying to get an idea of what can be done with custom Shuffleboard widgets. I have been able to clone the current shuffleboard repository, build the com.example:SimpleWidgetExample, and get the plugin to show up in Shuffleboard.

What I haven’t figured out is how to put data into the NetworkTable that the SimpleWidgetExample can consume; I don’t understand the mapping from data in the NetworkTables into the Point2D object (what the data in the network table needs to look like).

Does anyone have any pointers?

I made a little progress; this Sendable will appear on the Shuffleboard as a “Simple Data Point”, but I haven’t figured out how to change X and Y on the Widget. I can see the ‘x’ and ‘y’ numbers in OutlineViewer, but the Widget is not responding to their changes.

package frc.robot;

import edu.wpi.first.util.sendable.Sendable;
import edu.wpi.first.util.sendable.SendableBuilder;
import edu.wpi.first.util.sendable.SendableRegistry;

public class SendablePoint2D implements Sendable {
    double x = 0;
    double y = 0;

    public SendablePoint2D(double x, double y) {
        this.x = x;
        this.y = y;

        SendableRegistry.addLW(this, "foo");
    }

    @Override
    public void initSendable(SendableBuilder builder) {
        builder.setSmartDashboardType("Point2D");
        builder.addDoubleProperty("x", this::getX, null);
        builder.addDoubleProperty("y", this::getY, null);
    }

    double getX() {
        return x;
    }

    double getY() {
        return y;
    }

    public void setX(double x) {
        this.x = x;
    }

    public void setY(double y) {
        this.y = y;
    }
}

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