When running static optimization through the Python API, the results differ from those obtained through the GUI interface, despite identical setup files. The GUI output appears to have smoothing applied, while the API output does not.
Additional Information
- Python version (via conda): opensim 4.5.1
- GUI version: OpenSim 4.5
- OS: Windows 11 & MacOs Sequoia
- Lowpass cutoff frequency is identical in the setup files
Questions
- Is there a hidden smoothing parameter in the GUI that's not exposed in the API?
- Is there something wrong with my code implementation or am I missing any required steps/parameters?
Code: Select all
(...)
#Create the AnalyzeTool
analyze_tool = osim.AnalyzeTool()
analyze_tool.setModel(model)
analyze_tool.setStatesFromMotion(state, coordinates_file_sto, True)
analyze_tool.setStartTime(coordinates_file_sto.getFirstTime())
analyze_tool.setFinalTime(coordinates_file_sto.getLastTime())
analyze_tool.setReplaceForceSet(False)
analyze_tool.setSolveForEquilibrium(False)
# Initialize the StaticOptimization
static_opt = osim.StaticOptimization()
static_opt.setName("StaticOptimization")
static_opt.setUseModelForceSet(True)
static_opt.setStartTime(coordinates_file_sto.getFirstTime())
static_opt.setEndTime(coordinates_file_sto.getLastTime())
#analyze
analysis_set = analyze_tool.getAnalysisSet()
analysis_set.cloneAndAppend(static_opt)
analyze_tool.addAnalysisSetToModel()
analyze_tool.setCoordinatesFileName(coordinates_file)
analyze_tool.setExternalLoadsFileName(external_loads_file)
analyze_tool.setForceSetFiles(actuators)
# Save setup and results
analyze_tool.setResultsDir(results_directory)
analyze_tool.printToXML(os.path.join(folder, "setup_so.xml"))
analyze_tool.run()