Vehicle strategies

ola
Posts: 169
Joined: Sun Jan 14, 2007 7:56 pm
Location: Norway

Vehicle strategies

Post by ola »

Hi all,

I'm experimenting with various ways to create a vehicle with Bullet. I have integrated Bullet into our game engine and the basics are working nicely (can roll balls and things down hills etc), and visualize the collision shapes properly.

Haven't had much luck with the Bullet raycar so far, and I guess it might have to do with the coordinate system we use in the game engine. Is it possible to define a raycar that has the body x-axis pointing forward, y to the right and z down?

I also would like to do a car with proper wheels attached. I tried using the hinge as a simple test, and this works well enough, allthough I cannot steer and there's no suspension. The wheels do appear to be attached with a rubber axle, but I recon that was to be expected. Can the hinge axis vector be modified while the simulation is running, to be able to steer? I could not find any function for this.

How would you recommend going about implementing a car with "real" wheels in Bullet? Should I try using the 6DOF constraint? Is there a way to simulate suspension (apply the forces for sping and damper, basically) from the "outside" or does this have to be a part of the constraint itself?

Best regards,
Ola
User avatar
Erwin Coumans
Site Admin
Posts: 4221
Joined: Sun Jun 26, 2005 6:43 pm
Location: California, USA

Post by Erwin Coumans »

Haven't had much luck with the Bullet raycar so far, and I guess it might have to do with the coordinate system we use in the game engine. Is it possible to define a raycar that has the body x-axis pointing forward, y to the right and z down?
It should be possible to use the raycast vehicle with different up-axis and forward-axis. The vehicle demo only shows 2 sample cases where Y-axis or Z-axis are up, but with some more work it is possible to use your coordinate frame. I lack time to create such example right now.

The support for wheel constraints if limited, and for most applications raycast based vehicles are recommended over hinged wheels.

I am planning to add all constraints as are available in ODE to Bullet, which would give you the wheel constraint. It won't work as good as the raycast vehicles, especially at higher velocities. However, it would be better if you want to simulate low-speed vehicles with a more realistic tyre-surface interaction (like a 4-wheel drive car in a rocky terrain).

So the best is to try to get the raycast vehicle working with your coordinate system. There aren't many files, so it should be doable.
Hope this helps,
Erwin
ola
Posts: 169
Joined: Sun Jan 14, 2007 7:56 pm
Location: Norway

Post by ola »

Hi Erwin, thanks for the feedback!

I would like to have both vehicle models available in the program as there will be driving on- and offroad. I have done some more experiments that look promising using a custom made constraint based on the existing ones. I'm sure learning quite a bit about the internals of Bullet these days... I have now got springs and steering on my "car" but it's not quite there yet :-) I do see why you recommend the raycast models!

I'll try to figure out the raycar coordinate system, and when it works I can send you the code in case you'd like to have it.

By the way, if I define double precision (in btScalar.h) when compiling Bullet, the demos don't compile. It's no big deal, I just installed a second instance with single precision for demo experiments.

Best regards,
Ola
User avatar
Erwin Coumans
Site Admin
Posts: 4221
Joined: Sun Jun 26, 2005 6:43 pm
Location: California, USA

Post by Erwin Coumans »

The msvc projectfiles have already double precision build settings.
Basically you have to define 'BT_USE_DOUBLE_PRECISION' as C++ preprocessor. Under unix, this should be done using
-DBT_USE_DOUBLE_PRECISION
You don't need to change any headerfiles for this.

I would recommend to use single precision float, unless you really experience trouble in simulations.

Hope this helps,
Erwin
ola
Posts: 169
Joined: Sun Jan 14, 2007 7:56 pm
Location: Norway

Post by ola »

Ah ok. I just saw a posting here somewhere that it could be done in btScalar.h. I'm using Linux mostly by the way.

I need the double precision as we use a scenery engine with the whole earth globe in it, with geocentric coordinates. I tried using floats first but it was not working properly. So I set the gravity on each physics body individually for every iteration (if they move) and it works quite ok (can even put a satellite in orbit and such), and so far the performance seems good enough. Might worsen when I get more ambitious... :-)

Thanks again!
Ola