Page 1 of 1

Many question for API management

Posted: Fri Sep 01, 2017 6:04 pm
by nikorose
Hi all,

I was trying to do a lot of things in Python's API but I found some errors that I would like you to solve or help. Probably, These errors occur because I don't understand well the architecture of OpenSim. The errors are shown below:

1. When I try to print an array, what it is printed is the type, something like this:

Code: Select all

<opensim.common.ArrayStr; proxy of <Swig Object of type 'OpenSim::Array< std::string > *' at 0x7fdd0ccbb330> >
and not the specific array created in the following code:

Code: Select all

sto = osim.Storage(Dir + "/" + IK_results)
table = sto.getColumnLabels()
print (sto)
How can I see the array printed instead of the type?

2. I'm doing a gait analysis and I want to visualize my model in each task (e.g scaling, IK, ID, ...) and I'm trying doing it with the next functions:

Code: Select all

mystate = model.initSystem()
model.setUseVisualizer(True)
mystate = model.initSystem()
model.getVisualizer().show(mystate)
I don't know if this method is the most appropriate, however, I received a shutdown message from simbody, can you help me?

3. I tried to load the results of IK (.sto file) to my model, do you think that the best way to do it is with the AnalyzeTool, in fact, I tried but I got the next error
ERROR- Number of states in doesn't match number of states in model
, so I think that IK is just 1 state and I don't know how to configure the Analyzetool to run it.

Thank you very much for your attention.

Re: Many question for API management

Posted: Sat Sep 02, 2017 11:04 am
by chrisdembia
For (1), if you're using 4.0, then you can convert the Storage to a TimeSeriesTable and call toString().

Re: Many question for API management

Posted: Sat Sep 02, 2017 1:46 pm
by tkuchida
I tried to load the results of IK (.sto file) to my model, do you think that the best way to do it is with the AnalyzeTool
What are you trying to compute from your IK results?

You might find the tutorials and examples helpful: https://simtk-confluence.stanford.edu:8 ... +Tutorials.

Re: Many question for API management

Posted: Sat Sep 02, 2017 4:53 pm
by nikorose
Thanks to both for the answers:

Unfortunately, for the first one, it didn't work. I tried in the following way:

Code: Select all

sto = osim.Storage(Dir + "/" + IK_results)
table = sto.getAsTimeSeriesTable()
print(table.toString())
But I got the next error:
AttributeError: 'SwigPyObject' object has no attribute 'toString'
swig/python detected a memory leak of type 'TimeSeriesTable *', no destructor found.
With regard to Dr. Uchida's answer, basically, I got the angles for a gait analysis through IK and for my purposes, I've got the specific information desired. However, I want to visualize the IK behavior with the model, so that is why I want to do that task.

Thanks

Re: Many question for API management

Posted: Sun Sep 03, 2017 12:04 pm
by tkuchida
basically, I got the angles for a gait analysis through IK and for my purposes, I've got the specific information desired. However, I want to visualize the IK behavior with the model
Have you considered using the GUI for visualizing your results? To animate existing results from scripting, I think you would need to pose the model (by setting the states from your results), call model.getVisualizer().show(state), and repeat for each time step.