Setting model initial conditions and prescribing muscle activations for forward dynamic simulations
Posted: Thu Feb 27, 2020 11:50 am
Hi all,
I am wanting to 1) give my model initial conditions (positions and velocities) for forward simulations and 2) prescribe constant muscle activations through the duration of the simulations. I am simulating an impact so I am also applying external forces to the model and the simulation durations are in the order of Dt=0.05 s. Everything is ran through the OpenSim 3.3 Matlab API.
1) Initially I was having issues setting the initial conditions to the model through setting the positions and velocities to the model's state then passing these to the ForwardTool. I would check the position and velocity values before the simulation and they were correct but after the simulation was ran the results would show the model starting in the default configuration. Does the ForwardTool reset these values internally?
To work around this, I am now setting the default value of each coordinate to the one I require, saving a new model file, passing the new model file to the ForwardTool and running the simulation. This works (apart from specifying the velocities) but I don't believe is the best way to do it. I have also tried using setStatesFileName() and specifying the file with my initial conditions (positions and velocities) but I can't get this to work for me. I am assuming specifying the initial states filename would be preferable.
2) To prescribe the activations I am not passing a file to the setControlsFileName() of the ForwardTool the specified values then undergo activation dynamic procedures which isn't what I want. For the model's muscles to be at the required activation from the start of the simulation and through its duration (i.e. i_muscle_activation=0.3 for Dt=0.05) I am setting the muscles' minimum activation to the value I require with setMinimumActivation(). This works for having the muscles' activation constant throughout the simulation at the value I want as long as the value in >=0. If the specified value is <0 the activation starts at 0.05 and then begins to drop.
Is there a more preferable way of prescribing the muscle activations without applying controls/excitations and going through activation dynamics in the Forward Tool? I understand I could set the model in the required configuration, apply muscle and external forces then integrate forward in time for each time step but I was wondering if I could set the simulation up in a way that everything is handled by the ForwardTool.
If you have any comments on how I can improve the above method I would greatly appreciate them! Apologies for lengthy post - wanted to describe the problem in sufficient detail.
Thank you!
Pavlos
I am wanting to 1) give my model initial conditions (positions and velocities) for forward simulations and 2) prescribe constant muscle activations through the duration of the simulations. I am simulating an impact so I am also applying external forces to the model and the simulation durations are in the order of Dt=0.05 s. Everything is ran through the OpenSim 3.3 Matlab API.
1) Initially I was having issues setting the initial conditions to the model through setting the positions and velocities to the model's state then passing these to the ForwardTool. I would check the position and velocity values before the simulation and they were correct but after the simulation was ran the results would show the model starting in the default configuration. Does the ForwardTool reset these values internally?
To work around this, I am now setting the default value of each coordinate to the one I require, saving a new model file, passing the new model file to the ForwardTool and running the simulation. This works (apart from specifying the velocities) but I don't believe is the best way to do it. I have also tried using setStatesFileName() and specifying the file with my initial conditions (positions and velocities) but I can't get this to work for me. I am assuming specifying the initial states filename would be preferable.
2) To prescribe the activations I am not passing a file to the setControlsFileName() of the ForwardTool the specified values then undergo activation dynamic procedures which isn't what I want. For the model's muscles to be at the required activation from the start of the simulation and through its duration (i.e. i_muscle_activation=0.3 for Dt=0.05) I am setting the muscles' minimum activation to the value I require with setMinimumActivation(). This works for having the muscles' activation constant throughout the simulation at the value I want as long as the value in >=0. If the specified value is <0 the activation starts at 0.05 and then begins to drop.
Is there a more preferable way of prescribing the muscle activations without applying controls/excitations and going through activation dynamics in the Forward Tool? I understand I could set the model in the required configuration, apply muscle and external forces then integrate forward in time for each time step but I was wondering if I could set the simulation up in a way that everything is handled by the ForwardTool.
If you have any comments on how I can improve the above method I would greatly appreciate them! Apologies for lengthy post - wanted to describe the problem in sufficient detail.
Thank you!
Pavlos