Impact location detection from accelerometer data

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 Comments

How is the data stored? In which format?
How should the data be interpreted?
It would be better if you would share all the necessary details and information, which would aid us in providing suggestions/solutions accordingly.
you can probaly distinguish based on amplitude and duration
would of course be nice to hace access to the data
The accelerometer is Bosch BNO055 which gives acceleration in x, y, & z direction. I am capturing x, y & z and time in json format and drawing some chart to evaluate. I can write format also
{x:1, y:2,z:3}. I have drawn chart from the data manually, right now I am lacking analytical tools to evalutate it, please suggest some tools or solutions, algorithm or whatsoever help to detect the collide when bal hit the cricket bat.
Thanks
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
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.

Sign in to comment.

Answers (1)

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 Comments

hello
so have you solved your problem ?
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.
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

Sign in to comment.

Products

Asked:

on 1 Mar 2024

Commented:

on 5 Apr 2024

Community Treasure Hunt

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

Start Hunting!