Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feature Request] a general option in Moco solver to minimize the coordinates accelerations #3899

Open
mrrezaie opened this issue Sep 3, 2024 · 5 comments
Assignees

Comments

@mrrezaie
Copy link
Contributor

mrrezaie commented Sep 3, 2024

Hi, I was trying to implement what this article suggested about minimizing the derivatives of states. Since both coordinates value and speed are provided as state in OpenSim, I ended up with the accelerations. So, I added a MocoOutputGoal with a very small weight for every coordinate's acceleration output. For instance:

accel = osim.MocoOutputGoal('minimize_hip_flexion_r_accel', 1e-7)
accel.setExponent(2)
accel.setOutputPath('/jointset/hip_r/hip_flexion_r|acceleration')
problem.addGoal(accel)

I had to do this for every coordinate. The problem converged successfully; although it increased the convergence time, the solution states (coordinate values and speeds) were well-smoothed. I'm not expert, perhaps minimizing the derivatives of coordinate speeds instead of using MocoOutputGoal for coordinate accelerations could make it more efficient computationally. But the smoothness I see in the coordinate values and speeds in my markers+GRF tracking simulation is definitely worth it.

It would be great if you could make this option available for MocoCasADiSolver. For instance, a bool option (set_minimize_coordinates_accelerations) and its weight (set_coordinates_accelerations_weight).

Thank you in advance.

@nickbianco
Copy link
Member

Hi @mrrezaie, if using implicit multibody dynamics, the options minimize_implicit_multibody_accelerations and implicit_multibody_accelerations_weight exist. A more general feature would need to be implemented in a new MocoGoal.

@mrrezaie
Copy link
Contributor Author

mrrezaie commented Sep 3, 2024

Hi @nickbianco, thanks for your response. Actually I had tested set_minimize_implicit_multibody_accelerations, but the IPOPT output (e.g., objective, constraint violation, number of iterations, and overall NLP error) was exactly identical compared to before. My simulation was muscle driven marker + GRF tracking (I think the default multibody_dynamics_mode in MocoTrack is set to implicit). It also didn't appear in the solution headers. Could you please explain this option a little bit? What does it do exactly? Thank you.

@nickbianco nickbianco self-assigned this Sep 3, 2024
@nickbianco
Copy link
Member

@mrrezaie, the default multibody dynamics mode in MocoTrack is "explicit". In "explicit" mode, those settings will not have any effect.

@mrrezaie
Copy link
Contributor Author

mrrezaie commented Sep 4, 2024

Deeply sorry, my bad.

@nickbianco
Copy link
Member

No worries @mrrezaie!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants