Answers.Body: <p>This is a pretty common issue called &quot;gyro drift&quot;. If the gyroscope is rotating when plugged in and/or when the brick starts up, that constant rotation will be seen as &quot;resting&quot;, and when the gyroscope is still, it believes it is rotating.<br />
  There are two main fixes to this</p>
  <hr />
  <h2>Hardware fix</h2>
  <p>In this, you simply unplug the gyroscope, then plug it back in while holding the robot very still. Any rotation can drift the gyroscope, however, it is pretty simple for most robots.</p>
  <p>Alternatively, completely restart the robot while keeping it still. Most of the time this is easier to do, though it takes quite a while.</p>
  <hr />
  <h2>Software fix</h2>
  <p>In the software, you can account for the gyroscope drift. Instead of measuring the gyroscope directly, create a variable called <code>gyro</code>. At the start of the program, measure the gyroscope speed multiple times (about 10 should be good for most applications), waiting a small amount of time (try 0.05 seconds) between each, and take the average of the measurements. Then, every second, change the <code>gyro</code> variable by the gyro speed MINUS the averaged gyroscope drift. My preferred method for doing this is to broadcast a message, and have a forever loop in the broadcast receiver, updating <code>gyro</code> and waiting one second in the loop. This keeps your main forever loop free to run quickly.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2023-08-16T01:25:55.793Z
Answers.LastActivityDate: 2023-08-16T01:25:55.793Z
Answers.UserDisplayName: Jme
Body: <p>The gyroscope value continuously increases/decreases, even when the brick is not rotating! What could be done in order to avoid, mitigate or at least reduce the impact of this behaviour?</p>
  
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2023-08-16T01:27:11.667Z
Comments.Text: *I know that this has been answered a few other times, but it's such a common problem I thought it best to have a dedicated question/answer for it.
Comments.UserDisplayName: Jme
Tags: <ev3><gyro>
Title: EV3 gyroscope drifts when brick is still - what can be done?
UserDisplayName: Jme
ThreadText: # EV3 gyroscope drifts when brick is still - what can be done?
  
  (Asked by: username_0 on 2023-08-16)
  
  The gyroscope value continuously increases/decreases, even when the brick is not rotating! What could be done in order to avoid, mitigate or at least reduce the impact of this behaviour?
  
  **Tags:** ev3, gyro
  
  > **Comments:**
  > **username_0**: *I know that this has been answered a few other times, but it's such a common problem I thought it best to have a dedicated question/answer for it.  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_0 on 2023-08-16. Score: 2 | Accepted answer
  
  This is a pretty common issue called "gyro drift". If the gyroscope is rotating when plugged in and/or when the brick starts up, that constant rotation will be seen as "resting", and when the gyroscope is still, it believes it is rotating.  
  There are two main fixes to this
  
  ---
  
  ## Hardware fix
  
  In this, you simply unplug the gyroscope, then plug it back in while holding the robot very still. Any rotation can drift the gyroscope, however, it is pretty simple for most robots.
  
  Alternatively, completely restart the robot while keeping it still. Most of the time this is easier to do, though it takes quite a while.
  
  ---
  
  ## Software fix
  
  In the software, you can account for the gyroscope drift. Instead of measuring the gyroscope directly, create a variable called `gyro`. At the start of the program, measure the gyroscope speed multiple times (about 10 should be good for most applications), waiting a small amount of time (try 0.05 seconds) between each, and take the average of the measurements. Then, every second, change the `gyro` variable by the gyro speed MINUS the averaged gyroscope drift. My preferred method for doing this is to broadcast a message, and have a forever loop in the broadcast receiver, updating `gyro` and waiting one second in the loop. This keeps your main forever loop free to run quickly.
  
  
  ---
  
  