Page 1 of 1

Creating .mot file through API

Posted: Wed Aug 16, 2017 11:17 pm
by brycekillen05
Hi Everyone,

I have a technical question regarding the OpenSim API. I am trying to build a .mot file which I can use to drive an OpenSim model. I have been able to load a previous .mot file through the API :

Code: Select all

dir = ' dir\to\my\mot\file,mot '
mot = Storage(dir)
I am also able to create an empty storage object and add column labels to this storage file :

Code: Select all

mot = Storage()
colHead = ArrayStr()
colhead.setSize(1)
colHead.set(0,'time')
mot.setColumnLabels(colHead)
However in both of these situations I am unable to add rows with data eg. a time stamp and a value for a specific coordinate.
I have tried using both the append and also add functions associated with the Storage class (https://simtk.org/api_docs/opensim/api_ ... orage.html) . However when I print the .mot file their is no data rows , jsut the following text

Code: Select all

Coordinates
version=1
nRows=97
nColumns=56
inDegrees=yes
endheader
time	pelvis_tilt	pelvis_list	pelvis_rotation	pelvis_tx
If anyone has used the API to generate / edit .mot files and has suggestions I would be very grateful

Thanks for any feedback or suggestions.

Best

Bryce Killen

Re: Creating .mot file through API

Posted: Thu Aug 17, 2017 1:02 pm
by tkuchida
Here's a simple example using OpenSim 3.3 in MATLAB:

Code: Select all

import org.opensim.modeling.*;

storage = Storage();

labels = ArrayStr();
labels.append('time');
labels.append('value');
storage.setColumnLabels(labels);

v = Vector(1, 3.14);
storage.append(1.0, v);

storage.print('test.sto');

Re: Creating .mot file through API

Posted: Thu Aug 17, 2017 3:32 pm
by brycekillen05
Hi Tom,

I think I was just having trouble with the specific indexing when applying the Vector the the Storage file.

Thanks alot

Cheers

Re: Creating .mot file through API

Posted: Tue Jan 16, 2024 9:06 pm
by 1lll
Hello, I would like to ask about the relative pose (angle and position) of the coordinate system where I only have two points, and their paths are divided into multiple point poses. How can I create a MOT file based on these poses? This has been a problem that I have been struggling with lately.

Re: Creating .mot file through API

Posted: Thu Jan 18, 2024 11:25 am
by nbianco
Hi,

I'm not sure what you mean by "I only have two points" and "paths are divided into multiple point poses". Could you please clarify or perhaps provide a code snippet?

As for file creation, in OpenSim 4.0 or later, you can use STOFileAdapter::write() to save a TimeSeriesTable to a MOT file.

Best,
Nick