How to do Kinematics with IMU data workflow in Python
Posted: Mon Oct 02, 2023 3:52 pm
Hello!
I am currently trying to follow the tutorial located at: https://simtk-confluence.stanford.edu:8 ... h+IMU+Data
This tutorial allows you to use IMU data to compute motions of body segments. I do not have access to MatLab so I am trying to follow the tutorial with Python. There are no Python examples on that tutorial so I'm trying to do it myself, and the tutorial mentions support for Python.
This issue is in step 2, and I am unable to create an orientation file from IMU sensor data. My current Python file is:
I am receiving an error due to the osim.STOFileAdapterQuaternion.write() call. The error is:
The type of 'trialPrefix' is a 'str', so I'm unsure of how else to pass this to the function. In the tutorial it wraps the trial prefix with char() in MatLab, so perhaps it expects a char array? Char arrays do not exist in Python, so this is an unusable function? Does it need to be updated to be able to accept a string?
I would try using the CLI for OpenSense, but when I try to run it from the command line it tells me it is not recognized. Either way I would still prefer for it to work in Python.
I am currently trying to follow the tutorial located at: https://simtk-confluence.stanford.edu:8 ... h+IMU+Data
This tutorial allows you to use IMU data to compute motions of body segments. I do not have access to MatLab so I am trying to follow the tutorial with Python. There are no Python examples on that tutorial so I'm trying to do it myself, and the tutorial mentions support for Python.
This issue is in step 2, and I am unable to create an orientation file from IMU sensor data. My current Python file is:
Code: Select all
import opensim as osim
import os
ROOT = "C:\OpenSim 4.4\Resources\Code\Python\OpenSenseExample"
xsensSettings = osim.XsensDataReaderSettings(os.path.join(ROOT, 'myIMUMappings.xml'))
xsensReader = osim.XsensDataReader(xsensSettings)
tables = xsensReader.read(os.path.join(ROOT, 'IMUData\\'))
quaternionTable = xsensReader.getOrientationsTable(tables)
trialPrefix = xsensSettings.get_trial_prefix()
osim.STOFileAdapterQuaternion.write(quaternionTable, [trialPrefix, '_orientations.sto'])
print("Done")
Code: Select all
TypeError: in method 'STOFileAdapterQuaternion_write', argument 2 of type 'std::string const &'
I would try using the CLI for OpenSense, but when I try to run it from the command line it tells me it is not recognized. Either way I would still prefer for it to work in Python.