rbdl / rbdl-toolkit

Application for visualizing and working with rbdl models
European Union Public License 1.2
19 stars 11 forks source link

Inconsistent IK between Puppeteer and Toolkit #27

Closed jfslin closed 1 week ago

jfslin commented 3 years ago

The IK produced by Puppeteer and RBDL produce different results. @rvsagar

Puppeteer:

https://user-images.githubusercontent.com/24707634/108750570-2fb0b080-750f-11eb-8808-48666862e4b7.mp4

Toolkit:

https://user-images.githubusercontent.com/24707634/108750357-ed876f00-750e-11eb-8a71-71a8116e910e.mp4

ju6ge commented 3 years ago

This might be down to the parameters used in the IK. In the toolkit settings you are able to adjust the different parameters used when running the IK algorithm.

I do also remember that puppeteer had 3 different implementations of the inverse kinematics algorithm of which only one is used and to use another you hat do recompile the entire application. Also these IK implementation of puppeteer where implemented in the puppeteer source code. This is not the approach that rbdl-toolkit is using, since in my opinion these algorithms should be implemented in rbdl and not the frontend application. So if the differences are not just due to the parameters it might be useful to implement add these other algorithms to rbdl and make the one you want to use select able via the toolkit settings.

jfslin commented 3 years ago

Playing with the parameters got me this:

https://user-images.githubusercontent.com/24707634/108759334-3a247780-751a-11eb-96d2-063d95d74b1d.mp4

I agree with @ju6ge though, these IK routines should probably be ported into rbdl itself instead of toolkit. Is there a reference on how to tune the IK parameters?

@rvsagar, this is with IK lambda at 0.15, IK max step at 200 (default) and IK tol at 1e-8 (default). I'm looking at the underlying code now, I think the main value to adjust is lambda, which you basically tune to avoid singularity of the least square fit. Looking at the puppeteer code, I think the IK code that got ported over is the LevenbergMarquardIK since the other two method tries to automate lambda.

RVSagar commented 3 years ago

Thanks @jfslin, that looks pretty good. I guess the lambda parameter is important to tune for such models, a reference would be nice

jfslin commented 3 years ago

This is the base method, from reading the comments in the code: https://en.wikipedia.org/wiki/Levenberg%E2%80%93Marquardt_algorithm

The actual paper appears to be this one: https://ieeexplore-ieee-org.proxy.lib.uwaterloo.ca/document/5784347 - this paper refers to both a prior method (the standard LM least squares fit with lambda), as well as a newer "auto-lambda" method that is implemented in Puppeteer but doesn't seem to have been migrated over yet.