Inverse Kinematics...implementation

Provide easy-to-use, extensible software for modeling, simulating, controlling, and analyzing the neuromusculoskeletal system.
POST REPLY
User avatar
Anne Schmitz
Posts: 76
Joined: Thu May 31, 2007 7:44 am

Inverse Kinematics...implementation

Post by Anne Schmitz » Thu Dec 13, 2012 3:03 pm

Hello,

I am comparing hip kinematics calculated from the inverse kinematics tool of OpenSim and using custom C code with the SIMM dynamics pipeline. Both are solving the same optimization problem (sum of weighted errors squared). However, I get slightly different results. I think this may be in how the optimization problem is solved. How does OpenSim numerically solve the minimization problem?

Thanks,

Anne Schmitz

User avatar
Ajay Seth
Posts: 136
Joined: Thu Mar 15, 2007 10:39 am

Re: Inverse Kinematics...implementation

Post by Ajay Seth » Tue Dec 18, 2012 2:27 pm

You are likely correct that our optimization algorithms are not the same. In OpenSim/Simbody the inverse kinematics solver uses different optimization algorithms depending on the problem. If the solver has an unconstrained problem with unbounded coordinates it uses the LBFGS [1] method. If the problem is unconstrained but bounded (most common case, where the coordinate is limited to predefined range) then the solver uses the LBFGSB method [2]. Finally, if there are kinematic constraints that must be enforced, those constraints are included and the system is solved using an Interior Point algorithm, IPOPT [3].

It would be interesting to know whether or not the marker errors are the same. Have you compared marker errors?

[1] D. Liu and J. Nocedal, "On the limited memory BFGS method for large scale optimization", Mathematical Programming B 45 (1989) 503-528.

[2] R. H. Byrd, P. Lu, J. Nocedal and C. Zhu, "A limited memory algorithm for bound constrained optimization'', SIAM J. Scientific Computing 16 (1995), no. 5, pp. 1190--1208.

[3] Wächter and L. T. Biegler, "On the Implementation of a Primal-Dual Interior Point Filter Line Search Algorithm for Large-Scale Nonlinear Programming", Mathematical Programming 106(1), pp. 25-57, 2006

User avatar
Ton van den Bogert
Posts: 164
Joined: Thu Apr 27, 2006 11:37 am

Re: Inverse Kinematics...implementation

Post by Ton van den Bogert » Tue Dec 18, 2012 3:25 pm

As far as I know, SIMM's inverse kinematic solver uses a Levenberg-Marquardt algorithm (http://www.netlib.org/minpack/lmdif.f) so it could solve fast enough for real time applications.

If you use the exact same model, the same marker placements, and the same least-squares criterion in Opensim, without constraints or bounds, its LBFGS solver should find exactly the same answer as SIMM's LM solver. It may be take more (or fewer) iterations because the Hessian matrix is estimated differently. The Hessian matrix does not affect the answer, it only affects the speed of convergence of the optimization algorithm. A small difference between results could still happen if the minimum is shallow (i.e. the fit is poor) and/or the stopping criterion is not very strict.

When you have active constraints or bounds, a different model, different marker set, or different weighting of markers in the least-squares function, it would not be surprising to get different results between SIMM and Opensim. If the results are still similar enough, this would reassure you that the results are not sensitive to the model setup and to the details of the inverse kinematic analysis.

Ton van den Bogert

User avatar
iman nabiyouni
Posts: 6
Joined: Wed Dec 10, 2014 11:46 am

Re: Inverse Kinematics...implementation

Post by iman nabiyouni » Sat Apr 09, 2016 8:34 pm

aseth wrote:You are likely correct that our optimization algorithms are not the same. In OpenSim/Simbody the inverse kinematics solver uses different optimization algorithms depending on the problem. If the solver has an unconstrained problem with unbounded coordinates it uses the LBFGS [1] method. If the problem is unconstrained but bounded (most common case, where the coordinate is limited to predefined range) then the solver uses the LBFGSB method [2]. Finally, if there are kinematic constraints that must be enforced, those constraints are included and the system is solved using an Interior Point algorithm, IPOPT [3].

It would be interesting to know whether or not the marker errors are the same. Have you compared marker errors?

[1] D. Liu and J. Nocedal, "On the limited memory BFGS method for large scale optimization", Mathematical Programming B 45 (1989) 503-528.

[2] R. H. Byrd, P. Lu, J. Nocedal and C. Zhu, "A limited memory algorithm for bound constrained optimization'', SIAM J. Scientific Computing 16 (1995), no. 5, pp. 1190--1208.

[3] Wächter and L. T. Biegler, "On the Implementation of a Primal-Dual Interior Point Filter Line Search Algorithm for Large-Scale Nonlinear Programming", Mathematical Programming 106(1), pp. 25-57, 2006

Hello,
I could not use LBFGS, PARAMOPT, IMDIF and LAPACK optimizers in CMC part of Opensim 3.1,
The software made an error like this one: "CMCTool: ERROR- Unrecognized optimizer algorithm: 'LBFGS'"
If there is any necessary dll files for these optimizers please help me to find them.
Thanks

User avatar
Antoine Falisse
Posts: 428
Joined: Wed Jan 07, 2015 2:21 am

Re: Inverse Kinematics...implementation

Post by Antoine Falisse » Thu Sep 07, 2017 7:05 am

Hi,

I would like to know which optimizer is used when solving inverse kinematics in OpenSim 3.3. I found this post on the forum but I would like to make sure it is still up to date.

"In OpenSim/Simbody the inverse kinematics solver uses different optimization algorithms depending on the problem. If the solver has an unconstrained problem with unbounded coordinates it uses the LBFGS [1] method. If the problem is unconstrained but bounded (most common case, where the coordinate is limited to predefined range) then the solver uses the LBFGSB method [2]. Finally, if there are kinematic constraints that must be enforced, those constraints are included and the system is solved using an Interior Point algorithm, IPOPT [3]."

If I am right, this means that when using the gait2392 model (predefined ranges for coordinates) and without specifying any kinematic constraints then LBFGSB is selected.

Many thanks!

User avatar
Christopher Dembia
Posts: 506
Joined: Fri Oct 12, 2012 4:09 pm

Re: Inverse Kinematics...implementation

Post by Christopher Dembia » Thu Sep 07, 2017 10:07 am

Here's a comment in the Simbody source code for the Assembler that might be helpful:
// Optimizer will choose LBFGS for unconstrained (or just bounds-constrained)
// problems, InteriorPoint for constrained problems.
https://github.com/simbody/simbody/blob ... r.cpp#L754

It still might be the case that LBFGSB is used if there are bounds constraints, and that the comment was using "LBFGS" to mean either "LBFGS" or "LBFGSB." (see https://github.com/simbody/simbody/blob ... r.cpp#L133).

User avatar
Antoine Falisse
Posts: 428
Joined: Wed Jan 07, 2015 2:21 am

Re: Inverse Kinematics...implementation

Post by Antoine Falisse » Fri Sep 08, 2017 6:21 am

Thanks Chris!

User avatar
Radhakrishnan Vignesh
Posts: 104
Joined: Tue Jun 01, 2021 8:09 am

Re: Inverse Kinematics...implementation

Post by Radhakrishnan Vignesh » Sun Jun 25, 2023 2:47 pm

Hi,

I am sorry to reopen this issue but I am looking into residual errors and would like to understand the optimisation algortihms further. Specifically the comments made by Ajay: "It would be interesting to know whether or not the marker errors are the same. Have you compared marker errors?"

1) Has anyone analysed whether marker errors remain the same?
2) If I use a free joint with bounds compared to a ball joint, I am assuming the algorithm shifts from LBFGSB to IPOPT. Does this mean comparing residual errors between the two should not be done? How does the algorithm used change marker residuals?
3) Building on the second question, how would the marker residuals in Moco track vary?

Thanks
Vignesh

POST REPLY