jsantell / THREE.IK

inverse kinematics for three.js
https://jsantell.github.io/THREE.IK
MIT License
455 stars 54 forks source link

Iterations and simulated annealing #4

Open jsantell opened 6 years ago

jsantell commented 6 years ago

This article by Jonathan Blow describes a way of finding constraints similarly to the FABRIK paper -- as a valid ellipsoidal area infront of the joint. But since both CCD and FABRIK both are iterative solvers, there could be a point where the local maxima does not reach the target in a chain, however there's still a valid solution if the base joint was rotated on a different axis, for example.

The article covers simulated annealing, or as I understand it, try a second iteration from a different valid base joint rotation and see if it results in an end effector closer to the target than the original base joint rotation. I can try and post an example sketch if this needs further explanation.

zalo commented 6 years ago

Alternatively, you can try to anneal through the non-convexities by doing a few iterations with the rotation-limits disabled (allowing joints to rotate past their limits). Then, a few more iterations with the limits on. Some of the joints may "pop" to the other side of their limit, thus "teleporting" the chain to a configuration that can easily converge on the target. (This will not always work, but it's free)

jsantell commented 6 years ago

I believe my earlier attempt did not disable the rotation limits, I wonder if that'd be the key to prevent the non-stop "popping", but it was a quick and crude attempt that probably needed to prioritize the current pose if the "popped"/different pose did not result in a significantly closer solution