How do I use telemetry to debug my OpMode?
Telemetry can be used to display basic text from the robot controller to the driver station . This is accessible through the Telemetry class and the telemetry variable in OpMode and LinearOpMode .
To add information to telemetry:
addData(): This method takes two parameters: a string for the caption and a value of any object type. It prints to the phone screen in the formatcaption : value. IfaddData()is called multiple times with the same caption, the later call will override the value .
``java telemetry.addData("Caption 1", 2.5); telemetry.addData("Caption 2", "value"); ``
addLine(): This method can add a line with no parameters, or it can take a single string to add as a line .
``java telemetry.addLine("This is a line!"); ``
After adding telemetry items, telemetry.update() must be called to push the values to the phone . Without this call, telemetry will not appear on the phone screen . In a standard OpMode, telemetry.update() is called automatically once per loop . The SDK refreshes telemetry on the phone every 250 ms by default, but this interval can be changed using setMsTransmissionInterval() .
An example of using telemetry to display encoder positions, revolutions, and angles is shown in the EncoderOpmode :
// Show the position of the motor on telemetry
telemetry.addData("Encoder Position", position);
telemetry.addData("Encoder Revolutions", revolutions);
telemetry.addData("Encoder Angle (Degrees)", angle);
telemetry.addData("Encoder Angle - Normalized (Degrees)", angleNormalized);
telemetry.update();
While telemetry can be used for debugging, it is also important to debug OpModes extensively before official matches, as unhandled exceptions can cause an "emergency stop" routine, halting the OpMode and displaying a stacktrace .