Inverse Kinematics


#21

Hi! I really want to work on this but college is stopping me. :confused:

I do require IK in my game project though, so this will eventually be finished!


#22

Glad to hear it.
Actually, I have the same situation with my code stuff, but without college.


#23

“Yes teacher I have a question”

Progress has been slow, but I’m letting you know I haven’t stopped working on this yet. I’ve moved the solver code to a separate library which can be found here: https://github.com/thecomet93/ik

I’m currently working on calculating the correct segment angles. The current issue is that I’m calculating global angles for each node and not taking into account previous rotations.


#24

Today I finally fixed calculating correct angles when comparing the solved tree to the original tree. As you can see in the following image, the solver is fine with multiple targets on arbitrary trees. The blue segments you see is the original tree (before solving) and the red segments show the solved tree.

The next step now is to support target angles as well as target positions. It would allow rotating the hand correctly.


#25

So excited to use this! :smiley:

Is it possible to write a grounder with those effectors? e.g: youtube.com/watch?v=9MiZiaJorws6

As promised, here are weighted effectors, which will be useful in providing a smooth transition for grounders. You can specify how much influence an effector should have on the result, ranging from 0.0 to 1.0. I thought about this for a day before the incredibly simple solution struck me: I don’t need to write any elaborate tree interpolation algorithms, I just lerp the effector between original position and target position using its weight and solve for the resulting target position.


#26

Solver now works with animated characters:

Current TODO:
/*
* - Actually implement tolerance.
* - Target angle in addition to target position -> use weighted angles
* approach
* - Nlerp weighted effectors using total chain length + root node as axis
* of rotation (so arm moves in a circle, for example)

    • Fix rotation issue with shared sub-base nodes -> rotations need to be
  • averaged.
    • Add support for manually updating initial pose.
    • Pole targets?
    • Support for “stretchiness” with min/max lengths.
    • Support for “stiffness” factor, describes how well a bone rotates.
    • Apply bullet constraints to joints.
    • Script bindings.
    • Optimise.
    • Profile.
      */

Picking-up items
#27

Looks really good. For inspiration I would look at Final IK: http://www.root-motion.com/final-ik.html.


#28

I’ll take a look!

The following shows transitioning with and without nlerp when changing the effector weight. This feature makes transitioning look more natural when the original and solved trees are far apart


#29

We could even do FK/IK animation in the editor :slight_smile:


#30

That is so amazing! :heart_eyes:


#31

The cat animation looks really good inside the editor.
Thank you for sharing it!


#32

Hi, all!

@TheComet, could you please provide compiling instructions?

Thanks!


#33

@slapin I have made the proper Urho3D build system changes and am maintaining them in a fork. The easiest thing you can do is clone my fork. For linux, the process is as follows:

$ git clone git://github.com/thecomet93/Urho3D.git
$ git checkout InverseKinematics
# ik library is not yet part of Urho3D, so you have to clone it 
# into Source/ThirdParty
$ git clone git://github.com/thecomet93/ik.git Source/ThirdParty
# build as normal
$ mkdir build && cd build
$ cmake ..
$ make

If you have issues, feel free to contact me.


#34

Thanks, this works! Will try to figure out how to use from code.


#35

I’d be happy to know what you think! I’m sorry it’s not that well documented yet, that’s still on my TODO list.

You have to create an IKSolver component and attach it to the model you want to solve for. Then you create IKEffector components and attach them to the bones you want to control. That should be enough to get you started.

These components are also available in the editor under Components->Inverse Kinematics


#36

When you plan to merge it into Urho? This looks well written to me.


#37

A small feature request - is it possible to do some special-case IK as part of library?
These should be very fast to compute and speed things up a lot.


#38

I’m reluctant to say how much more time I need. Currently it feels like I should be done in about 2 more weeks. I’m still working on an acceptable algorithm for calculating target rotations. That’s the last major feature I’ll be adding. Then I’ll write script bindings and write documentation, and fix some known bugs in the library.


#39

Thanks for your hard work! Just do in small steps and that will eventually be done.


#40

Target rotations are implemented and can optionally be enabled:

It’s possible to change the rotation weight and decay parameters on a per-effector basis (not shown). And, like everything else, the rotations are propagated correctly over arbitrary trees.

My current TODO list is:

 * TODO
 *  - Actually implement tolerance.
 *  - Fix rotation issue with shared sub-base nodes -> rotations need to be
 *    averaged.
 *  - Add support for manually updating initial pose.
 *  - Script bindings.
 *  - Optimise.
 *  - Profile.
 *  - Documentation.
 *
 * FUTURE
 *  - Support for "stretchiness" with min/max lengths.
 *  - Support for "stiffness" factor, describes how well a bone rotates.
 *  - Apply bullet constraints to joints.