Impact location detection from accelerometer data

조회 수: 6 (최근 30일)
xubyr
xubyr 2024년 3월 1일
댓글: Mathieu NOE 2024년 4월 5일
I have accelerometer data coming from a accelerometer sensor which is mounted on top of handle of a cricket bat, I have played some shots some are missed and some hit, now I want to detect which shots are missed shots and which shots are hit shots. So how I can detect impact location or collide between cricket bat and ball. I guess there should be some algorithm or procedures by which we can get clue of impact location. Do matlab provide any script for it or how I can get help regarding this.
  댓글 수: 5
Mathieu NOE
Mathieu NOE 2024년 3월 4일
hello again
can you comment your graph and describes what you habe done to generate that data ? we needto make the correlation between the graph and the events
xubyr
xubyr 2024년 3월 8일
Hello Mathieu,
I have used a bno055 sensor accelerometer data to plot the graph on the browser and I am getting x,y, & z. I am attaching the image file of plot drawn. I am getting the buffer and converting them into json and saved in file.
I have also attached a data file in json format. This data is generated while playing cricket for one over ie 6 balls, it has hit and missed shots in it.

댓글을 달려면 로그인하십시오.

답변 (1개)

Mathieu NOE
Mathieu NOE 2024년 3월 8일
편집: Mathieu NOE 2024년 3월 8일
hello
so this would be my suggestion
I hope my conclusion is not completely wrong !
At the end it seems I can clearly see 3 sharp and high amplitude peaks (above 5 g's ) corresponding to good hits; the other minor peaks are either missed hits or you shaking the baseball
code :
filename = "data1.csv";
data = importfile(filename);
% data = readtable('data1.csv') ; %
% data format :
% x,"y","z","timestamp"
% 0.10,"-1.69","9.85","14:58:30:267"
x = data.x;
y = data.y;
z = data.z;
timestamp = data.timestamp;
tmp = split(timestamp,':');
h = str2double(tmp(:,1)); % h column
m = str2double(tmp(:,2)); % m column
s = str2double(tmp(:,3)); % s column
ms = str2double(tmp(:,4)); % ms column
ts = h*3600 + m*60 + s + ms/1e3; % time in seconds
ts = ts - ts(1);
% plot(diff(ts)) ; % Nb the non constant sampling interval
% resample the data on a constant time interval time vector
tt = linspace(ts(1),ts(end),numel(ts));
x = interp1(ts,x,tt);
y = interp1(ts,y,tt);
z = interp1(ts,z,tt);
dt = mean(diff(tt));
Fs = 1/dt;
figure(1)
plot(tt,x,tt,y,tt,z);
legend('x','y','z')
% some high pass filtering to remove DC / low frequency signals
flow = 1;
[b,a] = butter(2,flow*2/Fs,'high');
xf = filtfilt(b,a,x);
yf = filtfilt(b,a,y);
zf = filtfilt(b,a,z);
figure(2)
plot(tt,yf,tt,zf);
legend('y','z')
figure(3)
% combine x,y,z signals into one rms signal
% see x direction contribution is neglectable , we can focus on y and z
% components only
rms_xyz = sqrt(xf.^2 + yf.^2 + zf.^2);
rms_yz = sqrt(yf.^2 + zf.^2);
plot(tt,rms_yz,tt,rms_xyz);
title('RMS (X) Y and Z acceleration');
xlabel('time (s)');
ylabel('amplitude (g)');
legend('rms(yz)','rms(xyz)')
  댓글 수: 3
xubyr
xubyr 2024년 4월 5일
Hello,
Thanks for your humble response.
I am still away from the solution and could you please tell how to use the above code in matlab. I have also installed matlab desktop software. I am also trying python to draw some result. Kindly suggest what to do.
Mathieu NOE
Mathieu NOE 2024년 4월 5일
hello again
do you have access to matlab ? if yes , and if you are new to it , I would suggest to look at some tutorials :
all the best

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 RESTful API에 대해 자세히 알아보기

태그

제품

Community Treasure Hunt

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

Start Hunting!

Translated by