Reading Xsens DOT IMU sensor data into OpenSim via Python scripting!

Provide easy-to-use, extensible software for modeling, simulating, controlling, and analyzing the neuromusculoskeletal system.
POST REPLY
User avatar
Ton Leenen
Posts: 17
Joined: Tue Apr 07, 2020 3:16 am

Reading Xsens DOT IMU sensor data into OpenSim via Python scripting!

Post by Ton Leenen » Fri Jun 12, 2020 8:51 am

Dear all,

I am following the OpenSense - Kinematics with IMU (https://simtk-confluence.stanford.edu:8 ... h+IMU+Data) tutorial/example and in Step Two: Convert IMU Data into OpenSim Format I have to read, and convert, the Xsens IMU sensor data to the OpenSense friendly format, but when I use the following code nothing happens (Python console keeps on running without any output), but when I run the Python script (OpenSense_IMUDataConverter.py) the script works without errors. I concluded that the Python scripting/wrapping is functioning.

The IMU data from the example, for instance, 'MT_012005D6_009-001_00B421E6.txt' has a different format in which the data is organised in the .txt files compared to the IMU data from the relatively new Xsens DOT IMU sensors (I have added a example data file from the these new sensors in this post). I am guessing that the xsens.read() function is not working properly due to the differences in format, but I am not able find the desirable format. Could someone help me with this?

I used the following code in Python (part of the 'OpenSense_IMUDataConverter.py')

Code: Select all

# Import the opensim libraries
import opensim as osim

# Build an Xsens Settings Object. 
# Instantiate the Reader Settings Class
xsensSettings = osim.XsensDataReaderSettings('myIMUMappings.xml')

# Instantiate an XsensDataReader
xsens = osim.XsensDataReader(xsensSettings)

# Read in seprate tables of data from the specified IMU file(s)
tables = xsens.read('IMUData/')

# get the trial name from the settings
trial = xsensSettings.get_trial_prefix()

# Get Orientation Data as quaternions
quatTable = xsens.getOrientationsTable(tables)
I have changes the 'myIMUMappings.xml' (also added in this post)!

Furtermore, the advantage of the Xsens DOT IMU sensors is the output of the orientation of the sensor which is already provided in quaternions instead of the classical rotation matrix (3x3 or 1x6). I do not have to convert the rotation matrix to quaternions and therefore the final line of code

Code: Select all

quatTable = xsens.getOrientationsTable(tables)
is not necessary, but I do need to know the format of the quatTable variable since this is used in the rest of the code to get the .sto files.

Hopefully someone is able to help me with these issues!

Ton Leenen
Attachments
testdata_Upperarm.txt
(133.33 KiB) Downloaded 71 times
myIMUMappings.xml
(1.41 KiB) Downloaded 63 times

Tags:

User avatar
Ayman Habib
Posts: 2248
Joined: Fri Apr 01, 2005 12:24 pm

Re: Reading Xsens DOT IMU sensor data into OpenSim via Python scripting!

Post by Ayman Habib » Mon Jun 15, 2020 12:12 pm

Hi Ton,

The format for the file you sent is different from the format supported by the opensense parsers so it's no surprise the file(s) don't work out of the box, though we should try to provide more helpful feedback. If there's public domain documentation of the latest format we could support it in the future thus saving ourselves and users the need to convert file formats. For the time being though, I'd suggest you write a script (in python or matlab to read the quaternions directly into a TimeSeriesTable or to convert the file to supported format. An example of the supported format is available in the resources directory for OpenSim 4.1 at C:\Users\${USERNAME}\Documents\OpenSim\4.1\Code\Matlab\OpenSenseExample\IMUData

Hope this helps,
-Ayman

User avatar
Ton Leenen
Posts: 17
Joined: Tue Apr 07, 2020 3:16 am

Re: Reading Xsens DOT IMU sensor data into OpenSim via Python scripting!

Post by Ton Leenen » Mon Jun 22, 2020 1:38 am

Hi Ayman,

Thank you for your reply! I managed to write a Python script to convert the Xsens DOT format to the OpenSense readable format and it is working quite well!

Thanks,

Greetings,

Ton

User avatar
Qingyao Bian
Posts: 1
Joined: Thu Oct 08, 2020 2:02 am

Re: Reading Xsens DOT IMU sensor data into OpenSim via Python scripting!

Post by Qingyao Bian » Tue Nov 17, 2020 12:55 pm

Hi,

I am also having difficulty in importing imu data into Opensense. Could you please tell me how you finished the work at last? Thank you so much!!

Cheers

User avatar
Felipe Gonzalez
Posts: 1
Joined: Sat Feb 04, 2023 2:37 pm

Re: Reading Xsens DOT IMU sensor data into OpenSim via Python scripting!

Post by Felipe Gonzalez » Sun Apr 02, 2023 1:43 pm

antoniusleenen wrote:
Mon Jun 22, 2020 1:38 am
Hi Ayman,

Thank you for your reply! I managed to write a Python script to convert the Xsens DOT format to the OpenSense readable format and it is working quite well!

Thanks,

Greetings,

Ton
Hello Ton.

Could you share your Python script to convert the Xsens DOT format to the OpenSense readable format?
I'm also using Xsens DOT and I'm having a hard time trying to solve this problem.

Sincerely.
Felipe
Felipe_gonzalez@rush.edu

POST REPLY