Creating .mot file through API

Provide easy-to-use, extensible software for modeling, simulating, controlling, and analyzing the neuromusculoskeletal system.
POST REPLY
User avatar
Bryce Killen
Posts: 104
Joined: Mon Nov 24, 2014 7:12 pm

Creating .mot file through API

Post by Bryce Killen » Wed Aug 16, 2017 11:17 pm

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

User avatar
Thomas Uchida
Posts: 1792
Joined: Wed May 16, 2012 11:40 am

Re: Creating .mot file through API

Post by Thomas Uchida » Thu Aug 17, 2017 1:02 pm

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');

User avatar
Bryce Killen
Posts: 104
Joined: Mon Nov 24, 2014 7:12 pm

Re: Creating .mot file through API

Post by Bryce Killen » Thu Aug 17, 2017 3:32 pm

Hi Tom,

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

Thanks alot

Cheers

User avatar
l l
Posts: 3
Joined: Sat Oct 15, 2022 12:20 am

Re: Creating .mot file through API

Post by l l » Tue Jan 16, 2024 9:06 pm

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.

User avatar
Nicholas Bianco
Posts: 1041
Joined: Thu Oct 04, 2012 8:09 pm

Re: Creating .mot file through API

Post by Nicholas Bianco » Thu Jan 18, 2024 11:25 am

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

POST REPLY