# How to Calculate gyroscope bias given an input vector of measurements w?

I am developing a GPS-Localizer using accelerometer and gyroscope sensor values. for more accuracy, i want to calculate sensor biases, so i already implemented the accelerometer calculation via matlab using an input vector $a$ and it looks like this:

function [sigma_out, mean_out, bias_out] = aCalibration (a)

sigma_out = std(a, 0, 2);
mean_out = mean(a, 2);

% The direction of the mean acceleraion is assumed to be the direction
% of gravity (thus down). Any other component is considered bias. This
% is by no means an acurate representation of the biases.
bias_out = mean_out - mean_out / norm(mean_out) * 9.81;


For the Gyroscope i use an input vector $w$, so i calculate standard deviation and mean like this:

function [w_sigma, w_mean, w_bias] = wCalibration (w)

% TODO: implement the sigma/mean/bias computation
w_sigma = std(w,0,2);
w_mean = mean(w,2)
w_bias = [0; 0; 0];


How do i calculate the gyroscope bias $b_w$ now? i dont know i think i still need to consider some angular velocity constants but i dont know which ones.... :(

Thanks for the help!

Do the exact same thing you're doing for the accelerometer.

With the accelerometer, you're assuming that the device isn't actually constantly accelerating in any particular direction. You assume that the net long term acceleration is zero.

Are you expecting that the gyro is constantly rotating in a particular direction? Or are you assuming that the net long term rotational speed is also zero?

The only difference is that you know a "zero reading" of an accelerometer is [0; 0; -g], and the "zero reading" of a gyroscope is [0; 0; 0].

This is all pretty similar to another answer I gave recently. You could essentially use the same function for both, as in something like:

function [sigmaOut, meanOut, unknownBias] = Calibrate(data, knownBias)
sigmaOut = std(data);
meanOut = mean(data);
unknownBias = meanOut - knownBias;
end


Pass in [0; 0; -9.81] for an accelerometer's known bias and [0; 0; 0] for the gyro. I'll point out that you don't have any rotations included in your code, so be careful there. Orientation matters!

• Thanks for the suggestion! Actually i just calculated the bias using the formula: $Bias = \sqrt{MSE(w) - Var(w)}$.
– Leo
Jan 30, 2018 at 21:25