Go to Post "It's not a bug, it's an unlisted feature." - Barry Craig [more]
Home
Go Back   Chief Delphi > Technical > Programming > Java
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
Reply
Thread Tools Rate Thread Display Modes
  #1   Spotlight this post!  
Unread 02-09-2016, 11:11 PM
zDrakon zDrakon is offline
Registered User
FRC #3501
 
Join Date: Feb 2015
Location: Sunnyvale
Posts: 10
zDrakon is an unknown quantity at this point
Exclamation ITG3200 Gyroscope

Code we found on github for this specific gyro: https://github.com/bussell/SparkFun6...roITG3200.java

Problem: I can't seem to convert the "16 bit in 2's complement format" readings from the method "getRotationZ()" in the gyro class to be just degrees.

My team only cares about getting "pitch" rotation which is Z.

Anyone have tips or advice to make a method that will get degrees from the getRotationZ() method?

Email to me if you can help so I can reply faster!

evanyap.14@gmail.com
Reply With Quote
  #2   Spotlight this post!  
Unread 02-09-2016, 11:20 PM
Breadbocks Breadbocks is offline
Registered User
FRC #1002
 
Join Date: Oct 2013
Location: United States
Posts: 39
Breadbocks is on a distinguished road
Re: ITG3200 Gyroscope

My guess is that it does output in degrees. 16 bit 2s complement is fancy way to say "short" as far as Java is concerned. Presumably 1 degree = 1 on the short, 100 degrees = 100 etc.
Reply With Quote
  #3   Spotlight this post!  
Unread 02-10-2016, 03:25 AM
pblankenbaker pblankenbaker is offline
Registered User
FRC #0868
 
Join Date: Feb 2012
Location: Carmel, IN, USA
Posts: 102
pblankenbaker is a glorious beacon of lightpblankenbaker is a glorious beacon of lightpblankenbaker is a glorious beacon of lightpblankenbaker is a glorious beacon of lightpblankenbaker is a glorious beacon of light
Re: ITG3200 Gyroscope

Our team used the ITG3200 last season. It was a challenge to work with due to the following:
  • We typically wanted our measurements in degrees and the sensor reports readings in degrees/second (we ended up using a thread to accumulate values reported by the sensor).
  • The sensor did not tend to report zero when sitting idle. This error (bias) needed to be determined at start up while the robot was stationary and then taken into consideration with each reading.

In any case, here is the code we came up with that worked reasonably well for the ITG-3200 when we wanted to detect if the robot was tipping or needed to perform an operation like "make a 90 degree turn":

https://github.com/frc868/2015-FRC-R...roItg3200.java

As far as the answer to your original question, I think you can use the following to convert the raw 16 bit values to degrees/second (not degrees):

Code:
rawAxisValue / 14.375 - axisBias
Where rawAxisValue is the 16 bit signed integer (short) read from the sensor for your z axis and axisBias is the average error reported by the axis when the robot is stationary (when you wish that the sensor reported 0 but discover it does not).

Good luck and I hope that helps.
Reply With Quote
  #4   Spotlight this post!  
Unread 02-10-2016, 11:17 AM
zDrakon zDrakon is offline
Registered User
FRC #3501
 
Join Date: Feb 2015
Location: Sunnyvale
Posts: 10
zDrakon is an unknown quantity at this point
Re: ITG3200 Gyroscope

So I see in your code it says it has a method for getAngle(). Has your team already converted the rate from short to degrees? If so I'll definitely look into the code of it and will probably use it along with giving your team credit thanks.
Reply With Quote
  #5   Spotlight this post!  
Unread 02-10-2016, 11:49 AM
pblankenbaker pblankenbaker is offline
Registered User
FRC #0868
 
Join Date: Feb 2012
Location: Carmel, IN, USA
Posts: 102
pblankenbaker is a glorious beacon of lightpblankenbaker is a glorious beacon of lightpblankenbaker is a glorious beacon of lightpblankenbaker is a glorious beacon of lightpblankenbaker is a glorious beacon of light
Re: ITG3200 Gyroscope

Yes, the code mentioned does contain both the methods to convert the short into degrees/second and then convert the degrees/second values into degrees (by accumulating over time in a background thread). Just to reiterate, it is not possible to directly convert the short values read from the sensor into degrees as its unit of measurement is degrees/second.

Please feel free to use as much or as little of the code as you want.

As a side note.

We are looking at the BNO055 sensor (Adafruit has a break out board for this one). This chip has an onboard accumulator and it is possible to get degrees directly from the chip instead of accumulating values in a Java thread. It also appears very stable when the robot isn't moving (almost zero drift when sitting still).

We are still exploring the BNO055 and may not get it worked out for this season. However, if you are interested in this 9 DOF sensor, there is another thread with working sample code provided by "otherguy" at:

http://www.chiefdelphi.com/forums/sh...ghlight=bno055
Reply With Quote
  #6   Spotlight this post!  
Unread 02-11-2016, 12:17 AM
zDrakon zDrakon is offline
Registered User
FRC #3501
 
Join Date: Feb 2015
Location: Sunnyvale
Posts: 10
zDrakon is an unknown quantity at this point
Re: ITG3200 Gyroscope

Quote:
Originally Posted by pblankenbaker View Post
Our team used the ITG3200 last season. It was a challenge to work with due to the following:
  • We typically wanted our measurements in degrees and the sensor reports readings in degrees/second (we ended up using a thread to accumulate values reported by the sensor).
  • The sensor did not tend to report zero when sitting idle. This error (bias) needed to be determined at start up while the robot was stationary and then taken into consideration with each reading.

In any case, here is the code we came up with that worked reasonably well for the ITG-3200 when we wanted to detect if the robot was tipping or needed to perform an operation like "make a 90 degree turn":

https://github.com/frc868/2015-FRC-R...roItg3200.java

As far as the answer to your original question, I think you can use the following to convert the raw 16 bit values to degrees/second (not degrees):

Code:
rawAxisValue / 14.375 - axisBias
Where rawAxisValue is the 16 bit signed integer (short) read from the sensor for your z axis and axisBias is the average error reported by the axis when the robot is stationary (when you wish that the sensor reported 0 but discover it does not).

Good luck and I hope that helps.
Where do I get this "RotationTracker" interface that your code uses? I can't seem to find it or its called something else in the FRC lib jars?
Reply With Quote
  #7   Spotlight this post!  
Unread 02-11-2016, 07:20 AM
pblankenbaker pblankenbaker is offline
Registered User
FRC #0868
 
Join Date: Feb 2012
Location: Carmel, IN, USA
Posts: 102
pblankenbaker is a glorious beacon of lightpblankenbaker is a glorious beacon of lightpblankenbaker is a glorious beacon of lightpblankenbaker is a glorious beacon of lightpblankenbaker is a glorious beacon of light
Re: ITG3200 Gyroscope

You should be able to find the RotationTracker source in the same directory as the GyroItg3200 source out at github:

https://github.com/frc868/2015-FRC-R...echhounds/gyro
Reply With Quote
Reply


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT -5. The time now is 07:28 AM.

The Chief Delphi Forums are sponsored by Innovation First International, Inc.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi