Page 1 of 4

Orientation Tracking Setup

Posted: Thu Aug 24, 2023 12:25 pm
by nvanden
Hi all,

I recently started working with some IMU data that I'm trying to use with Moco, the good news being that there's a ton of data available but it's a bit like drinking out of a fire hose. The Xsens system we're using gives a ton of information and I've been able to adapt some conversion code from the native MVNX files to kinematics .mot files. However, (and this seems silly to say) I can only pull joint angle data from the MVN model joints which leaves gaps in various OpenSim model DOFs that don't have data to track (i.e., pelvis_tilt/list/rotation); resulting in solutions that aren't super great.

I have a question regarding the MocoOrientationTrackingGoal. I've used a variant of this goal in the past to assign a states trajectory for reference for the torso orientation. The description of this goal says that it can also take a trajectory in quaternion format, representing the orientation reference data which is provided in an array for all of the MVN model segments in each captured frame.
IMU_data_frames.png
IMU_data_frames.png (50.3 KiB) Viewed 1701 times
I'm wondering if it's as straightforward as building a TimeSeriesTable of the quaternion data and adding a Pelvis_Orientation tracking goal to my problem? Or am I missing something else?

Thanks!
Nick

Re: Orientation Tracking Setup

Posted: Fri Aug 25, 2023 10:17 am
by nbianco
Hi Nick,

Yes, that should work! It's been a while since I wrote that cost term, so hopefully everything works as expected.

One quick thing: you might run into issues with the Matlab bindings not supporting a TimeSeriesTable of Quaternion or Rotation objects. I believe we fixed that recently, but let me know if it still doesn't work.

Best,
Nick

Re: Orientation Tracking Setup

Posted: Mon Aug 28, 2023 11:27 am
by nvanden
Hey Nick,

I've tried working it up, pretty sure I've pulled the right section to construct the table itself and wrote up the goal:
Pel_OTG_code.png
Pel_OTG_code.png (11.85 KiB) Viewed 1656 times
Is this what you were referring to about the table not being supported? I tried it with the TableProcessor after trying just the TimeSeriesTableQuaternion and normal TimeSeriesTable.
Pel_OTG_err.png
Pel_OTG_err.png (14.32 KiB) Viewed 1656 times
If it's helpful I also included the .mot file that I made with the orientation data. I'm not sure if the issue is the type of table I'm trying to make or the data I'm trying to put in it.

Best,
Nick

Re: Orientation Tracking Setup

Posted: Mon Aug 28, 2023 11:48 am
by nbianco
Hey Nick,

You can't load that data directly into a TimeSeriesTableQuaternion, since it's currently just a table of "scalar" columns. But you can load the data into a TimeSeriesTable, and then "pack" it into a table of quaternions.

Code: Select all

pelvisTable = TimeSeriesTable('TFAB_02_SSWlk04_Xsens_PelQuat.mot');

% The "pack" method will take each 4 consecutive columns and pack them into a Quaternion object. It will choose a % column name based on a common prefix across all columns.
pelvisTableQuaternion = pelvisTable.pack();

% If you know the suffixes for each group of 4 columns, you can specify them during the pack operation.
suffixes = StdVectorString();
suffixes.add("_e0");
suffixes.add("_e1");
suffixes.add("_e2");
suffixes.add("_e3");
pelvisTableQuaternion = pelvisTable.pack(suffixes);
-Nick

Re: Orientation Tracking Setup

Posted: Mon Aug 28, 2023 12:04 pm
by nvanden
That makes sense, thanks! I've got that worked in now but I'm getting an error about too many output arguments when I use the pack function?

Re: Orientation Tracking Setup

Posted: Mon Aug 28, 2023 12:06 pm
by nbianco
Could you post a screenshot of the error message?

Re: Orientation Tracking Setup

Posted: Mon Aug 28, 2023 12:08 pm
by nvanden
Here's the error I'm seeing
Pel_OTG_err.png
Pel_OTG_err.png (3.33 KiB) Viewed 1615 times

Re: Orientation Tracking Setup

Posted: Mon Aug 28, 2023 12:10 pm
by nbianco
Ah, sorry -- you need to use the method "packQuaternion".

Code: Select all

pelvisTableQuaternion = pelvisTable.packQuaternion();

Re: Orientation Tracking Setup

Posted: Mon Aug 28, 2023 12:18 pm
by nvanden
Gotcha, that makes sense. I'm seeing this now, is it because there's header info or something? Not sure what's still missing.

Re: Orientation Tracking Setup

Posted: Mon Aug 28, 2023 12:29 pm
by nbianco
You need to provide column labels that have a common pattern so that OpenSim can auto-detect how to pack and name the columns. For quaternions, you could have column labels that end with "_e#", where # = 0, 1, 2, 3. For example: "pelvis_e0", "pelvis_e1", "pelvis_e2", "pelvis_e3". Then you can provide these suffixes (as in the example code above), or let OpenSim try to auto-detect (which it should be able to do after renaming).