[<< | Prev | Index | Next | >>]

Saturday, March 08, 2014

Tentacle Math



This is an email I just wrote the discussion group for Simon Funk's AI Challenge, which will probably only be of interest to people who make robots with tentacles, or who like math that's so abstract it's missing.

So, I spent a couple weeks writing a symbolic math package in order to run the euler-lagrange equations on an N-ary pendulum in a maximally general way (no trig, N is unspecified, etc) just in order to understand how the system might be qualitatively factored by an adaptive system. Should have been quicker just to use google, but I couldn't find examples that didn't expand into cos and sin with known N and create a huge, specific mess where I just wanted to see the structure of the solution in simplest terms...

Well worth the trouble even if the final solution was obvious (I was hoping for an obvious solution -- it felt like it shouldn't be as hard as google implied). It's obvious enough I'll describe it qualitatively rather than giving the math:

First, the easy things we already knew:

The position of the N'th joint (or end of the last segment) is obviously just the sum of the offsets of all joints up to N. The offset of the i'th joint is some non-linear function of the i'th joint angle in absolute terms. (Cos, sin, times radius; but this can be learned easily through observation.)

Likewise, the velocity of the N'th joint is just the sum of the contributing velocities of the joints up to N, where each of those is the joint velocity times some non-linear function of the i'th joint angle in absolute terms...

So here comes the obvious part that's much too hard to figure out if you mistakenly try to look up the solution first:

The acceleration of the N'th joint is *also* just the sum of the contributing accelerations of the joints up to N, where a direct component contributes much as velocity does, based on the accelleration of the i'th joint angle, but there is also another component which is the i'th joint velocity squared times some non- linear function of the absolute i'th joint angle... (this would be the second derivative of the offset function, but again we can learn this empirically). That much isn't non-obvious, but how it can be used most simply is something I haven't seen mentioned:

The euler-lagrange approach implicitly sets the joint forces all to zero, which provides a system of equations that lets us solve for the joint accelerations, which (I believe) involves a matrix inversion at each timestep, and this gives us the equations of motion of a slack N-ary pendulum in gravity.

However:

If you *know* the joint accelerations, it is relatively easy, instead of using the euler-lagrange approach, to directly compute the joint forces that is causing those accelerations. Interestingly, that is the more natural, forward computation and does not require the matrix inverse. It also happens to be the equation we care about, because if we can compute forces from accelerations, then we can just plug in the accelerations we *want* and make them so.

In other words, strangely, it's considerably easier to compute the forces needed to cause a desired path (even though you are having to account for all of the strange dynamics of the system) than it is to predict what the system would do if you, say, didn't apply any force at all. So it is (much) easier to make the system do what you want than to predict what it would do on its own.

Unless I got the math wrong. But I think it's right.

And this is true of an arm of any number of segments, and I think the resulting equations are O(N) and highly factorable by simple addition.

If correct, this applies just as well to the human body, of course. It means that it's very easy for your brain to model how to make your limbs move the way you want them to--without ever modeling (the strangely harder problem of) how they would move un-controlled.

If you were allowed to control velocity directly, this would be no surprise, but given that we're only talking about controlling forces at the joints, which have to offset all of the weird dynamics of the system, I'm kinda surprised.

I'll stop repeating myself now.

-Simon



[<< | Prev | Index | Next | >>]


Simon Funk / simonfunk@gmail.com