Generic6DofConstraint - strange behaviour of y-axis - jitter

evoboxagent
Posts: 3
Joined: Wed May 18, 2011 11:37 pm

Generic6DofConstraint - strange behaviour of y-axis - jitter

Post by evoboxagent »

Hi everybody,

I've been trying to get a hang on Bullet/jBullet for a few weeks now. My project works almost the way I'd like it to work except for one thing - a special form of a Generic6DofConstraint. Because C is not possible in this project, I have to use jBullet (the most recent version).
In my project robots are simulated which have the ability to set a desired angle for a certain constraint between themself and another BoxShape. The same idea is described here: http://bulletphysics.org/Bullet/phpBB3/ ... f=9&t=4857.
All translational axes are locked (lolimit is -SIMD_EPSILON, hilimit is +SIMD_EPSILON for each translational axis). All but one rotational axes are locked to epsilon, too. The last axis may be changed by the robot (using the RotationalLimitMotor for this axis), which means that it is locked to angle-epsilon/angle+epsilon. This works perfectly nice for the x- and z-axis. No problems, no jitter, nice and smooth.
As soon as I try using this for the y-axis there seems to be a wrong impulse/torque which makes the whole construct jump and jitter like crazy. The code is EXACTLY the same for all three axes, no differences there. That's why I tried looking at the Generic6DofConstraint.java file. There I found the following part:

Code: Select all

        // in euler angle mode we do not actually constrain the angular velocity
        // along the axes axis[0] and axis[2] (although we do use axis[1]) :
        //
        //    to get            constrain w2-w1 along        ...not
        //    ------            ---------------------        ------
        //    d(angle[0])/dt = 0    ax[1] x ax[2]            ax[0]
        //    d(angle[1])/dt = 0    ax[1]
        //    d(angle[2])/dt = 0    ax[0] x ax[1]            ax[2]
        //
        // constraining w2-w1 along an axis 'a' means that a'*(w2-w1)=0.
        // to prove the result for angle[0], write the expression for angle[0] from
        // GetInfo1 then take the derivative. to prove this for angle[2] it is
        // easier to take the euler rate expression for d(angle[2])/dt with respect
        // to the components of w and set that to 0.
I must admit that I can't understand that part completely. What I do understand though is that for axis 1 there is something different - exactly the axis which causes problems for me. Right now, I'm using a workaround by only allowing the x- and z-axis to be changed but that isn't really satisfying.

I've already changed the parameters mentioned in the above thread. Also, I tried adjusting the RotationalLimitMotor parameters - no luck there either. As I said, the problem ONLY occurs with y-axis. Of course all angles are inside -90 and +90 degrees (tried -45 to 45, too).

Does anybody have an idea for a solution? Is it a bug? Has this been fixed in newer bullet versions or is it still an issue?

Thank you all in advance
User avatar
majestik666
Posts: 66
Joined: Tue Mar 02, 2010 6:13 am

Re: Generic6DofConstraint - strange behaviour of y-axis - ji

Post by majestik666 »

the generic6Dof constraint is limited to -180 180 on the y axis
as far as i can remember, if you want rotation only on the y axis
you can either rotate the constraint or use a hinge constraint.

F
evoboxagent
Posts: 3
Joined: Wed May 18, 2011 11:37 pm

Re: Generic6DofConstraint - strange behaviour of y-axis - ji

Post by evoboxagent »

Hi,

thank you for your reply!

That does not seem to be the reason for the jitter. Even if I stay in very small angles (-20 +20) the problem occurs.

I've turned the constraint but that is rather unpleasent to do. :mrgreen: I'm trying to automatically generate new robots by using a random input. And therefore it'd be great if the y-axis worked, too.
User avatar
projectileman
Posts: 109
Joined: Thu Dec 14, 2006 4:27 pm
Location: Colombia

Re: Generic6DofConstraint - strange behaviour of y-axis - ji

Post by projectileman »

Due of its mathematical nature, Generic6DofConstraint has a "Gimbal Lock" issue at Y axis:
http://en.wikipedia.org/wiki/Gimbal_lock

So both Y axis as Z should be limited to a reduced angular range of freedom: [-PI/2 to PI/2]. Only the X axis could be configured with "free" rotation (as a Hinge). So if you want to get a more wide angular range for Y axis, consider changing the orientation of the constraint, aligning the X axis for pointing to the Y direction by accessing the method getFrameOffsetA: http://bulletphysics.com/Bullet/BulletF ... b03a65c219
evoboxagent
Posts: 3
Joined: Wed May 18, 2011 11:37 pm

Re: Generic6DofConstraint - strange behaviour of y-axis - ji

Post by evoboxagent »

Hi,

thanks for your answer! Transforming/rotating the constraint seems to be one possibility. Perhaps I didn't explain myself properly. I don't (!) want any axis to be free as in loose. When saying free I meant "the axis which the robot is allowed to change". And the change is supposed to be induced by setting the angles to new values.

For example from:

lower: 0,0,45-e
upper: 0,0,45+e

to:

lower: 0,0,48-e
upper: 0,0,48+e

in the RotationalLimitMotor for the angular limits. The translatiomal limits are all fixed to -e/+e where e is epsilon.