Edit existing model in Matlab
Posted: Thu Jun 11, 2020 7:16 am
Hello,
I am working on a project using a full body model in 4.1. Instead of rewriting the model in Matlab, I was hoping to load the existing model and then make a couple adjustments to fit my project. I was wondering how you can edit the joints in Matlab. I tried this:
But I get this error that says that I can't access this joint when I try to put the updated version back in:
Error using ottobock_v3 (line 45)
Java exception occurred:
java.lang.RuntimeException: Component 'ground_pelvis' already owned by tree
to which 'jointset' belongs. Clone the component to adopt a fresh copy.
Thrown at Component.cpp:1224 in markAsPropertySubcomponent().
at
org.opensim.modeling.opensimSimulationJNI.Model_private_addJoint(Native
Method)
at org.opensim.modeling.Model.private_addJoint(Model.java:976)
at org.opensim.modeling.Model.addJoint(Model.java:110)
Has anyone seen this before? Is there a way around this?
Or a place with more documentation of usable commands for the Matlab/OpenSim interface? Mostly, I've been piecing it together based on methodsview(), examples from the resources, answers on this forum, and the common scripting page. There seem to be duplicates and updates and I was just wondering what the best place to start looking for options might be.
Thanks,
EAD
I am working on a project using a full body model in 4.1. Instead of rewriting the model in Matlab, I was hoping to load the existing model and then make a couple adjustments to fit my project. I was wondering how you can edit the joints in Matlab. I tried this:
Code: Select all
modelFilePath = 'E:\22_BuildWalkerInMatlab';
modelFile = 'FullBodyModel_SimpleArms_Hamner2010_Markers_v4_0.osim'; % _v2_0 opened and saved in 4.1 to get v4
model = Model(fullfile(modelFilePath, modelFile));
% put human on floor
groundPelvis = model.getJointSet().get('ground_pelvis');
% groundPelvis = model.getJointSet();
Human_TX = groundPelvis.upd_coordinates(3); % OpenSim starts counting at 0, so translation starts at 3
Human_TX.setRange([-10, 10]);
Human_TX.setName('Human_TX');
Human_TX.setDefaultValue(0.5);
Human_TY = groundPelvis.upd_coordinates(4);
Human_TY.setRange([-5, 5]);
Human_TY.setName('Human_TY');
Human_TY.setDefaultValue(1);
Human_TZ = groundPelvis.upd_coordinates(5);
Human_TZ.setRange([-5, 5]);
Human_TZ.setName('Human_TZ');
Human_TZ.setDefaultValue(-0.25);
allJoints = model.getJointSet();
allJoints.cloneAndAppend(groundPelvis);
allJoints.connectToModel(model);
model.addJoint(groundPelvis); % add joint back to model
Error using ottobock_v3 (line 45)
Java exception occurred:
java.lang.RuntimeException: Component 'ground_pelvis' already owned by tree
to which 'jointset' belongs. Clone the component to adopt a fresh copy.
Thrown at Component.cpp:1224 in markAsPropertySubcomponent().
at
org.opensim.modeling.opensimSimulationJNI.Model_private_addJoint(Native
Method)
at org.opensim.modeling.Model.private_addJoint(Model.java:976)
at org.opensim.modeling.Model.addJoint(Model.java:110)
Has anyone seen this before? Is there a way around this?
Or a place with more documentation of usable commands for the Matlab/OpenSim interface? Mostly, I've been piecing it together based on methodsview(), examples from the resources, answers on this forum, and the common scripting page. There seem to be duplicates and updates and I was just wondering what the best place to start looking for options might be.
Thanks,
EAD