x


ConfigurableJoint - angular positions (rotation) problem

I'm using ConfigurableJoints for a mechanical rig. Some some joints have 1 DOF (angular X), some joints have 2 DOF (angular X,Y) and some joints have 3 DOF (angular X,Y,Z). I switch between velocity mode and position mode - velocity mode when I'm moving the joint, and position mode when the joint is at the desired position. This works as should.

Problem is when rotating the joint beyond 90 degrees around any axis. I "measure" the actual position (rotation) of the joint by using:

(Quaternion.Inverse(_ConnectedRigidBody.rotation) * _JointRigidBody.rotation).eulerAngles

If I for example rotate the X-axis of the joint, the measured x-value is fine up to 90 degrees. When the rotation > 90, the x-value starts to decrease, ie 89, 88, 87, 86 ... Same goes for rotations down to -90 degress - they are fine. But below -90 degrees, the measured value changes direction, ie -89, -88, -87, -86 ...

I have tried different ways of measuring the angle. I have re-inported my meshes with corrected pivot points, I have made children to the rotating parts trying to measure their rotation ... and I always get the same result - measured rotation values are fine up to 90 degrees (or down to -90) and then they change "direction".

I'm guessing there is something about the conversion from Quaternion to euler angles that is the problem, but I know too little about such conversions to figure out how to fix this.

Any idea of what I'm missing out on? Any advice is appreciated.

Thanx in advance ///JmD

more ▼

asked Sep 20 '11 at 02:14 PM

JmD gravatar image

JmD
1 3 4 4

The problem is that there are several ways to build a facing out of x,y,z Euler angles, using different combinations of numbers. For example (which may be what you are getting) an x-rotation of 95 degrees can be made by rotating 85 degrees in x, then 180 around y.

If you actually need the angle on, say, the x-axis the common trick is to project to the yz-plane first.

Sep 20 '11 at 03:29 PM Owen Reynolds

Thank you for the tip, Owen! I guess that principle works for the other axes as well, ie, for the y-angle, project to the xz-plane first and for the z-angle project to the xy-plane first?

///JmD

Sep 20 '11 at 04:58 PM JmD

The thing to be careful about is that the project-to-plane trick gives the world angle, only good for the direction of the "first" spin. Usually when you have x,y,z angles, you're thinking of a spin on the global y, but then the second spin on the new, local z, then on the even newer local x.

So, for combining it won't work (I think,) but for checking against maximums should be fine.

Sep 22 '11 at 12:34 AM Owen Reynolds
(comments are locked)
10|3000 characters needed characters left

0 answers: sort newest
Be the first one to answer this question
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Topics:

x2155
x437
x134
x63

asked: Sep 20 '11 at 02:14 PM

Seen: 962 times

Last Updated: Nov 14 '11 at 06:23 PM