I've had some trials/tribulations recently in generating "multi-subject" simulations of walking, using the ScaleTool in OpenSim to alter a generic model's height and mass for Moco simulations, and thought I would share them. Might save some time and trouble for others.
Suppose you have a good simulation result for one model, then want to scale the model and use the old unscaled model's simulation result as the initial guess for the new scaled model. Will this work well? My experience has been that it will not work well if you substantially change the height of the model. What this seems to do, at least with the typical OpenSim model definitions where the pelvis is jointed to the ground, is it produces an initial guess where the model's feet are either a considerable distance above or below the ground. This generates large violations of the system dynamics constraints, which IPOPT seems to struggle with minimizing.
How to fix this? What's worked reasonably well for me is to scale the model in the OpenSim GUI, which places the scaled model visually right next to the original model, then adjust the height of the scaled model's pelvis coordinate until its feet are just sitting on the ground like the original model, then add that pelvis height adjustment to the initial guess to be used with the scaled model. Here's an example Matlab code where I added 6 cm of pelvis height:
Code: Select all
% Load a previous solution and adjust its vertical pelvis coordinate
prevSolution = MocoTrajectory('previous_solution.sto');
prevPelvisTy = prevSolution.getStateMat('/jointset/groundPelvis/pelvis_ty/value');
prevPelvisTy = prevPelvisTy+0.06;
prevSolution.setState('/jointset/groundPelvis/pelvis_ty/value',prevPelvisTy);
solver.setGuess(prevSolution);
I've also had better results (more consistent convergence) by running the initial simulation with a new scaled model on a coarse grid, e.g. 10 intervals per step instead of 50. This coarse grid will usually converge on a good result then I can use it as the initial guess on a finer grid. Often for the coarse grid I'll have to relax the convergence criteria a little.
Lastly, I discovered recently that the ScaleTool was not adjusting the values for optimal fiber length and tendon slack length if using DGF muscles, prior to the latest OpenSim 4.4 release. So if you are using ScaleTool and DGF muscles and expecting those values to be scaled as they normally are with that tool, make sure you're using 4.4, or if not using 4.4, define the muscles as some other type and convert them to DGF type after scaling.
Ross