Does EV3GyroSensor need OFFSET_CALIBRATION?

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

Moderators: roger, gloomyandy, skoehler

salamanders
New User
Posts: 5
Joined: Sun Jul 16, 2017 5:10 pm

Does EV3GyroSensor need OFFSET_CALIBRATION?

Postby salamanders » Sun Aug 20, 2017 8:53 pm

Question 1: EV3GyroSensor - Given that the .reset() method mentions calibration, I wasn't sure if lejos.hardware.sensor.EV3GyroSensor is best wrapped in

Code: Select all

sampleProviderGyro = new LinearCalibrationFilter(new MeanFilter(sensorGyro.getAngleAndRateMode(), 30));

or if I can use it bare and do a .reset() at the beginning while the EV3 is still, and not have to worry about it. Does the LinearCalibrationFilter calibrate both the angle and angleRate values? (or again, is that already built in to EV3GyroSensor)

Question 2: MeanFilter - I wasn't sure if I'm using this right. If I have a thread that spin-reads from the sensor, is it reading faster than the sensor can provide values? Slower? Perhaps blocking on new values being available? Should I use the MeanFilter 30 from above and not worry about it? Is 30 good?

User avatar
gloomyandy
leJOS Team Member
Posts: 5899
Joined: Fri Sep 28, 2007 2:06 pm
Location: UK

Re: Does EV3GyroSensor need OFFSET_CALIBRATION?

Postby gloomyandy » Sun Aug 20, 2017 10:36 pm

Aswin is really the expert on this stuff, but here is my take on it...

Performing a reset operation will zero out the offset. However it may still drift over time. I'd be tempted to perform some tests to see exactly how well things work both with and without the various filters in your particular configuration.

The best way to understand what happens with the filters is probably to look at the source code:
https://sourceforge.net/p/lejos/ev3/cod ... cs/filter/
from a quick glance it would seem that every call to fetchSample will read a new value from the sensor. The sensor reading logic does not contain anything to blobk and wait for a new sample, so if you read data too fast you simply end up reading the same value multiple times. The LEGO hardware developers kit reports that the gyro can deliver 1000 samples a second. But again you may want to run your tests to verify the actual update rate if it is important to you.
leJOS news https://lejosnews.wordpress.com/

salamanders
New User
Posts: 5
Joined: Sun Jul 16, 2017 5:10 pm

Re: Does EV3GyroSensor need OFFSET_CALIBRATION?

Postby salamanders » Sun Aug 20, 2017 11:52 pm

So "sampleProviderGyro = new LinearCalibrationFilter(new MeanFilter(sensorGyro.getAngleAndRateMode(), 30));" is a good place to start. Cool, will go with it, thanks!

User avatar
gloomyandy
leJOS Team Member
Posts: 5899
Joined: Fri Sep 28, 2007 2:06 pm
Location: UK

Re: Does EV3GyroSensor need OFFSET_CALIBRATION?

Postby gloomyandy » Mon Aug 21, 2017 6:49 am

I didn't actually say that! I'd just spend some time looking at the gyro output in the way you want to use it and experimenting with the filters to get the best results. It may may more sense for instance to adjust the offset before taking the mean, I'm not really sure.
leJOS news https://lejosnews.wordpress.com/

Aswin
leJOS Team Member
Posts: 310
Joined: Tue Apr 26, 2011 9:18 pm
Location: Netherlands
Contact:

Re: Does EV3GyroSensor need OFFSET_CALIBRATION?

Postby Aswin » Tue Aug 22, 2017 8:11 am

Hi,

The Lego gyro sensor does not need offset calibration. It has offset calibration built in the sensor. It is recalibrated every time you call the reset method. Be sure only to call it when the sensor is motionless.

You did not explain why you would like to use a mean filter. In general a mean filter removes noise from the sensor but it introduces some lag. (The output might indicate the sensor is still moving when it just got to a stand still.) Gyro sensors are not very noisy, so a mean filter will not help you much.

Lejos does have a filter that creates a thread for sampling, the ThreadFilter. It allows you to control the sampling frequency precisely and will return the most actual read from the sensor when calling fetchSample. In most cases a sampling rate of 20 samples/second is sufficient, but you should experiment with it. More is not always better.

Aswin
My NXT blog: http://nxttime.wordpress.com/


Return to “EV3 Software”

Who is online

Users browsing this forum: No registered users and 1 guest