Using the OpenSim API through python scripting, how can I create a SimTK Rotation from a numpy array matrix?
More generally - I am trying to update the transform of an IMU PhysicalOffsetFrame associated with a body in my model (so I can manually apply my own calibrations, rather than rely on OpenSim's built-in IMUPlacer tool).
My code looks like this so far:
Code: Select all
import opensim as osim
import numpy as np
model = osim.Model(model_file)
IMU_frame = model.getBodySet().get('thorax').getComponent('thorax_imu')
rotation_array = np.array([[1, 0, 0],[0, 1, 0],[0, 0, 1]]) # Create an example numpy array
osim_rotation = osim.Rotation(rotation_array) # Create an opensim rotation (this doesn't work)
transform = osim.Transform(osim_rotation) # Create an opensim transform from the rotation
IMU_frame.setOffsetTransform(transform) # Update the IMU frame transform
Thanks for any help,
Mhairi