eV3 Gyro Sensor

gyroscope_md_wmThe new gyroscopic (gyro) sensor on our new eV3 robot is a potentially powerful but sensitive device.  You can basically think of it as a fancy electronic compass with the following twists:

1)  It doesn’t measure true North/South/East/West and all points inbetween.  Instead, our FlopBot can read two numbers from the gyro:  (a) a number representing current angle in degrees turned in a 2D plane, and (b) a number representing the rate of turning or rotation in units of degrees per second in that plane.

2)  Everytime the gyro is (a) programmically reset or (b) powered on by turning on gryo the angle value is (re)set to zero.  There is an undocumented way to reset the gyro that appears better than just using the reset option on the gyro sensor block (see Caution #3 below).

3)  With the gryo placed parallel to the mat surface and looking down on the robot, a right or clockwise turn will increase the angle value from while a left or counter-clockwise turn will decrease the angle value.  For example, starting from a gyro reset/powerup condition, turning right 1 full circle should increase the gyro angle sensor from 0 to 360 while turning left 2 full circles should leave the angle sensor at -720.

( Do not un/replug in gyro sensor to reset )


1)  Unlike Platonic Forms, the gyro sensor like all other material sensors and motors suffer inherent inaccuracies.  Manufacturers of electronic components statistically analyze and use quality control to ensure every component will reliably work within a given range of errors under various ranges of operating conditions (summarized in various charts and spec sheets).

The eV3 gyro spec sheet is very sparse and ambigious.  It states the gyro can measure angles within + or – 3 degrees of accuracy.  An optimist may hope for an accuracy of 3 degrees per 360 complete turn or 0.83% accuracy – wrong.  In fact, the error should increase as the turn angle increases and recorded more than 3 degrees error per 360 degree turn in our tests a few weeks ago. Manufactures generally game these specs by measuring these errors under unrealistic opering conditions, raises the question of how large an turn can you make and stay within that +/- 3 error range under normal conditions.

Since each turn adds some error to our gyro reading, it’s best to minimize the number of turns and, since errors accumulate, line up with a known wall or line and periodically reset the gyro to eliminate the accumulated error.  Note the trick to reset the gyro in #3 below.

2) The gyro needs to be very still when powering up or resetting to get a more accurate angle value.  Any giggling of the device when the powering up or resetting the gyro may result in greater errors.  Un/replugging the gyro cable is an unreliable way to reset the gyro (besides it is virtually impossible to keep the gyro motionless while un/plugging cables).

3)  The gyro may suffers drift where, even when stationary, the angle readings change.  One recommended way to fix drift is to reset the gyro by switching the gyro sensor block from angular velocity to angle mode with a 2-4 second pause afterwards to let the gyro stablize before proceeding.  Simply dropping a gyro sensor block and selecting reset doesn’t solve this nether does un/replugging the gyro cable.

4)  The gyro readings have latency and often overturn slightly.  If you’re turning from rest until your gyro reads 90 degrees, you’ll often overturn because the inertia of the robot and/or the fact that by the time the gyro reads 90 degrees and your subsequent software blocks test it and shut off the turning motors the bot will have turned a few degrees more.  What are three ways you could compensate for this over turning based upon gyro readings (hints:  pad, rev and PID)?

FlopBot needs the gyro to help navigate the field accurately.  It can help us make (1) more accurate turns and (2) possibly drive in straighter lines.  Here are two links to study and discuss in our next meeting:

(1) Creating Gyro 90 degree Turn “My Block” (with simple fixed correction factor)

* NOTE:  Try to think of a more general way to correct turns of any degree

Another example of making a simple 90 degree gyro guided turn

(2) How to Use the EV3 Gyro Sensor to Make Your Robot Go Straight

* NOTE:  There may be an error in this code as written.  It did not work when we tested it.  Can you spot the potential bug?  We can debug it to track it down and come up with several solutions.


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s