Improvements to Inverse Kinematics

Hello everyone,

after several long months I finally managed to create well working IK algorithm for blender importer that uses Jacobian matrix with pseudoinversion :smile: The previous one (Cyclic Coordinate Descent) did not always give the results that were close enough to what was in the Blender.

I know it took me really a long time, but I never was good at algebra so reading all the stuff about the algorithm was actually a pain. I also tried several different solutions (triangulation, fabric) but they were not good enough.
The models I used, behaved a lot better that when imported with the previous algorithm. Although sometimes the bones ‘jump’ too rapidly so it will need further polishing, even after I commit it.

The algorithm prepares the Jacobian matrix and computes its pseudoinverse using the Singular Value Decomposition of the matrix. The only problem is that I used the Efficient Java Matrix Library to compute the SVD of the Jacobian.

And here is my question. Shall I include the EJML in the blender’s plugin dependencies or should I rather implement the SVD on my own. The EJML library is on Apache Licence. I know we can use it, but I am not sure If I can copy-paste the needed piece of code to JME sources.

Please let me know what you think about it.

8 Likes

Any suggestions ?

Well if you look at the Apache Licence v2 http://www.apache.org/licenses/LICENSE-2.0 (the distribution chapter) it seems that you can copy the code under some conditions.
I’m not completely fond of adding another dependency to the engine but it’s pointless to reimplement a working code inside of the core…
@normen, @Momoko_Fan, @pspeed what do you think?

How big is the library? It’s only needed by the blender importer and not the core, right?

The library contains 5 files that have 533KB in total. But I guess I won’t be needing all the files so in the end it will be less.

And yes, it is only needed for Blender importer so the gradle dependency would be defined only there.

Apache 2 and BSD are supposed to be compatible so in this case I think it should be fine to just include it as a gradle dependency.

OK, I’ll just need a little help with gradle because I am totally unfamiliar with it :stuck_out_tongue_winking_eye:

I added these lines to the dependency block in blender’s build.gradle
compile (‘org.ejml:core:0.27’)
compile (‘org.ejml:dense64:0.27’)
compile (‘org.ejml:simple:0.27’)

When I run the dist task on gradle (after I disable mergeJavadoc task) I get all the libs with the EJML included so it looks fine for me. I am just not sure if I need to do anything more.

And by the way, when I run mergeJavadoc task I get these errors:

    :mergedJavadocC:\Users\Marcin\git\jmonkeyengine\jme3-core\src\main\java\com\jme3\scene\shape\StripBox.java:133: error: unmappable character for encoding Cp1250
     * The cloned box will have �_clone’ appended to it’s name, but all other
                                  ^
C:\Users\Marcin\git\jmonkeyengine\jme3-core\src\main\java\com\jme3\util\MemoryUtils.java:67: error: unmappable character for encoding Cp1250
            Logger.getLogger(MemoryUtils.class.getName()).log(Level.SEVERE, "Error retrieving �MemoryUsed’", ex);
                                                                                                ^
C:\Users\Marcin\git\jmonkeyengine\jme3-core\src\main\java\com\jme3\util\MemoryUtils.java:81: error: unmappable character for encoding Cp1250
            Logger.getLogger(MemoryUtils.class.getName()).log(Level.SEVERE, "Error retrieving �Count’", ex);
                                                                                                ^
C:\Users\Marcin\git\jmonkeyengine\jme3-core\src\main\java\com\jme3\util\MemoryUtils.java:96: error: unmappable character for encoding Cp1250
            Logger.getLogger(MemoryUtils.class.getName()).log(Level.SEVERE, "Error retrieving �TotalCapacity’", ex);
                                                                                                ^
C:\Users\Marcin\git\jmonkeyengine\jme3-desktop\src\main\java\jme3tools\navigation\Coordinate.java:117: error: unmappable character for encoding Cp1250
     * 38â?ž31.64'N for lat, and 28â?ž19.12'W for long
          ^
C:\Users\Marcin\git\jmonkeyengine\jme3-desktop\src\main\java\jme3tools\navigation\Coordinate.java:117: error: unmappable character for encoding Cp1250
     * 38â?ž31.64'N for lat, and 28â?ž19.12'W for long
                                    ^

6 errors
:mergedJavadoc FAILED

It happens on Windows7 64 bit. Anyone run into this ?

about dependencies, it should be enough
about javadoc issue, I guess it’s due to default encoding on windows, try to update the mergedJavadoc task in root build.gradle with :

    options.overview = file("javadoc-overview.html")
    options.charSet = 'UTF-8'

OK I have just commited the code. It should work but is not yet optimised so I will further work on it :smile:

As for the error unfortunately this did not help :frowning:

sorry charset is for output (html) in our case it should be encoding

    options.overview = file("javadoc-overview.html")
    options.encoding = 'UTF-8'
1 Like

OK, I will check this out next week, because I am on holidays at the moment :smile:
And I have only linux here :wink: