Provide easy-to-use, extensible software for modeling, simulating, controlling, and analyzing the neuromusculoskeletal system.
-
Donatella Simonetti
- Posts: 2
- Joined: Tue Jul 23, 2019 5:16 am
Post
by Donatella Simonetti » Thu Apr 27, 2023 9:52 am
Hello,
I'm trying to scale a generic model 2392 manually but I'm having problems getting to the right solution via Matlab script. Should I use the Model class and the function scale to perform the scaling? Or should I create a ScaleTool? In both cases (see below) I get stuck.
Could you please give me a hint on how to proceed?
Via the Model
Code: Select all
Model2 = Model(generic_model);
Model2.initSystem;
% How do I get the states? How do I define the scaleSet?
Model2.scale(states,scaleSet, true, mass);
Model2.print(output);
Via ScaleTool
Code: Select all
scale_tool = ScaleTool(scale_template);
% How do I connect the ScaleTool to a specific model to scale?
scale_tool.setPathToSubject(unscaled_model);
scale_tool.run();
Tags:
-
Donatella Simonetti
- Posts: 2
- Joined: Tue Jul 23, 2019 5:16 am
Post
by Donatella Simonetti » Fri Apr 28, 2023 12:44 am
Hi Thomas,
thank you for your reply. Now it's working
I will leave here the working Matlab function:
Code: Select all
function manual_scaling(scale_template,unscaled_model,mass, output)
% function to plate IMUs on a Osim model by calling OpenSim functions
import org.opensim.modeling.*
% open generic model
Model1 = Model(unscaled_model);
Model1.initSystem;
% create scale tool object from an exixtent template
scale_tool = ScaleTool(scale_template);
scale_tool.setName('scale_model');
scale_tool.setSubjectMass(mass);
%%% ModelPlacer stuff
scale_tool.getMarkerPlacer().setOutputModelFileName(scale_template); %2 of 2, markers
%%% ModelScaler stuff
scale_tool.getModelScaler().setApply(1)
scale_tool.getModelScaler().setOutputModelFileName(scale_template); %1 of 2, scaling
%%% ModelMaker stuff
scale_tool.getGenericModelMaker().setModelFileName(unscaled_model);
% scaling model
scale_tool.getModelScaler().processModel(Model1, unscaled_model, mass)
% print new model
Model1.print(output)
end