Answers.Body: <p>I'm assuming you are using <code>ev3dev-lang-java</code>. It looks like this bug was fixed in v2.6.0. <a href="https://github.com/ev3dev-lang-java/ev3dev-lang-java/commit/bd5540db6b0cae851f5f017eac4544b3faec7abd" rel="nofollow noreferrer">Source</a>.</p>
  <p>Make sure you are using the latest version. With your EV3 connected to the Internet, run <code>sudo apt udpate &amp;&amp; sudo apt upgrade</code>.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2021-01-30T18:06:49.567Z
Answers.Text: Thanks for this answer. I apologize for being late to mark this as an answer...
Answers.UserDisplayName: Budschie
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2021-01-29T15:00:59.390Z
Answers.LastActivityDate: 2021-01-29T15:00:59.390Z
Answers.UserDisplayName: David Lechner
Body: <p>So, basically, my problem is that my Ev3 Gyro Sensor clamps outputs beneath 0 to 0.
  If I were to rotate my robot clockwise, the gyro rotation would go up, but when I rotate my robot counter-clockwise, it would only go down until it reaches zero, then it stops.<br><br>Here is some code that could prove useful:
  <br><strong>Setup of the gyro sensor:</strong></p>
  <pre><code>    // Setting up the gyro sensor
      EV3GyroSensor gyro = new EV3GyroSensor(SensorPort.S2);
      gyro.switchMode(&quot;GYRO-ANG&quot;, 0);
      gyro.reset();
  </code></pre>
  <p><br><br><strong>Getting the sample:</strong></p>
  <pre><code>    public A[] getSample()
      {
          /** We first assert the mode here. **/
          assertMode();
          
          SampleProvider sampleProvider = baseSensor.getMode(baseSensor.getCurrentMode());
          
          float[] input = new float[sampleSize];
          sampleProvider.fetchSample(input, 0);
          
          @SuppressWarnings(&quot;unchecked&quot;)
          A[] castedArray = (A[]) Array.newInstance(clazz, sampleSize);
          
          // Please java. Tell me why I have to convert this to a Float first??!? This should all be done automatically...
          for(int i = 0; i &lt; input.length; i++)
          {
              castedArray[i] = caster.apply(input[i]);
          }
          
          if(modifier.isPresent())
          {
              for(int i = 0; i &lt; castedArray.length; i++)
              {
                  /** Apply modifiers if necessary **/
                  castedArray[i] = modifier.get().apply(castedArray[i]);
              }
          }
          
          return castedArray;
      }
  
      private void assertMode()
      {
          if(currentMode.isPresent())
          {
              if(System.currentTimeMillis() &gt; (timeToSwitch + timeSinceSwitchCall))
              {
                  baseSensor.switchMode(currentMode.get(), 0);
              }
          }
      }
  
  </code></pre>
  <p><br><br>Here is the log output:</p>
  <pre><code>Float value 21.0
  Float value 20.0
  20
  Float value 19.0
  Float value 18.0
  18
  Float value 16.0
  Float value 16.0
  16
  Float value 15.0
  Float value 15.0
  15
  Float value 14.0
  Float value 14.0
  14
  Float value 13.0
  Float value 13.0
  13
  Float value 12.0
  Float value 11.0
  11
  Float value 11.0
  Float value 11.0
  11
  Float value 11.0
  Float value 11.0
  11
  Float value 10.0
  Float value 10.0
  10
  Float value 9.0
  Float value 7.0
  7
  Float value 6.0
  Float value 6.0
  6
  Float value 0.0
  Float value 0.0
  0
  Float value 0.0
  Float value 0.0
  0
  Float value 0.0
  Float value 0.0
  0
  Float value 0.0
  Float value 0.0
  0
  Float value 0.0
  Float value 0.0
  0
  Float value 0.0
  Float value 0.0
  0
  Float value 0.0
  Float value 0.0
  0
  Float value 0.0
  Float value 0.0
  0
  Float value 0.0
  Float value 0.0
  0
  Float value 0.0
  Float value 0.0
  0
  Float value 0.0
  Float value 0.0
  </code></pre>
  <p><br><br>I hope you can help me. Thanks.</p>
  
Tags: <ev3><ev3dev><gyro>
Title: EV3Dev Gyro sensor doesn't output values beneath 0
UserDisplayName: Budschie
ThreadText: # EV3Dev Gyro sensor doesn't output values beneath 0
  
  (Asked by: username_0 on 2021-01-29)
  
  So, basically, my problem is that my Ev3 Gyro Sensor clamps outputs beneath 0 to 0.
  If I were to rotate my robot clockwise, the gyro rotation would go up, but when I rotate my robot counter-clockwise, it would only go down until it reaches zero, then it stops.  
    
  Here is some code that could prove useful:
    
  **Setup of the gyro sensor:**
  
  ```
      // Setting up the gyro sensor
      EV3GyroSensor gyro = new EV3GyroSensor(SensorPort.S2);
      gyro.switchMode("GYRO-ANG", 0);
      gyro.reset();
  
  ```
  
  **Getting the sample:**
  
  ```
      public A[] getSample()
      {
          /** We first assert the mode here. **/
          assertMode();
          
          SampleProvider sampleProvider = baseSensor.getMode(baseSensor.getCurrentMode());
          
          float[] input = new float[sampleSize];
          sampleProvider.fetchSample(input, 0);
          
          @SuppressWarnings("unchecked")
          A[] castedArray = (A[]) Array.newInstance(clazz, sampleSize);
          
          // Please java. Tell me why I have to convert this to a Float first??!? This should all be done automatically...
          for(int i = 0; i < input.length; i++)
          {
              castedArray[i] = caster.apply(input[i]);
          }
          
          if(modifier.isPresent())
          {
              for(int i = 0; i < castedArray.length; i++)
              {
                  /** Apply modifiers if necessary **/
                  castedArray[i] = modifier.get().apply(castedArray[i]);
              }
          }
          
          return castedArray;
      }
  
      private void assertMode()
      {
          if(currentMode.isPresent())
          {
              if(System.currentTimeMillis() > (timeToSwitch + timeSinceSwitchCall))
              {
                  baseSensor.switchMode(currentMode.get(), 0);
              }
          }
      }
  
  ```
  
  Here is the log output:
  
  ```
  Float value 21.0
  Float value 20.0
  20
  Float value 19.0
  Float value 18.0
  18
  Float value 16.0
  Float value 16.0
  16
  Float value 15.0
  Float value 15.0
  15
  Float value 14.0
  Float value 14.0
  14
  Float value 13.0
  Float value 13.0
  13
  Float value 12.0
  Float value 11.0
  11
  Float value 11.0
  Float value 11.0
  11
  Float value 11.0
  Float value 11.0
  11
  Float value 10.0
  Float value 10.0
  10
  Float value 9.0
  Float value 7.0
  7
  Float value 6.0
  Float value 6.0
  6
  Float value 0.0
  Float value 0.0
  0
  Float value 0.0
  Float value 0.0
  0
  Float value 0.0
  Float value 0.0
  0
  Float value 0.0
  Float value 0.0
  0
  Float value 0.0
  Float value 0.0
  0
  Float value 0.0
  Float value 0.0
  0
  Float value 0.0
  Float value 0.0
  0
  Float value 0.0
  Float value 0.0
  0
  Float value 0.0
  Float value 0.0
  0
  Float value 0.0
  Float value 0.0
  0
  Float value 0.0
  Float value 0.0
  
  ```
  
  I hope you can help me. Thanks.
  
  **Tags:** ev3, ev3dev, gyro
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2021-01-29. Score: 2 | Accepted answer
  
  I'm assuming you are using `ev3dev-lang-java`. It looks like this bug was fixed in v2.6.0. [Source](https://github.com/ev3dev-lang-java/ev3dev-lang-java/commit/bd5540db6b0cae851f5f017eac4544b3faec7abd).
  
  Make sure you are using the latest version. With your EV3 connected to the Internet, run `sudo apt udpate && sudo apt upgrade`.
  
  > **Comments:**
  > **username_0**: Thanks for this answer. I apologize for being late to mark this as an answer...  
  
  ---
  
  