HiTechnicGyro offset

This is where you talk about the EV3 software itself, installation issues, and programming talk.

Moderators: roger, gloomyandy, skoehler

HiTechnicGyro offset

Postby ruperty » Sun Jul 13, 2014 2:13 pm

I notice that the HiTechnicGyro API doesn't have methods for offset, e.g. recalibrateOffset(), setOffset(int offset), as they did for the NXT.

Are these no longer required?
Regards,
Rupert
www.perceptualrobots.com
ruperty
Active User
 
Posts: 116
Joined: Sun Oct 14, 2007 11:21 am

Re: HiTechnicGyro offset

Postby Aswin » Sun Jul 13, 2014 2:32 pm

Offset correction is now done with the OffsetCorrectionFilter. The filter does not need to be calibrated, it calibrates constantly.

Aswin
My NXT blog: http://nxttime.wordpress.com/
Aswin
leJOS Team Member
 
Posts: 205
Joined: Tue Apr 26, 2011 9:18 pm
Location: Netherlands

Re: HiTechnicGyro offset

Postby ruperty » Tue Oct 28, 2014 11:36 am

Just got around to looking at this.

Here is a comparison of the EV3 and the HiTechinic NXT gyro.

This shows the two without the filter. There is an offset of about 3, but apart from that they give more or less equal readings.

Image

Here is the NXT with the default OffsetCorrectionFilter.

Image

Although the offset is removed, the NXT signal is adversely effected.

What is the speed value? What settings would be suitable for this situation?
Regards,
Rupert
www.perceptualrobots.com
ruperty
Active User
 
Posts: 116
Joined: Sun Oct 14, 2007 11:21 am

Re: HiTechnicGyro offset

Postby gloomyandy » Tue Oct 28, 2014 3:08 pm

I'm a little surprised by those results (though Aswin is our filter expert so I hope he will comment soon), could you post the code used to obtain them.
User avatar
gloomyandy
leJOS Team Member
 
Posts: 4119
Joined: Fri Sep 28, 2007 2:06 pm
Location: UK

Re: HiTechnicGyro offset

Postby ruperty » Tue Oct 28, 2014 4:14 pm

Here it is. Removed my chart code.

Code: Select all
public class GyroCompare {

   public static void main(String[] args) {

      EV3GyroSensor ev3Gyro = new EV3GyroSensor(LocalEV3.get().getPort("S4"));
      SampleProvider ev3sp = ev3Gyro.getMode("Rate");
      float[] ev3Sample = new float[ev3sp.sampleSize()];

      HiTechnicGyro nxtGyro = new HiTechnicGyro(LocalEV3.get().getPort("S3"));
      OffsetCorrectionFilter nxtsp = new OffsetCorrectionFilter(nxtGyro.getMode("Gyro"));
      float[] nxtSample = new float[nxtsp.sampleSize()];

      try {

         LCD.drawString("EV3", 1, 3);
         LCD.drawString("NXT", 8, 3);
         double tInterval = 0;
         long cLoop = 1;
         float[] vals = new float[2];
         long tCalcStart = System.currentTimeMillis();
         while (!Button.ESCAPE.isDown()) {
            ev3sp.fetchSample(ev3Sample, 0);
            vals[0] = ev3Sample[0];
            nxtsp.fetchSample(nxtSample, 0);
            vals[1] = -nxtSample[0];
            long time = System.currentTimeMillis();
            long diff = time - tCalcStart;
            tInterval = diff / cLoop;

            if (cLoop % 100 == 0) {
               LCD.clear(5);
               LCD.drawString(String.format("%3.0f", vals[0]), 0, 5);
               LCD.drawString(String.format("%3.0f", vals[1]), 8, 5);
               LCD.clear(0);
               LCD.drawString(String.format("%3.3f", tInterval), 4, 0);
            }
            cLoop++;
            Delay.msDelay(10);
         }
      } catch (RemoteException e) {
         String err = "EXC: " + e.toString();
         LCD.drawString(err, 0, 4);
      }
      ev3Gyro.close();
      nxtGyro.close();

      LCD.drawString("Press any button", 0, 0);

      Button.waitForAnyPress();
   }

}
Regards,
Rupert
www.perceptualrobots.com
ruperty
Active User
 
Posts: 116
Joined: Sun Oct 14, 2007 11:21 am

Re: HiTechnicGyro offset

Postby gloomyandy » Tue Oct 28, 2014 5:03 pm

Thanks for that. One of the things that is puzzling me is that on the first graph you have a small amount of noise on the EV3 sensor, but this does not seem to be present on the second. May not be an issue but it seems strange that it has disappeared. Did you make any other changes between the two runs? Looking at the source of the filter:
https://sourceforge.net/p/lejos/ev3/ci/ ... ilter.java
I don't really see how it could introduce some of the differences you are seeing (in particular there seems to be a shift in the data and a difference in amplitude). Did anything change in the mechanical setup? If you remove the filter can you reproduce the results from run 1?
User avatar
gloomyandy
leJOS Team Member
 
Posts: 4119
Joined: Fri Sep 28, 2007 2:06 pm
Location: UK

Re: HiTechnicGyro offset

Postby Aswin » Tue Oct 28, 2014 9:29 pm

Hi,

There is an error in the OffsetCorrectionFilter of the current version of lejos (0.8.1-beta). The error is removed in 0.8.2-beta. At the time of writing this is not jet released. But you can get the improved source form here and use it to recreate the filter in your own environment. (or use the snapshot instead).

Also note that there is an article on using gyro's on lejosnews.wordpress.com that explores the use of the OffsetCorrectionFilter and the IntegrationFilter in combination with gyro sensors.

Aswin
My NXT blog: http://nxttime.wordpress.com/
Aswin
leJOS Team Member
 
Posts: 205
Joined: Tue Apr 26, 2011 9:18 pm
Location: Netherlands


Return to EV3 Software

Who is online

Users browsing this forum: No registered users and 3 guests

more stuff