PDA

View Full Version : Gimbal Locking


jedijrmax
03-01-2004, 06:18 AM
Hey guys,


I basically would like someone to explain gimbal locking to me... not just in basic concept but how it works in Maya.

I've done countless searches about Gimbal locking, and not too much comes up but I've found out and understand that it is when two axis are on the same plane. Although I might not have just worded that right, either way, I do understand what it is. I understand...decently... the idea of rotation order and the fact that the problem exists because maya uses eular angles..etc...

However, those descriptions really doesn't help me understand how that comes into play in Maya....

Under the rotation tools, you can move things locally, globally, or 'gimbal'.... and when you use gimbal, it's just plain weird... assuming because it uses the rotation order, and so therefore if you just rotate in the 'y axis' then that's what makes the rotation rings not stay together?

But gimbal locking seems to be a problem that people would encounter by animating using the global or local rotations and still having a problem with gimbal. I've tried to move a piece of geometry globally, and then clicked on the gimbal rotation 'method?' in the rotation options box, and indeed, the rings start to get offset from each other. But apparently.. so then what gimbal locking is, is that when i'm animating using global or local, and then under gimbal, all of my rotations have someone gotten two axis perfectly aligned? But then that is weird, because all you'd have to do is just slightly rotate the global rotation again and then the gimbal axis would move a little bit, and therefore not be perfectly lined up?

Also, I'll be in global mode under the rotations, and rotate everything just fine, but then if under that object, I go into the channel box, select rotate 'y', and mmb drag, it moves it as it if is in gimbal.... meaning the other axis don't follow like it does in global mode.... can anybody explain this too?

I really do hope that someone who has a definite understanding of this can take the time to help me. I've really run out of places that go into how gimbal locking and regular rotations seem to work in maya. And being as I believe I am running into problems in my animation with it, and would like to take everything here into account while rigging future characters, any information or directions to point me in would be truly appreciated.

Thanks in advance.

~jeff

jedijrmax
03-01-2004, 06:32 AM
Just to let everyone know also, I have done a search on this site, and did find information, however I'm still not able to understand all of the details yet.

kiaran
03-01-2004, 07:47 AM
Personally, I've never run into any gimbal lock problems in any of my rigs or animations. That being said, I would still like to hear more about how one can run into this problem so that it can be avoided.

dwalden74
03-01-2004, 08:19 AM
Much has been posted about this in the past, and I think I addressed most of your questions in past threads. Anyway, yes, gimbal lock is when 2 axises line up, and as a result you find yourself unable to rotate in one axis (because it´s not there any more).

I think one of the main misunderstandings that people have is this: rotation "mode" in Maya - believe it or not, this does not really exist. There´s only one mode - "gimbal "mode - which represents the true rotations of your object according to its rotation order. The other "modes" - "global" and "local" - are simply visual helpers that Maya offers to assist you in rotating the object (which becomes difficult to do when you´re in a gimbal lock situtation). Global and local "mode" have nothing at all to do with the true euler values of the object´s rotations. Read this paragraph again if you´re still confused!

Sometimes local or global "mode" can help you when you´re nearing a gimbal lock situation. The problem with this however, is that you have no way of knowing exactly what rotational values will be produced when you use these modes. You just have to try it, then when you´re happy with the movement, look at your curves to see if there is any flipping (values jumping 180 degrees within 1 or so frames). This is usually how I deal with gimbal lock while animating. If I find situation wherein it is extremely difficult to produce good rotation values using this method, then I´ll simply zero out everything and try to find a better rotational approach from scratch. Remember, gimbal lock occurs because of rotation order; as a result, there are different roational values that will produce the same worldspace orientation.

Jeff, you are correct in taking the time to understand this. This is an important issue, no, a fundamental one, that requires attention and understanding if it is to be dealt with in an efficient way. Ask again if something is not clear.



Personally, I've never run into any gimbal lock problems in any of my rigs or animations.

Kiaran-
Post one of your rigs and I´ll show you a gimbal lock situation. Gimbal lock can occur every time one object has 3 degrees of rotational freedom.

jedijrmax
03-07-2004, 04:29 AM
Hey, I'm sorry for taking so long to respond to this.

I greatly appreciate the time and energy you spent posting... I hope you can read this response of mine.


As for understanding gimbal lock, I do......kinda but i'm still not clear on many things. Your explanation of how global and local rotations methods don't 'really' exist... helped me understand that part very much........ but although I still do have many things unclear, I think that this is perhaps the most difficult to understand.... How do you actually make this occur? and when you say the 2 axis line up... like... does that mean when they are within a degree or so of each other... 'essentially lining up' or does something happen that makes the axis mathetmatically PERFECTLY line up?


Thank you so much.

dwalden74
03-07-2004, 10:38 AM
How do you actually make this occur?

You mean, how do you make a gimbal lock situation occur (ie, when 2 axis´ line up)? OK, create a standard nurbsSphere- it should have a default rotation order of xyz. Now, go into the rotation tool, and set the mode to "gimbal". Drag the y axis about 90 degrees in either direction. See how the x axis is moving with it, and now aligning with the z axis? You can no longer rotate on the x - it´s gone the way of the dodo. The only way you could now effectively rotate in the original "x" would be to go into local or global mode, and drag the x axis. But see what happens to the rotate attrs when you do this? Maya is now adjusting all 3 axis to output a proper euler value that matches this orientation. This becomes tedious to adjust when you´re tweaking curves in the graphEditor, because you have to adjust more than one axis to get the orientation that you want.

kiaran
03-08-2004, 06:26 AM
I followed your instuctions on how to get something into a gimbal lock situation. I have to say that this appears to be a null issue. Rotating in 'Gimbal' mode appears to be the ONLY way of getting into a gimbal lock situation. Perhaps this is not true but it's the only way I've ever done it.
So instead of worrying about this why don't we all agree to just not touch the 'gimbal mode' in maya? I've done alot of animating / rigging and I've never had a problem with my trusty 'local' rotation mode.

Maybe I'm oversimplifying, but I doubt it.

macaroniKazoo
03-08-2004, 07:01 AM
i think you're missing the point kiaran. gimbal mode is how rotations are achieved. local mode, and world mode are just illusions. they're just ways to make gimbal lock harder to see. It doesn't make it go away.

when euler rotations are done, they are performed in a certain order - hence the rotation order attribute. now, and this has nothing to do with maya, but instead with the logic of doing 3 dimensional rotations, gimbal lock happens all the time with euler rotations.

if you believe that you're not having gimbal problems, then one of two things is happening:

a) you don't know what to look for, or
b) you don't animate very much :)

c) ok, a third option is, you're animating using quats for your rotation interp

i know a lot of the guys around here don't know what gimbal lock is either, but most of the time, they just set heaps of keys to get around the problem. the easiest way to see it happen, is to have a character with its root controller set to xyz rot order, turn him 90 degrees to the left (so hes facing down the x-axis), and try to animate him lean to the side...

now gimbal is a problem of varying degrees. it doesn't just suddenly appear, it gradually comes about. you notice it as maya interpolating objects in weird ways between two rotations. the closer you are to gimbal lock, the weirder the interpolation.

so its not the gimbal mode that causes gimbal lock. if it were as simple as avoiding gimbal mode, i expect alias would have left it out all together.

anyway, I hope I'm not being rude or anything, but gimbal is a fact of life animating with eulers. there is no way around it, only remedies, and pain relief. the problem will always be there. having said that, if it hasn't been a problem for you, then more power to ya. :)

kiaran
03-08-2004, 07:45 AM
I think understand what you're getting at MacaroniKazoo. You are saying that gimbal lock isn't something that just suddenly 'happens' and starts screwing with your rotations. Rather, it sort of occurs over time and becomes a problem after a while.

I admit that most of my animations are less that four seconds between cuts, and I always start with a fresh zero-ed out rig for each scene. Maybe this is why I haven't experienced this problem?

the easiest way to see it happen, is to have a character with its root controller set to xyz rot order, turn him 90 degrees to the left (so hes facing down the x-axis), and try to animate him lean to the side...

I can't seem to replicate this problem. I don't use quaternion interpolation either. :shrug:

I'm just going to say thanks to you guys for explaining gimbal lock to me and keep an eye out for it in the future.

CaptainSam
08-10-2004, 09:16 PM
Ooooh, gimbal lock, my favourite subject

Imagine that the x y and z orientation axes were three nurbCurves in Maya, one named X, one named Y and one named Z. Z is the parent of Y and Y is the parent of X

When you rotate X, nothing at all happens, because it is the child of Y

When you rotate Y, Z stays where it is and X follows, since Y is the middle of the hierarchy

When you rotate Z, Y and X follow, as they're the children of Z.


This is the way Euler rotations work. In order to achieve any orientation, using Euler, Maya rotates one axis at a time - i.e. first rotate 30 degrees in X, then 20 degrees in Y and finally 55 degrees in Z

Rotation order decides the order in which the axes are rotated. The example above is with XYZ rotation order. I usually find it practical to use the parenting analogy when deciding on what rotation order to use (the last axis in the rotationOrder being the top parent). No matter which rotationOrder you select, the first axis, for example Z if the order is ZYX, will be the one that gimbal locks, and the last one, X will be the one that has the two other axes following when you rotate it.

As has been explained already, the gimbal rotation mode in Maya is the only one that gives you a proper one to one relationship between what the XYZ rotation axes are actually doing and how the axes appear on the rotate manipulator.

The same goes for local mode with translations, the other modes are only there as parts of the user interface. No matter if you translate something with the translate manipulator set to object, along rotation axis or world, Maya treats the result internally, in the channelBox and the graphEditor as what you get with the local mode.

When you rotate using the world or local modes, Maya is actually rotating like crazy on all three axes at once in order to achieve the orientation you are asking for. This works fine as long as youre not animating the object, BUT, and thats a really big but, once you try to animate any rotations created with local or world, you will indeed get exactly the orientations you wanted on your keyframes (which can be impossible once youve gimbal locked), but the interpolation will be wrong. Even if you try to change the orientation of the object just a little bit, Maya may make it spin around 180 degrees between the keyframes, as it is changing the X Y Z values around to reach the next key.

Create a cylinder, set rotation mode to local and then animate the cylinder by rotating it 90 degrees along one axis, keyframe and step a few frames forward, rotate another axis 90 degrees, keyframe, and so on. You'll pretty soon be able to see what Im talking about once you play back the animation.

Also, notice that when you rotate in gimbal mode, only one axis has its values changed in the channelBox, whereas with local and world, all three axes change simultaneously.


OK, this brings us on to the next subject: quaternions. Quaternions is a different way of desribing rotations mathematically. It has one big advantage: It doesnt gimbal lock, and another equally big one: It doesnt make sense.

Basically, quaternions use four axes to describe the orientation of an object, X, Y, Z and W. The problem is that while this makes perfectly sense mathematically, it doesnt make much sense to an animator trying to edit functionCurves, as there is no direct correspondence between each function curve and the axes on the rotation wheel. If you try to move the X curve a little bit, the object may move equal amounts in X and Y, or a little bit in Z and the rest in X, and so on. So you can pretty much forget about editing your animation using curves if you animate with quatenions. Still, you dont gimbal lock, ewhich for me is more than enough reason to prefer quaternions.

Theres a whole lot more to be said about quaternions, but it isnt really useful anyway in a Maya forum, as Alias' implementation of them are absolutely one hundred percent useless - in fact one of the most pathetic failures in the history of Maya. There is no control for ease in and out on the keys, and unless you set interpolation to linear, the whole thing usually just spins around like crazy. How Alias has managed to get away with this without anyone complaining is beyond me.

Theres also a lot more to be said about the differences between quaternions and Euler when it comes to rigging, but I gotta get back to work. Maya finally got quaternion orientConstraints in Maya 5 (about bloody time) but still lacks quaternion drivenKeys, which pretty much makes it impossible to use the orientation of an IK chain, (the upper arm bone for example) to drive anything.




Fun fact: quaternion is written with a lower case q, whereas Euler is written with a capital E. Why? Because quaternion is simply a mathematical concept, whereas Euler rotations are named after the Belgian 18th century mathematician Louis Euler, who defined the concept

Damn it, this turned out way too long. I really need to get back to work now

SuperApe
08-11-2004, 05:26 PM
If I may, (first post), the quick way to expose yourself to gimbal lock is to rotate an object 90 degree on one axis, and 90 degrees on another. Two rotational axis will line up and act upon the object in the same way; leaving one 'local" rotational axis out (that's the Lock part of Gimbal Lock).
Previous posts have already explained that the CG industry has developed ways to hide most Gimbal Lock occurances or allow an alternative rotaional tool (such as Maya does).

Octagon
08-11-2004, 06:08 PM
with it, and would like to take everything here into account while rigging future characters, any information or directions to point me in would be truly appreciated.



You should check out Jason Schleifers DVD from Alias "Intergrating creatures into a production pipeline". I think he gives a rather good explanation of why gimbal locking happens and how to prevent it (for the most).
What are your problems exactly? To make the best out of a bad situation (bad meaning the fact that for extreme rotations on ALL axes gimbal lock WILL happen) I do the following:
1) check that your rotation orders are correct for your joints and your controls. They have to match of course and you have to test/judge what axes are going to be rotated the most and adjust your rotate order accordingly. For example for a root joint the default xyz order means that your skeleton is going into gimbal mode when you rotate it on y by 90 degress (!). This is because xyz means, z rotates first, then y, then x. If you rotate on y you will lose the correct orientation of z axis, the x axis will still be working correctly because it will be evaluated after the y axis. So to cut a long story short: put your at least used rotation axis on your joint and control to the lower end of the rotation, meaning if z isn´t going to rotate or not as much (below 70-90 degrees) choose the rotation order to zxy if y is your most important axis or zyx if x is most important. Notice that Mayas notation of rotation order is the other way round: xyz in the AE means, z rotates first, then y, then x. It´s critical to remember this!
2) Include extra controls in your rig for critical controls such as the wrist or shoulder that can be unhidden by an animator using an attribute on your regular control. This controls should be parented above your controls and just serve as another object to rotate if your regular controls gimbals out.
3) dont worry too much about gimbal issues. I´ve completed quite a few animation where i´ve run into gimbal troubles. What gimbal means after all, is that you are going to get value on 2 or 3 axes even if you are just rotating on one (visually). This is bad for editing animation of course, but it still works.

Hope this helps.
-matthias

strarup
08-11-2004, 07:21 PM
Hi,


here is a page with a good explanation of Gimbal Lock... What is Gimbal Lock and why does it occur? (http://www.anticz.com/eularqua.htm)... :)

an here an example of how you e.g. can deal with it... Forward and Inverse Kinematics for Arm Skeletons with Gimble Lock Controls in Maya (http://www.jawa9000.com/technical/fk-ik-arm/fk-ik-arm.htm) by Brian J. Immel...

besides the DVD by Jason Schleifer, that Matthias mentions, gives a really good explanations as well... :)

regards

Alex

kiaran
08-12-2004, 01:32 AM
Create a cylinder, set rotation mode to local and then animate the cylinder by rotating it 90 degrees along one axis, keyframe and step a few frames forward, rotate another axis 90 degrees, keyframe, and so on. You'll pretty soon be able to see what Im talking about once you play back the animation.
www.kiaran.net/gimbalTest.mb (http://www.kiaran.net/gimbalTest.mb)

I think that's what you described. I was unable to re-create the gimbol lock problems. If I've done something wrong, would it be possible to re-do and post an example scene file with this cylinder example?

I've purchased a couple 3d math books and I'll be getting into the rotation chapters soon. Maybe then I'll understand this better. Thanks :)

macaroniKazoo
08-12-2004, 01:36 AM
dude, from frame 160 onwards, you've got gimbal lock in that file... check out your gimbal rotation mode... you've got no x-axis. for such a simple example tho, you're not really getting any problems, but usually character controls don't rotate in such simple ways do they... ;)

skull_leader
08-30-2004, 11:30 AM
Let me get this straight... so in MAYA... for example...
If I used x the most, then y the second most and z the least, I should set the rotation to zyx.
If I used z the most, then x the second most and y the least, I should set the rotation to yxz.

... etc. Is this the right idea? Thanks guys.

Funny that the person in the site http://www.anticz.com/eularqua.htm said that...

"2. If your rotating down two axis, change the order of axis to correspond with the first and last axis i.e... if your rotating down the X and Y axis, change the order of axis to X,Z,Y "

Shouldn't it be, change the order of axis to correspond with the first and second axis so that if you are rotating down the X and Y axis, change the order to ZYX (meaning x rotates first, then y, then z). Shouldn't it be like this?

Octagon
08-30-2004, 02:39 PM
Shouldn't it be, change the order of axis to correspond with the first and second axis so that if you are rotating down the X and Y axis, change the order to ZYX (meaning x rotates first, then y, then z). Shouldn't it be like this? As you point out correctly, (I´m repeating it here, because it cannot be repeated enough) , the way the rotation order is handled and displayed in Maya e.g. in the attribute editor is kind of reversed, at least from an animators point of view: "xyz" means, z is evaluated first, then y, then x.

For the case you are referring to, rotating on two axes only I´m not even sure you need to set a specific rotation order at all. The way I understand euler you cannot reach a gimbal lock (meaning loose an axis of rotation that needs to be compensated by the other two axes) with just rotating on two axes. Any rotation order would do for the "rotate on two axes" scenario. Still, I like to set my rotationOrders like you described, even for two axes joints ( Most important rotation evaluated first, then second important, least important is evalled last).

So, I wouldn't know why the second axis has to be evaluated last as the guy points out in his article. But I'd be glad to be corrected wrong :)

-m

greenSloth
08-30-2004, 05:33 PM
first, thank you all for this topic.
but I still got one question here, say, I use Maya default "XYZ" rotation order.
when Gimbal Lock occurs, X and Z axis are overlapped.
However, I still can use middle mouse button to set keys and drag both of the X and Z axis
in Channel Box.
and I playback my animation, everything seems fine.

I wonder if the weird thing will only happen in complicated animation curves.

regards,
greenSloth

skull_leader
08-31-2004, 11:25 AM
Thanks for the info Octagon. This clears things up for me a bit more... for now... until another person confuses me again. :P

Thanks again... this has been a very informative thread!

Octagon
08-31-2004, 03:25 PM
first, thank you all for this topic.
but I still got one question here, say, I use Maya default "XYZ" rotation order.
when Gimbal Lock occurs, X and Z axis are overlapped.
However, I still can use middle mouse button to set keys and drag both of the X and Z axis
in Channel Box.
and I playback my animation, everything seems fine.

I wonder if the weird thing will only happen in complicated animation curves.

greenSloth, I assume you're referring to keying the rotation channels by saying keying using middle mouse button, right?
Well, you can always key anything (sorry, couldn't resist ;) ) And you can always use the channels to do your rotations, of course. But the point is, when you are in gimbal lock and two axes overlap you will need to manipulate two axes to rotate your object about the one axis that you lost. This might not really bother you since Maya does this in the background. But when editing in the graph editor I can be really frustrating to have to tweak at least two or often three curves in order to tweak one rotation.

Hope this clears it up a bit.

-m

greenSloth
09-01-2004, 02:09 AM
ah, finally, I understand what Gimbal Lock is.

thank you very much, Octagon!

anthonymcgrath
12-20-2004, 04:15 PM
wow - this is a good thread. The rotation order was something I knew about but never really bothered to change till yday animating a character. I switched the rotation order (cant remember what to and only had to tweak a few keyframes and I lost all my head flipping problems!! It pretty much what everyone is saying - figure out your most used rotation, then the second and the 3rd then set your rotation so it reads in the opposite order!! so if you want z, then x, then y you want to switch it to YXZ (I think). anyhow - it works a treat and now my character does what I want with it woohoooo!!! made my xmas that has as I've been one of those 'keyframe it till it works!' chaps!

ant

macaroniKazoo
12-21-2004, 05:14 AM
by the way i've written a script to change the rotation order of objects that have already been animated without buggering up the animation. its called zooChangeRoo (http://www.macaronikazoo.com/mel/download/zooChangeRoo.zip). its a pretty simple script really. to use it, select all the objects you want to change the rotation order of, and just type the commandL

zooChangeRoo zxy;

or put whatever rotation order you want at the end, and bingo. it goes through all your keys and makes sure the orientation doesn't change.

Iotrez
12-21-2004, 12:26 PM
Thanks for the cool script macaroniKazoo.

BTW do any of you guys recommend changing the rotation order of a character control during the course of the animation, as I notice that rotation order is an attribute that can be animated.(If you make it so using channel control.)

If the ideal rotation order is determined by the particular movement that a character is going to be doing throughout it's animation, then if the character is going to be doing some pretty crazy stuff like backflips etc, doesn't that mean that the ideal rotation order will change as the character's rotation changes?

Cheers.

macaroniKazoo
12-21-2004, 10:31 PM
you absolutely could animate if you wanted to. but i personally wouldn't reccommend it as a solution to gimbal problems unless you had absolutely exhausted every other solution. the obviously weird thing about doing that is that the rotation order is not a highly visible attribute, and hence you'd have to absolutely make sure you, or whoever was animating, was aware of exactly when the rotation order was changing.

so yes, you can do it, and yes it would work, but i don't expect many people would reccommend it. or so i would have thought. :)

CGTalk Moderation
01-17-2006, 03:00 PM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.