realizePosition instead of assemble for faster computation

This commit is contained in:
davidpagnon 2024-11-20 20:51:25 +01:00
parent 4f18dd770d
commit 890ac14eb9
2 changed files with 5 additions and 3 deletions

View File

@ -123,8 +123,9 @@ def bodykin_from_mot_osim_func(*args):
model.getCoordinateSet().get(coord).setValue(state, motion_data_np[n,c], enforceContraints=False)
except:
pass
model.assemble(state)
# model.assemble(state)
model.realizePosition(state) # much faster (IK already done, no need to compute it again)
# Use state of model to get body coordinates in ground
loc_rot_frame = []
for b in bodies:

View File

@ -81,7 +81,8 @@ def get_marker_positions(motion_data, model, in_degrees=True, marker_list=[]):
else:
value = motion_data_pd.loc[n,coord]
model.getCoordinateSet().get(coord).setValue(state,value, enforceContraints=False)
model.assemble(state)
# model.assemble(state)
model.realizePosition(state) # much faster (IK already done, no need to compute it again)
# get marker positions
marker_positions += [np.array([marker_set.get(mk_name).findLocationInFrame(state, model.getGround()).to_numpy() for mk_name in marker_set_names]).flatten()]
marker_positions_pd = pd.DataFrame(marker_positions, columns=marker_set_names_xyz)