Dear all,
How to edit or change muscle excitations in MATLAB and then use it for forward dynamics simulation?
Thanks.
Edit muscle excitations using MATLAB
Re: Edit muscle excitations using MATLAB
Hi, William-
I assume you are using OpenSim 3.3?
If so, you will have to edit the controls file that the Forward Tool uses to set the actuator controls.
the doxygen documenation for ControlLinear is here;
https://simtk.org/api_docs/opensim/api_ ... c45beb6534
I assume you are using OpenSim 3.3?
If so, you will have to edit the controls file that the Forward Tool uses to set the actuator controls.
Code: Select all
import org.opensim.modeling.*
% read the controls file into memory
cset = ControlSet('ResultsCMC/subject01_walk1_controls.xml')
% get the number of controls
sz = cset.getSize()
for i = 0 : sz - 1
csi = cset.get(0)
% safedowncast to the concrete classs — ControlLinear in this case
csiL = ControlLinear.safeDownCast(csi)
controlName = csi.getName()
% Get the control value at time 0
csiL.getControlValue(0.0)
% Set the control value at time 0
csiL.setControlValue(0.0, 0.9)
end
https://simtk.org/api_docs/opensim/api_ ... c45beb6534
Re: Edit muscle excitations using MATLAB
Thanks James!
Using this code i am able to edit control values but how can I save these new values to a new control(.xml) file ? Because forward tool takes excitations through control files. Or is there any other way to give controls to forward tool through MATLAB?
Using this code i am able to edit control values but how can I save these new values to a new control(.xml) file ? Because forward tool takes excitations through control files. Or is there any other way to give controls to forward tool through MATLAB?
Re: Edit muscle excitations using MATLAB
Once you have made your edits, then you print the ControlSet back to file. In this case, your last line of code would be something like;
Code: Select all
% Write edited controls to file
cset.print('ResultsCMC/subject01_walk1_controls_EDITED.xml')