Gyro Acting Weird (V5)

  1. 2 weeks ago

    Chris_A

    Dec 2 Virginia 80708X

    Hey guys,

    Our gyro is returning weird values. We are printing the value of the gyro on the brain screen, but when we tell it to turn 45 degrees, it rotates around 90 degrees in real life. Any tips or fixes? Thanks!

  2. Terrel_T

    Dec 2 Montclair, Virginia 80708X

    Same problem here

  3. R.D.Z.

    Dec 2 9181Z

    I had a similar problem but one of my coaches told me that it was probably because the gyro was faulty. I tried replacing the gyro and even switching the port it was in on the brain but it still didn't work. He just said that it may be a V5 bug and he also said to use the degree rotations on the wheels to turn to a set position.

  4. jpearman

    Dec 2 Moderator, ROBOTC Tech Support, V5 Beta Moderator Los Angeles 8888
    Edited 2 weeks ago by jpearman

    @Chris_A Hey guys,

    Our gyro is returning weird values. We are printing the value of the gyro on the brain screen, but when we tell it to turn 45 degrees, it rotates around 90 degrees in real life. Any tips or fixes? Thanks!

    when you tell what to turn 45 degrees ?

  5. Chris_A

    Dec 2 Virginia 80708X
    Edited 2 weeks ago by Chris_A

    @jpearman when you tell what to turn 45 degrees ?

    the pseudo code is:

    while the value of the gyro is under 45 degrees, turn

  6. Joshua_L

    Dec 2 Virginia 80708X Exobytes
    Edited 2 weeks ago by Joshua_L

    @jpearman I'm on the same team, and basically what is happening is we have function with a while loop like

    while(gyro value in degrees < 45) move(); 

    We have all the other gimmicks like brakes and stuff to make it more consistent, but basically when we use this function the robot rotates over 90 degrees in real life. The actual value of the gyro (printed on the brain's screen) is around 60, but that's expected because of drift/slight overshoot. So to fix this for now we made a linear equation that adjusts the value of the gyro (sort of).

    TL;DR
    When the gyro reads 60 degrees, the robot actually rotates over 90 degrees in real life. Does this sound like a defective gyro or is it a V5-specific problem? (we're on V5)

    EDIT:
    Also, we are giving the gyro a full 1.5 seconds to calibrate

  7. jpearman

    Dec 2 Moderator, ROBOTC Tech Support, V5 Beta Moderator Los Angeles 8888
    Edited 2 weeks ago by jpearman

    @Joshua_L Does this sound like a defective gyro or is it a V5-specific problem? (we're on V5)

    Last time I checked the Gyro was working ok on V5. The best way to test is to mount it onto something other than the robot that allows you to easily rotate it. If its value is stable when not moving and consistently shows a different angle when rotated 90 degrees (I mean a large difference, not 1-2 degrees), either there is a fault or you have a gyro that needs a very different scale factor. Try it in another V5 3wire port and see if that helps, I'll check functionality on Monday but nothing has been changed in that areas for months now.

  8. Joshua_L

    Dec 2 Virginia 80708X Exobytes

    @jpearman Last time I checked the Gyro was working ok on V5. The best way to test is to mount it onto something other than the robot that allows you to easily rotate it. If its value is stable when not moving and consistently shows a different angle when rotated 90 degrees (I mean a large difference, not 1-2 degrees), either there is a fault or you have a gyro that needs a very different scale factor. Try it in another V5 3wire port and see if that helps, I'll check functionality on Monday but nothing has been changed in that areas for months now.

    Ok, we did what you said and found that when the gyro is turned 90 degrees, it returns a value (in degrees) of 50. Turning 180 degrees returns a value of around 100. The values are basically proportionate, so they probably have a very different scale factor.

  9. last week

    jpearman

    Dec 4 Moderator, ROBOTC Tech Support, V5 Beta Moderator Los Angeles 8888
    Edited last week by jpearman

    I checked gyro operation today, I don't see any issues but I only have one gyro here. To calculate the gyro angle in degrees we use a raw internal value and scale that

    value = raw_gyro / scale;

    The default scale we use is 130, that's actually the same value as we used to use in ROBOTC. You can start a calibration and pass a different scale factor using the startCalibration method, this is usually called without any parameters but it's possible to pass a scale factor which must be larger than 32. So if your gyro returns 60.0 instead of 90.0 you would need a smaller scale factor so the returned number was larger. Here is an example. Although this value is saved with your program, to put the gyro back to default you would need to pass 130 or power cycle the brain.

    int main() {
        Gyro1.startCalibration( 87 );
        
        while(1) {
            Brain.Screen.printAt( 10, 20, "Gyro: %6.2f", Gyro1.value( rotationUnits::deg));
        }
    }
  10. Joshua_L

    Dec 4 Virginia 80708X Exobytes
    Edited last week by Joshua_L

    @jpearman I checked gyro operation today, I don't see any issues but I only have one gyro here. To calculate the gyro angle in degrees we use a raw internal value and scale that

    value = raw_gyro / scale;

    The default scale we use is 130, that's actually the same value as we used to use in ROBOTC. You can start a calibration and pass a different scale factor using the startCalibration method, this is usually called without any parameters but it's possible to pass a scale factor which must be larger than 32. So if your gyro returns 60.0 instead of 90.0 you would need a smaller scale factor so the returned number was larger. Here is an example. Although this value is saved with your program, to put the gyro back to default you would need to pass 130 or power cycle the brain.

    int main() { Gyro1.startCalibration( 87 ); while(1) { Brain.Screen.printAt( 10, 20, "Gyro: %6.2f", Gyro1.value( rotationUnits::deg)); } }

    Wait, the argument inside of startCalibration isn't a delay?

  11. jpearman

    Dec 4 Moderator, ROBOTC Tech Support, V5 Beta Moderator Los Angeles 8888

    @Joshua_L Wait, the argument inside of startCalibration isn't a delay?

    Unfortunately, the documentation in VCS 1.0 is a bit misleading. We generally don't expect you to pass anything to startCalibration. It can be a time, but not as you may expect. Here are my notes from the source code.

    /*----------------------------------------------------------------------------*/
    // Using set value on the gyro to start calibration and, optionally, change scaling
    // value of 0 means calibrate for 1024 samples (essentially 1024 mS) Default setting
    // value of 1 means calibrate fot 2048 samples
    // value of 2 means calibrate fot 4096 samples
    // during calibration returned value of gyro will be 0x8000 (-32768)
    // values above 32 can be used to set the gyro scaling, the default value for
    // this is 130, that is, output gyro value is raw gyro integrated value / 130
    // changing gyro scale alone will cause recalibration using last cal setting
    // for number of samples.
    /*----------------------------------------------------------------------------*/

    The only deviation from that is that we force the value to 0 during calibration, that may not have been released yet though, I forget.

  12. Joshua_L

    Dec 4 Virginia 80708X Exobytes
    Edited last week by Joshua_L

    @jpearman Unfortunately, the documentation in VCS 1.0 is a bit misleading. We generally don't expect you to pass anything to startCalibration. It can be a time, but not as you may expect. Here are my notes from the source code.

    /*----------------------------------------------------------------------------*/
    // Using set value on the gyro to start calibration and, optionally, change scaling
    // value of 0 means calibrate for 1024 samples (essentially 1024 mS) Default setting
    // value of 1 means calibrate fot 2048 samples
    // value of 2 means calibrate fot 4096 samples
    // during calibration returned value of gyro will be 0x8000 (-32768)
    // values above 32 can be used to set the gyro scaling, the default value for
    // this is 130, that is, output gyro value is raw gyro integrated value / 130
    // changing gyro scale alone will cause recalibration using last cal setting
    // for number of samples.
    /*----------------------------------------------------------------------------*/

    The only deviation from that is that we force the value to 0 during calibration, that may not have been released yet though, I forget.

    What would happen if we put in a value higher than 130? Say, 1500? Would the scale factor be 1500? Or would it be 70, since 1500 % 130 is 70?

    70/130 = 0.54, and currently this is very close to the number we are multiplying our input arguments by to translate our input values into actual gyro values. Say we want to turn 90 degrees, our function first mutiplies 90 by 0.6, so that our gyro actually turns to 54. And for 180 degrees, it would turn to 108.

  13. jpearman

    Dec 4 Moderator, ROBOTC Tech Support, V5 Beta Moderator Los Angeles 8888

    scale is limited to the range 32 to 255. A larger value of scale would make the returned value of the gyro smaller for a given rotation. It pretty much behaves the same way as ROBOTC SensorScale.

  14. Kselva20

    Dec 5 5249Z

    Are you guys calibrating the gyroscope beforehand? Also I have had trouble using rotationUnits. Use analogUnits::range12bit. It outputs in 10th of a degree. So 180 degrees will be 1800.

  15. Joshua_L

    Dec 5 Virginia 80708X Exobytes

    @Kselva20 Are you guys calibrating the gyroscope beforehand? Also I have had trouble using rotationUnits. Use analogUnits::range12bit. It outputs in 10th of a degree. So 180 degrees will be 1800.

    We did calibrate the gyro beforehand, but we were putting 1500 in startCalibrsation. This may have pushed the scale factor to 255 which is why we are getting numbers that are smaller than they should be.

  16. Kselva20

    Dec 5 5249Z

    Try starting the calibration and rather than passing 1500 to the method, pass nothing to it and use the vex sleep task for maybe 5 seconds (5000). It works perfectly for us. also use the analongUnits too.

  17. Kselva20

    Dec 5 5249Z

    I can post my code if it would help (can't do it right now maybe in 3 hours).

  18. Joshua_L

    Dec 5 Virginia 80708X Exobytes

    Yeah we were gonna try this either today or tomorrow when we got ahold of the robot again. Thanks for the tip though, we'll probably switch to analog units now.

  19. Lukyan_1

    Dec 5 Woodbridge, VA 4303A
    Edited last week by Lukyan_1

    @Joshua_L ya the analog units are better. im not sure, but i think you dont have to calibrate them. Here is the post bout analog if u want.

  20. Joshua_L

    Dec 5 Virginia 80708X Exobytes

    Im pretty sure you have to calibrate the gyro every time the robot turns on regardless of units used

  21. Newer ›
 

or Sign Up to reply!