Page 1 of 1

Title: Issues Reading Movella Sensor Data in OpenSim

Posted: Thu Sep 12, 2024 2:00 pm
by mwdkim
Hello everyone,

I'm trying to read data from the Movella sensor in OpenSim, but I've encountered an error that I can't resolve. When I run the following code, I receive the following error message:

Copiar
Index(['PacketCounter', 'SampleTimeFine', 'Acc_X', 'Acc_Y', 'Acc_Z', 'Gyr_X',
'Gyr_Y', 'Gyr_Z', 'Quat_W', 'Quat_X', 'Quat_Y', 'Quat_Z'],
dtype='object')
---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
<ipython-input-35-a8123a3131fa> in <cell line: 11>()
18 # Create a RowVectorQuaternion and set the quaternion at position 0
19 row_vector = osim.RowVectorQuaternion(1)
---> 20 row_vector.set(0, quaternion)
21
22 # Append the time and row_vector to the TimeSeriesTableQuaternion
The traceback indicates that the RowVectorQuaternion object does not have a method named set. It's possible that this method was removed or renamed in a newer version of the OpenSim library, or there might be a typo in the method name.

Has anyone encountered a similar issue or know how I might resolve this? I appreciate any help or suggestions you can offer.

Thank you!

Re: Title: Issues Reading Movella Sensor Data in OpenSim

Posted: Fri Sep 13, 2024 9:27 am
by aymanh
Hello,

Thanks for reporting but it's not clear where the script you're referring to comes from. If it's published by us we'll need to fix and incorporate into our testing suite. If however this is your custom code, we'll need to find out what changed, and when and if we confirm the API has changed, update the documentation accordingly so that we can help other users in the similar situations as well.

Best regards,
-Ayman

Re: Title: Issues Reading Movella Sensor Data in OpenSim

Posted: Fri Sep 13, 2024 2:30 pm
by mwdkim
Hello Ayman,

Thank you for your response. I have attached a Python snippet for your review. I hope this clarifies the issue I am facing.

Wangdo

Python code

import pandas as pd
import opensim as osim

try:
# Load CSV data with semicolon delimiter and skip metadata rows
csv_data = pd.read_csv('ForearmR_20240715_102815_631.csv', skiprows=10, delimiter=';')
print(csv_data.columns)

# Create a TimeSeriesTableQuaternion for quaternion orientation data
table = osim.TimeSeriesTableQuaternion()

# Add column labels to the table
table.setColumnLabels(['orientation'])

for index, row in csv_data.iterrows():
# Use 'SampleTimeFine' as time
time = float(row['SampleTimeFine'])

# Create a Quaternion using the appropriate columns from the CSV
quaternion = osim.Quaternion(row['Quat_W'], row['Quat_X'], row['Quat_Y'], row['Quat_Z'])

# Create a RowVectorQuaternion and set the quaternion
row_vector = osim.RowVectorQuaternion(1, quaternion)

# Append the time and row_vector to the TimeSeriesTableQuaternion
table.appendRow(time, row_vector)

# Write the data into a .sto file
osim.STOFileAdapterQuaternion.write(table, 'output.sto')

print("Data processing complete. Output written to 'output.sto'.")

except Exception as e:
print(f"An error occurred: {e}")
# You might want to add more specific error handling for different types of exceptions