Announcement

Collapse
No announcement yet.

Gyro sensor drift

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

  • Gyro sensor drift

    Can someone explain to me why I have to put 71.5 degrees instead of 90, to make a 90 degree turn in the next program? #pragma config(StandardModel, "Autopilot Robot")
    //*!!Code automatically generated by 'ROBOTC' configuration wizard !!*//



    task main()
    {
    //Reset the gyro sensor to remove any previous data
    for(int i=0 ; i<8 ;i++)
    {
    resetGyro(gyroSensor);
    sleep(1000);

    displayTextLine(1, "Inicial Degrees: %d", getGyroDegrees(gyroSensor));
    //Loop while the gyro sees a value less than 90 degrees.
    repeatUntil(getGyroHeading(port4) > 71.5)
    {
    //Set the motors to turn to the left at 15% speed.
    setMotorSpeed(leftMotor, -15);
    setMotorSpeed(rightMotor, 15);
    }

    //Specifically stop the motor at the end to force the robot to come to a "Holding" stop.
    setMotorSpeed(leftMotor, 0);
    setMotorSpeed(rightMotor, 0);
    displayTextLine(2, "Final Degrees: %d", getGyroDegrees(gyroSensor));
    sleep(1000); //wait 1 second for the robot to come to a complete stop.
    }
    }

  • #2
    You might want to check your brackets, they appear off and it would definitely cause some off behavior (you are doing your turn loop within your reset gyro loop.)

    Comment


    • #3
      Inertia? (but 71 is way off, we usually used 85).
      Add displaySensorValue into the loop, then one more printout _after_ the 1s delay.
      Or better yet, start a task that will just keep displaying the current heading on a different LCD line...

      Comment


      • #4
        The program works well and makes eight accurate 90-degree turns to observe a displacement with greater precision (sum errors) and the initial reading is 2 and the final72. Also the speed is set to 15 to minimize inertia but I do not know why the value of 71.5 gives 720 degrees when the value should be close to 90 degrees.

        Comment


        • #5
          Ah, didn't realize you wanted it to go 8 times.

          Here is a function Jpearman posted at some point in some forum that teams around here use. Try making a call to it prior to your code and see if it helps at all. I know it has made a difference for some teams in programs with more then 1-2 movements.

          Is the gyro mounted level and in a spot away from the brain/motors?

          PHP Code:
          /*
          * Function to calibrate gyro
          */
          void iqCalibrateGyro()
          {
          short count 20;

          startGyroCalibration(gyroSensorgyroCalibrateSamples512);
          // delay so calibrate flag can be set internally to the gyro
          wait1Msec(100);

          eraseDisplay();

          // wait for calibration to finish or 2 seconds, whichever is longer
          while(getGyroCalibrationFlag(gyroSensor) || (count-- > 0))
          {
          displayTextLine(1"Calibrating... %02d"count/10);
          wait1Msec(100);
          }

          eraseDisplay();

          // reset so this is 0 heading
          resetGyro(gyroSensor);

          displayTextLine(3"Gyro Value is: %d"getGyroHeading(gyroSensor));

          Comment


          • #6
            So there are two typically two aspects to calibrate on a gyro - zero level and gain. The thing being calibrated by the above code is the zero level, that is, to prevent drift when the sensor is stationary. The gain (how much degrees does the sensor report for given amount of actual rotation) for VexIQ gyro should be fixed and right - I haven't seen a VexIQ gyro that would report significantly wrong angle.
            But there is a simple way to verify yours, while eliminating the effect of your robot and program:
            • Put your robot on the field and align it with the wall.
            • Turn it on, go to Settings -> Device info and scroll to the gyro port
            • With robot well aligned and stationary, press the "check" button - it will calibrate and reset the angle
            • Still on the Gyro screen, lift the robot, do a full rotation in the air and align it against the field wall again
            • Read the angle. In a perfect case, you should see 0, but it could be anything from 356...359, 0 ... 4 (the value wraps)
            • Alternatively, you should inspect the "Turns" line, which should read "1.00" or "-1.0"
            From your experiment, should your gyro be really that bad, you'd see an angle of about 288, or 0.8 turns, so this test should provide very clear evidence.

            Comment


            • #7
              Quarkmine and nenik, Many but many thanks for your collaboration. I will do the tests that advised me and I will keep them informed of the result.

              Comment


              • #8

                Comment


                • #9
                  I have performed the tests that advised me and the results are the following:
                  1.- including the Jpearman function, I can do 8 exact 90 ° turns with a value of 63 ° and a speed of 16. It is evident that the problem is not the zero but the gain.
                  2.- Making the test of nenik the value obtained is always 259 +/- 1 and if the rotation I do it 360 ° in a clockwise direction, the value is 100 ° +/- 1, which seems logical and that summed gives 360 °.
                  The question is: What will be the reason?

                  Comment


                  • #10
                    Your gyro looks broken then. Just a last possibility: Have you updated the gyro and the brain to the latest firmware?
                    Originally posted by Robbyg View Post
                    the value obtained is always 259 +/- 1 and if the rotation I do it 360 ° in a clockwise direction, the value is 100 °
                    Are you saying that for 360° rotation, the gyro only counts 100° (or -100° if turning counterclockwise)?
                    That would be very strange and won't match neither 63 nor 72 you need to use to get 90° turn. Could you record the intermediate values after every 90° of turning it manually?


                    Comment


                    • #11
                      Yeah I guess we never did ask if you had tried a different gyro...

                      In the event yours is broken contact VEX - they are really good about getting these issues taken care of.

                      Comment


                      • #12
                        When I manually rotate it clockwise, it starts at 360 ° and the full turn (360 °) ends at 100. When I turn anti-clockwise, it starts at 0 ° and ends at 259 °. say missing 100 just like clockwise. Unfortunately I do not have another gyro to try and in Argentina VEX is not sold. I would have to import it from the USA.

                        Comment


                        • #13
                          Nobility forces!!!! Finally and although somewhat delayed I got the new Gyro sensor that so kindly send me without charge the people of Vex Sopport and all the problems were solved. Now everything works as expected. Thank you very much to all those who offered me a hand to solve the case.

                          Comment


                          • #14
                            Nobility forces! Finally and although somewhat delayed I got the new turn sensor that so kindly send me without charge the people of Vex Sopport and all the problems were solved. Now everything works as expected. Thank you very much to all those who offered me a hand to solve the case.

                            Comment

                            Working...
                            X