package org.firstinspires.ftc.teamcode;
// import lines were omitted. OnBotJava will add them automatically.
public class JavaRunToPositionExample extends LinearOpMode {
public void runOpMode() {
motor = hardwareMap.get(DcMotorEx.class, "Motor");
// Reset the encoder during initialization
motor.setMode(DcMotor.RunMode.STOP_AND_RESET_ENCODER);
// Set the motor's target position to 300 ticks
motor.setTargetPosition(300);
// Switch to RUN_TO_POSITION mode
motor.setMode(DcMotor.RunMode.RUN_TO_POSITION);
// Start the motor moving by setting the max velocity to 200 ticks per second
// While the Op Mode is running, show the motor's status via telemetry
while (opModeIsActive()) {
telemetry.addData("velocity", motor.getVelocity());
telemetry.addData("position", motor.getCurrentPosition());
telemetry.addData("is at target", !motor.isBusy());