Custom IK solver

   6933   9   0
User Avatar
Member
51 posts
Joined: Oct. 2006
Offline
I'm trying to implement a custom IK solver, CHOPs seems like the natural place for such things and this is where I started. I've got an almost working CHOP prototype, but the whole setup is rather cumbersome.
The scene I'm posting here appears to be a much simpler solution. However this seems like a somewhat unorthodox way of doing things, so my question is: what options exist for implementing such a system in Houdini? Also is there something obviously wrong with my approach of doing calculations in SOPs?

About the scene:
I'm a programmer, not an artist, so modeling is rough and weighting is obviously defective.
There are no bones at all in this scene - the joints are just Nulls with cregions.
Paths to chain nodes are hard-wired in the Python code for simplicity.
The schematic picture below is supposed to illustrate the setup, but it's quite simple - I have a Python operator in SOPs that calculates the chain angles based on the control Nulls' transforms, the results are stored in geometry attributes and then read into appropriate joints via simple expressions.

Attachments:
SOP_IK_scheme.jpg (89.3 KB)
SOP_IK_leg.jpg (117.9 KB)
SOP_IK.zip (22.9 KB)

User Avatar
Staff
3455 posts
Joined: July 2005
Offline
cool…
I'll try to check this out when I get home…

can I ask why you're implementing a custom solver?
Michael Goldfarb | www.odforce.net
Training Lead
SideFX
www.sidefx.com
User Avatar
Member
12474 posts
Joined: July 2005
Offline
Interesting

Just in case you didn't know about it, there are such things are “Python Objects”. These execute python for their transform information and so there is a chance these might be an alternative approach for you.

An example: http://www.sidefx.com/docs/houdini11.0/hom/cookbook/xforms_from_disk/ [sidefx.com]

Good luck,
Jason


. I guess the docs could use a bona fide “Define a new Object type using Python” next to the others on the HOM page.
Jason Iversen, Technology Supervisor & FX Pipeline/R+D Lead @ Weta FX
also, http://www.odforce.net [www.odforce.net]
User Avatar
Member
192 posts
Joined: Nov. 2008
Offline
hi axebeak. this is cool, i dig the python approach. i'm not a programmer, but doing f.k. in vex has worked really well for doing simple skeletons for crowds/flocking so i thought perhaps doing an i.k. in vex would be useful aswell.

i think i might have messed up the math or something because i'm not getting as precise a result as i would sort of expect, but i.k. in vex seems to work. here's a first test with just using attribute transfer to do a ‘rigid bind’ of sorts. this is just a first try in a few minutes, so i think it can be cleaner and nicer and less hardcoded (i want to keep trying stuff with this).

super curious to see what you come up with…

Attachments:
ik.jpg (27.2 KB)
bb_sopik_v001.hipnc (259.1 KB)

User Avatar
Member
1390 posts
Joined: July 2005
Offline
It would be great to have vex based rigging (specially with render time skinning).
User Avatar
Member
51 posts
Joined: Oct. 2006
Offline
arctor
can I ask why you're implementing a custom solver?
I want to export unbaked IK animations for real-time use (in a game).
So I must replicate the IK solution exactly at run-time and this seems like the easiest (if not, indeed, the only) way to achieve this.
The scene shows just the simplest two-bone chain, but I need around a dosen of such specialized solvers - mostly short chains for limbs, reverse-foot leg is the most obvious example.

The are numerous reasons why I want unbaked IK, some are very specific to my real-time system… But, in general, it makes certain things easier to code, faster and more predictable - things like character limbs interacting with the environment, adjusting legs to slopes, aiming with a weapon etc.

Now, I guess, this can also be used to build fully equivalent rigs and animate in different packages. I tried something like this several years ago between LW and XSI, albeit with a limited success.
User Avatar
Member
51 posts
Joined: Oct. 2006
Offline
jason_iversen
Just in case you didn't know about it, there are such things are “Python Objects”.
Ah yes, I tried this but ran into some problems… This was some time ago though, can't remember the exact details right now, but something to do with forcing it to recook properly due to chain dependencies.
Still, the problems were most likely due to my own error so this must be investigated further.
User Avatar
Member
51 posts
Joined: Oct. 2006
Offline
Brian, this is a very interesting scene.
I see you have a pre-transform on the “hip” node, not saying that it's actually causing any problems, it seems like it's properly accounted for (in solve_ik, via origin expressions), it's just that have some prejudice against pre-transforms. Anyway, am going to take a closer look at the scene.
I did some initial tests with VOP SOP before turning to Python - essentially the same as in the scene I've posted but coded in Vex. Though, in contrast to your scene, my Vex was mostly a single inline with a chunk of code in it…

BTW, I guess the solution can be calculated in COPs as well (again, using either Vex or Python) - store solution in pixels, use pic/picni to read the values. Perhaps not really practical, but seems amusing nonetheless.
User Avatar
Member
192 posts
Joined: Nov. 2008
Offline
SYmek
It would be great to have vex based rigging (specially with render time skinning).

totally. even just having a cvex ‘sop procedural’ would be amazing…
User Avatar
Member
51 posts
Joined: Oct. 2006
Offline
Here is a small update.
I started working on some animations for my project, I'm using these specialized Python solvers, and it looks like it's working well - no obvious problems so far.
Here is an example scene, using two instances of the solver this time and animated.
I have a capture pose set at frame 600, that's because I'm using deform regions for weighting - have yet to figure out how to use _capture_ regions properly… not sure if this makes any difference, e.g. making things a bit slower (BTW, if animation playback seems too slow, enable frame-skip in the Global Animation Options dialog).

Animation curves use cubic interpolation - the only reason for this is that I want to make a small example, demonstrating how to export and evaluate Houdini keyframes and cubic() is the only non-trivial interpolation I have figured out thus far.

Attachments:
SOP_IK_anim.jpg (56.8 KB)
SOP_IK_anim_example.zip (47.3 KB)

  • Quick Links