elastic constraint, why ?

gjaegy
Posts: 178
Joined: Fri Apr 18, 2008 2:20 pm

elastic constraint, why ?

Post by gjaegy »

Hi,

I have modeled the case where a tug vehicle pushes an aircraft using a tow bar.

For that, I have created two vehicles (the tug and the aircraft), linked by a cylinder shape and two btUniversalConstraint constraints.

This works pretty well, however the constraint seems to be "elastic", in other words the distance between the aircraft and the tug is not constant: it grows when the tug accelerates, then shorten when the tug brakes, and finally oscilates a while when the tug stops.

Any idea how I can fix that ? Should I use another constraint type ?

Thanks for any input !

Cheers,
Greg

[EDIT]: increasing the mass of the cylinder shapes fixed the issue. This is not very intuitive and doesn't sound logical from a user perspective (I am aware there might be some numerical reason for that - just take this as a feedback).
Dirk Gregorius
Posts: 861
Joined: Sun Jul 03, 2005 4:06 pm
Location: Kirkland, WA

Re: elastic constraint, why ?

Post by Dirk Gregorius »

Another solution is to use a smaller timestep and/or more iterations. This is usually the best way to make joints stiffer. The softness you notice has two reasons:

1) The iterative solver might terminate before the velocity constraints are fully satisfied (e.g. the relative velocities at the joint are not zero)
2) Even with perfectly satisfied velocity constraints you can still get drift due to the discretization of a continuous problem. The main problem are high angular velocities. This is why tweaking inertias usually helps. You can think of the inertia as the resistance of a body against rotation. Less rotation -> better linearization


Cheers,
-Dirk
gjaegy
Posts: 178
Joined: Fri Apr 18, 2008 2:20 pm

Re: elastic constraint, why ?

Post by gjaegy »

Dirk, thanks a lot for your answer.
Another solution is to use a smaller timestep and/or more iterations. This is usually the best way to make joints stiffer. The softness you notice has two reasons:

1) The iterative solver might terminate before the velocity constraints are fully satisfied (e.g. the relative velocities at the joint are not zero)
I have set the number of iterations to 10, so I think this is already a high enough value, am I right ?
My time step is 1/60. Decreasing it will impact performance, but I will try to use a 1/120 one and see if this helps.
2) Even with perfectly satisfied velocity constraints you can still get drift due to the discretization of a continuous problem. The main problem are high angular velocities. This is why tweaking inertias usually helps. You can think of the inertia as the resistance of a body against rotation. Less rotation -> better linearization
Do you mean I should modify the inertia matrix of the cylinder shape ? Or of the vehicles ?
Strangely (not sure I understand the problem completely, I studied inertia matrices some years ago and honestly I don't remember everything ;) this happens also when all bodies are aligned ( straight in a row), so there is no rotation movement... Maybe I misunderstand the problem ?
Dirk Gregorius
Posts: 861
Joined: Sun Jul 03, 2005 4:06 pm
Location: Kirkland, WA

Re: elastic constraint, why ?

Post by Dirk Gregorius »

10 is a *relative* high value. The iterative solver in Bullet is a Projected Gauss-Seidel. The Gauss-Seidel solver is usually very good to find a good guess of the solution within 10 iterations. To find the *exact* solution you need many more iterations. I suggest playing a little bit around. Use e.g. 4 steps at 240 Hz and/or set the iterations count to 128 or 256. I would not go into such an extreme in practise, but it should give you a feeling for Bullet.

There are actually two more things you can try as well. In the solver settings you can try to use the SOR parameter to speed up convergence. The value should be between 1.0 and 2.0. There is also a parameter called m_warmstartingFactor. You can try setting it to 1.0.

You can think of mass as the resistance against translation of a body. In this sense the inertia tensor is basically the resistance against rotation. Less rotation makes the system easier to solve (better linearization). So what you can also try is to artifically scale the inertia tensors of your cylinders. I would try factors between 4-32. This will also help to make your system less stretchy.


Cheers,
-Dirk
gjaegy
Posts: 178
Joined: Fri Apr 18, 2008 2:20 pm

Re: elastic constraint, why ?

Post by gjaegy »

I finally went for the mass increase solution. Scaling the inertia doesn't seem to work (I tried 24x).

thanks a lot for your help !!!