Page 2 of 2 FirstFirst 12
Results 11 to 20 of 20

Thread: Gyro Sensor Accuracy

  1. #11
    Join Date
    Sep 2008
    Location
    Minnesota
    Posts
    2,637

    Default Re: Gyro Sensor Accuracy

    To verify I plugged the gyro into port 1 and jiggled it by hand. I couldn't get any drift to speak of. I hooked it back up to my test robot and it was still rock solid. Then I stared moving it to different ports to see if that made a difference. The sticky drifting returned when I plugged into port 3. After I got it to drift in port 3 I wend back to port 1 and it drifts.

    I repeated the experiment today and got the same results. Good performance in port 1, bad when I moved to another port. So I turned off the brick and turned it back on with the sensor plugged into port 3. Now port 3 is solid and moving to other ports (moving wire with brick on) made the sensor susceptible to drift.

    So it looks like something happens when you turn on the EV3 that doesn't happen when you run a program or when you plug in a sensor with power on. Whatever it is, it is very important to the operation of the gyro sensor. If the gyro is plugged in before I turn on the EV3 saturating the sensor (at 440 deg/sec) causes sensor inaccuracy, but does not install a persistent offset in the angle reading. Unplugging the sensor and plugging it back in does make the offset go away, but the sensor will acquire an offset if it saturates again. Resetting the sensor from software does not correct the drift.
    Last edited by Dean Hystad; 08-18-2013 at 12:27 PM. Reason: More information

  2. #12

    Default Re: Gyro Sensor Accuracy

    The kids sat down an tried a bunch of things related to the gyro and the initial "glitch" it sometimes has. They took last year's robot and mashed on the new brick and a couple sensors - including the gyro rate and angle outputs. They had a loop that measured all the sensors and stuffed the values into variables. And a separate loop that displayed those variables on the screen. And then some code, in a third thread, to play with a gyro "line follower" and a angle&gyro "line follower". I saw some odd things that might help others figure out what they are seeing:

    1. The brick is definitely doing something with all its sensors on power up. Like Dean noted elsewhere, moving wires and doing stuff makes it all different. There is some sort of initialization auto-cal. And I wonder what happens if the robot is moving on power up...
    2. It matters when and where you do a gyro reset block in your code. Things work without one. But not always on every power up. Making me wonder about #1 above again, and what the brick is doing. Without a reset block the gyro just seems to have different glitches or drift. Sometimes.
    3. The gryo reset takes 2 seconds or more. During which time if you turn the robot it might calibrate that turn rate as "zero" which makes a mess of later code. And the thread you have the gyro reset in has stopped at that block and is not proceeding.
    4. During the calibration period the numbers coming out of the gyro sensor block are NaN. That is to say if you have your code printing them to the screen it will read "---" not even "0" . This was true for both the heading and rate wires coming out. I figure any code expecting good values during this time would behave in unexpected ways.
    5. There may be some time after the gyro reset is done where you want to wait to use the values coming out. Not sure about this. But as they added delays and waits after resets and before the robot tried moving, things got better.

    In the end, if they powered up the robot and didn't fuss with anything; Let the gyro reset happen with the robot totally still (they had a pause-for-button-press loop there at this point); waited for the display variables to go from NaN "---" to valid values, then:

    The rate and angle read a nice stable zero. And the angle didn't integrate an error (again robot just sitting there not moving/turning) of more than a degree every 20 seconds or so. And then they could make an "angle & gyro follower" work and steer the robot across the board. There initial results were not exactly more accurate than I thought they could do with some careful odometry, but it was really good for something carelessly thrown together to learn EV3 and new sensors. And... I could bump the robot off course and it fixed itself like it was running a line follower, except without the line.

    I don't know if overcoming the gyro weirdness will result in some sort of major navigational advantage. And even if it helps a bit, it also introduces some potential problems (like bumping the competition table during a reset between run 1 and 2 while they are trying to hold things still before a new launch). Either way though, I got to explain how it was coming up with "angle" at all, and now they are on to the idea of integral and derivative. And they are learning cool new stuff.
    Team M
    Coach

  3. #13
    Join Date
    Sep 2008
    Location
    Minnesota
    Posts
    2,637

    Default Re: Gyro Sensor Accuracy

    Quote Originally Posted by Zain View Post
    4. During the calibration period the numbers coming out of the gyro sensor block are NaN. That is to say if you have your code printing them to the screen it will read "---" not even "0" . This was true for both the heading and rate wires coming out. I figure any code expecting good values during this time would behave in unexpected ways.
    I've been having a problem with the gyro sensor and eventually found a very short test case. I wrote a program that writes the gyro rate to the screen until you press an NXT button. This loop is followed by a second loop that does the same thing. If I configure the first loop to read Angle AND Rate and the second loop to read only Rate or only Angle I get NANs (Not A Number, displayed as "---") for 2 seconds. Other combinations work fine, but going from Rate AND Angle to Rate only or Angle only forces a reset. I verified this by displaying Angle from a Rate and Angle Gyro block in the first loop, and displaying Angle from an Angle only Gyro block in the second loop. The angle reading resets to zero when the second loop starts.

    Using what I learned I wrote a new gyro turn block, making sure to never use the Measure Angle and Rate mode for the gyro sensor block. I added drift compensation and my test program starts with a loop that displays gyro rate until I press a NXT button. When I press the button the program divides the gyro angle by the value of timer 1 (elapsed time since start of the program) to get a gyro rate offset. I write the offset to the screen and begin the turn. I ran the program and the display shows "Offset 0" even though the rate was not zero the angle reported by the gyro was. After further experimentation it appears that they gyro does not measure angle unless you use a gyro sensor block that measures angle. This is different than motors that always measure rotation or timers that are always measuring time. The gyro sensor only measures angle when asked. I changed all my gyro blocks to now measure Rate and Angle and the program works. Results are pretty good (about as good as a well designed robot using rotation sensors), but I don't think FLL teams will want to wait 5 seconds at the start of each mission to measure a gyro rate offset, and you have to be careful that your turns are slower than 440 degrees/sec or you'll saturate the gyro sensor and turn too far. Doing turns with steering set to 45 and power at 50 my max gyro rate was 390. Doing one wheel turns I would likely saturate the sensor and spin turns (steer = 100) would have to be done at a much lower power setting.


    There appears to be a few issues with the gyro sensor software.
    Attached Images Attached Images
    Last edited by Dean Hystad; 08-27-2013 at 11:12 AM.

  4. #14
    Join Date
    Aug 2012
    Location
    Bloomington, IN
    Posts
    373

    Default Re: Gyro Sensor Accuracy

    Just a tad off topic: how are you getting the jpg of your program? Are you printing it to a file and then cropping it, or are you using a screenshot?

  5. #15
    Join Date
    Sep 2008
    Location
    Minnesota
    Posts
    2,637

    Default Re: Gyro Sensor Accuracy

    Snipping tool in Windows 7 Accessories. Works great for printing programs too.

  6. #16
    Join Date
    Aug 2012
    Location
    Bloomington, IN
    Posts
    373

    Default Re: Gyro Sensor Accuracy

    That's pretty cool, I didn't know it was there (I'm a linux guy except for the lego stuff)

  7. #17

    Default Re: Gyro Sensor Accuracy

    Dean, yes, I think that tracks exactly what we've been seeing. It may be that the "correct" way to use the gyro block is to use it exactly once in some looping thread which stuffs the rate and angle into variables that are used elsewhere. I'm not sure using the block multiple times in multiple modes will produce entirely predictable results. Especially if the integrator that runs to go from "rate" to "angle" gets switched off if you use the block in rate-only mode.
    Team M
    Coach

  8. #18
    Join Date
    Sep 2008
    Location
    Minnesota
    Posts
    2,637

    Default Re: Gyro Sensor Accuracy

    Quote Originally Posted by Zain View Post
    It may be that the "correct" way to use the gyro block is to use it exactly once in some looping thread which stuffs the rate and angle into variables that are used elsewhere.
    I decided to give this a try. I put the gyro block in a loop that runs parallel to the main task. I ignore the angle measurement and integrate the rate myself. When motors are off (measured current power = 0) I adjust the rate offset. The rate, angle and offset are stored in variables. A second MyBlock is used by the program to access the rate and angle. In has a Reset to set the angle back to zero.

    This worked pretty well and I was getting really good 90 degree turns on a carpeted floor with lots of wheel slip. Whoo-hoo!! But then I picked up the robot and somehow introduced a huge offset in the gyro sensor rate and everything was a mess again.

    More experimentation required.

  9. #19

    Default Re: Gyro Sensor Accuracy

    Well, if your reset happened to run when you were picking up the robot it may have nulled it's rate at an in opportune time - like when you were Turing the robot. (?)

    I think that the kids will want to have the robot totally still, push a button that executes a reset, and beeps when the robot is clear to touch again. Like during set up time. After that rate should be correct, and angle will be good within some small drift. Rather than "resetting" the sensor every time angle needs to go back to zero it would probably be better to record a current angle at reference moments (like up against a wall) and then subtract it from measured angle in order to null out any remaining drift from time to time during operation.
    Team M
    Coach

  10. #20
    Join Date
    Sep 2008
    Location
    Minnesota
    Posts
    2,637

    Default Re: Gyro Sensor Accuracy

    Quote Originally Posted by Zain View Post
    Well, if your reset happened to run when you were picking up the robot it may have nulled it's rate at an in opportune time - like when you were Turing the robot. (?)

    I think that the kids will want to have the robot totally still, push a button that executes a reset, and beeps when the robot is clear to touch again. Like during set up time. After that rate should be correct, and angle will be good within some small drift. Rather than "resetting" the sensor every time angle needs to go back to zero it would probably be better to record a current angle at reference moments (like up against a wall) and then subtract it from measured angle in order to null out any remaining drift from time to time during operation.
    Instead of resetting the gyro sensor my gyro block resets the angle I calculate (integrated rate). The gyro is only reset once at the beginning of the program, and that probably isn't needed. When I picked up the robot the gyro sensor rate took on a big offset. A handling test may be in order. Run a program that displays the rate and see what happens when it is handled.

Page 2 of 2 FirstFirst 12

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. EV3 Gyro Sensor
    By rakar in forum Products & Equipment
    Replies: 39
    Last Post: 11-20-2013, 03:59 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •