Class FtcDashboard

java.lang.Object
com.acmerobotics.dashboard.FtcDashboard
All Implemented Interfaces:
com.qualcomm.robotcore.eventloop.opmode.OpModeManagerNotifier.Notifications

public class FtcDashboard extends Object implements com.qualcomm.robotcore.eventloop.opmode.OpModeManagerNotifier.Notifications
Main class for interacting with the instance.
  • Method Details

    • registerOpMode

      @OpModeRegistrar public static void registerOpMode(com.qualcomm.robotcore.eventloop.opmode.OpModeManager manager)
    • suppressOpMode

      public static void suppressOpMode()
      Call before start to suppress the enable/disable op mode.
    • start

      @OnCreate public static void start(Context context)
      Starts the dashboard.
    • attachWebServer

      @WebHandlerRegistrar public static void attachWebServer(Context context, com.qualcomm.robotcore.util.WebHandlerManager manager)
      Attaches a web server for accessing the dashboard through the phone (like OBJ/Blocks).
    • attachEventLoop

      @OnCreateEventLoop public static void attachEventLoop(Context context, com.qualcomm.ftccommon.FtcEventLoop eventLoop)
      Attaches the event loop to the instance for op mode management.
    • populateMenu

      @OnCreateMenu public static void populateMenu(Context context, Menu menu)
      Populates the menu with dashboard enable/disable options.
      Parameters:
      menu - menu
    • stop

      @OnDestroy public static void stop(Context context)
      Stops the instance and the underlying WebSocket server.
    • getInstance

      public static FtcDashboard getInstance()
      Returns the active instance instance. This should be called after start(Context).
      Returns:
      active instance instance or null outside of its lifecycle
    • sendTelemetryPacket

      public void sendTelemetryPacket(TelemetryPacket telemetryPacket)
      Queues a telemetry packet to be sent to all clients. Packets are sent in batches of approximate period getTelemetryTransmissionInterval(). Clients display the most recent value received for each key, and the data is cleared upon op mode init or a call to clearTelemetry().
      Parameters:
      telemetryPacket - packet to send
    • clearTelemetry

      public void clearTelemetry()
      Clears telemetry data from all clients.
    • getTelemetry

      public org.firstinspires.ftc.robotcore.external.Telemetry getTelemetry()
      Returns a Telemetry object that delegates to the telemetry methods of this class. Beware that the implementation of the interface is incomplete, and users should test each method they intend to use.
    • getTelemetryTransmissionInterval

      public int getTelemetryTransmissionInterval()
      Returns the telemetry transmission interval in milliseconds.
    • setTelemetryTransmissionInterval

      public void setTelemetryTransmissionInterval(int newTransmissionInterval)
      Sets the telemetry transmission interval.
      Parameters:
      newTransmissionInterval - transmission interval in milliseconds
    • updateConfig

      public void updateConfig()
      Sends updated configuration data to all instance clients.
    • withConfigRoot

      public void withConfigRoot(CustomVariableConsumer function)
      Executes in an exclusive context for thread-safe config tree modification and calls updateConfig() to keep clients up to date. Do not leak the config tree outside the function.
      Parameters:
      function -
    • addConfigVariable

      public <T> void addConfigVariable(String category, String name, ValueProvider<T> provider)
      Add config variable with custom provider that is automatically removed when op mode ends.
      Type Parameters:
      T - variable type
      Parameters:
      category - top-level category
      name - variable name
      provider - getter/setter for the variable
    • addConfigVariable

      public <T> void addConfigVariable(String category, String name, ValueProvider<T> provider, boolean autoRemove)
      Add config variable with custom provider.
      Type Parameters:
      T - variable type
      Parameters:
      category - top-level category
      name - variable name
      provider - getter/setter for the variable
      autoRemove - if true, the variable is removed on op mode termination
    • removeConfigVariable

      public void removeConfigVariable(String category, String name)
      Remove a config variable.
      Parameters:
      category - top-level category
      name - variable name
    • sendImage

      public void sendImage(Bitmap bitmap)
      Sends an image to the dashboard for display (MJPEG style). Note that the encoding process is synchronous. Stops the active stream if running.
      Parameters:
      bitmap - bitmap to send
    • startCameraStream

      public void startCameraStream(org.firstinspires.ftc.robotcore.external.stream.CameraStreamSource source, double maxFps)
      Sends a stream of camera frames at a regular interval.
      Parameters:
      source - camera stream source
      maxFps - maximum frames per second; 0 indicates unlimited
    • stopCameraStream

      public void stopCameraStream()
      Stops the camera frame stream.
    • getImageQuality

      public int getImageQuality()
    • setImageQuality

      public void setImageQuality(int quality)
    • copyIntoSdkGamepad

      public static void copyIntoSdkGamepad(ReceiveGamepadState.Gamepad src, com.qualcomm.robotcore.hardware.Gamepad dst)
    • onOpModePreInit

      public void onOpModePreInit(com.qualcomm.robotcore.eventloop.opmode.OpMode opMode)
      Specified by:
      onOpModePreInit in interface com.qualcomm.robotcore.eventloop.opmode.OpModeManagerNotifier.Notifications
    • onOpModePreStart

      public void onOpModePreStart(com.qualcomm.robotcore.eventloop.opmode.OpMode opMode)
      Specified by:
      onOpModePreStart in interface com.qualcomm.robotcore.eventloop.opmode.OpModeManagerNotifier.Notifications
    • onOpModePostStop

      public void onOpModePostStop(com.qualcomm.robotcore.eventloop.opmode.OpMode opMode)
      Specified by:
      onOpModePostStop in interface com.qualcomm.robotcore.eventloop.opmode.OpModeManagerNotifier.Notifications