Hello! I am using this basic function to perform Inverse Dynamics: def run_inverse_dynamics(grf_xml_path, ik_mot_path, output_folder):
# Carica il modello
model = osim.Model(r"C:\Users\acer\Desktop\THESIS_GIOVANNI\Gait2354_Simbody\subject01_simbody.osim") # Assicurati di aggiungere il percorso al tuo modello OpenSim
model.initSystem()
# Configura l'analisi di Inverse Dynamics
idTool = osim.InverseDynamicsTool()
idTool.setModel(model)
idTool.setExternalLoadsFileName(grf_xml_path)
idTool.setCoordinatesFileName(ik_mot_path)
idTool.setOutputGenForceFileName("inverse_dynamics_prova.sto")
idTool.setResultsDir(output_folder).
# Esegui l'Inverse Dynamics
idTool.run()
# Percorsi ai file di input
grf_xml_path = r"C:\Users\acer\Desktop\THESIS_GIOVANNI\Gait2354_Simbody\subject01_walk1_grf.xml"
ik_mot_path = r"C:\Users\acer\Desktop\THESIS_GIOVANNI\Gait2354_Simbody\subject01_walk1_ik.mot"
output_folder = r"C:\Users\acer\Desktop\THESIS_GIOVANNI\Gait2354_Simbody\ResultsIDON"
# Esegui la funzione
run_inverse_dynamics(grf_xml_path, ik_mot_path, output_folder)
If I put the same files into the GUI, I get the first 5 more or less and the last 5/6 columns very very similar, but the other very different values. Can someone help me? It is for my master thesis, I would be very glad.
Giovanni
Very different results between Inverse Dynamics GUI vs Python code
- giovanni pestrichella
- Posts: 4
- Joined: Wed Sep 27, 2023 3:15 am
- Mohammadreza Rezaie
- Posts: 407
- Joined: Fri Nov 24, 2017 12:48 am
Re: Very different results between Inverse Dynamics GUI vs Python code
Hi, similar to the setup file generated by ID tool in GUI, you need to exclude muscles:
You may also want to apply filter and crop the time stamp:
Hope these help.
Code: Select all
exclude = osim.ArrayStr()
exclude.append('Muscles')
idTool.setExcludedForces(exclude)
Code: Select all
idTool.setLowpassCutoffFrequency(6)
IKData = osim.Storage(ik_mot_path)
idTool.setStartTime(IKData.getFirstTime())
idTool.setEndTime(IKData.getLastTime())
- giovanni pestrichella
- Posts: 4
- Joined: Wed Sep 27, 2023 3:15 am
Re: Very different results between Inverse Dynamics GUI vs Python code
So do you mean that to get the same results using python and using the GUI, I have exclude forces in my python code even if I am using exactly the same setup file ID and the same motion file?
And another question, the filter that I could applied filters the motion files or the grf data (or both)?
And another question, the filter that I could applied filters the motion files or the grf data (or both)?
- Mohammadreza Rezaie
- Posts: 407
- Joined: Fri Nov 24, 2017 12:48 am
Re: Very different results between Inverse Dynamics GUI vs Python code
Hi, to get identical results, you need identical setup files. You can use either of these to see what is happening inside the tool:So do you mean that to get the same results using python and using the GUI, I have exclude forces in my python code even if I am using exactly the same setup file ID and the same motion file?
Code: Select all
print(idTool.dump())
idTool.printToXML('test.xml')
As its description says, it would be applied to your motion file only.And another question, the filter that I could applied filters the motion files or the grf data (or both)?
"Low-pass cut-off frequency for filtering the coordinates_file data"