Page 1 of 1

Update Muscle Path

Posted: Tue Jul 18, 2023 4:18 am
by ebulygin
Hi, this question is related to my question in viewtopic.php?f=91&t=16752

I am updating muscle paths in a model.

The problem is that stating

"state = model.initSystem()"

before "loc=model.getMuscles().get(muscle).getGeometryPath().getPathPointSet().get(point).getLocation(state)",

does not allow for an automatic update of the model.

What do I need to do to update the default model state so that I can export the updated model to a .osim file?

Re: Update Muscle Path

Posted: Thu Jul 20, 2023 8:43 am
by nicos1993
Hello Ekaterina!

I just did some exploring and maybe this works (Matlab):
import org.opensim.modeling.*
mod = Model('gait2392_simbody.osim');
state = mod.initSystem();
musc0 = mod.getMuscles().get(0)
gp0=musc0.getGeometryPath();
cp0 = gp0.getCurrentPath(state);
cp0_0 = cp0.get(0); %0th pathpoint, returns abstract pathpoint
pathpoint0 = PathPoint.safeDownCast(cp0_0); % need to downcast to concrete class to edit
pathpoint0.set_location(Vec3(1,2,3)); % 1,2,3 the new locations of the path points
state = mod.initSystem(); % Reinitialize state for changes to take effect
mod.print('test.osim'); % Print to model file to see if changes worked

Hope that works!

Thanks,

Nicos

Re: Update Muscle Path

Posted: Fri Jul 21, 2023 9:59 pm
by ebulygin
Thank you -- I will give it a go!