sailplane RigidBody wheel - constraint setup

Post Reply
semo
Posts: 6
Joined: Wed Sep 24, 2014 2:23 pm

sailplane RigidBody wheel - constraint setup

Post by semo »

Hi, I'am new here.

We have physical library for simulating classic subsonic aircrafts based on Bullet. It works and flying well :-). Maybe, we will also simulate other vehicles in the future.
Now, I'am trying to add RigidBody wheels connected to main body using constraints. Like here: http://www.bulletphysics.org/Bullet/php ... =17&t=4660.

I'am testing it on sailplane with fixed wheel (fixed means without suspension). It seems to be very difficult to choose and setup right constraint. When flying, wheel moves as inertia acts on it. But when hits the ground, it looks more stable: rotation axis is moslty on right place.
Please, look at the video: https://www.youtube.com/watch?v=SAo7u5jNz7Y.

I have read bullet source code, have tried different constraint types and parameters, searched on internet, ....everything with same result (same as on video :-)).

Implementation info:
- Now it's using btGeneric6DofConstraint with linear and angular limits set to 0 (except angular limit for rotation axis). btHinge2Constraint, btHingeConstraint, btPoint2PointConstraint gaves same results.
- Aircraft Hull weighs ~290 kg, wheel 10 kg (it is too much, but with 1 kg every constraint violates it's limits).
- I have tried different values for "constraint->setOverrideNumSolverIterations".
- Experiments with BT_CONSTRAINT_STOP_CFM and BT_CONSTRAINT_STOP_ERP does not help too.


Of course I know, constraint solver can't be perfectly exact, but behaviour of my wheel (during flight) is strange. Please, is there anybody with any idea? Thank you :-).
Basroil
Posts: 463
Joined: Fri Nov 30, 2012 4:50 am

Re: sailplane RigidBody wheel - constraint setup

Post by Basroil »

Everything looks like it's working as intended, you just need two changes:


1) Increase joint iterations to improve positional stability (also, standard hinge joint would probably work better). Depending on your forces you might have to hit over 200 iterations to get good results (20x higher than default)
2) Add a bit of "friction" in the form of a zero velocity motor (tries to make the wheel go to zero velocity, should stop a good portion of the in axis rotation)
semo
Posts: 6
Joined: Wed Sep 24, 2014 2:23 pm

Re: sailplane RigidBody wheel - constraint setup

Post by semo »

Thank You for the reply and zero-velicity motor tip!

I incereased joint iterations, firstly to 250, then to 1250. Unfortunatelly without significant changes :-/. When I change anything, wheel acts still like connected by spring. But only during flight! Behaviour is same as in the video from my previous post. Note: the code responds, so it is not probably "stupid bug". I'am helpless.

Is there something what I omitted, or it is constraint solver usage limit? I understand small inaccuracy (~1-2 cm), but 10 or more cm is too much for not loaded joint, isn't it?
DannyChapman
Posts: 84
Joined: Sun Jan 07, 2007 4:29 pm
Location: Oxford, England
Contact:

Re: sailplane RigidBody wheel - constraint setup

Post by DannyChapman »

I wonder if the wheel and airframe have got different values for m_linearDamping (in the rigid body construction). If so then this would drive them apart. However, I suspect this isn't it, looking at the video again, and how the displacement happens - the wheel isn't lagging behind the airframe due to velocity. Instead it gets displaced in the opposite direction to the acceleration of the plane.

So it _looks_ like it's solving the 6dof constraint assuming the airframe doesn't have any external forces (i.e. your lift forces on the wings etc) acting on it. Looking at btTranslationalLimitMotor::solveLinearAxis (I don't have any code to debug/step through at the moment, and only a few minutes, so am guessing here!), it uses getVelocityInLocalPoint which just uses m_linearVelocity. If m_linearVelocity hasn't been modified by the external forces at this point, then the constraint will lag behind any externally caused accelerations.

Contrast this with code in, say, btSequentialImpulseConstraintSolver::setupRollingFrictionConstraint which uses

solverBodyA.m_linearVelocity+solverBodyA.m_externalForceImpulse

(remember - variables in bullet don't always have the units that you'd expect from their name!) so I would investigate this area (in the 6dof constraint setup) to see if it's causing the problem.

Maybe set up a test case that is easier to repro than the full glider simulation.
Flix
Posts: 456
Joined: Tue Dec 25, 2007 1:06 pm

Re: sailplane RigidBody wheel - constraint setup

Post by Flix »

semo wrote:Now, I'am trying to add RigidBody wheels connected to main body using constraints. Like here: http://www.bulletphysics.org/Bullet/php ... =17&t=4660.
As far as I can remember about that link (not much to tell the truth :oops:), the constraint I used (I don't remember the type right now :roll:) had three purposes:
1) allow the wheel to steer (you don't seem to need this behavior as far as I can see).
2) allow the wheel to spin.
3) allow the vertical suspension to work.

Point 3 was implemented naively by applying a vertical motor that separates the chassis from the wheel (that motor was always active and was supposed to simulate toy vehicles as far as I remember).

If you have copied these settings, maybe you have forgotten to apply the motor (and the vertical suspension is left loose), or its force is too little to separate the 2 objects as needed (the approach you've used to "drive" the plane might affect it).

However, I guess that if you use a plain btHingeConstraint (AND center it in the middle of the wheel), there's no way for your simulation to figure out that there's a predominant vertical suspension direction along which the wheel can shift... so maybe you should take a look at the Bullet Constraint Demo again (it's not always trivial to set up the two transforms required by the constraint).
semo
Posts: 6
Joined: Wed Sep 24, 2014 2:23 pm

Re: sailplane RigidBody wheel - constraint setup

Post by semo »

DannyChapman:
thank You for the interesting idea! I'am trying to follow this way. Airplane aerodynamic forces are calculated and applied to rigidbody each physical frame. We use dynamics world internal pre-tick callback. Resulting force is then aplied using btRigidBody methods applyCentralForce(); and applyTorque(). I guess, this is a standard way. I looked to the Bullet code. Constraints are solved after our aircraft forces are applied. This is ok, I guess. Now, I'am trying to find, where are the velicities updated (Bullet is slightly bigger, than my old physical engine :-).).

However...do You think, Bullet doesn't affect constraints by external forces? Is it possible?

Flix:
You writes about suspension, but I'am not using it. Your demo was inspiration for me, not the source for copy-pasting code :-). My code uses btHingeConstraint and btGeneric6DofConstraint - both with same result. Transformations are not the problem, hopefuly :-). Look at the end of my video, wheel is connected to axis well.
DannyChapman
Posts: 84
Joined: Sun Jan 07, 2007 4:29 pm
Location: Oxford, England
Contact:

Re: sailplane RigidBody wheel - constraint setup

Post by DannyChapman »

semo wrote:DannyChapman:
However...do You think, Bullet doesn't affect constraints by external forces? Is it possible?
I would make a test (e.g. hijack one of the bullet samples):

Create two dynamic boxes (A and B), unit mass, zero damping, zero gravity, no static geometry. Make them not collide.

Attach them together with a 6dof constraint at their centres (so they overlap)

Apply a periodic (e.g. sinusoidal) force to A.

Check that B tracks A _exactly_. If it doesn't, this is almost certainly the reason your wheel doesn't track your airframe, but it should be much easier to debug.

By the way - I too have written a simulator using Bullet - primarily for gliders (though R/C rather than full size, since that's what I fly). I'm quite happy to discuss aerodynamics too if you want :) Shameless plug http://youtu.be/7kudDPjr_gQ
semo
Posts: 6
Joined: Wed Sep 24, 2014 2:23 pm

Re: sailplane RigidBody wheel - constraint setup

Post by semo »

Yes, I will try this kind of test, but probably on monday (now I'am out of office).

OT:
Your simulator looks quite realistic! I'am interested on it, because I'am RC pilot and modeller too ;-). RC simulator is my dream job (note: my work on full scale aircraft simulator is hobby, I'am working on it for my ex-colleagues from game industry).
It is good to find other man to discuss aerodynamics. I hope, my experiences will help you too. I have not too much time now, but I will send You PM late.
semo
Posts: 6
Joined: Wed Sep 24, 2014 2:23 pm

Re: sailplane RigidBody wheel - constraint setup

Post by semo »

I spent lot of time with testing and must say, "it is not a bug, it is a feature". Simple demo described here by DannyChapman gave same results - constraint is out of it's limits - more and more, as force acting to one of attached body increasing. I thought, that I use it wrongly, because error is quite big, but it seems this behaviour is normal. However, when you have scene with rope-bridge, doors, or other typical things...error is not significant.

I have plan "B" :-). This wheel is tightly connected with aircraft hull and whole aircraft don't interact with other rigid bodies (when it flying). So, I will act on wheel by acceleration caused by aircraft (lift) forces, or simply put it to sleep. First test promised good result :-).


In summary: It seems, constraints can't transfer forces between bodies, this is task for user, right?
DannyChapman
Posts: 84
Joined: Sun Jan 07, 2007 4:29 pm
Location: Oxford, England
Contact:

Re: sailplane RigidBody wheel - constraint setup

Post by DannyChapman »

semo wrote: In summary: It seems, constraints can't transfer forces between bodies, this is task for user, right?
It sounds to me like a bug in the constraint, or in the way that constraints are solved. If you have two bodies that are connected together by a hard constraint (you say linear limit is zero), then at the end of the solve, the two bodies should have consistent velocities (i.e. the relative velocity at the constraint position should be zero). The only reasonable reason for this not to be the case is if there are too many constraints to be solved in the number of iterations available.
semo
Posts: 6
Joined: Wed Sep 24, 2014 2:23 pm

Re: sailplane RigidBody wheel - constraint setup

Post by semo »

Relative velocity is zero, but relative position varies :-) (when one body is affected by powerful force).
Post Reply