Package com.acmerobotics.dashboard
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 Summary
Modifier and TypeMethodDescription<T> voidaddConfigVariable(String category, String name, ValueProvider<T> provider) Add config variable with custom provider that is automatically removed when op mode ends.<T> voidaddConfigVariable(String category, String name, ValueProvider<T> provider, boolean autoRemove) Add config variable with custom provider.static voidattachEventLoop(Context context, com.qualcomm.ftccommon.FtcEventLoop eventLoop) Attaches the event loop to the instance for op mode management.static voidattachWebServer(Context context, com.qualcomm.robotcore.util.WebHandlerManager manager) Attaches a web server for accessing the dashboard through the phone (like OBJ/Blocks).voidClears telemetry data from all clients.static voidcopyIntoSdkGamepad(ReceiveGamepadState.Gamepad src, com.qualcomm.robotcore.hardware.Gamepad dst) intReturns the image quality used bysendImage(Bitmap)andstartCameraStream(CameraStreamSource, double)static FtcDashboardReturns the active instance instance.org.firstinspires.ftc.robotcore.external.TelemetryReturns aTelemetryobject that delegates to the telemetry methods of this class.intReturns the telemetry transmission interval in milliseconds.voidonOpModePostStop(com.qualcomm.robotcore.eventloop.opmode.OpMode opMode) voidonOpModePreInit(com.qualcomm.robotcore.eventloop.opmode.OpMode opMode) voidonOpModePreStart(com.qualcomm.robotcore.eventloop.opmode.OpMode opMode) static voidpopulateMenu(Context context, Menu menu) Populates the menu with dashboard enable/disable options.static voidregisterOpMode(com.qualcomm.robotcore.eventloop.opmode.OpModeManager manager) voidremoveConfigVariable(String category, String name) Remove a config variable.voidsendImage(Bitmap bitmap) Sends an image to the dashboard for display (MJPEG style).voidsendTelemetryPacket(TelemetryPacket telemetryPacket) Queues a telemetry packet to be sent to all clients.voidsetImageQuality(int quality) Sets the image quality used bysendImage(Bitmap)andstartCameraStream(CameraStreamSource, double)voidsetTelemetryTransmissionInterval(int newTransmissionInterval) Sets the telemetry transmission interval.static voidstart(Context context) Starts the dashboard.voidstartCameraStream(org.firstinspires.ftc.robotcore.external.stream.CameraStreamSource source, double maxFps) Sends a stream of camera frames at a regular interval.static voidstop(Context context) Stops the instance and the underlying WebSocket server.voidStops the camera frame stream.static voidCall before start to suppress the enable/disable op mode.voidSends updated configuration data to all instance clients.voidwithConfigRoot(CustomVariableConsumer function) Executes in an exclusive context for thread-safe config tree modification and callsupdateConfig()to keep clients up to date.
-
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
Returns the active instance instance. This should be called afterstart(Context).- Returns:
- active instance instance or null outside of its lifecycle
-
sendTelemetryPacket
Queues a telemetry packet to be sent to all clients. Packets are sent in batches of approximate periodgetTelemetryTransmissionInterval(). Clients display the most recent value received for each key, and the data is cleared upon op mode init or a call toclearTelemetry().- 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 aTelemetryobject 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
Executes in an exclusive context for thread-safe config tree modification and callsupdateConfig()to keep clients up to date. Do not leak the config tree outside the function.- Parameters:
function-
-
addConfigVariable
Add config variable with custom provider that is automatically removed when op mode ends.- Type Parameters:
T- variable type- Parameters:
category- top-level categoryname- variable nameprovider- 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 categoryname- variable nameprovider- getter/setter for the variableautoRemove- if true, the variable is removed on op mode termination
-
removeConfigVariable
Remove a config variable.- Parameters:
category- top-level categoryname- 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 sourcemaxFps- maximum frames per second; 0 indicates unlimited
-
stopCameraStream
public void stopCameraStream()Stops the camera frame stream. -
getImageQuality
public int getImageQuality()Returns the image quality used bysendImage(Bitmap)andstartCameraStream(CameraStreamSource, double) -
setImageQuality
public void setImageQuality(int quality) Sets the image quality used bysendImage(Bitmap)andstartCameraStream(CameraStreamSource, double) -
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:
onOpModePreInitin interfacecom.qualcomm.robotcore.eventloop.opmode.OpModeManagerNotifier.Notifications
-
onOpModePreStart
public void onOpModePreStart(com.qualcomm.robotcore.eventloop.opmode.OpMode opMode) - Specified by:
onOpModePreStartin interfacecom.qualcomm.robotcore.eventloop.opmode.OpModeManagerNotifier.Notifications
-
onOpModePostStop
public void onOpModePostStop(com.qualcomm.robotcore.eventloop.opmode.OpMode opMode) - Specified by:
onOpModePostStopin interfacecom.qualcomm.robotcore.eventloop.opmode.OpModeManagerNotifier.Notifications
-