Can the Kalman filter handle variations in sampling interval?

Click For Summary
SUMMARY

The discussion focuses on the application of the Kalman filter for calculating inclination angles from accelerometer and gyroscope data, specifically addressing the challenge of non-constant sampling intervals (dt jitter). The MATLAB code provided demonstrates the implementation of the Kalman filter, revealing that it can manage dt jitter effectively if the sampling rate is significantly higher than the filter's settling time, which should be approximately 20 times the raw data sampling interval. Additionally, it is noted that using explicit integration for Fourier transforms is more effective than FFT methods when dealing with variable step sizes.

PREREQUISITES
  • Understanding of Kalman filter principles and implementation
  • Familiarity with MATLAB programming and its plotting functions
  • Knowledge of accelerometer and gyroscope data processing
  • Basic concepts of signal processing, including Fourier transforms
NEXT STEPS
  • Research "Kalman filter tuning for variable sampling rates" to optimize performance
  • Explore "MATLAB explicit integration techniques" for handling variable step sizes
  • Study "Fourier transform methods in signal processing" to compare FFT and explicit integration
  • Investigate "settling time in Kalman filters" to understand its impact on filter performance
USEFUL FOR

This discussion is beneficial for data scientists, control engineers, and anyone involved in sensor data fusion or real-time signal processing, particularly those working with Kalman filters and variable sampling intervals.

bolly
Messages
16
Reaction score
2
Dear Community,

I want to use a Kalman- filter approach to calculate inclination angles (pitch and roll) obtained from accelerometer- and gyroscope- raw data. However the problem is that my sampling interval dt is not constant – it has a significant jitter instead. To investigate whether the kalman filter can handle such data I’ve experimented using the following MATLAB code copied from here (http://web.csulb.edu/~hill/ee400d/Project%20Folder/Kalman%20Filter%20Research.pdf):

Code:
stacksize = 100;dt_stack  = rand(stacksize,1)/2;
t_stack = zeros(stacksize,1);

t_stack(1) = 0;
for count=2:stacksize
t_stack(count) = t_stack(count-1) + dt_stack(count);
end

x =     sin(t_stack); % angle
x_dot = cos(t_stack); % angular velocity

figure;
subplot(3,1,1);
plot(t_stack);
subplot(3,1,2);
plot(t_stack,x);
hold on;
plot(t_stack,x_dot,    'Color','red');
P = [1 0; 0 1];R_angle = 0.9;
Q_angle = 0.05;
Q_gyro = 0.5;

Q = [Q_angle 0; 0 Q_gyro];
A = [0 -1; 0 0];
q_bias = 0; % Initialize gyro bias
angle = 0; % Initialize gyro angle
q_m = 0;
X = [0; 0];
x1 = zeros(stacksize);
x2 = zeros(stacksize);

 H = [1 0];

 x_calc  = 0;
 x_dot_corr = 0;
 gyro_bias = 0;

 angle_err = 0;

 for i=1:100 

  x_dot_corr = x_dot(i) - gyro_bias; % /* Pitch gyro measurement */ 
  x_calc = x_calc + x_dot_corr*dt_stack(i);
  x_err = x(i)- x_calc;
 
  Pdot = A*P + P*A' + Q; 
  P = P + Pdot*dt_stack(i);
  E = H*P*H' + R_angle;

  K = P*H'*inv(E);
  P = P - K*H*P;

  X = X + K * x_err; 
  x1(i) = X(1);
  x2(i) = X(2);
  x_calc= x1(i);
  gyro_bias = x2(i); 
end

 x = x(1:stacksize);
 x1 = x1(1:stacksize);

 length(x)
 length(x1)
 length(t_stack)% Plot the result using kalman filter
subplot(3,1,3);
plot(t_stack,x);
hold on
plot(t_stack,x1,'Color','green');

xlabel('time(s)');
ylabel('x(t)');
legend('actual','kalman');
I’ve found that with increasing bandwidth of dt the filter refuses to work. As far I’ve understood the kalman approach can be applied to zero the linear integration-error obtained by integrating the angular velocity measured using a gyroscope (if the this error propagtes linear).
However can it also be applied to zero the sampling error caused by a jitter of dt ?

I would be very happy if someone could give a hint why the kalman approach refuses to work with increasing bandwidth of dt.
 
Last edited:
Physics news on Phys.org
Dear Community,

after investigating the Kalman filter in more detail I've found that it can handle dt jitter if the sampling rate is set high compared with the settling time of the filter since the filter only yields good results after a settling time of approx. 20 times higher than the raw data sampling interval dt. Shorting the settling time by changing the kalman variances causes noisy results.
 
  • Like
Likes   Reactions: FactChecker
https://arxiv.org/pdf/1507.01832.pdf

Computing Fourier transforms with explicit integration rather than FFT methods is better able to handle variations in step sizes. The speed of most computers no longer requires FFT methods for many data analysis tasks.
 

Similar threads

  • · Replies 14 ·
Replies
14
Views
4K
  • · Replies 3 ·
Replies
3
Views
4K
Replies
2
Views
2K
  • · Replies 1 ·
Replies
1
Views
2K
  • · Replies 1 ·
Replies
1
Views
2K
Replies
9
Views
7K
  • · Replies 1 ·
Replies
1
Views
9K
  • · Replies 1 ·
Replies
1
Views
14K
  • · Replies 1 ·
Replies
1
Views
1K
  • · Replies 2 ·
Replies
2
Views
4K