Python API: Geometry path and joint center location
Posted: Fri Jun 23, 2023 6:18 pm
Hi, I am trying to use Python API to get geometry muscle point and joint center in "global coordinate system".
Recently, I could get optimal fiber length, tendon slack length, maximum isometric force, pennation angle, musculotendon length, and moment arm from 'gait2392_simbody.osim'.
Also, I think that I want to get geometry muscle point and joint center in "global coordinate system" in various generalized coordinates.
=============
model = opensim.Model('gait2392_simbody.osim')
state = model.initSystem()
list_coordinates = ['lumbar_extension',
'hip_flexion_l',
'knee_angle_l',
'ankle_angle_l',
'hip_flexion_r',
'knee_angle_r',
'ankle_angle_r']
values_coordinate = np.array([0,0,0,0,0,0,0]) # Angle: Trunk, left hip, knee, ankle, right hip, knee, ankle, e.g., all zero
for i_coordinate, _name_coordinate in enumerate(list_coordinates):
# Set posture
model.updCoordinateSet().get(_name_coordinate).setValue(state,np.deg2rad(values_coordinate[i_coordinate]))
_muscle = model.getMuscles().get('psoas_r')
_points = _muscle.getGeometryPath().getPathPointSet()
n_points = _points.getSize()
_point = _points.get(0) # e.g., first point
_vec = _point.getLocation(state)
============
Would you modify the code or tell me how to get geometry muscle point and joint center in "global coordinate system" in various generalized coordinates?
Sincerely yours,
Takuma Inai
Advanced Industrial Science and Technology
Recently, I could get optimal fiber length, tendon slack length, maximum isometric force, pennation angle, musculotendon length, and moment arm from 'gait2392_simbody.osim'.
Also, I think that I want to get geometry muscle point and joint center in "global coordinate system" in various generalized coordinates.
=============
model = opensim.Model('gait2392_simbody.osim')
state = model.initSystem()
list_coordinates = ['lumbar_extension',
'hip_flexion_l',
'knee_angle_l',
'ankle_angle_l',
'hip_flexion_r',
'knee_angle_r',
'ankle_angle_r']
values_coordinate = np.array([0,0,0,0,0,0,0]) # Angle: Trunk, left hip, knee, ankle, right hip, knee, ankle, e.g., all zero
for i_coordinate, _name_coordinate in enumerate(list_coordinates):
# Set posture
model.updCoordinateSet().get(_name_coordinate).setValue(state,np.deg2rad(values_coordinate[i_coordinate]))
_muscle = model.getMuscles().get('psoas_r')
_points = _muscle.getGeometryPath().getPathPointSet()
n_points = _points.getSize()
_point = _points.get(0) # e.g., first point
_vec = _point.getLocation(state)
============
Would you modify the code or tell me how to get geometry muscle point and joint center in "global coordinate system" in various generalized coordinates?
Sincerely yours,
Takuma Inai
Advanced Industrial Science and Technology