Displacement from accelerometer data

Dear everyone,
I am trying to integrate data from accelerometer measurements to determine velocity and displacement of the system. The velocity looks ok, for which i consider the following approach
acceleration = [nx1]; % Data from accelerometer
dt = [1x1]; % Length of each time-step
velocity = cumtrapz(dt,acceleration);
However, when I try to utilize the same approach once again in the aim of determining displacement of the system i get unrealistic displacements. The following code is considered
displacement = cumtrapz(dt,velocity);
I have also tried other resources and functions available on matlab community, however, no progress yet.
Plotted data

 Respuesta aceptada

Mathieu NOE
Mathieu NOE el 22 de Abr. de 2021

1 voto

hello
the drift in the displacement is due to the fact that the velocity itself is not a zero mean signal
so if you are interested in the dynamic signal only , before each integration with cumtrapz you have to detrend your input data
help detrend
detrend Remove a polynomial trend.
Y = detrend(X) removes the best straight-line fit linear trend from the data in vector X and returns the residual in vector Y. If X is a matrix, detrend removes the trend from each column of the matrix.

10 comentarios

Derek Cooper
Derek Cooper el 22 de Abr. de 2021
Editada: Derek Cooper el 22 de Abr. de 2021
Unfortunately it doesnt look corret after detrending too
Mathieu NOE
Mathieu NOE el 22 de Abr. de 2021
you shoud add some high pass filtering , to remove that large bump
Derek Cooper
Derek Cooper el 27 de Abr. de 2021
Still not working
Mathieu NOE
Mathieu NOE el 27 de Abr. de 2021
hi
what do you get ? why "stil not working" ? what do you expect as result ?
can you share your code ?
tx
Hello,
Thanks for your response. I am expecting an exponential decay of the displacmenet. Here comes my code and attached is the acceleration data. The initial displacmement is around 200 [mm].
load('Acceleration.mat');
% Acceleration data
acc = acc*9.81; % Add gravity effect
acc = detrend(acc)
% Time
tStep = 0.00048828 % Length of each time step
N = length(acc)*tStep;
t = 0:tStep:N;
t(end) = [];
N = length(t);
dt = median(diff(t)); % Average dt
fs = 1/dt; % Frequency [Hz] or sampling rate
%
velocity = cumtrapz(dt,acc);
velocity = detrend(velocity);
disp = cumtrapz(dt,velocity);
disp = detrend(disp);
%
figure
plot(velocity);
figure
plot(disp);
here you are , as I suggested , use a bit of high pass filtering in conjunction with detrend
clc
clearvars
load('Acceleration.mat');
% Acceleration data
acc = acc*9.81; % Add gravity effect
acc = detrend(acc);
% Time
tStep = 0.00048828; % Length of each time step
N = length(acc)*tStep;
t = 0:tStep:N;
t(end) = [];
N = length(t);
dt = mean(diff(t)); % Average dt
fs = 1/dt; % Frequency [Hz] or sampling rate
% some additionnal high pass filtering
N = 2;
fc = 0.5; % Hz
[B,A] = butter(N,2*fc/fs,'high');
acc2 = filter(B,A,acc);
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
velocity = cumtrapz(dt,acc2);
velocity = detrend(velocity);
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
disp = cumtrapz(dt,velocity);
%
figure(1)
plot(t,acc);
figure(2)
plot(t,velocity);
figure(3)
plot(t,disp);
William Rose
William Rose el 7 de Abr. de 2022
Nice answer by @Mathieu NOE!
We put accelerometers on ice skaters doing their jumps. If we double-integrated the signal, without highpass filtering or detrending, the doubly-integrated signal put them mny miles away by the end of their practice! We observed similar results when measuring cranium acceleration of soccer players doing headers.
Oskar Kilgus
Oskar Kilgus el 28 de Jun. de 2023
Hey @Mathieu NOE, is it reasonable to simply detrend data?
I´m analyzing accelerometer data too and i am wondering if i detrend acceleration aswell as velocity or just acceleration. Looking at the plots, both outcomes look okay to me considering the underlying system.
Thanks in advance.
Mathieu NOE
Mathieu NOE el 28 de Jun. de 2023
it depends of your signal quality and fft spectrum
if you have a loft of drift / ofset and very low frequency noise , then you may need more filtering
with very clean data , you may have to use only detrend but every situation is a special case
William Rose
William Rose el 28 de Jun. de 2023
Excellent advice form @Mathieu NOE, as always.
A good general principle is to avoid detrending and filtering of your raw data as much as possible, so that you preserve the information in the data. Detrend and filter only to the extent that it is required to get reasonable looking results. Even then, consider whether the required detrending and filtering indicates some probelm with the instrumentaiton which you could correct in future experiments. It is not surprising that accelerometer signals need detrending, since even small offsets will grow parabolically when integrated twice. And for this reason, fitting a quadratic to the full length acceleration signal is a reasonable next step, if linear detrending seems to be insufficient.

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre MATLAB en Centro de ayuda y File Exchange.

Productos

Versión

R2019b

Preguntada:

el 22 de Abr. de 2021

Comentada:

el 28 de Jun. de 2023

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by