Set ForceSet to AnalyzeTool-Instance with Python API
Posted: Tue May 31, 2016 4:46 am
Hey there,
I like to run Static Optimization from within Python using the Python Wrapper. Thus I create an analyzeTool from a template setupXML file and then fill in the specific values e.g. for the coordinate file to use.
> analyzeTool = opensim.AnalyzeTool(setupXMLFile)
...
> analyzeTool.run()
The tool basically runs through. However I need to set the force set file to add actuators, which is failing unfortunately... I already tried the following ideas:
1. I tried to set it programmatically:
forceSetFile = "I:/somePath/Actuators.xml"
arr = opensim.ArrayStr()
arr.append(forceSetFile)
analyzeTool.setForceSetFiles(arr)
--> It runs through without errors, but seems to ignore the file and doesn't give the usual output "Adding force object set from "I:/somePath..."
2. I tried to already add the file in the setupXMLFile
<force_set_files>I:/somePath/Actuators.xml</force_set_files>
--> Now the analyzeTool doesn't seem to parse the setup XML file and the scripts exits with an undefined error
Do you know a way to set the force set file? Maybe using the class ForceSet and creating an instance of it?
And one more Question: I know that the above mentioned problem works when I save a final setup file and run it via console using > os.system("analyze -S \"finalSOSetupFile.xml\"") instead of using > analyzeTool.run(). But how can I save out the currenct analyzeTool-Settings to a setup script with the Python API?
The function > analyzeTool.print(setupFilePath) - which used to work as Python script from within OSIM - doesn't work in the Python Wrapper --> invalid syntax "print". And analyzeTool.printResults also doesn't show any effect. Could you please tell me which command to use instead?
Any help is appreciated! Thank you very much!
Stefanie
I like to run Static Optimization from within Python using the Python Wrapper. Thus I create an analyzeTool from a template setupXML file and then fill in the specific values e.g. for the coordinate file to use.
> analyzeTool = opensim.AnalyzeTool(setupXMLFile)
...
> analyzeTool.run()
The tool basically runs through. However I need to set the force set file to add actuators, which is failing unfortunately... I already tried the following ideas:
1. I tried to set it programmatically:
forceSetFile = "I:/somePath/Actuators.xml"
arr = opensim.ArrayStr()
arr.append(forceSetFile)
analyzeTool.setForceSetFiles(arr)
--> It runs through without errors, but seems to ignore the file and doesn't give the usual output "Adding force object set from "I:/somePath..."
2. I tried to already add the file in the setupXMLFile
<force_set_files>I:/somePath/Actuators.xml</force_set_files>
--> Now the analyzeTool doesn't seem to parse the setup XML file and the scripts exits with an undefined error
Do you know a way to set the force set file? Maybe using the class ForceSet and creating an instance of it?
And one more Question: I know that the above mentioned problem works when I save a final setup file and run it via console using > os.system("analyze -S \"finalSOSetupFile.xml\"") instead of using > analyzeTool.run(). But how can I save out the currenct analyzeTool-Settings to a setup script with the Python API?
The function > analyzeTool.print(setupFilePath) - which used to work as Python script from within OSIM - doesn't work in the Python Wrapper --> invalid syntax "print". And analyzeTool.printResults also doesn't show any effect. Could you please tell me which command to use instead?
Any help is appreciated! Thank you very much!
Stefanie