package org.firstinspires.ftc.teamcode; import java.io.File; // Import the File class import java.io.IOException; // Import the IOException class to handle errors import com.qualcomm.robotcore.eventloop.opmode.LinearOpMode; import org.firstinspires.ftc.robotcore.external.Telemetry; import com.qualcomm.robotcore.robot.Robot; import com.qualcomm.robotcore.hardware.DcMotorEx; @TeleOp public class MaxVelocityTest extends LinearOpMode { DcMotorEx motor; double currentVelocity; double maxVelocity = 0.0; @Override public void runOpMode() { motor = hardwareMap.get(DcMotorEx.class, "elv1"); motor.setMode(DcMotor.RunMode.RUN_WITHOUT_ENCODER); motor.setPower(1); waitForStart(); while (opModeIsActive()) { currentVelocity = motor.getVelocity(); if (currentVelocity > maxVelocity) { maxVelocity = currentVelocity; } telemetry.addData("current velocity", currentVelocity); telemetry.addData("maximum velocity", maxVelocity); telemetry.update(); } } private void writeFile(String filename, String content){ File file = getFile(filename); FileOutputStream stream = new FileOutputStream(file); try { stream.write(content.getBytes()); } finally { stream.close(); } } private File getFile(String filename){ File file = new File(filename); try{ file.createNewFile(); } return file; } private String readFile(String filename){ File file = getFile(filename); int length = (int) file.length(); byte[] bytes = new byte[length]; FileInputStream in = new FileInputStream(file); try { in.read(bytes); } finally { in.close(); } String contents = new String(bytes); return contents; } }