GyroSensor recalibrateOffset

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

Moderators: 99jonathan, roger, imaqine

Re: GyroSensor recalibrateOffset

Postby Aswin » Wed Nov 20, 2013 8:26 am

Hi Rupert,

The graph shows gyro speed in red. Notice that there are times when gyro speed is noisy and times when it is smoother. The noisier periods are also periods without much bias drift. This is an effect of the drift compensation algorhythm and has little to do with the true bias of the sensor.
The drift compensation algorhythm works like this. The algorhythm assumes there is no speed, so the output of the sensor should be zero. If it is not then this must be caused by noise or sensor bias. If it were just bias one could take the sensor value as the bias and correct the next reading with this value to get a bias free reading. However as there is also noise in the reading it is better to take the average of a lot of readings to calculate the bias, this reduces the effect of noise. That is what the algorhythm does. It takes a running average of the gyro values and substracting this from the current value to get a bias free value.
But there is more. The algorhythm is based on the assumption that the gyro is motionless. This might be true for most robots in the long run, but there are times when it certainly is not. The algorhythm tries to detect this and when it does detect motion it will temporarily stop updating the moving average. The motion detection logic is based on the expected noise level of the gyro. If a reading falls outside the expected noise then the algorhythm rejects it for updating the bias. The expected noise level btw is computed during calibration.

So I think that during the noisy periods in your experiment the sensor offset correction value is not (always) updated. During the smoother periods it is updated. Also during the noisy periods an error in the offset correction can build up. It takes time to correct for this error. This might explain why the offset seems to move in one direction.

Under a constant situation. The offset should be a random walk. It is not a constant and it does not evolve in one direction. If this is not the case than something else is happening. Apart from the effect described above there are two things that could change over time. The input voltage to the sensor (or AD converter) and the sensor temperature. Sensors do get warmer when using them.

I think, but cannot check right now, that the problem with the algorhythm with balancing robots is known.there is a balancing robot example or pilot that uses another gyro class and its own drift compensation algorhythm. You might want to check this out.

Another issue is using angle for balancing. This will not work. Suppose you want your robot to move around. For this the robot needs to accelerate and brake at times. If the robot accelerates while standing upright it will fall backwards. During acceleration it needs to lean forward a bit not to fall.

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

Re: GyroSensor recalibrateOffset

Postby gloomyandy » Wed Nov 20, 2013 2:54 pm

I think it would be worth making sure we are all talking about the same code base being used here, and which offset adjustment we are talking about... The Segoway class:
https://sourceforge.net/p/lejos/code/HE ... goway.java
does not attempt to detect when the gyro is in motion it just assumes that on average over time it will be stationary and adjusts the offset based on that assumption. Note however that this code is calling getAngularVelocity which (in the case of the HiTechnics gyro) itself contains code to perform offset correction. This code does contain an attempt to only correct things when the gyro si stationary (as described by Aswin above). As Brian noted in the Segoway source having both of this corrections operating at the same time may not be a very good idea (to be honest I'm not sure if it is or it isn't). I'd be tempted to use the raw sensor reading with the Segoway code and see how that works out.

Is this code that you are using? If not can you post the code (or a link to it), so we can be sure we are all talking about the same thing!

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

Re: GyroSensor recalibrateOffset

Postby ruperty » Wed Nov 20, 2013 2:57 pm

Thanks all, for your responses.

Aswin wrote:...there is a balancing robot example or pilot that uses another gyro class and its own drift compensation algorhythm. You might want to check this out.


That sounds interesting, can you point me to it, I can't see where it is in the samples?

[quote="Aswin"]Another issue is using angle for balancing. This will not work. Suppose you want your robot to move around. For this the robot needs to accelerate and brake at times. If the robot accelerates while standing upright it will fall backwards. During acceleration it needs to lean forward a bit not to fall.

I was interested in the angle to drive motion of the balancer, not the actual balancing itself. It is probably not actually essential, as introducing error is sufficient, but it is "neater" if the angle value is valid; and I would like to understand what is happening with the gyro.
Regards,
Rupert
www.perceptualrobots.com
ruperty
Active User
 
Posts: 114
Joined: Sun Oct 14, 2007 11:21 am

Re: GyroSensor recalibrateOffset

Postby ruperty » Wed Nov 20, 2013 3:03 pm

gloomyandy wrote:I think it would be worth making sure we are all talking about the same code base being used here, and which offset adjustment we are talking about... The Segoway class:
https://sourceforge.net/p/lejos/code/HE ... goway.java


Yes, for the graph above it is modified from that code. That is, I am using getAngularVelocity, but without the initial calibration, and without the additional offset (gOffset) adjustment.

I am going to have a look at the raw value.
Regards,
Rupert
www.perceptualrobots.com
ruperty
Active User
 
Posts: 114
Joined: Sun Oct 14, 2007 11:21 am

Re: GyroSensor recalibrateOffset

Postby gloomyandy » Wed Nov 20, 2013 3:11 pm

Personally I would change the Segoway code to use something like getValue, which is pretty much the RAW sensor reading and I would use the offset calculation in the Segoway class and the initial calibration in that class and start from there....
User avatar
gloomyandy
leJOS Team Member
 
Posts: 4078
Joined: Fri Sep 28, 2007 2:06 pm
Location: UK

Previous

Return to NXJ Software

Who is online

Users browsing this forum: gloomyandy and 1 guest

more stuff