opensim-org / opensim-core

SimTK OpenSim C++ libraries and command-line applications, and Java/Python wrapping.
https://opensim.stanford.edu
Apache License 2.0
797 stars 320 forks source link

AttributeError: module 'opensim' has no attribute 'IMUInverseKinematicsTool' #2767

Closed annshorn closed 4 years ago

annshorn commented 4 years ago

Hi, it's a little bit strange for me that module 'opensim' has no attribute 'IMUInverseKinematicsTool', this is standard code that I want to run:

import opensim as osim
import numpy as np

# Set variables to use
modelFileName = '/Users/anna/open_sim/models_2/arm26_calib.osim' # The path to an input model
orientationsFileName = '/Users/anna/open_sim/models_2/data_from_sensor_orientations.sto' # The path to orientation data for calibration 
sensor_to_opensim_rotation = osim.Vec3(-np.pi/2, 0, 0); # The rotation of IMU data to the OpenSim world frame 
visualizeTracking = True  # Boolean to Visualize the tracking simulation
startTime = 7.25;          # Start time (in seconds) of the tracking simulation. 
endTime = 15;              # End time (in seconds) of the tracking simulation.
resultsDirectory = '/Users/anna/open_sim/models_2/IKResults';

# Instantiate an InverseKinematicsTool
imuIK = osim.IMUInverseKinematicsTool();

# Set tool properties
imuIK.set_model_file(modelFileName);
imuIK.set_orientations_file(orientationsFileName);
imuIK.set_sensor_to_opensim_rotations(sensor_to_opensim_rotation)
imuIK.set_results_directory(resultsDirectory)

# Set time range in seconds
imuIK.set_time_range(0, startTime); 
imuIK.set_time_range(1, endTime);   

# Run IK
imuIK.run(visualizeTracking);

Gives:

---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
<ipython-input-3-aabccc6d64f4> in <module>
     13 
     14 # Instantiate an InverseKinematicsTool
---> 15 imuIK = osim.IMUInverseKinematicsTool();
     16 
     17 # Set tool properties

AttributeError: module 'opensim' has no attribute 'IMUInverseKinematicsTool'

What's happen and how to solve it? :) Thank you in advance.

PS. This model (arm26_calib.osim) and file (data_from_sensor_orientations.sto) work fine in matlab, but I need actually all in python

aymanhab commented 4 years ago

@annshorn thanks for reporting, the class IMUInverseKinematicsTool is available only since version 4.1, if you're using an earlier version or have connected python on this machine with an earlier version of OpenSim you'll see this error. Please check what version(s) you have on your machine.