Programming Motor Telemetry

Motors and Telemetry

Recall that telemetry is the process of collecting and transmitting data. There is a lot of useful information our motors could send back to us, but to start let's have it output the power based on the joystick's movement.

Similar to our servo program, let's add a new line of telemetry.addData();.

while (opModeIsActive()) {
            test_motor.setPower(- this.gamepad1.left_stick_y);
            telemetry.addData();
            telemetry.addData("Status", "Running");
            telemetry.update();
        }

This time we are going to set our string as "Motor Power" and after our comma will use test_motor.getPower()

while (opModeIsActive()) {
            test_motor.setPower(- this.gamepad1.left_stick_y);
            telemetry.addData("Motor Power", test_motor.getPower());
            telemetry.addData("Status", "Running");
            telemetry.update();
        }

Full Code:

    @Override
public void runOpMode() {
        control_Hub = hardwareMap.get(Blinker.class, "Control Hub");
        arm = hardwareMap.get(DcMotor.class, "arm");
        leftmotor = hardwareMap.get(DcMotor.class, "leftmotor");
        rightmotor = hardwareMap.get(DcMotor.class, "rightmotor");
        test_motor = hardwareMap.get(DcMotor.class, "test_motor");
        test_servo = hardwareMap.get(Servo.class, "test_servo");
        test_touch = hardwareMap.get(TouchSensor.class, "test_touch");
        
        test_servo.setPosition(0);

        telemetry.addData("Status", "Initialized");
        telemetry.update();
        // Wait for the game to start (driver presses PLAY)
        waitForStart();

        // run until the end of the match (driver presses STOP)
        while (opModeIsActive()) {
            test_motor.setPower(-this.gamepad1.left_stick_y);
            telemetry.addData("Motor Power", test_motor.getPower());
            telemetry.addData("Status", "Running");
            telemetry.update();

        }
    }

Last updated