Page 1 of 1

Import of quaternion using TimeSeriesTableQuaternion in python

Posted: Mon Jan 24, 2022 11:58 am
by swathihg
Hello,
I am using IMU other than Xsens and APDM. I have a csv file which contains quaternions of orientation. But I try to access the csv file using the below code. The code freezes for long time without any output. And I even tried many other methods which didn't work for me.

import opensim as osim
tables = osim.TimeSeriesTableQuaternion('out_static.csv')
print(tables)

It would be really helpful if anyone could lead me on how to proceed with reading the quaternion from csv file into opensim in python for creating .sto file.
Thank you

Re: Import of quaternion using TimeSeriesTableQuaternion in python

Posted: Wed Jan 26, 2022 2:14 pm
by aymanh
Hi Swathi,

The syntax looks correct (trying to construct a TimeSeriesTable from a .csv file), the issue likely has to do with the contents of the file, which you didn't include. It maybe misleading in the documentation to imply that we can handle reading arbitrary .csv file contents. Typically the files we use have a specific header, a row of labels that matches the number of data columns in the file etc. The fact that you're trying to read Quaternions (which we typically write/read as a comma separated quadruple x,y,z,w) is a bit more tricky for csv which is comma delimited. My suggestion would be to create the TimeSeriesTableQuaternion in memory using synthetic data, then use the write methods to create .csv or .sto file and inspect it for the expected layout. We should be able to read the same files we write. If not please open an issue and attach the relevant files and we'll investigate.

Please let us know how that goes,
-Ayman