FABRIK Inverse Kinematics


#1

Hi all,

In bits of free time over the last couple of months, I’ve been working on implementing the FABRIK inverse kinematics solver in Panda 3D, with the end goal of producing something sufficiently general that anyone can drop it into a project without much bother. For those of you not familiar with FABRIK, in short it’s a heuristic IK solver, that uses conformal geometric algebra in an forward and backward (up and down kinematic chains) iterative fashion. Check out the paper here, and the website here if you’re interested.

Some of the advantages:

  • It’s fast, even when constrained.
  • It doesn’t suffer from the same singularity issues as many other solvers.
  • Can be used with multiple joined chains with multiple effectors.
  • Produces visually smooth movements without oscillations and discontinuities.

Thus far I’ve implemented the basic unconstrained algorithm, and tested it with a single chain for both a reachable and unreachable target, and it seems to perform well. I made a short teaser video, which you can watch here. It’ll look weird at the moment, since the solver uses joint positions rather than orientations, and I’ve not yet implemented anything to re-orient the joints after they’ve moved. That’ll be done next, together with methods to constrain the joints (the other reason why it looks weird). After that I’ll be tying it together to work for multiple kinematic chains/effectors, and creating some helper features so that, for example, you can set targets on an actor’s joints, and the kinematic chains are automatically built, linked, and solvers started. Basically it should be as easy as specifying where you want a limb to try to go. After that I’ll look at using it to do things like automatic grounding of feet, automatically turning eyes/head/torso to look at something. Things like that. I may also have a go at adding a solver for muscle bulging based on angles between limbs.

Anyway I’ll be trying to keep this thread up to date with progress as it happens, and hopefully pretty soon I’ll put this up on Github or the like so that people can play with it if they wish, and give some feedback. Big thanks to rdb, and also to Thaumaturge for getting me this far, and of course thanks to the folks who came up with the solver.

Update 5/10/2014: I’ve gotten joint reorientation working well using a quaternion method, since lookAt() doesn’t work properly if bones aren’t Y-axis aligned. I’m working on constraints at the moment, but it’s taking a little time since I’ve not really used quaternions much until now, so I’m having to do some reading before I can understand the maths required to implement the constraints (it’s not straightforward HPR clamping). I’ve also quickly tested the solver using one of the sample models that come with Panda, and it works great apart from a strange direction offset (the limb is pointing/moving in the opposite direction), so I’ve got to investigate why that’s happening in case I’ve made a mistake that my usual test model was hiding. Onwards and upwards.


Using a rigged ManuelbastioniLAB character in Panda 3D
#2

Hi there, do you have any code examples up of how far you got with fabric ? I and a friend would like to work on this same problem and are wondering if you have anything publicly available. thank you


#3

Yeah, sadly IIRC a mixture of quaternion trouble (weak maths skills) plus an ME flareup put this one on hold indefinitely. I’ve dug out what I believe was the last version I have. I couldn’t attach it here for some reason (maybe file size). If you PM me an email, I’ll shoot it over that way. Not sure what state it’s in, and can’t speak to code quality/idiomatic approaches, but it should at least give you a partially working implementation to reference. If you understand how to use quaternions in Panda, you can probably fix what’s there pretty quickly. I think I was also looking at integrating it into a “fake” looping one-frame animation (so you could blend IK with existing animations). There may or may not be code for that in there, but if you spot any, that’s what it’s for :slight_smile: . Unfortunately the model I used for testing wasn’t archived with the files, but I pulled what could very well be the same model from another source. Fingers crossed that’ll let you get the test scripts running without too much fuss, so you can see where I left things.

I still remember a fair bit about the original FABRIK papers I read (there are more than one, and I remember some giving nuggets of info not present in others), so feel free to PM me if you have questions, and I’ll try my best to answer them. Good luck.