Page 1 of 1

Flatten Issue in Python

Posted: Mon Aug 24, 2020 1:21 pm
by catherinebelle
For the python code, what are the specifications that need to be included in the markers and forces section of the code? The error that I am receiving is "'AbstractDataTable' object has no attribute 'flatten'". Not sure where to go from here.

Re: Flatten Issue in Python

Posted: Tue Aug 25, 2020 12:58 am
by mitkof6
Hi Catherine,

I am not sure if I understood your question properly. If you want to create the marker trajectory file (.trc) manually you can follow the code example below:

Code: Select all

import opensim

# create table
table = opensim.TimeSeriesTableVec3()
table.addTableMetaDataString('DataRate', str(60))  # must read the frame rate
table.addTableMetaDataString('Units', 'mm')        # use mm
table.setColumnLabels(('RASIS', 'PASIS'))          # set the name of the markers

row1 = opensim.RowVectorVec3([opensim.Vec3(1, 2, 3),
                              opensim.Vec3(4, 5, 6)])
table.appendRow(0.1, row1)                         # 0.1 is time

adapter = opensim.TRCFileAdapter()
adapter.write(table, 'test.trc')
I think you have to use TimeSeriesTableVec3 instead of AbstractDataTable to avoid the flatten error.