Moco result inconsistent with the set kinematics
Posted: Thu Aug 05, 2021 10:16 pm
Hi there,
I was trying to use moco to solve the muscle activation of an arm model with 50 muscles.
There were some optimization errors but I can still get the result.
[error] Model unable to assemble: SimTK Exception thrown at Optimizer.h:133:
Value out of range in OptimizerSystem Constructor: expected 1 <= number of parameters <= 2.14748e+09 but number of parameters=0..Model relaxing constraints and trying again.
[error] Model unable to assemble with relaxed constraints: SimTK Exception thrown at Optimizer.h:133:
Value out of range in OptimizerSystem Constructor: expected 1 <= number of parameters <= 2.14748e+09 but number of parameters=0.
When I tried to input the moco solution to the Forward Dynamics tool in opensim, the simulation result was very far-off from the kinematics that I set in the code. I tried to use a simpler model (arm26). But the forward dynamic simulation was still very inconsistent with the motion file that I set.
So I am wondering that if there's anything wrong with the optimizer or they way I'm using it.
Thanks in advance!
I was trying to use moco to solve the muscle activation of an arm model with 50 muscles.
Code: Select all
import opensim as osim
inverse = osim.MocoInverse()
# Construct a ModelProcessor and set it on the tool. The default
# muscles in the model are replaced with optimization-friendly
# DeGrooteFregly2016Muscles, and adjustments are made to the default muscle
# parameters.
modelProcessor = osim.ModelProcessor(r'C:\Users\fxgcy\PycharmProjects\OpenSim Moco\MOBL_ARMS_fixed_41.osim')
modelProcessor.append(osim.ModOpIgnoreTendonCompliance())
modelProcessor.append(osim.ModOpReplaceMusclesWithDeGrooteFregly2016())
# Only valid for DeGrooteFregly2016Muscles.
modelProcessor.append(osim.ModOpIgnorePassiveFiberForcesDGF())
# Only valid for DeGrooteFregly2016Muscles.
modelProcessor.append(osim.ModOpScaleActiveFiberForceCurveWidthDGF(1.5))
modelProcessor.append(osim.ModOpAddReserves(1.0))
inverse.setModel(modelProcessor)
# Construct a TableProcessor of the coordinate data and pass it to the
# inverse tool. TableProcessors can be used in the same way as
# ModelProcessors by appending TableOperators to modify the base table.
# A TableProcessor with no operators, as we have here, simply returns the
# base table.
inverse.setKinematics(osim.TableProcessor(r'C:\Users\fxgcy\PycharmProjects\OpenSim Moco\bicep_curl.sto'))
# Initial time, final time, and mesh interval.
inverse.set_initial_time(0.00)
inverse.set_final_time(6.75)
inverse.set_mesh_interval(0.01)
# By default, Moco gives an error if the kinematics contains extra columns.
# Here, we tell Moco to allow (and ignore) those extra columns.
inverse.set_kinematics_allow_extra_columns(True)
# Solve the problem and write the solution to a Storage file.
solution = inverse.solve()
solution.getMocoSolution().write(r'C:\Users\fxgcy\PycharmProjects\OpenSim Moco\MoBL_ARMS_MocoInverse_solution.sto')
[error] Model unable to assemble: SimTK Exception thrown at Optimizer.h:133:
Value out of range in OptimizerSystem Constructor: expected 1 <= number of parameters <= 2.14748e+09 but number of parameters=0..Model relaxing constraints and trying again.
[error] Model unable to assemble with relaxed constraints: SimTK Exception thrown at Optimizer.h:133:
Value out of range in OptimizerSystem Constructor: expected 1 <= number of parameters <= 2.14748e+09 but number of parameters=0.
When I tried to input the moco solution to the Forward Dynamics tool in opensim, the simulation result was very far-off from the kinematics that I set in the code. I tried to use a simpler model (arm26). But the forward dynamic simulation was still very inconsistent with the motion file that I set.
So I am wondering that if there's anything wrong with the optimizer or they way I'm using it.
Thanks in advance!