package org.firstinspires.ftc.robotcontroller.external.samples;

import com.qualcomm.robotcore.eventloop.opmode.Disabled;
import com.qualcomm.robotcore.eventloop.opmode.LinearOpMode;
import com.qualcomm.robotcore.eventloop.opmode.TeleOp;
import com.qualcomm.robotcore.hardware.DcMotor;

@TeleOp(name = "Concept: Ramp Motor Speed", group = "Concept")
//@Disabled
public class ConceptRampMotorSpeed extends LinearOpMode {

    private DcMotor pair1motor1;
    private DcMotor pair1motor2;
    private DcMotor pair2motor1;
    private DcMotor pair2motor2;

    @Override
    public void runOpMode() {

        // Initialize motors
        pair1motor1 = hardwareMap.get(DcMotor.class, "verticalMotorLeft");
        pair1motor2 = hardwareMap.get(DcMotor.class, "verticalMotorRight");
        pair2motor1 = hardwareMap.get(DcMotor.class, "horizontalMotorLeft");
        pair2motor2 = hardwareMap.get(DcMotor.class, "horizontalMotorRight");

        // Telemetry message before starting
        telemetry.addData("Status", "Ready to start. Press Start.");
        telemetry.update();
        waitForStart();

        // Ramp motor speeds until stop is pressed
        double yPower;
        double xPower;
        double rotationPower;
        double powerPair1Motor1;
        double powerPair1Motor2;
        double powerPair2Motor1;
        double powerPair2Motor2;
        double maxPower;

        while (opModeIsActive()) {  // Replace 'true' with 'opModeIsActive()' to allow for proper shutdown
            // Get gamepad inputs
            yPower = -gamepad1.left_stick_y;         // Forward/backward
            xPower = gamepad1.left_stick_x;          // Left/right strafe
            rotationPower = gamepad1.right_stick_x;  // Rotation

            // Calculate motor powers
            powerPair1Motor1 = yPower + rotationPower;
            powerPair1Motor2 = -yPower + rotationPower;
            powerPair2Motor1 = xPower + rotationPower;
            powerPair2Motor2 = -xPower + rotationPower;

            // Normalize the motor powers if any exceed 1.0
            if (Math.abs(powerPair1Motor1) > 1 || Math.abs(powerPair1Motor2) > 1 ||
                Math.abs(powerPair2Motor1) > 1 || Math.abs(powerPair2Motor2) > 1) {

                maxPower = findMax(powerPair1Motor1, powerPair1Motor2, powerPair2Motor1, powerPair2Motor2);
                powerPair1Motor1 /= maxPower;
                powerPair1Motor2 /= maxPower;
                powerPair2Motor1 /= maxPower;
                powerPair2Motor2 /= maxPower;
            }

            // Set motor powers
            pair1motor1.setPower(powerPair1Motor1);
            pair1motor2.setPower(powerPair1Motor2);
            pair2motor1.setPower(powerPair2Motor1);
            pair2motor2.setPower(powerPair2Motor2);

            // Optional: Telemetry for debugging
            telemetry.addData("yPower", yPower);
            telemetry.addData("xPower", xPower);
            telemetry.addData("rotationPower", rotationPower);
            telemetry.addData("Motor1 Power", powerPair1Motor1);
            telemetry.addData("Motor2 Power", powerPair1Motor2);
            telemetry.addData("Motor3 Power", powerPair2Motor1);
            telemetry.addData("Motor4 Power", powerPair2Motor2);
            telemetry.update();
        }
    }

    // Helper method to find the maximum absolute power value
    public double findMax(double power1, double power2, double power3, double power4) {
        double max = Math.max(Math.abs(power1), Math.abs(power2));
        max = Math.max(max, Math.abs(power3));
        max = Math.max(max, Math.abs(power4));
        return max;
    }
}
Please explain how this code for an x-drive type architecture works step by step. thanks