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> void
addConfigVariable
(String category, String name, ValueProvider<T> provider) Add config variable with custom provider that is automatically removed when op mode ends.<T> void
addConfigVariable
(String category, String name, ValueProvider<T> provider, boolean autoRemove) Add config variable with custom provider.static void
attachEventLoop
(Context context, com.qualcomm.ftccommon.FtcEventLoop eventLoop) Attaches the event loop to the instance for op mode management.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).void
Clears telemetry data from all clients.static void
copyIntoSdkGamepad
(ReceiveGamepadState.Gamepad src, com.qualcomm.robotcore.hardware.Gamepad dst) int
Returns the image quality used bysendImage(Bitmap)
andstartCameraStream(CameraStreamSource, double)
static FtcDashboard
Returns the active instance instance.org.firstinspires.ftc.robotcore.external.Telemetry
Returns aTelemetry
object that delegates to the telemetry methods of this class.int
Returns the telemetry transmission interval in milliseconds.void
onOpModePostStop
(com.qualcomm.robotcore.eventloop.opmode.OpMode opMode) void
onOpModePreInit
(com.qualcomm.robotcore.eventloop.opmode.OpMode opMode) void
onOpModePreStart
(com.qualcomm.robotcore.eventloop.opmode.OpMode opMode) static void
populateMenu
(Context context, Menu menu) Populates the menu with dashboard enable/disable options.static void
registerOpMode
(com.qualcomm.robotcore.eventloop.opmode.OpModeManager manager) void
removeConfigVariable
(String category, String name) Remove a config variable.void
sendImage
(Bitmap bitmap) Sends an image to the dashboard for display (MJPEG style).void
sendTelemetryPacket
(TelemetryPacket telemetryPacket) Queues a telemetry packet to be sent to all clients.void
setImageQuality
(int quality) Sets the image quality used bysendImage(Bitmap)
andstartCameraStream(CameraStreamSource, double)
void
setTelemetryTransmissionInterval
(int newTransmissionInterval) Sets the telemetry transmission interval.static void
start
(Context context) Starts the dashboard.void
startCameraStream
(org.firstinspires.ftc.robotcore.external.stream.CameraStreamSource source, double maxFps) Sends a stream of camera frames at a regular interval.static void
stop
(Context context) Stops the instance and the underlying WebSocket server.void
Stops the camera frame stream.static void
Call before start to suppress the enable/disable op mode.void
Sends updated configuration data to all instance clients.void
withConfigRoot
(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 aTelemetry
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
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:
onOpModePreInit
in interfacecom.qualcomm.robotcore.eventloop.opmode.OpModeManagerNotifier.Notifications
-
onOpModePreStart
public void onOpModePreStart(com.qualcomm.robotcore.eventloop.opmode.OpMode opMode) - Specified by:
onOpModePreStart
in interfacecom.qualcomm.robotcore.eventloop.opmode.OpModeManagerNotifier.Notifications
-
onOpModePostStop
public void onOpModePostStop(com.qualcomm.robotcore.eventloop.opmode.OpMode opMode) - Specified by:
onOpModePostStop
in interfacecom.qualcomm.robotcore.eventloop.opmode.OpModeManagerNotifier.Notifications
-