ME2400
ASSIGNMENT 2
connector on connector;
m=mobiledev;
m.AccelerationSensorEnabled = 1
pause(2)
m.logging = 1
pause(10)
m.logging = 0
figure(1)
plot(tacc, acc)
xlabel('time')
ylabel('acceleration')
legend('x component','y component','z component')
a=mean(acc)
max=max(acc)
jerk=diff(acc);
figure(2)
plot(jerk)
legend('x component','y component','z component')
xlabel('time')
ylabel('jerk')
BASKETBALL ACCELERATION
BASKETBALL JERK
1) BASKETBALL JUMP
TENNIS JERK
2) TENNIS FOREHAND
X-COMP Y-COMP Z-COMP
Mean = 5.3772 3.0198 7.4594
Max = 20.6712 6.3008 38.4641
TYPICAL DURATION= 2.0 sec
TIME FOR MAX. ACCL= 0.2 sec
CRICKET ACCELERATION
CRICKET JERK
3) CRICKET BOWLING
X-COMP Y-COMP Z-COMP
Mean = 1.0134 -1.3621 9.8970
Max = 26.0969 10.7712 38.4641
TYPICAL DURATION= 2.9 sec
TIME FOR MAX. ACCL= 0.25 sec
QUESTION 2) ALL ANGLES ARE IN DEGREES
CODE
close all
clear all
connector on connector;
m=mobiledev;
m.OrientationSensorEnabled = 1
pause(2)
m.logging = 1
pause(20)
m.logging = 0
figure(1)
plot(to, o)
xlabel('time')
ylabel('angle in degrees')
legend('azimuth','pitch','roll')
x=o(:,1);
y=o(:,2);
z=o(:,3);
x=degtorad(x);
y=degtorad(y);
z=degtorad(z);
s=size(x);
num=s(1,1);
to=sqrt(2);
theta=linspace(0,2*pi);
phi=linspace(0,pi/2);
[theta1 phi1]=meshgrid(theta,phi);
r=1;
[a,b,c]=sph2cart(theta1,phi1,r);
figure;
surf(a,b,c)
shading interp
hold on
for n=1:num
a1=x(n,1);
b1=y(n,1);
c1=z(n,1);
scatter3(a,c,b,'k','filled','h');
axis equal;
hold on
end
[a,b,c]=sphere;
mesh(a,b,c)
hidden off;
THE ORINTATION WILL CHANGE AT THE MEAN VALUE OF TWO ORIENTATION
PORTRAIT TO LANDSCAPE
AZIMUTH= -105.7949 ROLL= -43.4892 PITCH= -31.9080
connector on connector
pause(5)
final = []; ini = [];
m=mobiledev
m.AngularVelocitySensorEnabled = 1
m.OrientationSensorEnabled = 1
m.logging = 1;
pause(10)
m.logging=0;
[av,tav]=angvellog(m);
[o,to]= orientlog(m);
o = o*pi/180.0;
final = o(length(to),1:3);
ini = o(1,1:3);
figure(1)
plot(tav,av)
xlabel('time')
ylabel('angular velocity')
figure(2)
plot(to,o)
xlabel('time')
ylabel('orientation')
legend('azimuth','roll','pitch')
%Error calculation
l=length(tav);
azx=[];pix=[];rox=[];
for i=1:l
azx(i)=o(3*i-2);
pix(i)=o(3*i-1);
rox(i)=o(3*i);
end
azy = trapz(azx,tav);
piy = trapz(pix,tav);
roy = trapz(rox,tav);
az_error = azy-(final(1)-ini(1));
pi_error = piy-(final(1)-ini(1));
ro_error = roy-(final(1)-ini(1));
fprintf('Error in angles,in radians,are [%f,%f,%f]\n',
az_error,pi_error,ro_error);
ANGULAR VELOCITY (Radian/sec)
ORIENTATION
QUESTION 4)
CODE
connector on connector
pause (10)
m=mobiledev
m.AccelerationSensorEnabled=1
m.logging=1
m.sampleRate
m.logging=0
m.AccelerationSensorEnabled=0
pause(10)
m.AngularVelocitySensorEnabled=1
m.logging=1
m.sampleRate
m.logging=0
m.AngularVelocitySensorEnabled=0
pause(10)
m.MagneticSensorEnabled=1
m.logging=1
m.sampleRate
m.logging=0
m.MagneticSensorEnabled=0
pause(10)
m.OrientationSensorEnabled=1
m.logging=1
m.sampleRate
m.logging=0
m.OrientationSensorEnabled=0
pause(10)
m.PositionSensorEnabled=1
m.logging=1
m.sampleRate
m.logging=0
m.PositionSensorEnabled=0
pause(10)
ACCELERATION SENSOR = 10 Hz
ANGULAR VELOCITY SENSOR = 10 Hz
MAGNETIC SENSOR = 10 Hz
ORIENTATION SENSOR = 10 Hz
POSITION SENSOR = 10 Hz
RESOLUTION
ACCELERATION SENSOR= 0.002 m/sq.sec
ANGULAR VELOCITY SENSOR = 0.001 rad/sec
MAGNETIC SENSOR = 0.301 microT
QUESTION 5)
GRAY CODE
x = [0; 1];
for a=1:(n-1)
k=2^a;
y=flipud(x);
z=zeros(k,1);
o=ones(k,1);
at=[z,x];
bt=[o,y];
x=[xt;yt];
continue
end
disp(x);