keenon / nimblephysics

Nimble: Physics Engine for Biomechanics and Deep Learning
http://www.nimblephysics.org
Other
403 stars 44 forks source link

Improve heuristics for angular dynamics fitting #177

Open nickbianco opened 1 year ago

nickbianco commented 1 year ago

Currently, the angular dynamics fitting step (handled by DynamicsFitter::zeroLinearResidualsAndOptimizeAngular works generally well but can either fail or lead to undesired results in a few specific ways:

  1. The threshold set by avgAngularChangeThreshold may cause the iterative fitter to abort early for subjects/trials that might have converged if using a looser tolerance.
  2. For data with large angular dynamics residuals, the iterative fitter will agressively try to minimize residuals at the expense of mangling the good kinematic trajectory achieved by MarkerFitter.

These issues could be addressed using improved heuristics for the angular dynamics fitting step. The first issue could be handled by ignoring the threshold for a set number of initial iterations and then checking to see if the threshold is violated and re-running with reaction wheels enabled. The second issue could be addressed in a similar fashion: we check if the converged solution deviates from the marker fitting solution based on some percentage increase in marker error and/or change in joint angles, upon which we also re-run with reaction wheels enabled.