Missing function of idTool.setModel( )

Provide easy-to-use, extensible software for modeling, simulating, controlling, and analyzing the neuromusculoskeletal system.
POST REPLY
User avatar
D T
Posts: 24
Joined: Thu Nov 21, 2019 3:40 pm

Missing function of idTool.setModel( )

Post by D T » Fri Apr 10, 2020 6:45 pm

Hi all, very quick clarification:

I've successfully written a batch python (3.7) file for running inverse kinematics on various models and trials. Likewise, I'd like to have a separate file for running inverse dynamics.

Per the C++ developer API, InverseKinematicsTool has the function setModel(). This works successfully. However, it seems that InverseDynamicsTool does not have a function setModel() listed in the API. As a result, my idTool.run() does not assign a model, and therefore prints no output file (I know this because the printed setup file for every trial has <model_file>Unassigned</model_file>).

How can I assign the model being used so that I may run my idTool successfully (in the same way that ikTool is able to setModel())?

If it is helpful for further context, I can post the portion of code upon request.

Thank you for any/all information,
Dylan

Tags:

User avatar
Thomas Uchida
Posts: 1793
Joined: Wed May 16, 2012 11:40 am

Re: Missing function of idTool.setModel( )

Post by Thomas Uchida » Sun Apr 12, 2020 7:21 am

InverseDynamicsTool inherits setModel() from DynamicsTool (see image). In the doxygen (API) documentation, inherited methods are listed in sections that are collapsed by default.

User avatar
D T
Posts: 24
Joined: Thu Nov 21, 2019 3:40 pm

Re: Missing function of idTool.setModel( )

Post by D T » Sun Apr 12, 2020 12:43 pm

tkuchida wrote:
Sun Apr 12, 2020 7:21 am
InverseDynamicsTool inherits setModel() from DynamicsTool (see image). In the doxygen (API) documentation, inherited methods are listed in sections that are collapsed by default.
Apologies, I've found in the meantime that the issue is not setting the model of the tool (it was functioning as intended without myself knowing). However, the program still does not output an outputGenForces.sto file. For comparison, I have run the RunTutorialThree.py without any edits or changes to the script which came with OpenSim, and it also does not create its inversedynamics.sto output file.

I am quite confused, as the ikTool has been successfully creating output files without issue, but the idTool will not create an output file in either my own script or the premade tutorial scripts. The idTool does however successfully create an output saved settings file. Here is a portion of my script:

# Model import portion is excluded for this portion, but is nearly identical to "runMultipleIKTrials.py" with proper changes for idTool

# Set name of external loads file
extLoadsFile = os.path.join(motDataFolder, subject + 'id', newExtLoadsFileName)
idTool.setExternalLoadsFileName(extLoadsFile)

# Set name of input mot file and output motion in tool
idTool.setCoordinatesFileName(os.path.join(motDataFolder, filename))
outFileName = filename.replace('.mot', '_id.sto')
idTool.setOutputGenForceFileName(os.path.join(resultsFolder, outFileName))

# Run the tool
print("Running trial file "+idTool.getCoordinatesFileName()+" Output:"+idTool.getOutputGenForceFileName())
idTool.run()
print("Finished processing trial "+filename)

# Save the setup file
trialSetupFileName = filename.replace('.mot', '_ID_Setup.xml')
idTool.print(os.path.join(resultsFolder, trialSetupFileName))



newExtLoadsFileName is a procedurally generated external loads setup file that I have veryified to be functioning and a proper file address. It creates this file succesfully in the output directory to use.

POST REPLY