opensim-core: Required format for printing external loads files can't be met (Matlab)

When printing out forces from a c3d, you have to rely on STOFileAdapter(), which prints external loads in a non-compliant .mot format.

%% import java libraries
import org.opensim.modeling.*

%% Use a c3dAdapter to turn read a c3d file
adapter = C3DFileAdapter();
forces = adapter.read(filepath).tables.get('forces');

%% flatten the Vec3 table to a table of doubles. 
postfix = StdVectorString(); postfix.add('_x');postfix.add('_y');postfix.add('_z');
forces_flattened = forces_rot.flatten(postfix);
% make a sto adapter and write the forces table to file.
STOFileAdapter().write(forces_flattened,[filepath '.mot']);

The output file header looks like this

CalibrationMatrices=Corners=DataRate=2000.000000
Origins=Types=events=DataType=double
version=2
endheader
time	f1_x	f1_y	f1_z	m1_x	m1_y	m1_z	p1_x	p1_y	p1_z	f2_x	f2_y	f2_z	m2_x	m2_y	m2_z	p2_x	p2_y	p2_z
0	1.472130060195923	17.71418762207031	-2.357758045196534	61.67040961382952	742.0819913723619	-98.77109934038099	827.2036135380047	3.6909246695582e-14	602.7737421316849	0	22.82806015014648	0.04444999992847303	2.273736754432321e-13	814.478227169007	1.585923503849422	318.8885687585697	3.419024461569678e-14	558.3690683632433

There are a few issues with this. (i) the header information is not compliant with standard .mot file format, and (ii) the order of colomns is also incorrect (we require f1,p1,f2,p2,…fn,pn, m1,m2,…mn).

I should be able to open the .mot in the (3.3) GUI to test/visualize, which I currently can not do.

About this issue

  • Original URL
  • State: closed
  • Created 7 years ago
  • Reactions: 1
  • Comments: 24 (24 by maintainers)

Most upvoted comments

I suggest useSIMMColumnOrdering because (1) “traditional” is ambiguous, (2) the .mot format is specific to SIMM (based on this Confluence page), and (3) IIUC the only difference will be the column ordering.