IMU's values

144 views
Skip to first unread message

Roberto Foletti

unread,
Oct 3, 2012, 6:04:55 AM10/3/12
to imusim...@googlegroups.com
Hello,

thanks for releasing the IMUSIM project!

I'm using it to write my graduation thesis, but I found some troubles..
I'm using the ASF/AMC file in the Mocap's database because I want to use the IMU's values to test others orientaion algorithms in Matlab. Is there a way to save the simulated IMU's values and the quaternions of the joints?
I simulate the walk using the database source by an IdealIMU and I see some glitch in the tibia accelerometer's values. Is it right or there's something wrong?
Is the IMU's orientation unvaried for all the simulated IMUs of the joints?

Thank,
Roberto

Kjartan Halvorsen

unread,
Oct 25, 2012, 10:52:09 AM10/25/12
to imusim...@googlegroups.com
Roberto,

yes, indeed you can save the data to matlab .mat files. Here is how I did it:

import scipy.io as sio # For writing .mat files
import itertools

# Assuming you have simulated IMUs in code above. In my case imu1 and imu2 
 
# First write to numpy array, then write array as matfile
shape_ = imu1.accelerometer.rawMeasurements.timestamps.shape
imu1.accelerometer.rawMeasurements.timestamps.shape = (shape_[0], 1)
imudta = np.hstack(( imu1.accelerometer.rawMeasurements.timestamps, 
                               imu1.accelerometer.rawMeasurements.values.T,
                               imu1.gyroscope.rawMeasurements.values.T,
                               imu2.accelerometer.rawMeasurements.values.T,
                               imu2.gyroscope.rawMeasurements.values.T))

# The true trajectories of the two imus
# Columns are qx, qy, qz, qw, dx1, dy1, dz1, vx1, vy1, vz1, dx2, dy2, dz2, vx2, vy2, vz2

truedta = np.zeros((imudta.shape[0], 16))
for imu, tdta in itertools.izip((imu1, imu2), (truedta[:,4:10], truedta[:,10:])):
   for t, i in itertools.izip(imu.accelerometer.rawMeasurements.timestamps, range(tdta.shape[0])):
     qt = imu.trajectory.rotation(t)
     dt = imu.trajectory.position(t)
     vt = imu.trajectory.velocity(t)

     truedta[i,0] = qt.x
     truedta[i,1] = qt.y
     truedta[i,2] = qt.z
     truedta[i,3] = qt.w
     tdta[i,:3] = dt.ravel()
     tdta[i,3:] = vt.ravel()

# Save in mat format
sio.savemat("twoimus.mat", {'imudta':imudta, 'truedta':truedta})


I can't help you with your second question, though.

Cheers,

Kjartan

Roberto Foletti

unread,
Oct 31, 2012, 5:14:22 AM10/31/12
to imusim...@googlegroups.com
Thank you very much Kjartan!!!!

Roberto
Reply all
Reply to author
Forward
0 new messages