Elastic Documentation
DownloadGitHub Repository
  • Home
  • Getting Started
    • Installation
    • App Navigation
    • Connecting To Your Robot
  • Customizing your Dashboard
    • Adding and Customizing Widgets
    • Adding and Customizing Layouts
  • Additional Features and References
    • Widgets List & Properties Reference
    • ElasticLib
    • Remote Layout Downloading
    • Custom Widget Examples
    • Shuffleboard API
  • Legal
    • Open Source License
    • Privacy Policy
Powered by GitBook
On this page
  • Single Color View
  • SwerveDrive
  • YAGSL Swerve Drive
  • Alerts
Edit on GitHub
  1. Additional Features and References

Custom Widget Examples

Single Color View

Color exampleColor = new Color(68, 238, 255);
SmartDashboard.putString("Example Color", exampleColor.toHexString());

SwerveDrive

Note: Velocity must be in meters per second, and angles must be in either radians, degrees, or rotations, and CCW+

SmartDashboard.putData("Swerve Drive", new Sendable() {
  @Override
  public void initSendable(SendableBuilder builder) {
    builder.setSmartDashboardType("SwerveDrive");

    builder.addDoubleProperty("Front Left Angle", () -> frontLeftModule.getAngle().getRadians(), null);
    builder.addDoubleProperty("Front Left Velocity", () -> frontLeftModule.getVelocity(), null);

    builder.addDoubleProperty("Front Right Angle", () -> frontRightModule.getAngle().getRadians(), null);
    builder.addDoubleProperty("Front Right Velocity", () -> frontRightModule.getVelocity(), null);

    builder.addDoubleProperty("Back Left Angle", () -> backLeftModule.getAngle().getRadians(), null);
    builder.addDoubleProperty("Back Left Velocity", () -> backLeftModule.getVelocity(), null);

    builder.addDoubleProperty("Back Right Angle", () -> backRightModule.getAngle().getRadians(), null);
    builder.addDoubleProperty("Back Right Velocity", () -> backRightModule.getVelocity(), null);

    builder.addDoubleProperty("Robot Angle", () -> getRotation().getRadians(), null);
  }
});

YAGSL Swerve Drive

If you are using the YAGSL Swerve Library, you can create a Swerve Drive widget without even modifying your code. Simply head to the SmartDashboard table, and drag the swerve table onto the grid, and you will have created a Swerve widget that shows your current and desired module states.

Alerts

For robot code using a WPILib version after 2024, this will be available in all WPILib projects and no additional files need to be added.

PreviousRemote Layout DownloadingNextShuffleboard API

Last updated 6 months ago

This displays data from the NetworkAlerts by . For examples and implementation, see

Team 6328
Mechanical Advantage 2023 Robot Code