Announcement

Collapse
No announcement yet.

MR Integrated Gyro problems

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • MR Integrated Gyro problems

    Hello,

    My FTC team is currently using the MR Gyro, and we are facing two major problems:

    1. The gyro doesn't seem to be recognized. We have tried to test using the Core Device Discovery software, and it worked perfectly (is calibrating and can properly measure angle/heading) there on the same devices (Core Device Interface, Core Power Dist., etc). This means that it is not a hardware problem
    2. When the gyro works (is recognized and actually measures angle), we constantly get the endless spinning when turning in autonomous, as seen by many MR Gyro-based robots

    We really hope someone can help as we have searched everywhere, albeit no prevail

    Our code:

    public void gyroTurn(double speed, double angle){ telemetry.addData("starting gyro turn","-----"); telemetry.update(); while(opModeIsActive() && !onTargetAngle(speed, angle, P_TURN_COEFF)){ telemetry.update(); idle(); telemetry.addData("-->","inside while loop :-("); telemetry.update(); } stopMotors(); telemetry.addData("done with gyro turn","-----"); telemetry.update(); } boolean onTargetAngle(double speed, double angle, double PCoeff){ double error; double steer; boolean onTarget = false; double leftSpeed; double rightSpeed; //determine turm power based on error error = getError(angle); if (Math.abs(error) <= TURN_THRESHOLD){ steer = 0.0; leftSpeed = 0.0; rightSpeed = 0.0; onTarget = true; } else{ steer = getSteer(error, PCoeff); rightSpeed = speed * steer; leftSpeed = -rightSpeed; //leftSpeed = -5; } front_left_motor.setMode(DcMotor.RunMode.RUN_WITHO UT_ENCODER); back_left_motor.setMode(DcMotor.RunMode.RUN_WITHOU T_ENCODER); front_right_motor.setMode(DcMotor.RunMode.RUN_WITH OUT_ENCODER); back_right_motor.setMode(DcMotor.RunMode.RUN_WITHO UT_ENCODER); front_left_motor.setPower(leftSpeed); front_right_motor.setPower(rightSpeed); back_left_motor.setPower(leftSpeed); back_right_motor.setPower(rightSpeed); telemetry.addData("Target angle","%5.2f",angle); telemetry.addData("Error/Steer", "%5.2f/%5.2f", error, steer); telemetry.addData("speed", "%5.2f/%5.2f", leftSpeed, rightSpeed); return onTarget; } public double getError(double targetAngle){ double robotError; robotError = targetAngle - gyro.getIntegratedZValue(); //telemetry.addData("Zvalue","%5.2f",gyro.getIntegra tedZValue()); //telemetry.update(); while(robotError > 180) robotError -= 360; while(robotError <= -180) robotError += 360; telemetry.addData("Robot Error","%5.2f",robotError); telemetry.update(); return robotError; } public double getSteer(double error , double PCoeff){ return Range.clip(error * PCoeff, -1 , 1); } ----------------- Variables used:
    double P_TURN_COEFF = 0.1; //Multiplier to reduce speed when turning double TURN_THRESHOLD = 2.5; //Range of margin for turn to achieve

  • #2
    Hi! FTC has their own forum where you are much more likely to receive assistance with your issue: https://ftcforum.usfirst.org/
    FIRST®
    FRC Robotics Engineer

    Comment

    Working...
    X