Matlab - PhidgetSpatial 3/3/3
Posted: Fri Oct 09, 2020 4:23 am
Hi guys,
I am facing problem with the 1044 PhidgetSpatial. I kindof figured out the code to get some data. But this is a 1x30000 or more array for X Y Z acceleration and its too much if it samples every 5ms. Also, its repeating data for 5-6 times.
I did a lot of research, google burned up by phidgetspatial and Matlab searches but I am stuck. The user guide of phidget 1044 is also helpless.
What I want is to have the data read into Matlab and each with a corresponding timestamp in the IMU (DataRate).
E.g.: time(s) X acc Y acc Z acc
0.05 0.037 0.015 -0.998
0.1 0.036 0.013 -1.002
0.15 ...
0.2 ...
Can someone link something which can guide me through? OR if someone has a working code with anything similar is also helpfull.
Thanks:)
clc, clear all
tic;
loadphidget21;
handle = libpointer('int32Ptr');
calllib('phidget21', 'CPhidgetSpatial_create', handle);
calllib('phidget21', 'CPhidget_open', handle, -1);
calllib('phidget21', 'CPhidgetSpatial_getDataRate', handle, -1)
if calllib('phidget21', 'CPhidget_waitForAttachment', handle, 2500) == 0
disp('IMU Opened')
% Start code
rt = 3; % run time for 3 seconds to see sampling
i = 0;
while rt >= toc
i = i+1;
Acc_Xdata = libpointer('doublePtr',1);
% Acc_Ydata = libpointer('doublePtr',1);
% Acc_Zdata = libpointer('doublePtr',1);
calllib('phidget21', 'CPhidgetSpatial_getAcceleration', handle, 0, Acc_Xdata);
% calllib('phidget21', 'CPhidgetSpatial_getAcceleration', handle, 1, Acc_Ydata);
% calllib('phidget21', 'CPhidgetSpatial_getAcceleration', handle, 2, Acc_Zdata);
Acc_X(i) = Acc_Xdata.Value;
% Acc_Y(i) = Acc_Xdata.Value;
% Acc_Z(i) = Acc_Xdata.Value;
end
else
disp('Could not open IMU')
end
plot(Acc_X)
% clean up
calllib('phidget21', 'CPhidget_close', handle);
calllib('phidget21', 'CPhidget_delete', handle);
%unloading the library too quickly causes issues.
pause(0.5)
unloadlibrary phidget21;
I am facing problem with the 1044 PhidgetSpatial. I kindof figured out the code to get some data. But this is a 1x30000 or more array for X Y Z acceleration and its too much if it samples every 5ms. Also, its repeating data for 5-6 times.
I did a lot of research, google burned up by phidgetspatial and Matlab searches but I am stuck. The user guide of phidget 1044 is also helpless.
What I want is to have the data read into Matlab and each with a corresponding timestamp in the IMU (DataRate).
E.g.: time(s) X acc Y acc Z acc
0.05 0.037 0.015 -0.998
0.1 0.036 0.013 -1.002
0.15 ...
0.2 ...
Can someone link something which can guide me through? OR if someone has a working code with anything similar is also helpfull.
Thanks:)
clc, clear all
tic;
loadphidget21;
handle = libpointer('int32Ptr');
calllib('phidget21', 'CPhidgetSpatial_create', handle);
calllib('phidget21', 'CPhidget_open', handle, -1);
calllib('phidget21', 'CPhidgetSpatial_getDataRate', handle, -1)
if calllib('phidget21', 'CPhidget_waitForAttachment', handle, 2500) == 0
disp('IMU Opened')
% Start code
rt = 3; % run time for 3 seconds to see sampling
i = 0;
while rt >= toc
i = i+1;
Acc_Xdata = libpointer('doublePtr',1);
% Acc_Ydata = libpointer('doublePtr',1);
% Acc_Zdata = libpointer('doublePtr',1);
calllib('phidget21', 'CPhidgetSpatial_getAcceleration', handle, 0, Acc_Xdata);
% calllib('phidget21', 'CPhidgetSpatial_getAcceleration', handle, 1, Acc_Ydata);
% calllib('phidget21', 'CPhidgetSpatial_getAcceleration', handle, 2, Acc_Zdata);
Acc_X(i) = Acc_Xdata.Value;
% Acc_Y(i) = Acc_Xdata.Value;
% Acc_Z(i) = Acc_Xdata.Value;
end
else
disp('Could not open IMU')
end
plot(Acc_X)
% clean up
calllib('phidget21', 'CPhidget_close', handle);
calllib('phidget21', 'CPhidget_delete', handle);
%unloading the library too quickly causes issues.
pause(0.5)
unloadlibrary phidget21;